mirror of https://github.com/facebook/rocksdb.git
[RocksJava] Code-cleanup + Java7 warnings removed
This commit is contained in:
parent
9a255b95f0
commit
079d942ea8
|
@ -104,7 +104,7 @@ public class BackupableDB extends RocksDB {
|
|||
super();
|
||||
}
|
||||
|
||||
@Override protected void finalize() {
|
||||
@Override protected void finalize() throws Throwable {
|
||||
close();
|
||||
super.finalize();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -131,7 +131,7 @@ public class PlainTableConfig extends TableFormatConfig {
|
|||
*
|
||||
* <p>See linux doc Documentation/vm/hugetlbpage.txt</p>
|
||||
*
|
||||
* @param hugePageTlbSize
|
||||
* @param hugePageTlbSize huge page tlb size
|
||||
* @return the reference to the current config.
|
||||
*/
|
||||
public PlainTableConfig setHugePageTlbSize(int hugePageTlbSize) {
|
||||
|
|
|
@ -734,7 +734,7 @@ public class RocksDB extends RocksObject {
|
|||
List<byte[]> values = multiGet(
|
||||
nativeHandle_, keys, keys.size());
|
||||
|
||||
Map<byte[], byte[]> keyValueMap = new HashMap<byte[], byte[]>();
|
||||
Map<byte[], byte[]> 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<byte[]> values = multiGet(nativeHandle_, keys, keys.size(),
|
||||
columnFamilyHandleList);
|
||||
|
||||
Map<byte[], byte[]> keyValueMap = new HashMap<byte[], byte[]>();
|
||||
Map<byte[], byte[]> 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<byte[]> values = multiGet(
|
||||
nativeHandle_, opt.nativeHandle_, keys, keys.size());
|
||||
|
||||
Map<byte[], byte[]> keyValueMap = new HashMap<byte[], byte[]>();
|
||||
Map<byte[], byte[]> 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<byte[]> values = multiGet(nativeHandle_, opt.nativeHandle_,
|
||||
keys, keys.size(), columnFamilyHandleList);
|
||||
|
||||
Map<byte[], byte[]> keyValueMap = new HashMap<byte[], byte[]>();
|
||||
Map<byte[], byte[]> 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<RocksIterator> newIterators(
|
||||
List<ColumnFamilyHandle> columnFamilyHandleList) throws RocksDBException {
|
||||
List<RocksIterator> iterators =
|
||||
new ArrayList<RocksIterator>(columnFamilyHandleList.size());
|
||||
new ArrayList<>(columnFamilyHandleList.size());
|
||||
|
||||
long[] iteratorRefs = iterators(nativeHandle_, columnFamilyHandleList);
|
||||
for (int i=0; i<columnFamilyHandleList.size(); i++){
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
|
||||
package org.rocksdb;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* A RocksDBException encapsulates the error of an operation. This exception
|
||||
* type is used to describe an internal error from the c++ rocksdb library.
|
||||
|
|
|
@ -107,8 +107,9 @@ public abstract class RocksObject {
|
|||
* Simply calls {@code dispose()} and release its c++ resource if it has not
|
||||
* yet released.
|
||||
*/
|
||||
@Override protected void finalize() {
|
||||
@Override protected void finalize() throws Throwable {
|
||||
dispose();
|
||||
super.finalize();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,9 +24,8 @@ public class Statistics {
|
|||
|
||||
public HistogramData geHistogramData(HistogramType histogramType) {
|
||||
assert(isInitialized());
|
||||
HistogramData hist = geHistogramData0(
|
||||
return geHistogramData0(
|
||||
histogramType.getValue(), statsHandle_);
|
||||
return hist;
|
||||
}
|
||||
|
||||
private boolean isInitialized() {
|
||||
|
|
|
@ -6,11 +6,9 @@
|
|||
package org.rocksdb;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* <p>Helper class to collect DB statistics periodically at a period specified in
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue