public Object processEdge(final Range annotation, final Method method, final Object[] arguments, final FramedGraph framedGraph, final Edge edge, final Direction direction) { return framedGraph.frame(edge.getVertex(direction.opposite()), method.getReturnType()); }
public Object processEdge(final Range annotation, final Method method, final Object[] arguments, final FramedGraph framedGraph, final Edge edge, final Direction direction) { return framedGraph.frame(edge.getVertex(direction.opposite()), method.getReturnType()); }
private void removeEdges(final Direction direction, final String label, final Vertex element, final Vertex otherVertex, final FramedGraph framedGraph) { for (final Edge edge : element.getEdges(direction, label)) { if (null == otherVertex || edge.getVertex(direction.opposite()).equals(otherVertex)) { framedGraph.removeEdge(edge); } } } }
private void removeEdges(final Direction direction, final String label, final Vertex element, final Vertex otherVertex, final FramedGraph framedGraph) { for (final Edge edge : element.getEdges(direction, label)) { if (null == otherVertex || edge.getVertex(direction.opposite()).equals(otherVertex)) { framedGraph.removeEdge(edge); } } } }
@Override public void setup(final Reducer.Context context) throws IOException, InterruptedException { this.direction = Direction.valueOf(context.getConfiguration().get(LinkMapReduce.DIRECTION)); this.direction = this.direction.opposite(); this.vertex = new FaunusVertex(context.getConfiguration().getBoolean(FaunusCompiler.PATH_ENABLED, false)); }
@Override public void setup(final Reducer.Context context) throws IOException, InterruptedException { this.direction = Direction.valueOf(context.getConfiguration().get(DIRECTION)); this.direction = this.direction.opposite(); this.vertex = new FaunusVertex(context.getConfiguration().getBoolean(FaunusCompiler.PATH_ENABLED, false)); }
@Override public void setup(final Reducer.Context context) throws IOException, InterruptedException { this.direction = Direction.valueOf(context.getConfiguration().get(DIRECTION)); if (!this.direction.equals(BOTH)) this.direction = this.direction.opposite(); this.labels = context.getConfiguration().getStrings(LABELS); this.vertex = new FaunusVertex(context.getConfiguration().getBoolean(FaunusCompiler.PATH_ENABLED, false)); }
@Override public void reduce(final LongWritable key, final Iterable<Holder<FaunusVertex>> values, final Reducer<LongWritable, Holder<FaunusVertex>, NullWritable, FaunusVertex>.Context context) throws IOException, InterruptedException { long edgesAggregated = 0; this.vertex.reuse(key.get()); for (final Holder<FaunusVertex> holder : values) { if (holder.getTag() == 's') { edgesAggregated = edgesAggregated + ((List) holder.get().getEdges(direction.opposite())).size(); this.vertex.addEdges(direction.opposite(), holder.get()); } else { this.vertex.addAll(holder.get()); } } context.write(NullWritable.get(), this.vertex); context.getCounter(Counters.EDGES_ADDED).increment(edgesAggregated); } }
@Override public void map(final NullWritable key, final FaunusVertex value, final Mapper<NullWritable, FaunusVertex, LongWritable, Holder<FaunusVertex>>.Context context) throws IOException, InterruptedException { long edgesInverted = 0; for (final Edge edge : value.getEdges(this.direction)) { final long id = (Long) edge.getVertex(this.direction.opposite()).getId(); this.longWritable.set(id); this.shellVertex.reuse(id); this.shellVertex.addEdge(this.direction.opposite(), (FaunusEdge) edge); context.write(this.longWritable, this.vertexHolder.set('s', this.shellVertex)); edgesInverted++; } this.longWritable.set(value.getIdAsLong()); context.write(this.longWritable, this.vertexHolder.set('r', value)); context.getCounter(Counters.EDGES_COPIED).increment(edgesInverted); }
@Override public EdgeLabel make() { TypeDefinitionMap definition = makeDefinition(); Preconditions.checkArgument(unidirectionality==Direction.BOTH || !getMultiplicity().isUnique(unidirectionality.opposite()), "Unidirectional labels cannot have restricted multiplicity at the other end"); Preconditions.checkArgument(unidirectionality==Direction.BOTH || !hasSortKey() || !getMultiplicity().isUnique(unidirectionality), "Unidirectional labels with restricted multiplicity cannot have a sort key"); Preconditions.checkArgument(unidirectionality!=Direction.IN || definition.getValue(HIDDEN,Boolean.class)); definition.setValue(UNIDIRECTIONAL, unidirectionality); return tx.makeEdgeLabel(getName(), definition); }
public boolean filter(final OrientEdge iObject) { if (targetVertex != null && !targetVertex.equals(iObject.getVertex(connection.getKey().opposite()))) return false; return this.sourceVertex.settings.isUseVertexFieldsForEdgeLabels() || iObject.isLabeled(labels); }
private void writeEdges(final Vertex vertex, final Direction direction, final DataOutput out) throws IOException { final CounterMap<String> map = new CounterMap<String>(); for (final Edge edge : vertex.getEdges(direction)) { map.incr(edge.getLabel(), 1); } WritableUtils.writeVInt(out, map.size()); for (final Map.Entry<String, Long> entry : map.entrySet()) { out.writeUTF(entry.getKey()); WritableUtils.writeVInt(out, entry.getValue().intValue()); for (final Edge edge : vertex.getEdges(direction, entry.getKey())) { WritableUtils.writeVLong(out, elementIdHandler.convertIdentifier(edge)); out.writeBoolean(false); WritableUtils.writeVLong(out, 0); writeProperties(edge, out); WritableUtils.writeVLong(out, elementIdHandler.convertIdentifier(edge.getVertex(direction.opposite()))); } } }
@Override public OIdentifiable getGraphElementRecord(final Object iObject) { final ORecord rec = ((OIdentifiable) iObject).getRecord(); if (rec == null || !(rec instanceof ODocument)) return null; final ODocument value = (ODocument) rec; final OIdentifiable v; OImmutableClass immutableClass = ODocumentInternal.getImmutableSchemaClass(value); if (immutableClass.isVertexType()) { // DIRECT VERTEX v = value; } else if (immutableClass.isEdgeType()) { // EDGE if (vertex.settings.isUseVertexFieldsForEdgeLabels() || OrientEdge.isLabeled(OrientEdge.getRecordLabel(value), iLabels)) v = OrientEdge.getConnection(value, connection.getKey().opposite()); else v = null; } else throw new IllegalStateException("Invalid content found between connections: " + value); return v; }
@Override public Vertex createWrapper(final Object iObject) { if (iObject instanceof OrientVertex) return (OrientVertex) iObject; final ODocument value = ((OIdentifiable) iObject).getRecord(); final OrientVertex v; if (value.getSchemaClass().isSubClassOf(OrientVertex.CLASS_NAME)) { // DIRECT VERTEX v = new OrientVertex(vertex.graph, value); } else if (value.getSchemaClass().isSubClassOf(OrientEdge.CLASS_NAME)) { // EDGE if (vertex.graph.isUseVertexFieldsForEdgeLabels() || OrientEdge.isLabeled(OrientEdge.getRecordLabel(value), iLabels)) v = new OrientVertex(vertex.graph, OrientEdge.getConnection(value, connection.getKey().opposite())); else v = null; } else throw new IllegalStateException("Invalid content found between connections:" + value); return v; }
OrientEdge.getRecordLabel(fieldRecord), iLabels)) { final OIdentifiable vertexDoc = OrientEdge.getConnection( fieldRecord, connection.getKey().opposite()); if (vertexDoc == null) { fieldRecord.reload(); "Cannot load edge " + fieldRecord + " to get the " + connection.getKey().opposite() + " vertex"); return;
OIdentifiable vertexDoc = OrientEdge.getConnection(fieldRecord, connection.getKey().opposite()); if (vertexDoc == null) { vertexDoc = OrientEdge.getConnection(fieldRecord, connection.getKey().opposite()); .warn(this, "Cannot load edge " + fieldRecord + " to get the " + connection.getKey().opposite() + " vertex"); return;
Object targetVertex = OrientEdge.getConnection(fieldRecord, connection.getKey().opposite());
TitanVertex oth = edge.getVertex(dir.opposite()); assert oth instanceof TitanSchemaVertex; TypeDefinitionDescription desc = edge.getProperty(BaseKey.SchemaDefinitionDesc);