use of org.janusgraph.graphdb.olap.VertexScanJob in project janusgraph by JanusGraph.
the class OLAPTest method scannerShouldSeeAllVertices.
@Test
public void scannerShouldSeeAllVertices() throws Exception {
GraphTraversalSource g = graph.traversal();
Vertex v1 = g.addV().next();
Vertex v2 = g.addV().next();
g.V(v1).addE("connect").to(v2).iterate();
g.addV().addV().addV().property("p", "v").iterate();
g.tx().commit();
AtomicInteger vertexNum = new AtomicInteger();
executeScanJob(new VertexScanJob() {
@Override
public void process(final JanusGraphVertex vertex, final ScanMetrics metrics) {
vertexNum.incrementAndGet();
}
@Override
public void getQueries(final QueryContainer queries) {
queries.addQuery().properties();
queries.addQuery().edges();
}
@Override
public VertexScanJob clone() {
return this;
}
});
assertEquals(g.V().count().next(), vertexNum.get());
}
use of org.janusgraph.graphdb.olap.VertexScanJob in project janusgraph by JanusGraph.
the class HadoopVertexScanMapper method setup.
@Override
protected void setup(Context context) throws IOException, InterruptedException {
/* Don't call super implementation super.setup(context); */
org.apache.hadoop.conf.Configuration hadoopConf = context.getConfiguration();
ModifiableHadoopConfiguration scanConf = ModifiableHadoopConfiguration.of(JanusGraphHadoopConfiguration.MAPRED_NS, hadoopConf);
VertexScanJob vertexScan = getVertexScanJob(scanConf);
ModifiableConfiguration graphConf = getJanusGraphConfiguration(context);
graph = JanusGraphFactory.open(graphConf);
job = VertexJobConverter.convert(graph, vertexScan);
metrics = new HadoopContextScanMetrics(context);
finishSetup(scanConf, graphConf);
}
use of org.janusgraph.graphdb.olap.VertexScanJob in project janusgraph by JanusGraph.
the class OLAPTest method testVertexScan.
@Test
public void testVertexScan() throws Exception {
int numV = 100;
int numE = generateRandomGraph(numV);
final String DEGREE_COUNT = "degree";
final String VERTEX_COUNT = "numV";
clopen();
ScanMetrics result1 = executeScanJob(new VertexScanJob() {
@Override
public void process(JanusGraphVertex vertex, ScanMetrics metrics) {
long outDegree = vertex.query().labels("knows").direction(Direction.OUT).edgeCount();
assertEquals(0, vertex.query().labels("knows").direction(Direction.IN).edgeCount());
assertEquals(1, vertex.query().labels("uid").propertyCount());
assertTrue(vertex.<Integer>property("uid").orElse(0) > 0);
metrics.incrementCustom(DEGREE_COUNT, outDegree);
metrics.incrementCustom(VERTEX_COUNT);
}
@Override
public void getQueries(QueryContainer queries) {
queries.addQuery().labels("knows").direction(Direction.OUT).edges();
queries.addQuery().keys("uid").properties();
}
@Override
public VertexScanJob clone() {
return this;
}
});
assertEquals(numV, result1.getCustom(VERTEX_COUNT));
assertEquals(numE, result1.getCustom(DEGREE_COUNT));
ScanMetrics result2 = executeScanJob(new VertexScanJob() {
@Override
public void process(JanusGraphVertex vertex, ScanMetrics metrics) {
metrics.incrementCustom(VERTEX_COUNT);
assertEquals(1, vertex.query().labels("numvals").propertyCount());
int numvals = vertex.value("numvals");
assertEquals(numvals, vertex.query().labels("values").propertyCount());
}
@Override
public void getQueries(QueryContainer queries) {
queries.addQuery().keys("values").properties();
queries.addQuery().keys("numvals").properties();
}
@Override
public VertexScanJob clone() {
return this;
}
});
assertEquals(numV, result2.getCustom(VERTEX_COUNT));
}
Aggregations