private void benchmarkFindVerticesById(Random random, int vertexCount, int findVerticesByIdCount) { double startTime = System.currentTimeMillis(); for (int i = 0; i < findVerticesByIdCount; i++) { String vertexId = "v" + random.nextInt(vertexCount); graph.getVertex(vertexId, AUTHORIZATIONS_ALL); } graph.flush(); double endTime = System.currentTimeMillis(); LOGGER.info("find vertices by id in %.3fs", (endTime - startTime) / 1000); }
@Override public void clearCache(String workspaceId) { checkNotNull(workspaceId, "Workspace should not be null"); LOGGER.info("clearing ontology cache for workspace %s", workspaceId); super.clearCache(workspaceId); graph.flush(); }
@Override public void cleanUpElements(Graph graph, Vertex productVertex, Authorizations authorizations) { Iterable<Edge> productElementEdges = productVertex.getEdges( Direction.OUT, WorkspaceProperties.PRODUCT_TO_ENTITY_RELATIONSHIP_IRI, authorizations ); for (Edge productToElement : productElementEdges) { graph.softDeleteEdge(productToElement, authorizations); } graph.flush(); }
@Override public void clearCache() { LOGGER.info("clearing ontology cache"); super.clearCache(); graph.flush(); }
@Override protected void addEntityGlyphIconToEntityConcept(Concept entityConcept, byte[] rawImg, Authorizations authorizations) { StreamingPropertyValue raw = new StreamingPropertyValue(new ByteArrayInputStream(rawImg), byte[].class); raw.searchIndex(false); entityConcept.setProperty(OntologyProperties.GLYPH_ICON.getPropertyName(), raw, getSystemUser(), authorizations); graph.flush(); }
@Override public void addIntent(String intent, User user, Authorizations authorizations) { Visibility visibility = OntologyRepository.VISIBILITY.getVisibility(); Metadata metadata = createPropertyMetadata(user, new Date(), visibility); OntologyProperties.INTENT.addPropertyValue(vertex, intent, intent, metadata, visibility, authorizations); vertex.getGraph().flush(); }
@Override public void removeProperty(String name, Authorizations authorizations) { removeProperty(ElementMutation.DEFAULT_KEY, name, authorizations); getVertex().getGraph().flush(); }
@Override public void removeIntent(String intent, Authorizations authorizations) { OntologyProperties.INTENT.removeProperty(vertex, intent, authorizations); getVertex().getGraph().flush(); }
@Override public void removeIntent(String intent, Authorizations authorizations) { OntologyProperties.INTENT.removeProperty(vertex, intent, authorizations); getVertex().getGraph().flush(); }
public void updateEntitiesOnWorkspace( String workspaceId, Collection<String> vertexIds, User user ) { Workspace workspace = workspaceRepository.findById(workspaceId, user); workspaceRepository.updateEntitiesOnWorkspace(workspace, vertexIds, user); workQueueRepository.pushUserCurrentWorkspaceChange(user, workspaceId); graph.flush(); }
@Test public void testLargeFieldValuesThatAreMarkedWithExactMatch() { graph.defineProperty("field1").dataType(String.class).textIndexHint(TextIndexHint.EXACT_MATCH).define(); StringBuilder largeText = new StringBuilder(); for (int i = 0; i < 10000; i++) { largeText.append("test "); } graph.prepareVertex("v1", VISIBILITY_EMPTY) .addPropertyValue("", "field1", largeText.toString(), VISIBILITY_EMPTY) .save(AUTHORIZATIONS_EMPTY); graph.flush(); }
@Override public void setDisplayName(User user, String displayName) { Vertex userVertex = findByIdUserVertex(user.getUserId()); UserVisalloProperties.DISPLAY_NAME.setProperty( userVertex, displayName, VISIBILITY.getVisibility(), authorizations ); graph.flush(); }
public void lrpUpdate(Vertex vertex, Graph graph, Authorizations authorizations) { Date updateDate = new Date(); Long waitTimeMs = updateDate.getTime() - PingOntology.CREATE_DATE.getPropertyValueRequired(vertex).getTime(); ElementMutation<Vertex> mutation = vertex.prepareMutation(); PingOntology.LONG_RUNNING_PROCESS_DATE.setProperty(mutation, updateDate, VISIBILITY); PingOntology.LONG_RUNNING_PROCESS_HOSTNAME.setProperty(mutation, getHostname(), VISIBILITY); PingOntology.LONG_RUNNING_PROCESS_HOST_ADDRESS.setProperty(mutation, getHostAddress(), VISIBILITY); PingOntology.LONG_RUNNING_PROCESS_WAIT_TIME_MS.setProperty(mutation, waitTimeMs, VISIBILITY); mutation.save(authorizations); graph.flush(); }
@Override public void updatePropertyDependentIris(OntologyProperty property, Collection<String> newDependentPropertyIris, User user, String workspaceId) { VertexiumOntologyProperty vertexiumProperty = (VertexiumOntologyProperty) property; if (!isPublic(workspaceId) || property.getSandboxStatus() == SandboxStatus.PRIVATE) { throw new UnsupportedOperationException("Sandboxed updating of dependent iris is not currently supported for properties"); } saveDependentProperties(vertexiumProperty.getVertex().getId(), newDependentPropertyIris, user, workspaceId); graph.flush(); vertexiumProperty.setDependentProperties(newDependentPropertyIris); }
@Test public void testDeleteVertex() { graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A); graph.flush(); Assert.assertEquals(1, count(graph.getVertices(AUTHORIZATIONS_A))); graph.deleteVertex("v1", AUTHORIZATIONS_A); graph.flush(); Assert.assertEquals(0, count(graph.getVertices(AUTHORIZATIONS_A))); }
@Override public void setProperty(String name, Object value, User user, Authorizations authorizations) { Visibility visibility = OntologyRepository.VISIBILITY.getVisibility(); Metadata metadata = createPropertyMetadata(user, new Date(), visibility); getVertex().setProperty(name, value, metadata, OntologyRepository.VISIBILITY.getVisibility(), authorizations); getVertex().getGraph().flush(); }
@Override public void setPassword(User user, byte[] salt, byte[] passwordHash) { Vertex userVertex = findByIdUserVertex(user.getUserId()); UserVisalloProperties.PASSWORD_SALT.setProperty(userVertex, salt, VISIBILITY.getVisibility(), authorizations); UserVisalloProperties.PASSWORD_HASH.setProperty( userVertex, passwordHash, VISIBILITY.getVisibility(), authorizations ); graph.flush(); }
@Override public void setProperty(String name, Object value, User user, Authorizations authorizations) { Visibility visibility = OntologyRepository.VISIBILITY.getVisibility(); Metadata metadata = new Metadata(); VisalloProperties.MODIFIED_DATE_METADATA.setMetadata(metadata, new Date(), visibility); if (user != null) { VisalloProperties.MODIFIED_BY_METADATA.setMetadata(metadata, user.getUserId(), visibility); } getVertex().setProperty(name, value, metadata, visibility, authorizations); getVertex().getGraph().flush(); }
@Test public void testGetSingleVertexWithSameRowPrefix() { graph.addVertex("prefix", VISIBILITY_EMPTY, AUTHORIZATIONS_EMPTY); graph.addVertex("prefixA", VISIBILITY_EMPTY, AUTHORIZATIONS_EMPTY); graph.flush(); Vertex v = graph.getVertex("prefix", AUTHORIZATIONS_EMPTY); assertEquals("prefix", v.getId()); v = graph.getVertex("prefixA", AUTHORIZATIONS_EMPTY); assertEquals("prefixA", v.getId()); }
@Test public void testStreamingPropertyValueReadAsString() { graph.prepareVertex("v1", VISIBILITY_EMPTY) .setProperty("spv", StreamingPropertyValue.create("Hello World"), VISIBILITY_EMPTY) .save(AUTHORIZATIONS_EMPTY); graph.flush(); Vertex v1 = graph.getVertex("v1", AUTHORIZATIONS_EMPTY); assertEquals("Hello World", ((StreamingPropertyValue) v1.getPropertyValue("spv")).readToString()); assertEquals("Wor", ((StreamingPropertyValue) v1.getPropertyValue("spv")).readToString(6, 3)); assertEquals("", ((StreamingPropertyValue) v1.getPropertyValue("spv")).readToString("Hello World".length(), 1)); assertEquals("Hello World", ((StreamingPropertyValue) v1.getPropertyValue("spv")).readToString(0, 100)); }