@Override public Iterable<RelatedEdge> findRelatedEdgeSummary(Iterable<String> vertexIds, Long endTime, Authorizations authorizations) { FetchHints fetchHints = new FetchHintsBuilder() .setIncludeOutEdgeRefs(true) .build(); return findRelatedEdgeSummaryForVertices(getVertices(vertexIds, fetchHints, endTime, authorizations), authorizations); }
public FetchHints build() { if (!isIncludeProperties() && isIncludePropertyMetadata()) { includeAllProperties = true; } return new FetchHints( includeAllProperties, propertyNamesToInclude == null ? null : ImmutableSet.copyOf(propertyNamesToInclude), includeAllPropertyMetadata, metadataKeysToInclude == null ? null : ImmutableSet.copyOf(metadataKeysToInclude), includeHidden, includeAllEdgeRefs, includeOutEdgeRefs || includeAllEdgeRefs, includeInEdgeRefs || includeAllEdgeRefs, edgeLabelsOfEdgeRefsToInclude == null ? null : ImmutableSet.copyOf(edgeLabelsOfEdgeRefsToInclude), includeEdgeLabelsAndCounts, includeExtendedDataTableNames ); }
protected FetchHints idFetchHintsToElementFetchHints(EnumSet<IdFetchHint> idFetchHints) { return idFetchHints.contains(IdFetchHint.INCLUDE_HIDDEN) ? FetchHints.builder().setIncludeHidden(true).build() : FetchHints.NONE; }
.setIncludeAllProperties(true) .build(); FetchHints inEdgeRefsFetchHints = FetchHints.builder() .setIncludeInEdgeRefs(true) .build(); FetchHints outEdgeRefsFetchHints = FetchHints.builder() .setIncludeOutEdgeRefs(true) .build();
int maxVersions = 1; FetchHints fetchHints = FetchHints.builder() .setIncludeOutEdgeRefs(true) .build(); ScannerBase scanner = createElementScanner( fetchHints,
@Test public void testSearchingForHiddenEdges() { Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_ALL); Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_ALL); Vertex v3 = graph.addVertex("v3", VISIBILITY_A, AUTHORIZATIONS_ALL); Edge e1 = graph.addEdge("v1tov2", v1, v2, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_ALL); Edge e2 = graph.addEdge("v2tov3", v2, v3, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_ALL); graph.flush(); graph.markEdgeHidden(e1, VISIBILITY_B, AUTHORIZATIONS_ALL); graph.flush(); FetchHints propertiesFetchHints = FetchHints.builder() .setIncludeAllProperties(true) .build(); QueryResultsIterable<Edge> edges = graph.query(AUTHORIZATIONS_A) .edges(propertiesFetchHints); assertResultsCount(2, edges); assertEdgeIdsAnyOrder(edges, e1.getId(), e2.getId()); edges = graph.query(AUTHORIZATIONS_A_AND_B) .edges(propertiesFetchHints); assertResultsCount(1, edges); assertEdgeIdsAnyOrder(edges, e2.getId()); graph.markEdgeVisible(e1, VISIBILITY_B, AUTHORIZATIONS_ALL); graph.flush(); edges = graph.query(AUTHORIZATIONS_A_AND_B) .edges(propertiesFetchHints); assertResultsCount(2, edges); assertEdgeIdsAnyOrder(edges, e1.getId(), e2.getId()); }
@Override protected QueryResultsIterable<? extends VertexiumObject> extendedData(FetchHints extendedDataFetchHints) { FetchHints fetchHints = FetchHints.builder() .setIncludeExtendedDataTableNames(true) .build(); return extendedData(extendedDataFetchHints, new JoinIterable<>( allVertices(fetchHints), allEdges(fetchHints) )); }
@Test public void testFetchHintsExceptions() { Metadata prop1Metadata = Metadata.create(); prop1Metadata.add("metadata1", "metadata1Value", VISIBILITY_A); prop1Metadata.add("metadata2", "metadata2Value", VISIBILITY_A); graph.prepareVertex("v1", VISIBILITY_A) .setProperty("prop1", "value1", prop1Metadata, VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); graph.flush(); FetchHints propertyFetchHints = FetchHints.builder() .setPropertyNamesToInclude("prop2") .build(); Vertex v1WithOnlyProp2 = graph.getVertex("v1", propertyFetchHints, AUTHORIZATIONS_A); assertNotNull(v1WithOnlyProp2.getProperties()); assertThrowsException(() -> v1WithOnlyProp2.getProperty("prop1")); FetchHints propertiesFetchHints = FetchHints.builder() .setIncludeAllProperties(true) .build(); Vertex v1WithAllProperties = graph.getVertex("v1", propertiesFetchHints, AUTHORIZATIONS_A); assertThrowsException(v1WithAllProperties.getProperty("prop1")::getMetadata); FetchHints metadataFetchHints = FetchHints.builder() .setIncludeAllProperties(true) .setMetadataKeysToInclude("metadata1") .build(); Vertex v1WithOnlyMetadata1 = graph.getVertex("v1", metadataFetchHints, AUTHORIZATIONS_A); Property prop1 = v1WithOnlyMetadata1.getProperty("prop1"); assertNotNull(prop1.getMetadata()); assertNotNull(v1WithOnlyMetadata1.getProperty("prop1").getMetadata().getEntry("metadata1")); assertThrowsException(() -> v1WithOnlyMetadata1.getProperty("prop1").getMetadata().getEntry("metadata2")); }
graph.flush(); FetchHints fetchHints = new FetchHintsBuilder() .setPropertyNamesToInclude("propBmeta") .build(); Vertex vertex = graph.getVertex("v1", fetchHints, AUTHORIZATIONS_A); ExistingElementMutation<Vertex> m = vertex.prepareMutation(); assertEquals("value2", vertex.getProperty("propBmeta").getMetadata().getEntry("meta1").getValue()); fetchHints = new FetchHintsBuilder() .setPropertyNamesToInclude("propBmeta") .build(); vertex = graph.getVertex("v1", fetchHints, AUTHORIZATIONS_A); m = vertex.prepareMutation();
.setMetadataKeysToInclude("m1", "m3") .build(); v1 = graph.getVertex("v1", specificPropertiesFetchHints, AUTHORIZATIONS_A); Metadata n1WithoutM2 = v1.getProperty("n1").getMetadata(); .setIncludeAllProperties(true) .build(); Vertex v1_noMetadata = graph.getVertex("v1", noPropertiesFetchHints, AUTHORIZATIONS_A); assertThrowsException(() -> v1_noMetadata.getProperty("n1").getMetadata()); .setIncludeAllPropertyMetadata(true) .setMetadataKeysToInclude("m1", "m3") .build(); Vertex v1_withMetadata = graph.getVertex("v1", allPropertiesFetchHints, AUTHORIZATIONS_A); Metadata n1 = v1_withMetadata.getProperty("n1").getMetadata();
.setEdgeLabelsOfEdgeRefsToInclude(LABEL_LABEL1, LABEL_LABEL3) .build(); v1 = graph.getVertex("v1", specificEdgeLabelFetchHints, AUTHORIZATIONS_A); List<org.vertexium.EdgeInfo> edgeInfos = toList(v1.getEdgeInfos(Direction.BOTH, AUTHORIZATIONS_A)); .setIncludeEdgeLabelsAndCounts(true) .build(); Vertex v1_withEdgeLabelsAndCounts = graph.getVertex("v1", edgeLabelsAndCountsFetchHints, AUTHORIZATIONS_A); assertThrowsException(() -> v1_withEdgeLabelsAndCounts.getEdgeInfos(Direction.BOTH, AUTHORIZATIONS_A)); .setIncludeAllEdgeRefs(true) .setEdgeLabelsOfEdgeRefsToInclude("m1", "m3") .build(); Vertex v1_withEdgeRefs = graph.getVertex("v1", allEdgeInfoFetchHints, AUTHORIZATIONS_A); edgeInfos = toList(v1_withEdgeRefs.getEdgeInfos(Direction.BOTH, AUTHORIZATIONS_A));
@Test public void testFetchHintsProperties() { Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A); v1.addPropertyValue("k1", "n1", "value1", VISIBILITY_A, AUTHORIZATIONS_A); v1.addPropertyValue("k1", "n2", "value2", VISIBILITY_A, AUTHORIZATIONS_A); v1.addPropertyValue("k1", "n3", "value3", VISIBILITY_A, AUTHORIZATIONS_A); graph.flush(); FetchHints specificPropertiesFetchHints = FetchHints.builder() .setPropertyNamesToInclude("n1", "n3") .build(); Vertex v1WithoutN2 = graph.getVertex("v1", specificPropertiesFetchHints, AUTHORIZATIONS_A); assertEquals("value1", v1WithoutN2.getPropertyValue("n1")); assertThrowsException(() -> v1WithoutN2.getProperty("n1").getMetadata()); assertThrowsException(() -> v1WithoutN2.getPropertyValue("n2")); assertEquals("value3", v1WithoutN2.getPropertyValue("n3")); FetchHints noPropertiesFetchHints = FetchHints.NONE; Vertex v1WithNotProperties = graph.getVertex("v1", noPropertiesFetchHints, AUTHORIZATIONS_A); assertThrowsException(v1WithNotProperties::getProperties); assertThrowsException(() -> v1WithNotProperties.getProperty("n1")); FetchHints allPropertiesFetchHints = FetchHints.builder() .setIncludeAllProperties(true) .setPropertyNamesToInclude("n1", "n3") .build(); v1 = graph.getVertex("v1", allPropertiesFetchHints, AUTHORIZATIONS_A); assertEquals("value1", v1.getPropertyValue("n1")); assertEquals("value2", v1.getPropertyValue("n2")); assertEquals("value3", v1.getPropertyValue("n3")); }
public static FetchHintsBuilder builder() { return new FetchHintsBuilder(); }
.setIncludeAllProperties(true) .build(); FetchHints inEdgeRefsFetchHints = FetchHints.builder() .setIncludeInEdgeRefs(true) .build(); FetchHints outEdgeRefsFetchHints = FetchHints.builder() .setIncludeOutEdgeRefs(true) .build();
int maxVersions = 1; FetchHints fetchHints = FetchHints.builder() .setIncludeOutEdgeRefs(true) .build(); ScannerBase scanner = createElementScanner( fetchHints,
.setIncludeAllProperties(true) .build(); QueryResultsIterable<Vertex> vertices = graph.query(AUTHORIZATIONS_A) .has("name", "joe")
@Override protected QueryResultsIterable<? extends VertexiumObject> extendedData(FetchHints extendedDataFetchHints) { FetchHints extendedDataTableNamesFetchHints = FetchHints.builder() .setIncludeExtendedDataTableNames(true) .build(); return extendedData(extendedDataFetchHints, new JoinIterable<>( getIterableFromElementType(ElementType.VERTEX, extendedDataTableNamesFetchHints), getIterableFromElementType(ElementType.EDGE, extendedDataTableNamesFetchHints) )); }
@Test public void testFetchHintsExceptions() { Metadata prop1Metadata = Metadata.create(); prop1Metadata.add("metadata1", "metadata1Value", VISIBILITY_A); prop1Metadata.add("metadata2", "metadata2Value", VISIBILITY_A); graph.prepareVertex("v1", VISIBILITY_A) .setProperty("prop1", "value1", prop1Metadata, VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); graph.flush(); FetchHints propertyFetchHints = FetchHints.builder() .setPropertyNamesToInclude("prop2") .build(); Vertex v1WithOnlyProp2 = graph.getVertex("v1", propertyFetchHints, AUTHORIZATIONS_A); assertNotNull(v1WithOnlyProp2.getProperties()); assertThrowsException(() -> v1WithOnlyProp2.getProperty("prop1")); FetchHints propertiesFetchHints = FetchHints.builder() .setIncludeAllProperties(true) .build(); Vertex v1WithAllProperties = graph.getVertex("v1", propertiesFetchHints, AUTHORIZATIONS_A); assertThrowsException(v1WithAllProperties.getProperty("prop1")::getMetadata); FetchHints metadataFetchHints = FetchHints.builder() .setIncludeAllProperties(true) .setMetadataKeysToInclude("metadata1") .build(); Vertex v1WithOnlyMetadata1 = graph.getVertex("v1", metadataFetchHints, AUTHORIZATIONS_A); Property prop1 = v1WithOnlyMetadata1.getProperty("prop1"); assertNotNull(prop1.getMetadata()); assertNotNull(v1WithOnlyMetadata1.getProperty("prop1").getMetadata().getEntry("metadata1")); assertThrowsException(() -> v1WithOnlyMetadata1.getProperty("prop1").getMetadata().getEntry("metadata2")); }
graph.flush(); FetchHints fetchHints = new FetchHintsBuilder() .setPropertyNamesToInclude("propBmeta") .build(); Vertex vertex = graph.getVertex("v1", fetchHints, AUTHORIZATIONS_A); ExistingElementMutation<Vertex> m = vertex.prepareMutation(); assertEquals("value2", vertex.getProperty("propBmeta").getMetadata().getEntry("meta1").getValue()); fetchHints = new FetchHintsBuilder() .setPropertyNamesToInclude("propBmeta") .build(); vertex = graph.getVertex("v1", fetchHints, AUTHORIZATIONS_A); m = vertex.prepareMutation();
.setMetadataKeysToInclude("m1", "m3") .build(); v1 = graph.getVertex("v1", specificPropertiesFetchHints, AUTHORIZATIONS_A); Metadata n1WithoutM2 = v1.getProperty("n1").getMetadata(); .setIncludeAllProperties(true) .build(); Vertex v1_noMetadata = graph.getVertex("v1", noPropertiesFetchHints, AUTHORIZATIONS_A); assertThrowsException(() -> v1_noMetadata.getProperty("n1").getMetadata()); .setIncludeAllPropertyMetadata(true) .setMetadataKeysToInclude("m1", "m3") .build(); Vertex v1_withMetadata = graph.getVertex("v1", allPropertiesFetchHints, AUTHORIZATIONS_A); Metadata n1 = v1_withMetadata.getProperty("n1").getMetadata();