From c5d76cf03e5adf73582d18288d29ed538ac307ca Mon Sep 17 00:00:00 2001 From: Michael Hunger Date: Sun, 28 Sep 2014 22:57:31 +0200 Subject: [PATCH 01/33] update to 2.1.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 112b95a..cea89c3 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.neo4j store-util - 2.0.1 + 2.1.4 jar store-util From e81fde1831052380168337a483b7726247e2dda8 Mon Sep 17 00:00:00 2001 From: Michael Hunger Date: Sun, 28 Sep 2014 22:58:13 +0200 Subject: [PATCH 02/33] Update readme.md --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index d28ab0b..b72dd06 100644 --- a/readme.md +++ b/readme.md @@ -7,7 +7,7 @@ Ignores broken nodes and relationships. Also useful to skip no longer wanted properties or relationships with a certain type. Good for store compaction as it rewrites the store file reclaiming space that is sitting empty. -Change the Neo4j version in pom.xml before running. (Currently 1.9.5) +Change the Neo4j version in pom.xml before running. (Currently 2.1.4) ### Store Copy From a7aed40154988fc8091ebf830f1179c5f883a18e Mon Sep 17 00:00:00 2001 From: Michael Hunger Date: Thu, 9 Oct 2014 01:21:25 +0200 Subject: [PATCH 03/33] fixed batch-caches in BatchInserterImpl filling up endlessly --- src/main/java/org/neo4j/tool/StoreCopy.java | 36 ++++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/neo4j/tool/StoreCopy.java b/src/main/java/org/neo4j/tool/StoreCopy.java index 95fe717..27dd09d 100644 --- a/src/main/java/org/neo4j/tool/StoreCopy.java +++ b/src/main/java/org/neo4j/tool/StoreCopy.java @@ -37,7 +37,8 @@ public static Map config() { "neostore.propertystore.db.arrays.mapped_memory", "300M", "neostore.propertystore.db.index.keys.mapped_memory", "100M", "neostore.propertystore.db.index.mapped_memory", "100M", - "cache_type", "weak" + "use_memory_mapped_buffers","true", + "cache_type", "none" ); } @@ -74,8 +75,9 @@ private static void copyStore(String sourceDir, String targetDir, Set ig BatchInserter sourceDb = BatchInserters.inserter(source.getAbsolutePath(), config()); logs = new PrintWriter(new FileWriter(new File(target, "store-copy.log"))); + long firstNode = firstNode(sourceDb, highestIds.first()); copyNodes(sourceDb, targetDb, ignoreProperties, ignoreLabels, highestIds.first()); - copyRelationships(sourceDb, targetDb, ignoreRelTypes, ignoreProperties, highestIds.other()); + copyRelationships(sourceDb, targetDb, ignoreRelTypes, ignoreProperties, highestIds.other(), firstNode); targetDb.shutdown(); sourceDb.shutdown(); @@ -103,7 +105,7 @@ private static void copyIndex(File source, File target) throws IOException { } } - private static void copyRelationships(BatchInserter sourceDb, BatchInserter targetDb, Set ignoreRelTypes, Set ignoreProperties, long highestRelId) { + private static void copyRelationships(BatchInserter sourceDb, BatchInserter targetDb, Set ignoreRelTypes, Set ignoreProperties, long highestRelId, long firstNode) { long time = System.currentTimeMillis(); long relId = 0; long notFound = 0; @@ -117,12 +119,25 @@ private static void copyRelationships(BatchInserter sourceDb, BatchInserter targ } if (ignoreRelTypes.contains(rel.getType().name().toLowerCase())) continue; createRelationship(targetDb, sourceDb, rel, ignoreProperties); - if (relId % 1000 == 0) System.out.print("."); - if (relId % 100000 == 0) System.out.println(" " + rel); + if (relId % 1000 == 0) { + System.out.print("."); + } + if (relId % 100000 == 0) { + flushCache(sourceDb, firstNode); + System.out.println(" " + rel.getId()); + } } System.out.println("\n copying of "+relId+" relationships took "+(System.currentTimeMillis()-time)+" ms. Not found "+notFound); } + private static long firstNode(BatchInserter sourceDb, long highestNodeId) { + int node = -1; + while (++node <= highestNodeId) { + if (sourceDb.nodeExists(node)) return node; + } + return -1; + } + private static void createRelationship(BatchInserter targetDb, BatchInserter sourceDb, BatchRelationship rel, Set ignoreProperties) { long startNodeId = rel.getStartNode(); long endNodeId = rel.getEndNode(); @@ -142,6 +157,7 @@ private static void copyNodes(BatchInserter sourceDb, BatchInserter targetDb, Se targetDb.createNode(node, getProperties(sourceDb.getNodeProperties(node), ignoreProperties), labelsArray(sourceDb, node,ignoreLabels)); if (node % 1000 == 0) System.out.print("."); if (node % 100000 == 0) { + flushCache(sourceDb, node); logs.flush(); System.out.println(" " + node); } @@ -149,6 +165,16 @@ private static void copyNodes(BatchInserter sourceDb, BatchInserter targetDb, Se System.out.println("\n copying of " + node + " nodes took " + (System.currentTimeMillis() - time) + " ms."); } + private static void flushCache(BatchInserter sourceDb, long node) { + Map nodeProperties = sourceDb.getNodeProperties(node); + Iterator> iterator = nodeProperties.entrySet().iterator(); + if (iterator.hasNext()) { + Map.Entry firstProp = iterator.next(); + sourceDb.setNodeProperty(node, firstProp.getKey(), firstProp.getValue()); // force flush + System.out.print("F"); + } + } + private static Label[] labelsArray(BatchInserter db, long node, Set ignoreLabels) { Collection