public static void storeGraphFilter(final Configuration apacheConfiguration, final org.apache.hadoop.conf.Configuration hadoopConfiguration, final GraphFilter graphFilter) { if (graphFilter.hasFilter()) { VertexProgramHelper.serialize(graphFilter, apacheConfiguration, Constants.GREMLIN_HADOOP_GRAPH_FILTER); hadoopConfiguration.set(Constants.GREMLIN_HADOOP_GRAPH_FILTER, apacheConfiguration.getString(Constants.GREMLIN_HADOOP_GRAPH_FILTER)); } } }
@Override public String toString() { if (!this.hasFilter()) return "graphfilter[none]"; else if (this.hasVertexFilter() && this.hasEdgeFilter()) return "graphfilter[" + this.vertexFilter + "," + this.edgeFilter + "]"; else if (this.hasVertexFilter()) return "graphfilter[" + this.vertexFilter + "]"; else return "graphfilter[" + this.edgeFilter + "]"; } }
public TinkerGraphComputerView(final TinkerGraph graph, final GraphFilter graphFilter, final Set<VertexComputeKey> computeKeys) { this.graph = graph; this.computeKeys = new HashMap<>(); computeKeys.forEach(key -> this.computeKeys.put(key.getKey(), key)); this.computeProperties = new ConcurrentHashMap<>(); this.graphFilter = graphFilter; if (this.graphFilter.hasFilter()) { graph.vertices().forEachRemaining(vertex -> { boolean legalVertex = false; if (this.graphFilter.hasVertexFilter() && this.graphFilter.legalVertex(vertex)) { this.legalVertices.add(vertex.id()); legalVertex = true; } if ((legalVertex || !this.graphFilter.hasVertexFilter()) && this.graphFilter.hasEdgeFilter()) { final Set<Object> edges = new HashSet<>(); this.legalEdges.put(vertex.id(), edges); this.graphFilter.legalEdges(vertex).forEachRemaining(edge -> edges.add(edge.id())); } }); } }
public Optional<StarVertex> applyGraphFilter(final GraphFilter graphFilter) { if (!graphFilter.hasFilter()) return Optional.of(this); else if (graphFilter.legalVertex(this)) {
((GraphFilterAware) inputRDD).setGraphFilter(this.graphFilter); filtered = false; } else if (this.graphFilter.hasFilter()) { filtered = true; } else {
/** * If the returned {@link StarGraph} is null, that means that the {@link GraphFilter} filtered the vertex. */ @Override public <I extends InputShim> StarGraph read(final KryoShim<I, ?> kryo, final I input, final Class<StarGraph> clazz) { final StarGraph starGraph = StarGraph.open(); input.readByte(); // version field ignored for now - for future use with backward compatibility starGraph.edgeProperties = kryo.readObjectOrNull(input, HashMap.class); starGraph.metaProperties = kryo.readObjectOrNull(input, HashMap.class); starGraph.addVertex(T.id, kryo.readClassAndObject(input), T.label, kryo.readObject(input, String.class)); readEdges(kryo, input, starGraph, Direction.IN); readEdges(kryo, input, starGraph, Direction.OUT); if (kryo.readObject(input, Boolean.class)) { final int numberOfUniqueKeys = kryo.readObject(input, Integer.class); for (int i = 0; i < numberOfUniqueKeys; i++) { final String vertexPropertyKey = kryo.readObject(input, String.class); final int numberOfVertexPropertiesWithKey = kryo.readObject(input, Integer.class); for (int j = 0; j < numberOfVertexPropertiesWithKey; j++) { final Object id = kryo.readClassAndObject(input); final Object value = kryo.readClassAndObject(input); starGraph.starVertex.property(VertexProperty.Cardinality.list, vertexPropertyKey, value, T.id, id); } } } return this.graphFilter.hasFilter() ? starGraph.applyGraphFilter(this.graphFilter).orElse(null) : starGraph; }
public static void storeGraphFilter(final Configuration apacheConfiguration, final org.apache.hadoop.conf.Configuration hadoopConfiguration, final GraphFilter graphFilter) { if (graphFilter.hasFilter()) { VertexProgramHelper.serialize(graphFilter, apacheConfiguration, Constants.GREMLIN_HADOOP_GRAPH_FILTER); hadoopConfiguration.set(Constants.GREMLIN_HADOOP_GRAPH_FILTER, apacheConfiguration.getString(Constants.GREMLIN_HADOOP_GRAPH_FILTER)); } } }
@Override public String toString() { if (!this.hasFilter()) return "graphfilter[none]"; else if (this.hasVertexFilter() && this.hasEdgeFilter()) return "graphfilter[" + this.vertexFilter + "," + this.edgeFilter + "]"; else if (this.hasVertexFilter()) return "graphfilter[" + this.vertexFilter + "]"; else return "graphfilter[" + this.edgeFilter + "]"; } }
public TinkerGraphComputerView(final TinkerGraph graph, final GraphFilter graphFilter, final Set<VertexComputeKey> computeKeys) { this.graph = graph; this.computeKeys = new HashMap<>(); computeKeys.forEach(key -> this.computeKeys.put(key.getKey(), key)); this.computeProperties = new ConcurrentHashMap<>(); this.graphFilter = graphFilter; if (this.graphFilter.hasFilter()) { graph.vertices().forEachRemaining(vertex -> { boolean legalVertex = false; if (this.graphFilter.hasVertexFilter() && this.graphFilter.legalVertex(vertex)) { this.legalVertices.add(vertex.id()); legalVertex = true; } if ((legalVertex || !this.graphFilter.hasVertexFilter()) && this.graphFilter.hasEdgeFilter()) { final Set<Object> edges = new HashSet<>(); this.legalEdges.put(vertex.id(), edges); this.graphFilter.legalEdges(vertex).forEachRemaining(edge -> edges.add(edge.id())); } }); } }
public TinkerGraphComputerView(final TinkerGraph graph, final GraphFilter graphFilter, final Set<VertexComputeKey> computeKeys) { this.graph = graph; this.computeKeys = new HashMap<>(); computeKeys.forEach(key -> this.computeKeys.put(key.getKey(), key)); this.computeProperties = new ConcurrentHashMap<>(); this.graphFilter = graphFilter; if (this.graphFilter.hasFilter()) { graph.vertices().forEachRemaining(vertex -> { boolean legalVertex = false; if (this.graphFilter.hasVertexFilter() && this.graphFilter.legalVertex(vertex)) { this.legalVertices.add(vertex.id()); legalVertex = true; } if ((legalVertex || !this.graphFilter.hasVertexFilter()) && this.graphFilter.hasEdgeFilter()) { final Set<Object> edges = new HashSet<>(); this.legalEdges.put(vertex.id(), edges); this.graphFilter.legalEdges(vertex).forEachRemaining(edge -> edges.add(edge.id())); } }); } }
public Optional<StarVertex> applyGraphFilter(final GraphFilter graphFilter) { if (!graphFilter.hasFilter()) return Optional.of(this); else if (graphFilter.legalVertex(this)) {
((GraphFilterAware) inputRDD).setGraphFilter(this.graphFilter); filtered = false; } else filtered = this.graphFilter.hasFilter(); } catch (final InstantiationException | IllegalAccessException e) { throw new IllegalStateException(e.getMessage(), e);
((GraphFilterAware) inputRDD).setGraphFilter(this.graphFilter); filtered = false; } else if (this.graphFilter.hasFilter()) { filtered = true; } else {
/** * If the returned {@link StarGraph} is null, that means that the {@link GraphFilter} filtered the vertex. */ @Override public <I extends InputShim> StarGraph read(final KryoShim<I, ?> kryo, final I input, final Class<StarGraph> clazz) { final StarGraph starGraph = StarGraph.open(); input.readByte(); // version field ignored for now - for future use with backward compatibility starGraph.edgeProperties = kryo.readObjectOrNull(input, HashMap.class); starGraph.metaProperties = kryo.readObjectOrNull(input, HashMap.class); starGraph.addVertex(T.id, kryo.readClassAndObject(input), T.label, kryo.readObject(input, String.class)); readEdges(kryo, input, starGraph, Direction.IN); readEdges(kryo, input, starGraph, Direction.OUT); if (kryo.readObject(input, Boolean.class)) { final int numberOfUniqueKeys = kryo.readObject(input, Integer.class); for (int i = 0; i < numberOfUniqueKeys; i++) { final String vertexPropertyKey = kryo.readObject(input, String.class); final int numberOfVertexPropertiesWithKey = kryo.readObject(input, Integer.class); for (int j = 0; j < numberOfVertexPropertiesWithKey; j++) { final Object id = kryo.readClassAndObject(input); final Object value = kryo.readClassAndObject(input); starGraph.starVertex.property(VertexProperty.Cardinality.list, vertexPropertyKey, value, T.id, id); } } } return this.graphFilter.hasFilter() ? starGraph.applyGraphFilter(this.graphFilter).orElse(null) : starGraph; }