use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class CassandraSerializer method writeOlapVertex.
@Override
public BackendEntry writeOlapVertex(HugeVertex vertex) {
CassandraBackendEntry entry = newBackendEntry(HugeType.OLAP, vertex.id());
entry.column(HugeKeys.ID, this.writeId(vertex.id()));
Collection<HugeProperty<?>> properties = vertex.getProperties();
E.checkArgument(properties.size() == 1, "Expect only 1 property for olap vertex, but got %s", properties.size());
HugeProperty<?> property = properties.iterator().next();
PropertyKey pk = property.propertyKey();
entry.subId(pk.id());
entry.column(HugeKeys.PROPERTY_VALUE, this.writeProperty(pk, property.value()));
entry.olap(true);
return entry;
}
use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class FakeObjects method newPropertyKey.
public PropertyKey newPropertyKey(Id id, String name, DataType dataType, Cardinality cardinality) {
PropertyKey schema = new PropertyKey(this.graph, id, name);
schema.dataType(dataType);
schema.cardinality(cardinality);
Mockito.when(this.graph.propertyKey(id)).thenReturn(schema);
Mockito.when(this.graph.propertyKey(name)).thenReturn(schema);
return schema;
}
use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class FakeObjects method newEdge.
public HugeEdge newEdge(long sourceVertexId, long targetVertexId) {
PropertyKey name = this.newPropertyKey(IdGenerator.of(1), "name");
PropertyKey age = this.newPropertyKey(IdGenerator.of(2), "age", DataType.INT, Cardinality.SINGLE);
PropertyKey city = this.newPropertyKey(IdGenerator.of(3), "city");
PropertyKey date = this.newPropertyKey(IdGenerator.of(4), "date", DataType.DATE);
PropertyKey weight = this.newPropertyKey(IdGenerator.of(5), "weight", DataType.DOUBLE);
VertexLabel vl = this.newVertexLabel(IdGenerator.of(1), "person", IdStrategy.CUSTOMIZE_NUMBER, name.id(), age.id(), city.id());
EdgeLabel el = this.newEdgeLabel(IdGenerator.of(1), "knows", Frequency.SINGLE, vl.id(), vl.id(), date.id(), weight.id());
HugeVertex source = new HugeVertex(this.graph(), IdGenerator.of(sourceVertexId), vl);
source.addProperty(name, "tom");
source.addProperty(age, 18);
source.addProperty(city, "Beijing");
HugeVertex target = new HugeVertex(this.graph(), IdGenerator.of(targetVertexId), vl);
target.addProperty(name, "cat");
target.addProperty(age, 20);
target.addProperty(city, "Shanghai");
Id id = EdgeId.parse("L123456>1>>L987654");
HugeEdge edge = new HugeEdge(this.graph(), id, el);
Whitebox.setInternalState(edge, "sourceVertex", source);
Whitebox.setInternalState(edge, "targetVertex", target);
edge.assignId();
edge.addProperty(date, new Date());
edge.addProperty(weight, 0.75);
return edge;
}
use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class FakeObjects method newEdge.
public HugeEdge newEdge(String sourceVertexId, String targetVertexId) {
PropertyKey name = this.newPropertyKey(IdGenerator.of(1), "name");
PropertyKey age = this.newPropertyKey(IdGenerator.of(2), "age", DataType.INT, Cardinality.SINGLE);
PropertyKey city = this.newPropertyKey(IdGenerator.of(3), "city");
PropertyKey date = this.newPropertyKey(IdGenerator.of(4), "date", DataType.DATE);
PropertyKey weight = this.newPropertyKey(IdGenerator.of(5), "weight", DataType.DOUBLE);
VertexLabel vl = this.newVertexLabel(IdGenerator.of(1), "person", IdStrategy.CUSTOMIZE_NUMBER, name.id(), age.id(), city.id());
EdgeLabel el = this.newEdgeLabel(IdGenerator.of(1), "knows", Frequency.SINGLE, vl.id(), vl.id(), date.id(), weight.id());
HugeVertex source = new HugeVertex(this.graph(), IdGenerator.of(sourceVertexId), vl);
source.addProperty(name, "tom");
source.addProperty(age, 18);
source.addProperty(city, "Beijing");
HugeVertex target = new HugeVertex(this.graph(), IdGenerator.of(targetVertexId), vl);
target.addProperty(name, "cat");
target.addProperty(age, 20);
target.addProperty(city, "Shanghai");
Id id = EdgeId.parse("L123456>1>>L987654");
HugeEdge edge = new HugeEdge(this.graph(), id, el);
Whitebox.setInternalState(edge, "sourceVertex", source);
Whitebox.setInternalState(edge, "targetVertex", target);
edge.assignId();
edge.addProperty(date, new Date());
edge.addProperty(weight, 0.75);
return edge;
}
use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class BinarySerializer method writeOlapVertex.
@Override
public BackendEntry writeOlapVertex(HugeVertex vertex) {
BinaryBackendEntry entry = newBackendEntry(HugeType.OLAP, vertex.id());
BytesBuffer buffer = BytesBuffer.allocate(8 + 16);
Collection<HugeProperty<?>> properties = vertex.getProperties();
if (properties.size() != 1) {
E.checkArgument(false, "Expect 1 property for olap vertex, but got %s", properties.size());
}
HugeProperty<?> property = properties.iterator().next();
PropertyKey propertyKey = property.propertyKey();
buffer.writeVInt(SchemaElement.schemaId(propertyKey.id()));
buffer.writeProperty(propertyKey, property.value());
// Fill column
byte[] name = this.keyWithIdPrefix ? entry.id().asBytes() : BytesBuffer.BYTES_EMPTY;
entry.column(name, buffer.bytes());
entry.subId(propertyKey.id());
entry.olap(true);
return entry;
}
Aggregations