@Test public void testMore() { BatchInserter graphDb = globalInserter; long startNode = graphDb.createNode( properties ); long[] endNodes = new long[25]; Set<Long> rels = new HashSet<>(); for ( int i = 0; i < 25; i++ ) { endNodes[i] = graphDb.createNode( properties ); rels.add( graphDb.createRelationship( startNode, endNodes[i], relTypeArray[i % 5], properties ) ); } for ( BatchRelationship rel : graphDb.getRelationships( startNode ) ) { assertTrue( rels.contains( rel.getId() ) ); assertEquals( rel.getStartNode(), startNode ); } graphDb.setNodeProperties( startNode, properties ); }
/** * Construct a new proxy relationship. * * @param batchRelationship from Neo4j batch API. * @param batchInserter currently used for batch inserts. */ public BatchInserterRelationship(BatchRelationship batchRelationship, BatchInserter batchInserter) { this(batchRelationship.getId(), batchRelationship.getStartNode(), batchRelationship.getEndNode(), batchRelationship.getType(), batchInserter); }
private static boolean createRelationship(BatchInserter targetDb, BatchInserter sourceDb, BatchRelationship rel, Set<String> ignoreProperties, PrimitiveLongLongMap copiedNodeIds) { long startNodeId = copiedNodeIds.get(rel.getStartNode()); long endNodeId = copiedNodeIds.get(rel.getEndNode()); if (startNodeId == -1L || endNodeId == -1L) return false; final RelationshipType type = rel.getType(); try { Map<String, Object> props = getProperties(sourceDb.getRelationshipProperties(rel.getId()), ignoreProperties); // if (props.isEmpty()) props = Collections.<String,Object>singletonMap("old_id",rel.getId()); else props.put("old_id",rel.getId()); targetDb.createRelationship(startNodeId, endNodeId, type, props); return true; } catch (Exception e) { addLog(rel, "create Relationship: " + startNodeId + "-[:" + type + "]" + "->" + endNodeId, e.getMessage()); return false; } }