public static Id getIdValue(Object idValue) { Id id = HugeElement.getIdValue(idValue); if (id == null || id instanceof EdgeId) { return id; } return EdgeId.parse(id.asString()); } }
@Override public EdgeId read(Kryo kryo, Input input, Class<EdgeId> clazz) { int length = input.read(); byte[] idBytes = input.readBytes(length); return EdgeId.parse(StringEncoding.decode(idBytes)); } }
@Override public T deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException { Class<?> clazz = this.handledType(); if (clazz.equals(IdGenerator.LongId.class)) { Number idValue = ctxt.readValue(jsonParser, Number.class); return (T) IdGenerator.of(idValue.longValue()); } else if (clazz.equals(IdGenerator.StringId.class)) { String idValue = ctxt.readValue(jsonParser, String.class); return (T) IdGenerator.of(idValue); } else { assert clazz.equals(EdgeId.class); String idValue = ctxt.readValue(jsonParser, String.class); return (T) EdgeId.parse(idValue); } } }
public static Id getIdValue(HugeType type, Object idValue) { assert type.isGraph(); Id id = getIdValue(idValue); if (type.isVertex()) { return id; } else { return EdgeId.parse(id.asString()); } }
private String writeEdgeId(Id id, boolean withOwnerVertex) { EdgeId edgeId; if (id instanceof EdgeId) { edgeId = (EdgeId) id; } else { edgeId = EdgeId.parse(id.asString()); } List<String> list = new ArrayList<>(5); if (withOwnerVertex) { list.add(writeEntryId(edgeId.ownerVertexId())); } // Edge name: type + edge-label-name + sortKeys + targetVertex list.add(writeType(edgeId.direction().type())); list.add(writeId(edgeId.edgeLabelId())); list.add(edgeId.sortValues()); list.add(writeEntryId(edgeId.otherVertexId())); return EdgeId.concat(list.toArray(new String[0])); }
@Override protected Id writeQueryId(HugeType type, Id id) { if (type.isEdge()) { if (!(id instanceof EdgeId)) { id = EdgeId.parse(id.asString()); } } else if (type.isGraph()) { id = IdGenerator.of(IdUtil.writeString(id)); } return id; }
@Override protected List<Object> idColumnValue(Id id) { EdgeId edgeId; if (!(id instanceof EdgeId)) { String[] idParts = EdgeId.split(id); if (idParts.length == 1) { // Delete edge by label return Arrays.asList((Object[]) idParts); } id = IdUtil.readString(id.asString()); edgeId = EdgeId.parse(id.asString()); } else { edgeId = (EdgeId) id; } E.checkState(edgeId.direction() == this.direction, "Can't query %s edges from %s edges table", edgeId.direction(), this.direction); List<Object> list = new ArrayList<>(5); list.add(IdUtil.writeString(edgeId.ownerVertexId())); list.add(edgeId.direction().code()); list.add(edgeId.edgeLabelId().asLong()); list.add(edgeId.sortValues()); list.add(IdUtil.writeString(edgeId.otherVertexId())); return list; }
@Override protected List<Object> idColumnValue(Id id) { EdgeId edgeId; if (!(id instanceof EdgeId)) { String[] idParts = EdgeId.split(id); if (idParts.length == 1) { // Delete edge by label return Arrays.asList((Object[]) idParts); } id = IdUtil.readString(id.asString()); edgeId = EdgeId.parse(id.asString()); } else { edgeId = (EdgeId) id; } E.checkState(edgeId.direction() == this.direction, "Can't query %s edges from %s edges table", edgeId.direction(), this.direction); List<Object> list = new ArrayList<>(5); list.add(IdUtil.writeString(edgeId.ownerVertexId())); list.add(edgeId.direction().code()); list.add(edgeId.edgeLabelId().asLong()); list.add(edgeId.sortValues()); list.add(IdUtil.writeString(edgeId.otherVertexId())); return list; }
@Override protected List<Object> idColumnValue(Id id) { EdgeId edgeId; if (!(id instanceof EdgeId)) { String[] idParts = EdgeId.split(id); if (idParts.length == 1) { // Delete edge by label return Arrays.asList((Object[]) idParts); } id = IdUtil.readString(id.asString()); edgeId = EdgeId.parse(id.asString()); } else { edgeId = (EdgeId) id; } E.checkState(edgeId.direction() == this.direction, "Can't query %s edges from %s edges table", edgeId.direction(), this.direction); return idColumnValue(edgeId); }
EdgeId id = EdgeId.parse(rawId.asString()).directed(true); assert id.direction() == Directions.OUT; deleteEdge.accept(id);
private static BinaryId writeEdgeId(Id id) { EdgeId edgeId; if (id instanceof EdgeId) { edgeId = (EdgeId) id; } else { edgeId = EdgeId.parse(id.asString()); } BytesBuffer buffer = BytesBuffer.allocate(256); buffer.writeId(edgeId.ownerVertexId()); buffer.write(edgeId.direction().type().code()); buffer.writeId(edgeId.edgeLabelId()); buffer.writeString(edgeId.sortValues()); buffer.writeId(edgeId.otherVertexId()); return new BinaryId(buffer.bytes(), id); }
public static Id getIdValue(Object idValue) { Id id = HugeElement.getIdValue(idValue); if (id == null || id instanceof EdgeId) { return id; } return EdgeId.parse(id.asString()); } }
@Override public EdgeId read(Kryo kryo, Input input, Class<EdgeId> clazz) { int length = input.read(); byte[] idBytes = input.readBytes(length); return EdgeId.parse(StringEncoding.decode(idBytes)); } }
@Override public T deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException { Class<?> clazz = this.handledType(); if (clazz.equals(IdGenerator.LongId.class)) { Number idValue = ctxt.readValue(jsonParser, Number.class); return (T) IdGenerator.of(idValue.longValue()); } else if (clazz.equals(IdGenerator.StringId.class)) { String idValue = ctxt.readValue(jsonParser, String.class); return (T) IdGenerator.of(idValue); } else { assert clazz.equals(EdgeId.class); String idValue = ctxt.readValue(jsonParser, String.class); return (T) EdgeId.parse(idValue); } } }
public static Id getIdValue(HugeType type, Object idValue) { assert type.isGraph(); Id id = getIdValue(idValue); if (type.isVertex()) { return id; } else { return EdgeId.parse(id.asString()); } }
private String writeEdgeId(Id id, boolean withOwnerVertex) { EdgeId edgeId; if (id instanceof EdgeId) { edgeId = (EdgeId) id; } else { edgeId = EdgeId.parse(id.asString()); } List<String> list = new ArrayList<>(5); if (withOwnerVertex) { list.add(writeEntryId(edgeId.ownerVertexId())); } // Edge name: type + edge-label-name + sortKeys + targetVertex list.add(writeType(edgeId.direction().type())); list.add(writeId(edgeId.edgeLabelId())); list.add(edgeId.sortValues()); list.add(writeEntryId(edgeId.otherVertexId())); return EdgeId.concat(list.toArray(new String[0])); }
@Override protected Id writeQueryId(HugeType type, Id id) { if (type.isEdge()) { if (!(id instanceof EdgeId)) { id = EdgeId.parse(id.asString()); } } else if (type.isGraph()) { id = IdGenerator.of(IdUtil.writeString(id)); } return id; }
@Override protected List<Object> idColumnValue(Id id) { EdgeId edgeId; if (!(id instanceof EdgeId)) { String[] idParts = EdgeId.split(id); if (idParts.length == 1) { // Delete edge by label return Arrays.asList((Object[]) idParts); } id = IdUtil.readString(id.asString()); edgeId = EdgeId.parse(id.asString()); } else { edgeId = (EdgeId) id; } E.checkState(edgeId.direction() == this.direction, "Can't query %s edges from %s edges table", edgeId.direction(), this.direction); List<Object> list = new ArrayList<>(5); list.add(IdUtil.writeString(edgeId.ownerVertexId())); list.add(edgeId.direction().code()); list.add(edgeId.edgeLabelId().asLong()); list.add(edgeId.sortValues()); list.add(IdUtil.writeString(edgeId.otherVertexId())); return list; }
@Override protected List<Object> idColumnValue(Id id) { EdgeId edgeId; if (!(id instanceof EdgeId)) { String[] idParts = EdgeId.split(id); if (idParts.length == 1) { // Delete edge by label return Arrays.asList((Object[]) idParts); } id = IdUtil.readString(id.asString()); edgeId = EdgeId.parse(id.asString()); } else { edgeId = (EdgeId) id; } E.checkState(edgeId.direction() == this.direction, "Can't query %s edges from %s edges table", edgeId.direction(), this.direction); return idColumnValue(edgeId); }
private static BinaryId writeEdgeId(Id id) { EdgeId edgeId; if (id instanceof EdgeId) { edgeId = (EdgeId) id; } else { edgeId = EdgeId.parse(id.asString()); } BytesBuffer buffer = BytesBuffer.allocate(256); buffer.writeId(edgeId.ownerVertexId()); buffer.write(edgeId.direction().type().code()); buffer.writeId(edgeId.edgeLabelId()); buffer.writeString(edgeId.sortValues()); buffer.writeId(edgeId.otherVertexId()); return new BinaryId(buffer.bytes(), id); }