提交 079d942e 编写于 作者: F fyrz

[RocksJava] Code-cleanup + Java7 warnings removed

上级 9a255b95
......@@ -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() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册