From 079d942ea8be48f9d0670ee2f39514d54e606443 Mon Sep 17 00:00:00 2001 From: fyrz Date: Sat, 8 Nov 2014 19:19:29 +0100 Subject: [PATCH] [RocksJava] Code-cleanup + Java7 warnings removed --- java/org/rocksdb/BackupableDB.java | 2 +- java/org/rocksdb/MergeOperator.java | 2 -- java/org/rocksdb/NativeLibraryLoader.java | 6 ++---- java/org/rocksdb/PlainTableConfig.java | 2 +- java/org/rocksdb/RocksDB.java | 10 +++++----- java/org/rocksdb/RocksDBException.java | 2 -- java/org/rocksdb/RocksObject.java | 3 ++- java/org/rocksdb/Statistics.java | 3 +-- java/org/rocksdb/StatisticsCollector.java | 2 -- java/org/rocksdb/util/Environment.java | 10 +++++----- 10 files changed, 17 insertions(+), 25 deletions(-) diff --git a/java/org/rocksdb/BackupableDB.java b/java/org/rocksdb/BackupableDB.java index 7fa37abab..75683f587 100644 --- a/java/org/rocksdb/BackupableDB.java +++ b/java/org/rocksdb/BackupableDB.java @@ -104,7 +104,7 @@ public class BackupableDB extends RocksDB { super(); } - @Override protected void finalize() { + @Override protected void finalize() throws Throwable { close(); super.finalize(); } diff --git a/java/org/rocksdb/MergeOperator.java b/java/org/rocksdb/MergeOperator.java index aaf44d07c..2655e466f 100644 --- a/java/org/rocksdb/MergeOperator.java +++ b/java/org/rocksdb/MergeOperator.java @@ -5,8 +5,6 @@ package org.rocksdb; -import java.util.*; - /** * MergeOperator holds an operator to be applied when compacting * two merge operands held under the same key in order to obtain a single diff --git a/java/org/rocksdb/NativeLibraryLoader.java b/java/org/rocksdb/NativeLibraryLoader.java index 26a26bbca..bf0196e77 100644 --- a/java/org/rocksdb/NativeLibraryLoader.java +++ b/java/org/rocksdb/NativeLibraryLoader.java @@ -9,12 +9,12 @@ import org.rocksdb.util.Environment; */ public class NativeLibraryLoader { private static String sharedLibraryName = Environment.getJniLibraryName("rocksdb"); - private static String tempFilePrefix = "librocksdbjni"; private static String tempFileSuffix = "." + Environment.getJniLibraryExtension(); public static void loadLibraryFromJar(String tmpDir) throws IOException { File temp; + String tempFilePrefix = "librocksdbjni"; if(tmpDir == null || tmpDir.equals("")) temp = File.createTempFile(tempFilePrefix, tempFileSuffix); else @@ -43,9 +43,7 @@ public class NativeLibraryLoader { } finally { if(os != null) os.close(); - - if(is != null) - is.close(); + is.close(); } System.load(temp.getAbsolutePath()); diff --git a/java/org/rocksdb/PlainTableConfig.java b/java/org/rocksdb/PlainTableConfig.java index 7f0d672ef..3a41bea84 100644 --- a/java/org/rocksdb/PlainTableConfig.java +++ b/java/org/rocksdb/PlainTableConfig.java @@ -131,7 +131,7 @@ public class PlainTableConfig extends TableFormatConfig { * *

See linux doc Documentation/vm/hugetlbpage.txt

* - * @param hugePageTlbSize + * @param hugePageTlbSize huge page tlb size * @return the reference to the current config. */ public PlainTableConfig setHugePageTlbSize(int hugePageTlbSize) { diff --git a/java/org/rocksdb/RocksDB.java b/java/org/rocksdb/RocksDB.java index 690d84ec8..c3b8072a2 100644 --- a/java/org/rocksdb/RocksDB.java +++ b/java/org/rocksdb/RocksDB.java @@ -734,7 +734,7 @@ public class RocksDB extends RocksObject { List values = multiGet( nativeHandle_, keys, keys.size()); - Map keyValueMap = new HashMap(); + Map keyValueMap = new HashMap<>(); for(int i = 0; i < values.size(); i++) { if(values.get(i) == null) { continue; @@ -774,7 +774,7 @@ public class RocksDB extends RocksObject { List values = multiGet(nativeHandle_, keys, keys.size(), columnFamilyHandleList); - Map keyValueMap = new HashMap(); + Map keyValueMap = new HashMap<>(); for(int i = 0; i < values.size(); i++) { if (values.get(i) == null) { continue; @@ -801,7 +801,7 @@ public class RocksDB extends RocksObject { List values = multiGet( nativeHandle_, opt.nativeHandle_, keys, keys.size()); - Map keyValueMap = new HashMap(); + Map keyValueMap = new HashMap<>(); for(int i = 0; i < values.size(); i++) { if(values.get(i) == null) { continue; @@ -844,7 +844,7 @@ public class RocksDB extends RocksObject { List values = multiGet(nativeHandle_, opt.nativeHandle_, keys, keys.size(), columnFamilyHandleList); - Map keyValueMap = new HashMap(); + Map keyValueMap = new HashMap<>(); for(int i = 0; i < values.size(); i++) { if(values.get(i) == null) { continue; @@ -1051,7 +1051,7 @@ public class RocksDB extends RocksObject { public List newIterators( List columnFamilyHandleList) throws RocksDBException { List iterators = - new ArrayList(columnFamilyHandleList.size()); + new ArrayList<>(columnFamilyHandleList.size()); long[] iteratorRefs = iterators(nativeHandle_, columnFamilyHandleList); for (int i=0; iHelper class to collect DB statistics periodically at a period specified in diff --git a/java/org/rocksdb/util/Environment.java b/java/org/rocksdb/util/Environment.java index 7bb42ace7..c121adb17 100644 --- a/java/org/rocksdb/util/Environment.java +++ b/java/org/rocksdb/util/Environment.java @@ -5,17 +5,17 @@ public class Environment { private static String ARCH = System.getProperty("os.arch").toLowerCase(); public static boolean isWindows() { - return (OS.indexOf("win") >= 0); + return (OS.contains("win")); } public static boolean isMac() { - return (OS.indexOf("mac") >= 0); + return (OS.contains("mac")); } public static boolean isUnix() { - return (OS.indexOf("nix") >= 0 || - OS.indexOf("nux") >= 0 || - OS.indexOf("aix") >= 0); + return (OS.contains("nix") || + OS.contains("nux") || + OS.contains("aix")); } public static boolean is64Bit() {