private Query writeQueryEdgePrefixCondition(ConditionQuery cq) { // Convert query-by-condition to query-by-id List<String> condParts = new ArrayList<>(cq.conditions().size()); for (HugeKeys key : EdgeId.KEYS) { Object value = cq.condition(key); if (value == null) { break; } // Serialize condition value if (key == HugeKeys.OWNER_VERTEX || key == HugeKeys.OTHER_VERTEX) { condParts.add(writeEntryId((Id) value)); } else if (key == HugeKeys.DIRECTION) { condParts.add(writeType(((Directions) value).type())); } else if (key == HugeKeys.LABEL) { condParts.add(writeId((Id) value)); } else { condParts.add(value.toString()); } } if (condParts.size() > 0) { // Conditions to id String id = EdgeId.concat(condParts.toArray(new String[0])); return new IdPrefixQuery(cq, IdGenerator.of(id)); } return null; }
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])); }
start.add(writeType(((Directions) direction).type())); start.add(writeId((Id) label));
@Override public String asString() { if (this.cache != null) { return this.cache; } if (this.directed) { this.cache = SplicingIdGenerator.concat( IdUtil.writeString(this.ownerVertexId), this.direction.type().string(), this.edgeLabelId.asString(), this.sortValues, IdUtil.writeString(this.otherVertexId)); } else { this.cache = SplicingIdGenerator.concat( IdUtil.writeString(this.sourceVertexId()), this.edgeLabelId.asString(), this.sortValues, IdUtil.writeString(this.targetVertexId())); } return this.cache; }
buffer.writeId(id); } else if (key == HugeKeys.DIRECTION) { byte t = ((Directions) value).type().code(); buffer.write(t); } else if (key == HugeKeys.LABEL) {
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); }
start.write(((Directions) direction).type().code()); start.writeId((Id) label);
@Override protected Id writeQueryEdgeCondition(Query query) { // Convert query-by-condition to query-by-id List<String> condParts = new ArrayList<>(query.conditions().size()); for (HugeKeys key : EdgeId.KEYS) { Object value = ((ConditionQuery) query).condition(key); if (value == null) { break; } // Serialize condition value if (key == HugeKeys.OWNER_VERTEX || key == HugeKeys.OTHER_VERTEX) { condParts.add(writeEntryId((Id) value)); } else if (key == HugeKeys.DIRECTION) { condParts.add(writeType(((Directions) value).type())); } else if (key == HugeKeys.LABEL) { condParts.add(writeId((Id) value)); } else { condParts.add(value.toString()); } } if (condParts.size() > 0) { // Conditions to id String id = EdgeId.concat(condParts.toArray(new String[0])); return IdGenerator.of(id); } return null; }
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])); }
buffer.writeId(id); } else if (key == HugeKeys.DIRECTION) { byte t = ((Directions) value).type().code(); buffer.write(t); } else if (key == HugeKeys.LABEL) {
@Override public String asString() { if (this.cache != null) { return this.cache; } if (this.directed) { this.cache = SplicingIdGenerator.concat( IdUtil.writeString(this.ownerVertexId), this.direction.type().string(), this.edgeLabelId.asString(), this.sortValues, IdUtil.writeString(this.otherVertexId)); } else { this.cache = SplicingIdGenerator.concat( IdUtil.writeString(this.sourceVertexId()), this.edgeLabelId.asString(), this.sortValues, IdUtil.writeString(this.targetVertexId())); } return this.cache; }
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); }