本文整理汇总了Java中org.neo4j.kernel.api.exceptions.EntityNotFoundException类的典型用法代码示例。如果您正苦于以下问题:Java EntityNotFoundException类的具体用法?Java EntityNotFoundException怎么用?Java EntityNotFoundException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EntityNotFoundException类属于org.neo4j.kernel.api.exceptions包,在下文中一共展示了EntityNotFoundException类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processEntry
import org.neo4j.kernel.api.exceptions.EntityNotFoundException; //导入依赖的package包/类
private void processEntry(Work work, ReadOperations ops) throws EntityNotFoundException, InterruptedException, IOException {
relationshipIterator = ops.nodeGetRelationships(work.getNodeId(), org.neo4j.graphdb.Direction.BOTH);
while (relationshipIterator.hasNext()) {
c = ops.relationshipCursor(relationshipIterator.next());
if (c.next()
&& (boolean) c.get().getProperty( Energization.propertyIncomingSwitchOn)
&& (boolean) c.get().getProperty( Energization.propertyOutgoingSwitchOn)) {
long otherNodeId = c.get().otherNode(work.getNodeId());
if (!energized2.contains((int) otherNodeId)) {
double newVoltage = (double) ops.nodeGetProperty(otherNodeId, Energization.propertyVoltage);
if (newVoltage <= (double) work.getVoltage()) {
if(energized2.checkedAdd((int) otherNodeId)) {
results.add((String) ops.nodeGetProperty(otherNodeId, Energization.propertyEquipmentId));
processQueue.put(new Work(otherNodeId, newVoltage));
}
}
}
}
}
}
示例2: compute
import org.neo4j.kernel.api.exceptions.EntityNotFoundException; //导入依赖的package包/类
@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();
}
}
示例3: compute
import org.neo4j.kernel.api.exceptions.EntityNotFoundException; //导入依赖的package包/类
@Override
public void compute(int iterations) {
final int[] src = new int[nodeCount];
dst = new AtomicIntegerArray(nodeCount);
try ( Transaction tx = db.beginTx()) {
ThreadToStatementContextBridge ctx = this.db.getDependencyResolver().resolveDependency(ThreadToStatementContextBridge.class);
final ReadOperations ops = ctx.get().readOperations();
int[] degrees = computeDegrees(ops);
final RelationshipVisitor<RuntimeException> visitor = new RelationshipVisitor<RuntimeException>() {
public void visit(long relId, int relTypeId, long startNode, long endNode) throws RuntimeException {
dst.addAndGet(((int) endNode), src[(int) startNode]);
}
};
for (int iteration = 0; iteration < iterations; iteration++) {
startIteration(src, dst, degrees);
PrimitiveLongIterator rels = ops.relationshipsGetAll();
runOperations(pool, rels, relCount , ops, new OpsRunner() {
public void run(int id) throws EntityNotFoundException {
ops.relationshipVisit(id, visitor);
}
});
}
tx.success();
} catch (EntityNotFoundException e) {
e.printStackTrace();
}
}
示例4: computeDegrees
import org.neo4j.kernel.api.exceptions.EntityNotFoundException; //导入依赖的package包/类
private int[] computeDegrees(final ReadOperations ops) throws EntityNotFoundException {
final int[] degree = new int[nodeCount];
Arrays.fill(degree, -1);
PrimitiveLongIterator it = ops.nodesGetAll();
int totalCount = nodeCount;
runOperations(pool, it, totalCount, ops, new OpsRunner() {
public void run(int id) throws EntityNotFoundException {
degree[id] = ops.nodeGetDegree(id, Direction.OUTGOING);
}
});
return degree;
}
示例5: run
import org.neo4j.kernel.api.exceptions.EntityNotFoundException; //导入依赖的package包/类
public void run() {
int notFound = 0;
for (int i=0;i<offset;i++) {
try {
run((int) ids[i]);
} catch (EntityNotFoundException e) {
notFound++;
}
}
if (notFound > 0 ) System.err.println("Entities not found "+notFound);
}
示例6: compute
import org.neo4j.kernel.api.exceptions.EntityNotFoundException; //导入依赖的package包/类
@Override
public void compute(String label, String type, int iterations) {
int[] src = new int[nodeCount];
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);
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.addAndGet(((int) endNode),src[(int) startNode]);
}
}
};
for (int iteration = 0; iteration < iterations; iteration++) {
startIteration(src, dst, degrees);
PrimitiveLongIterator rels = ops.relationshipsGetAll();
runOperations(pool, rels, relCount , ops, new OpsRunner() {
public void run(int id) throws EntityNotFoundException {
ops.relationshipVisit(id, visitor);
}
});
}
tx.success();
} catch (EntityNotFoundException e) {
e.printStackTrace();
}
}
示例7: computeDegrees
import org.neo4j.kernel.api.exceptions.EntityNotFoundException; //导入依赖的package包/类
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;
}
示例8: compute
import org.neo4j.kernel.api.exceptions.EntityNotFoundException; //导入依赖的package包/类
@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();
}
}
示例9: energizationSPI
import org.neo4j.kernel.api.exceptions.EntityNotFoundException; //导入依赖的package包/类
@POST
@Path("/spi")
public Response energizationSPI(String body, @Context GraphDatabaseService db) throws IndexNotFoundKernelException, IOException, SchemaRuleNotFoundException, IndexBrokenKernelException, EntityNotFoundException {
HashMap input = Validators.getValidEquipmentIds(body);
HashSet<String> results = new HashSet<>();
try (Transaction tx = db.beginTx()) {
ThreadToStatementContextBridge ctx = dbapi.getDependencyResolver().resolveDependency(ThreadToStatementContextBridge.class);
ReadOperations ops = ctx.get().readOperations();
IndexDescriptor descriptor = ops.indexGetForLabelAndPropertyKey(equipmentLabelId, propertyEquipmentId);
HashMap<Long, Double> equipmentMap = new HashMap<>();
for (String equipmentId : (Collection<String>) input.get("ids")) {
Cursor<NodeItem> nodes = ops.nodeCursorGetFromUniqueIndexSeek(descriptor, equipmentId);
if (nodes.next()) {
long equipmentNodeId = nodes.get().id();
energized.add((int) equipmentNodeId);
results.add(equipmentId);
equipmentMap.put(equipmentNodeId, (double) ops.nodeGetProperty(equipmentNodeId, propertyVoltage));
while (!equipmentMap.isEmpty()) {
Map.Entry<Long, Double> entry = equipmentMap.entrySet().iterator().next();
equipmentMap.remove(entry.getKey());
RelationshipIterator relationshipIterator = ops.nodeGetRelationships(entry.getKey(), org.neo4j.graphdb.Direction.BOTH);
Cursor<RelationshipItem> c;
while (relationshipIterator.hasNext()) {
c = ops.relationshipCursor(relationshipIterator.next());
if (c.next() && (boolean) c.get().getProperty(propertyIncomingSwitchOn) && (boolean) c.get().getProperty(propertyOutgoingSwitchOn)) {
long otherNodeId = c.get().otherNode(entry.getKey());
if (!energized.contains((int) otherNodeId)) {
double newVoltage = (double) ops.nodeGetProperty(otherNodeId, propertyVoltage);
if (newVoltage <= entry.getValue()) {
results.add( (String)ops.nodeGetProperty(otherNodeId, propertyEquipmentId));
energized.add((int) otherNodeId);
equipmentMap.put(otherNodeId, newVoltage);
}
}
}
}
}
} else {
System.out.println("none found");
}
nodes.close();
}
tx.success();
}
return Response.ok().entity(objectMapper.writeValueAsString(results)).build();
}
示例10: energizationStreaming
import org.neo4j.kernel.api.exceptions.EntityNotFoundException; //导入依赖的package包/类
@POST
@Path("/streaming")
public Response energizationStreaming(String body, @Context GraphDatabaseService db) throws IndexNotFoundKernelException, IOException, SchemaRuleNotFoundException, IndexBrokenKernelException, EntityNotFoundException {
HashMap input = Validators.getValidEquipmentIds(body);
StreamingOutput stream = os -> {
JsonGenerator jg = objectMapper.getJsonFactory().createJsonGenerator(os, JsonEncoding.UTF8);
jg.writeStartArray();
try (Transaction tx = db.beginTx()) {
ThreadToStatementContextBridge ctx = dbapi.getDependencyResolver().resolveDependency(ThreadToStatementContextBridge.class);
ReadOperations ops = ctx.get().readOperations();
IndexDescriptor descriptor = ops.indexGetForLabelAndPropertyKey(equipmentLabelId, propertyEquipmentId);
HashMap<Long, Double> equipmentMap = new HashMap<>();
for (String equipmentId : (Collection<String>) input.get("ids")) {
Cursor<NodeItem> nodes = ops.nodeCursorGetFromUniqueIndexSeek(descriptor, equipmentId);
if (nodes.next()) {
long equipmentNodeId = nodes.get().id();
energized.add((int) equipmentNodeId);
jg.writeString(equipmentId);
equipmentMap.put(equipmentNodeId, (double) ops.nodeGetProperty(equipmentNodeId, propertyVoltage));
while (!equipmentMap.isEmpty()) {
Map.Entry<Long, Double> entry = equipmentMap.entrySet().iterator().next();
equipmentMap.remove(entry.getKey());
RelationshipIterator relationshipIterator = ops.nodeGetRelationships(entry.getKey(), org.neo4j.graphdb.Direction.BOTH);
Cursor<RelationshipItem> c;
while (relationshipIterator.hasNext()) {
c = ops.relationshipCursor(relationshipIterator.next());
if (c.next() && (boolean) c.get().getProperty(propertyIncomingSwitchOn) && (boolean) c.get().getProperty(propertyOutgoingSwitchOn)) {
long otherNodeId = c.get().otherNode(entry.getKey());
if (!energized.contains((int) otherNodeId)) {
double newVoltage = (double) ops.nodeGetProperty(otherNodeId, propertyVoltage);
if (newVoltage <= entry.getValue()) {
jg.writeString((String) ops.nodeGetProperty(otherNodeId, propertyEquipmentId));
energized.add((int) otherNodeId);
equipmentMap.put(otherNodeId, newVoltage);
}
}
}
}
}
}
nodes.close();
}
tx.success();
} catch (Exception e) {
e.printStackTrace();
}
jg.writeEndArray();
jg.flush();
jg.close();
};
return Response.ok().entity(stream).type(MediaType.APPLICATION_JSON).build();
}
示例11: run
import org.neo4j.kernel.api.exceptions.EntityNotFoundException; //导入依赖的package包/类
void run(int node) throws EntityNotFoundException;