[RocksJava] Code-cleanup + Java7 warnings removed

main
fyrz 10 years ago
parent 9a255b95f0
commit 079d942ea8
  1. 2
      java/org/rocksdb/BackupableDB.java
  2. 2
      java/org/rocksdb/MergeOperator.java
  3. 4
      java/org/rocksdb/NativeLibraryLoader.java
  4. 2
      java/org/rocksdb/PlainTableConfig.java
  5. 10
      java/org/rocksdb/RocksDB.java
  6. 2
      java/org/rocksdb/RocksDBException.java
  7. 3
      java/org/rocksdb/RocksObject.java
  8. 3
      java/org/rocksdb/Statistics.java
  9. 2
      java/org/rocksdb/StatisticsCollector.java
  10. 10
      java/org/rocksdb/util/Environment.java

@ -104,7 +104,7 @@ public class BackupableDB extends RocksDB {
super(); super();
} }
@Override protected void finalize() { @Override protected void finalize() throws Throwable {
close(); close();
super.finalize(); super.finalize();
} }

@ -5,8 +5,6 @@
package org.rocksdb; package org.rocksdb;
import java.util.*;
/** /**
* MergeOperator holds an operator to be applied when compacting * MergeOperator holds an operator to be applied when compacting
* two merge operands held under the same key in order to obtain a single * 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 { public class NativeLibraryLoader {
private static String sharedLibraryName = Environment.getJniLibraryName("rocksdb"); private static String sharedLibraryName = Environment.getJniLibraryName("rocksdb");
private static String tempFilePrefix = "librocksdbjni";
private static String tempFileSuffix = "." + Environment.getJniLibraryExtension(); private static String tempFileSuffix = "." + Environment.getJniLibraryExtension();
public static void loadLibraryFromJar(String tmpDir) public static void loadLibraryFromJar(String tmpDir)
throws IOException { throws IOException {
File temp; File temp;
String tempFilePrefix = "librocksdbjni";
if(tmpDir == null || tmpDir.equals("")) if(tmpDir == null || tmpDir.equals(""))
temp = File.createTempFile(tempFilePrefix, tempFileSuffix); temp = File.createTempFile(tempFilePrefix, tempFileSuffix);
else else
@ -43,8 +43,6 @@ public class NativeLibraryLoader {
} finally { } finally {
if(os != null) if(os != null)
os.close(); os.close();
if(is != null)
is.close(); is.close();
} }

@ -131,7 +131,7 @@ public class PlainTableConfig extends TableFormatConfig {
* *
* <p>See linux doc Documentation/vm/hugetlbpage.txt</p> * <p>See linux doc Documentation/vm/hugetlbpage.txt</p>
* *
* @param hugePageTlbSize * @param hugePageTlbSize huge page tlb size
* @return the reference to the current config. * @return the reference to the current config.
*/ */
public PlainTableConfig setHugePageTlbSize(int hugePageTlbSize) { public PlainTableConfig setHugePageTlbSize(int hugePageTlbSize) {

@ -734,7 +734,7 @@ public class RocksDB extends RocksObject {
List<byte[]> values = multiGet( List<byte[]> values = multiGet(
nativeHandle_, keys, keys.size()); 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++) { for(int i = 0; i < values.size(); i++) {
if(values.get(i) == null) { if(values.get(i) == null) {
continue; continue;
@ -774,7 +774,7 @@ public class RocksDB extends RocksObject {
List<byte[]> values = multiGet(nativeHandle_, keys, keys.size(), List<byte[]> values = multiGet(nativeHandle_, keys, keys.size(),
columnFamilyHandleList); columnFamilyHandleList);
Map<byte[], byte[]> keyValueMap = new HashMap<byte[], byte[]>(); Map<byte[], byte[]> keyValueMap = new HashMap<>();
for(int i = 0; i < values.size(); i++) { for(int i = 0; i < values.size(); i++) {
if (values.get(i) == null) { if (values.get(i) == null) {
continue; continue;
@ -801,7 +801,7 @@ public class RocksDB extends RocksObject {
List<byte[]> values = multiGet( List<byte[]> values = multiGet(
nativeHandle_, opt.nativeHandle_, keys, keys.size()); 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++) { for(int i = 0; i < values.size(); i++) {
if(values.get(i) == null) { if(values.get(i) == null) {
continue; continue;
@ -844,7 +844,7 @@ public class RocksDB extends RocksObject {
List<byte[]> values = multiGet(nativeHandle_, opt.nativeHandle_, List<byte[]> values = multiGet(nativeHandle_, opt.nativeHandle_,
keys, keys.size(), columnFamilyHandleList); 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++) { for(int i = 0; i < values.size(); i++) {
if(values.get(i) == null) { if(values.get(i) == null) {
continue; continue;
@ -1051,7 +1051,7 @@ public class RocksDB extends RocksObject {
public List<RocksIterator> newIterators( public List<RocksIterator> newIterators(
List<ColumnFamilyHandle> columnFamilyHandleList) throws RocksDBException { List<ColumnFamilyHandle> columnFamilyHandleList) throws RocksDBException {
List<RocksIterator> iterators = List<RocksIterator> iterators =
new ArrayList<RocksIterator>(columnFamilyHandleList.size()); new ArrayList<>(columnFamilyHandleList.size());
long[] iteratorRefs = iterators(nativeHandle_, columnFamilyHandleList); long[] iteratorRefs = iterators(nativeHandle_, columnFamilyHandleList);
for (int i=0; i<columnFamilyHandleList.size(); i++){ for (int i=0; i<columnFamilyHandleList.size(); i++){

@ -5,8 +5,6 @@
package org.rocksdb; package org.rocksdb;
import java.util.*;
/** /**
* A RocksDBException encapsulates the error of an operation. This exception * A RocksDBException encapsulates the error of an operation. This exception
* type is used to describe an internal error from the c++ rocksdb library. * 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 * Simply calls {@code dispose()} and release its c++ resource if it has not
* yet released. * yet released.
*/ */
@Override protected void finalize() { @Override protected void finalize() throws Throwable {
dispose(); dispose();
super.finalize();
} }
/** /**

@ -24,9 +24,8 @@ public class Statistics {
public HistogramData geHistogramData(HistogramType histogramType) { public HistogramData geHistogramData(HistogramType histogramType) {
assert(isInitialized()); assert(isInitialized());
HistogramData hist = geHistogramData0( return geHistogramData0(
histogramType.getValue(), statsHandle_); histogramType.getValue(), statsHandle_);
return hist;
} }
private boolean isInitialized() { private boolean isInitialized() {

@ -6,11 +6,9 @@
package org.rocksdb; package org.rocksdb;
import java.util.List; import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
/** /**
* <p>Helper class to collect DB statistics periodically at a period specified in * <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(); private static String ARCH = System.getProperty("os.arch").toLowerCase();
public static boolean isWindows() { public static boolean isWindows() {
return (OS.indexOf("win") >= 0); return (OS.contains("win"));
} }
public static boolean isMac() { public static boolean isMac() {
return (OS.indexOf("mac") >= 0); return (OS.contains("mac"));
} }
public static boolean isUnix() { public static boolean isUnix() {
return (OS.indexOf("nix") >= 0 || return (OS.contains("nix") ||
OS.indexOf("nux") >= 0 || OS.contains("nux") ||
OS.indexOf("aix") >= 0); OS.contains("aix"));
} }
public static boolean is64Bit() { public static boolean is64Bit() {

Loading…
Cancel
Save