Skip to content

Commit

Permalink
No need for a intermediate map if keep_node_ids is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
jexp committed Jul 1, 2020
1 parent 2cf6825 commit 1c097ca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.neo4j</groupId>
<artifactId>store-util</artifactId>
<version>3.5.11</version>
<version>3.5.19</version>
<packaging>jar</packaging>

<name>store-util</name>
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/org/neo4j/tool/StoreCopy.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.eclipse.collections.api.map.primitive.MutableLongLongMap;
import org.eclipse.collections.impl.map.mutable.primitive.LongLongHashMap;
import org.neo4j.graphdb.*;
import org.neo4j.graphdb.factory.*;
import org.neo4j.helpers.Exceptions;
import org.neo4j.helpers.collection.Iterables;
import org.neo4j.helpers.collection.MapUtil;
Expand Down Expand Up @@ -208,8 +209,11 @@ private static void flushCache(BatchInserter sourceDb, long node) {
}

private static boolean createRelationship(BatchInserter targetDb, BatchInserter sourceDb, BatchRelationship rel, Set<String> ignoreProperties, LongLongMap copiedNodeIds) {
long startNodeId = copiedNodeIds.get(rel.getStartNode());
long endNodeId = copiedNodeIds.get(rel.getEndNode());
long startNodeId = rel.getStartNode(), endNodeId = rel.getEndNode();
if (copiedNodeIds != null) {
startNodeId = copiedNodeIds.get(startNodeId);
endNodeId = copiedNodeIds.get(endNodeId);
}
if (startNodeId == -1L || endNodeId == -1L) return false;
final RelationshipType type = rel.getType();
try {
Expand All @@ -224,7 +228,7 @@ private static boolean createRelationship(BatchInserter targetDb, BatchInserter
}

private static LongLongMap copyNodes(BatchInserter sourceDb, BatchInserter targetDb, Set<String> ignoreProperties, Set<String> ignoreLabels, Set<String> deleteNodesWithLabels, long highestNodeId, Flusher flusher, boolean stableNodeIds) {
MutableLongLongMap copiedNodes = stableNodeIds ? new LongLongHashMap() : new LongLongHashMap(10_000_000);
MutableLongLongMap copiedNodes = stableNodeIds ? new LongLongHashMap() : null;
long time = System.currentTimeMillis();
long node = 0;
long notFound = 0;
Expand All @@ -235,13 +239,12 @@ private static LongLongMap copyNodes(BatchInserter sourceDb, BatchInserter targe
if (labelInSet(sourceDb.getNodeLabels(node),deleteNodesWithLabels)) {
removed ++;
} else {
long newNodeId=node;
if (stableNodeIds) {
targetDb.createNode(node, getProperties(sourceDb.getNodeProperties(node), ignoreProperties), labelsArray(sourceDb, node, ignoreLabels));
} else {
newNodeId = targetDb.createNode(getProperties(sourceDb.getNodeProperties(node), ignoreProperties), labelsArray(sourceDb, node, ignoreLabels));
long newNodeId = targetDb.createNode(getProperties(sourceDb.getNodeProperties(node), ignoreProperties), labelsArray(sourceDb, node, ignoreLabels));
copiedNodes.put(node,newNodeId);
}
copiedNodes.put(node,newNodeId);
}
} else {
notFound++;
Expand Down

0 comments on commit 1c097ca

Please sign in to comment.