@Deprecated public LuceneBatchInserterIndexProviderNewImpl( final BatchInserter inserter ) { this.inserter = inserter; this.indexStore = ((IndexConfigStoreProvider) inserter).getIndexStore(); this.relationshipLookup = id -> { // TODO too may objects allocated here BatchRelationship rel = inserter.getRelationshipById( id ); return new EntityId.RelationshipData( id, rel.getStartNode(), rel.getEndNode() ); }; }
@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 ); }
@Test public void testSimple() { BatchInserter graphDb = globalInserter; long node1 = graphDb.createNode( null ); long node2 = graphDb.createNode( null ); long rel1 = graphDb.createRelationship( node1, node2, RelTypes.BATCH_TEST, null ); BatchRelationship rel = graphDb.getRelationshipById( rel1 ); assertEquals( rel.getStartNode(), node1 ); assertEquals( rel.getEndNode(), node2 ); assertEquals( RelTypes.BATCH_TEST.name(), rel.getType().name() ); }
assertEquals( startNode, rel.getStartNode() ); assertEquals( startNode, rel.getEndNode() ); assertEquals( startNode, rel.getStartNode() ); assertEquals( otherNode, rel.getEndNode() );
/** * 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 boolean directionMatches(BatchRelationship batchRelationship) { if (Direction.BOTH.equals(direction)) { return true; } if (Direction.INCOMING.equals(direction) && nodeId == batchRelationship.getEndNode()) { return true; } if (Direction.OUTGOING.equals(direction) && nodeId == batchRelationship.getStartNode()) { return true; } return false; }
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; } }