use of com.baidu.hugegraph.backend.store.Shard in project incubator-hugegraph by apache.
the class VertexCoreTest method testScanVertex.
@Test
public void testScanVertex() {
HugeGraph graph = graph();
// TODO: also support test scan by range
Assume.assumeTrue("Not support scan", storeFeatures().supportsScanToken() || storeFeatures().supportsScanKeyRange());
this.init10VerticesAndCommit();
List<Vertex> vertices = new LinkedList<>();
long splitSize = 1 * 1024 * 1024;
List<Shard> splits = graph.metadata(HugeType.VERTEX, "splits", splitSize);
for (Shard split : splits) {
ConditionQuery q = new ConditionQuery(HugeType.VERTEX);
q.scan(split.start(), split.end());
vertices.addAll(ImmutableList.copyOf(graph.vertices(q)));
}
Assert.assertEquals(10, vertices.size());
}
use of com.baidu.hugegraph.backend.store.Shard in project incubator-hugegraph by apache.
the class EdgesAPI method shards.
@GET
@Timed
@Path("shards")
@Compress
@Produces(APPLICATION_JSON_WITH_CHARSET)
public String shards(@Context GraphManager manager, @PathParam("graph") String graph, @QueryParam("split_size") long splitSize) {
LOG.debug("Graph [{}] get vertex shards with split size '{}'", graph, splitSize);
HugeGraph g = graph(manager, graph);
List<Shard> shards = g.metadata(HugeType.EDGE_OUT, "splits", splitSize);
return manager.serializer(g).writeList("shards", shards);
}
use of com.baidu.hugegraph.backend.store.Shard in project incubator-hugegraph by apache.
the class VerticesAPI method shards.
@GET
@Timed
@Path("shards")
@Compress
@Produces(APPLICATION_JSON_WITH_CHARSET)
public String shards(@Context GraphManager manager, @PathParam("graph") String graph, @QueryParam("split_size") long splitSize) {
LOG.debug("Graph [{}] get vertex shards with split size '{}'", graph, splitSize);
HugeGraph g = graph(manager, graph);
List<Shard> shards = g.metadata(HugeType.VERTEX, "splits", splitSize);
return manager.serializer(g).writeList("shards", shards);
}
use of com.baidu.hugegraph.backend.store.Shard in project incubator-hugegraph by apache.
the class RocksDBTable method queryByCond.
protected BackendColumnIterator queryByCond(Session session, ConditionQuery query) {
if (query.containsScanRelation()) {
E.checkArgument(query.relations().size() == 1, "Invalid scan with multi conditions: %s", query);
Relation scan = query.relations().iterator().next();
Shard shard = (Shard) scan.value();
return this.queryByRange(session, shard, query.page());
}
throw new NotSupportException("query: %s", query);
}
use of com.baidu.hugegraph.backend.store.Shard in project incubator-hugegraph by apache.
the class RangeTest method testRangeOfRegionWithStartKeyAndEndKey.
@Test
public void testRangeOfRegionWithStartKeyAndEndKey() {
byte[] start = new byte[] { -3, 0x31, 0x30, 0x30, 0x30, 0x77, 0x20, 0x09, 0x38, 0x31, 0x33, 0x32, 0x35 };
byte[] end = new byte[] { -3, 0x31, 0x33, 0x35, 0x33, 0x32, 0x37, 0x34, 0x31, 0x35, 0x32 };
Range range = new Range(start, end);
List<Shard> shards = range.splitEven(0);
Assert.assertEquals(1, shards.size());
Assert.assertEquals("/TEwMDB3IAk4MTMyNQ==", shards.get(0).start());
Assert.assertEquals("/TEzNTMyNzQxNTI=", shards.get(0).end());
shards = range.splitEven(1);
Assert.assertEquals(1, shards.size());
Assert.assertEquals("/TEwMDB3IAk4MTMyNQ==", shards.get(0).start());
Assert.assertEquals("/TEzNTMyNzQxNTI=", shards.get(0).end());
shards = range.splitEven(2);
Assert.assertEquals(3, shards.size());
Assert.assertEquals("/TEwMDB3IAk4MTMyNQ==", shards.get(0).start());
Assert.assertEquals("/TExsrHUq560szKZGg==", shards.get(0).end());
Assert.assertEquals("/TExsrHUq560szKZGg==", shards.get(1).start());
Assert.assertEquals("/TEzNTMyNzQxNTH//w==", shards.get(1).end());
Assert.assertEquals("/TEzNTMyNzQxNTH//w==", shards.get(2).start());
Assert.assertEquals("/TEzNTMyNzQxNTI=", shards.get(2).end());
for (int i = 3; i < 100; i++) {
range.splitEven(i);
}
}
Aggregations