public static void write( final Map<String, List<FaunusEdge>> edges, final DataOutput out, final Direction idToWrite) throws IOException { out.writeShort(edges.size()); for (final Map.Entry<String, List<FaunusEdge>> entry : edges.entrySet()) { out.writeUTF(entry.getKey()); WritableUtils.writeVInt(out, entry.getValue().size()); for (final FaunusEdge edge : entry.getValue()) { edge.writeCompressed(out, idToWrite); } } }
public void enablePath(final boolean enablePath) { super.enablePath(enablePath); if (this.pathEnabled) { for (final Edge edge : this.getEdges(BOTH)) { ((FaunusEdge) edge).enablePath(true); } } }
public FaunusEdge addEdge(final Direction direction, final FaunusEdge edge) { if (OUT.equals(direction)) { List<Edge> edges = this.outEdges.get(edge.getLabel()); if (null == edges) { edges = new ArrayList<Edge>(); this.outEdges.put(edge.getLabel(), edges); } edges.add(edge); } else if (IN.equals(direction)) { List<Edge> edges = this.inEdges.get(edge.getLabel()); if (null == edges) { edges = new ArrayList<Edge>(); this.inEdges.put(edge.getLabel(), edges); } edges.add(edge); } else throw ExceptionFactory.bothIsNotSupported(); return edge; }
public static Map<String, List<FaunusEdge>> readFields( final DataInput in, final Direction idToRead, final long otherId) throws IOException { final Map<String, List<FaunusEdge>> edges = new HashMap<String, List<FaunusEdge>>(); int edgeTypes = in.readShort(); for (int i = 0; i < edgeTypes; i++) { final String label = in.readUTF(); final int size = WritableUtils.readVInt(in); final List<FaunusEdge> temp = new ArrayList<FaunusEdge>(size); for (int j = 0; j < size; j++) { final FaunusEdge edge = new FaunusEdge(); edge.readFieldsCompressed(in, idToRead); edge.setLabel(label); if (idToRead.equals(Direction.OUT)) edge.inVertex = otherId; else edge.outVertex = otherId; temp.add(edge); } edges.put(label, temp); } return edges; }