diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/BackendTable.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/BackendTable.java index f8ec5fe238..6fb564df04 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/BackendTable.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/BackendTable.java @@ -193,13 +193,13 @@ public List getSplits(Session session, long splitSize) { count = 1; } long maxKey = this.maxKey(); - double each = maxKey / count; + Double each = maxKey / count; List splits = new ArrayList<>((int) count); String last = START; long offset = 0L; while (offset < maxKey) { - offset += each; + offset += each.longValue(); if (offset > maxKey) { splits.add(new Shard(last, END, 0L)); break; diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/util/ConfigUtil.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/util/ConfigUtil.java index 5dea629106..57462e7b99 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/util/ConfigUtil.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/util/ConfigUtil.java @@ -23,7 +23,6 @@ import java.io.IOException; import java.io.Reader; import java.io.StringReader; -import java.nio.file.Paths; import java.util.List; import java.util.Map; @@ -110,11 +109,13 @@ public static Map scanGraphsDir(String graphsDirPath) { public static String writeToFile(String dir, String graphName, HugeConfig config) { - E.checkArgument(FileUtils.getFile(dir).exists(), - "The directory '%s' must exist", dir); - String fileName = Paths.get(dir, graphName + CONF_SUFFIX).toString(); + File path = FileUtils.getFile(dir); + E.checkArgument(path.exists(), + "The directory '%s' must exist", dir); + String fileName = path.getPath() + File.separator + graphName + CONF_SUFFIX; try { - config.save(new File(fileName)); + File newFile = FileUtils.getFile(fileName); + config.save(newFile); LOG.info("Write HugeConfig to file: '{}'", fileName); } catch (ConfigurationException e) { throw new HugeException("Failed to write HugeConfig to file '%s'", diff --git a/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseMetrics.java b/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseMetrics.java index ed17ff0be3..beeca6fc4c 100644 --- a/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseMetrics.java +++ b/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseMetrics.java @@ -127,7 +127,8 @@ private static Map formatMetrics( .values(); long fileSizeBytes = 0L; for (RegionMetrics region : regions) { - fileSizeBytes += region.getStoreFileSize().get(Size.Unit.BYTE); + Double tempValue = region.getStoreFileSize().get(Size.Unit.BYTE); + fileSizeBytes += tempValue.longValue(); } metrics.put(DISK_USAGE, UnitUtil.bytesToGB(fileSizeBytes)); metrics.put(DISK_USAGE + READABLE, diff --git a/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseSessions.java b/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseSessions.java index 89f82d63c5..12631a85c8 100644 --- a/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseSessions.java +++ b/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseSessions.java @@ -315,8 +315,11 @@ public long storeSize(String table) throws IOException { //total += load.getMemStoreSizeMB() * Bytes.MB; TableName tableName = TableName.valueOf(this.namespace, table); for (RegionMetrics m : admin.getRegionMetrics(rs, tableName)) { - total += m.getStoreFileSize().get(Size.Unit.BYTE); - total += m.getMemStoreSize().get(Size.Unit.BYTE); + Double storeFileSize = m.getStoreFileSize().get(Size.Unit.BYTE); + total += storeFileSize.longValue(); + + Double memStoreFileSize = m.getMemStoreSize().get(Size.Unit.BYTE); + total += memStoreFileSize.longValue(); } } } diff --git a/hugegraph-test/src/main/java/com/baidu/hugegraph/core/EdgeCoreTest.java b/hugegraph-test/src/main/java/com/baidu/hugegraph/core/EdgeCoreTest.java index 5bfed17e4c..701fa31286 100644 --- a/hugegraph-test/src/main/java/com/baidu/hugegraph/core/EdgeCoreTest.java +++ b/hugegraph-test/src/main/java/com/baidu/hugegraph/core/EdgeCoreTest.java @@ -5218,15 +5218,15 @@ public void testQueryBothEdgesOfVertexInPaging() { while (page != null) { GraphTraversal iterator = graph.traversal().V(james).bothE() .has("~page", page).limit(1); - long size = IteratorUtils.count(iterator); + Long size = IteratorUtils.count(iterator); if (size == 0L) { // The last page is empty Assert.assertEquals(6, count); } else { - Assert.assertEquals(1, size); + Assert.assertEquals(1, size.intValue()); } page = TraversalUtil.page(iterator); - count += size; + count += size.intValue(); } Assert.assertEquals(6, count); } @@ -5244,15 +5244,15 @@ public void testQueryOutEdgesOfVertexInPaging() { while (page != null) { GraphTraversal iterator = graph.traversal().V(james).outE() .has("~page", page).limit(1); - long size = IteratorUtils.count(iterator); + Long size = IteratorUtils.count(iterator); if (size == 0L) { // The last page is empty Assert.assertEquals(4, count); } else { - Assert.assertEquals(1, size); + Assert.assertEquals(1, size.intValue()); } page = TraversalUtil.page(iterator); - count += size; + count += size.intValue(); } Assert.assertEquals(4, count); } @@ -5270,15 +5270,15 @@ public void testQueryInEdgesOfVertexInPaging() { while (page != null) { GraphTraversal iterator = graph.traversal().V(james).inE() .has("~page", page).limit(1); - long size = IteratorUtils.count(iterator); + Long size = IteratorUtils.count(iterator); if (size == 0L) { // The last page is empty Assert.assertEquals(2, count); } else { - Assert.assertEquals(1, size); + Assert.assertEquals(1, size.intValue()); } page = TraversalUtil.page(iterator); - count += size; + count += size.intValue(); } Assert.assertEquals(2, count); } @@ -7516,10 +7516,10 @@ private int traverseInPage(Function> fetcher) { int count = 0; while (page != null) { GraphTraversal iterator = fetcher.apply(page); - long size = IteratorUtils.count(iterator); + Long size = IteratorUtils.count(iterator); Assert.assertLte(1L, size); page = TraversalUtil.page(iterator); - count += size; + count += size.intValue(); } return count; }