public static String[] split(String id) { return SplicingIdGenerator.split(id); } }
private void parseColumn(String colName, String colValue, HugeVertex vertex) { // Column name String type = SplicingIdGenerator.split(colName)[0]; // Parse property if (type.equals(writeType(HugeType.PROPERTY))) { this.parseProperty(colName, colValue, vertex); } // Parse edge else if (type.equals(writeType(HugeType.EDGE_OUT)) || type.equals(writeType(HugeType.EDGE_IN))) { this.parseEdge(colName, colValue, vertex); } // Parse system property else if (type.equals(writeType(HugeType.SYS_PROPERTY))) { // pass } // Invalid entry else { E.checkState(false, "Invalid entry with unknown type(%s): %s", type, colName); } }
public static EdgeId parse(String id) throws NotFoundException { String[] idParts = SplicingIdGenerator.split(id); if (!(idParts.length == 4 || idParts.length == 5)) { throw new NotFoundException("Edge id must be formatted as 4~5 parts" + ", but got '%s'", id); } try { if (idParts.length == 4) { Id ownerVertexId = IdUtil.readString(idParts[0]); Id edgeLabelId = IdGenerator.of(Long.parseLong(idParts[1])); String sortValues = idParts[2]; Id otherVertexId = IdUtil.readString(idParts[3]); return new EdgeId(ownerVertexId, Directions.OUT, edgeLabelId, sortValues, otherVertexId); } else { assert idParts.length == 5; Id ownerVertexId = IdUtil.readString(idParts[0]); HugeType direction = HugeType.fromString(idParts[1]); Id edgeLabelId = IdGenerator.of(Long.parseLong(idParts[2])); String sortValues = idParts[3]; Id otherVertexId = IdUtil.readString(idParts[4]); return new EdgeId(ownerVertexId, Directions.convert(direction), edgeLabelId, sortValues, otherVertexId); } } catch (Exception e) { throw new NotFoundException("Invalid format of edge id '%s'", id); } }
public static String[] split(String id) { return SplicingIdGenerator.split(id); } }
private void parseProperty(String colName, String colValue, HugeElement owner) { String[] colParts = SplicingIdGenerator.split(colName); assert colParts.length == 2 : colName; // Get PropertyKey by PropertyKey id PropertyKey pkey = owner.graph().propertyKey(readId(colParts[1])); // Parse value Object value = JsonUtil.fromJson(colValue, pkey.clazz()); // Set properties of vertex/edge if (pkey.cardinality() == Cardinality.SINGLE) { owner.addProperty(pkey, value); } else { if (!(value instanceof Collection)) { throw new BackendException( "Invalid value of non-sigle property: %s", colValue); } for (Object v : (Collection<?>) value) { v = JsonUtil.castNumber(v, pkey.dataType().clazz()); owner.addProperty(pkey, v); } } }
private void parseColumn(String colName, String colValue, HugeVertex vertex) { // Column name String type = SplicingIdGenerator.split(colName)[0]; // Parse property if (type.equals(writeType(HugeType.PROPERTY))) { this.parseProperty(colName, colValue, vertex); } // Parse edge else if (type.equals(writeType(HugeType.EDGE_OUT)) || type.equals(writeType(HugeType.EDGE_IN))) { this.parseEdge(colName, colValue, vertex); } // Parse system property else if (type.equals(writeType(HugeType.SYS_PROPERTY))) { // pass } // Invalid entry else { E.checkState(false, "Invalid entry with unknown type(%s): %s", type, colName); } }
public static EdgeId parse(String id) throws NotFoundException { String[] idParts = SplicingIdGenerator.split(id); if (!(idParts.length == 4 || idParts.length == 5)) { throw new NotFoundException("Edge id must be formatted as 4~5 parts" + ", but got '%s'", id); } try { if (idParts.length == 4) { Id ownerVertexId = IdUtil.readString(idParts[0]); Id edgeLabelId = IdGenerator.of(Long.parseLong(idParts[1])); String sortValues = idParts[2]; Id otherVertexId = IdUtil.readString(idParts[3]); return new EdgeId(ownerVertexId, Directions.OUT, edgeLabelId, sortValues, otherVertexId); } else { assert idParts.length == 5; Id ownerVertexId = IdUtil.readString(idParts[0]); HugeType direction = HugeType.fromString(idParts[1]); Id edgeLabelId = IdGenerator.of(Long.parseLong(idParts[2])); String sortValues = idParts[3]; Id otherVertexId = IdUtil.readString(idParts[4]); return new EdgeId(ownerVertexId, Directions.convert(direction), edgeLabelId, sortValues, otherVertexId); } } catch (Exception e) { throw new NotFoundException("Invalid format of edge id '%s'", id); } }
private void parseProperty(String colName, String colValue, HugeElement owner) { String[] colParts = SplicingIdGenerator.split(colName); assert colParts.length == 2 : colName; // Get PropertyKey by PropertyKey id PropertyKey pkey = owner.graph().propertyKey(readId(colParts[1])); // Parse value Object value = JsonUtil.fromJson(colValue, pkey.clazz()); // Set properties of vertex/edge if (pkey.cardinality() == Cardinality.SINGLE) { owner.addProperty(pkey, value); } else { if (!(value instanceof Collection)) { throw new BackendException( "Invalid value of non-sigle property: %s", colValue); } for (Object v : (Collection<?>) value) { v = JsonUtil.castNumber(v, pkey.dataType().clazz()); owner.addProperty(pkey, v); } } }