public void run(int id) throws EntityNotFoundException { degree[id] = ops.nodeGetDegree(id, direction, relationshipTypeId); } });
public void run(int id) throws EntityNotFoundException { ops.relationshipVisit(id, visitor); } });
@Override public void compute(String label, String type, int iterations) { float[] src = new float[nodes]; dst = new float[nodes]; try ( Transaction tx = db.beginTx()) { ThreadToStatementContextBridge ctx = this.db.getDependencyResolver().resolveDependency(ThreadToStatementContextBridge.class); ReadOperations ops = ctx.get().readOperations(); int labelId = ops.labelGetForName(label); int typeId = ops.relationshipTypeGetForName(type); int[] degrees = computeDegrees(ops,labelId, typeId); RelationshipVisitor<RuntimeException> visitor = new RelationshipVisitor<RuntimeException>() { public void visit(long relId, int relTypeId, long startNode, long endNode) throws RuntimeException { if (relTypeId == typeId) { dst[((int) endNode)] += src[(int) startNode]; } } }; for (int iteration = 0; iteration < iterations; iteration++) { startIteration(src, dst, degrees); PrimitiveLongIterator rels = ops.relationshipsGetAll(); while (rels.hasNext()) { ops.relationshipVisit(rels.next(), visitor); } } tx.success(); } catch (EntityNotFoundException e) { e.printStackTrace(); } }
@Override public void compute(String label, String type, int iterations) { degree = new int[nodeCount]; Arrays.fill(degree, -1); try ( Transaction tx = db.beginTx()) { ThreadToStatementContextBridge ctx = this.db.getDependencyResolver().resolveDependency(ThreadToStatementContextBridge.class); ReadOperations ops = ctx.get().readOperations(); int labelId = ops.labelGetForName(label); int relationshipTypeId = ops.relationshipTypeGetForName(type); PrimitiveLongIterator it = ops.nodesGetForLabel(labelId); int totalCount = nodeCount; runOperations(pool, it, totalCount, ops, new OpsRunner() { public void run(int id) throws EntityNotFoundException { degree[id] = ops.nodeGetDegree(id, direction, relationshipTypeId); } }); tx.success(); } catch (Exception e) { e.printStackTrace(); } }
tx.success(); label1 = readOperationsOn( db ).labelGetForName( "label1" ); label2 = readOperationsOn( db ).labelGetForName( "label2" ); label3 = readOperationsOn( db ).labelGetForName( "label3" ); label4 = readOperationsOn( db ).labelGetForName( "label4" ); draconian = tokenWriteOperationsOn( db ).labelGetOrCreateForName( "draconian" ); key = readOperationsOn( db ).propertyKeyGetForName( "key" ); mandatory = tokenWriteOperationsOn( db ).propertyKeyGetOrCreateForName( "mandatory" ); C = readOperationsOn( db ).relationshipTypeGetForName( "C" ); T = readOperationsOn( db ).relationshipTypeGetForName( "T" ); M = tokenWriteOperationsOn( db ).relationshipTypeGetOrCreateForName( "M" );
private int[] computeDegrees(ReadOperations ops, int labelId, int relationshipId) throws EntityNotFoundException { int[] degrees = new int[nodes]; Arrays.fill(degrees,-1); PrimitiveLongIterator nodes = ops.nodesGetForLabel(labelId); while (nodes.hasNext()) { long node = nodes.next(); degrees[((int)node)]= ops.nodeGetDegree(node, Direction.OUTGOING, relationshipId); } return degrees; }
private int[] computeDegrees(ReadOperations ops, int labelId, int relationshipId) throws EntityNotFoundException { int[] degree = new int[nodeCount]; Arrays.fill(degree,-1); PrimitiveLongIterator it = ops.nodesGetForLabel(labelId); int totalCount = nodeCount; runOperations(pool, it, totalCount, ops, new OpsRunner() { public void run(int id) throws EntityNotFoundException { degree[id] = ops.nodeGetDegree(id, Direction.OUTGOING, relationshipId); } }); return degree; }
dst = new AtomicIntegerArray(nodeCount); try ( Transaction tx = db.beginTx()) { ThreadToStatementContextBridge ctx = this.db.getDependencyResolver().resolveDependency(ThreadToStatementContextBridge.class); ReadOperations ops = ctx.get().readOperations(); int labelId = ops.labelGetForName(label); int typeId = ops.relationshipTypeGetForName(type); startIteration(src, dst, degrees); PrimitiveLongIterator rels = ops.relationshipsGetAll(); runOperations(pool, rels, relCount , ops, new OpsRunner() { public void run(int id) throws EntityNotFoundException {
public void run(int id) throws EntityNotFoundException { degree[id] = ops.nodeGetDegree(id, Direction.OUTGOING, relationshipId); } });