提交 ab5883c5 authored 作者: andrei's avatar andrei

code review 3

上级 55b07c4c
......@@ -14,13 +14,13 @@ import java.util.Iterator;
* @param <V> the value type
*/
public final class Cursor<K, V> implements Iterator<K> {
private final K to;
private CursorPos cursorPos;
private CursorPos keeper;
private K current;
private K last;
private V lastValue;
private Page lastPage;
private final K to;
private CursorPos cursorPos;
private CursorPos keeper;
private K current;
private K last;
private V lastValue;
private Page lastPage;
public Cursor(Page root, K from) {
this(root, from, null);
......
......@@ -941,7 +941,7 @@ public final class DataUtils {
* @return the parsed value
* @throws IllegalStateException if parsing fails
*/
public static long readHexLong(Map<String,?> map, String key, long defaultValue) {
public static long readHexLong(Map<String, ?> map, String key, long defaultValue) {
Object v = map.get(key);
if (v == null) {
return defaultValue;
......@@ -1005,7 +1005,7 @@ public final class DataUtils {
* @return the parsed value
* @throws IllegalStateException if parsing fails
*/
public static int readHexInt(Map<String,?> map, String key, int defaultValue) {
public static int readHexInt(Map<String, ?> map, String key, int defaultValue) {
Object v = map.get(key);
if (v == null) {
return defaultValue;
......
......@@ -172,7 +172,7 @@ public class FreeSpaceBitSet {
if (cardinality == 0) {
return 0;
}
return (int)(100L * cardinality / set.length());
return Math.max(1, (int)(100L * cardinality / set.length()));
}
/**
......
......@@ -39,20 +39,20 @@ public class MVMap<K, V> extends AbstractMap<K, V>
/**
* Reference to the current root page.
*/
private final AtomicReference<RootReference> root;
private final AtomicReference<RootReference> root;
private int id;
private long createVersion;
private final DataType keyType;
private final DataType valueType;
private int id;
private long createVersion;
private final DataType keyType;
private final DataType valueType;
/**
* Whether the map is closed. Volatile so we don't accidentally write to a
* closed map in multithreaded mode.
*/
private volatile boolean closed;
private boolean readOnly;
private boolean isVolatile;
private boolean readOnly;
private boolean isVolatile;
/**
* This designates the "last stored" version for a store which was
......@@ -72,7 +72,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
}
// constructor for cloneIt()
protected MVMap(MVMap<K,V> source) {
protected MVMap(MVMap<K, V> source) {
this(source.store, source.keyType, source.valueType, source.id, source.createVersion,
new AtomicReference<>(source.root.get()));
}
......@@ -93,7 +93,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
this.root = root;
}
protected MVMap<K,V> cloneIt() {
protected MVMap<K, V> cloneIt() {
return new MVMap<>(this);
}
......@@ -1356,7 +1356,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
}
@Override
public Builder<K,V> valueType(DataType dataType) {
public Builder<K, V> valueType(DataType dataType) {
setValueType(dataType);
return this;
}
......
......@@ -197,7 +197,7 @@ public final class MVStore {
* The map of temporarily freed storage space caused by freed pages.
* It contains the number of freed entries per chunk.
*/
private final Map<Integer,Chunk> freedPageSpace = new HashMap<>();
private final Map<Integer, Chunk> freedPageSpace = new HashMap<>();
/**
* The metadata map. Write access to this map needs to be synchronized on
......@@ -524,10 +524,10 @@ public final class MVStore {
return map;
}
public <K,V> MVMap<K,V> getMap(int id) {
public <K, V> MVMap<K,V> getMap(int id) {
checkOpen();
@SuppressWarnings("unchecked")
MVMap<K,V> map = (MVMap<K, V>) maps.get(id);
MVMap<K, V> map = (MVMap<K, V>) maps.get(id);
return map;
}
......
......@@ -736,7 +736,7 @@ public class TestMVTableEngine extends TestBase {
conn.close();
long sizeNew = FileUtils.size(getBaseDir() + "/" + getTestName()
+ Constants.SUFFIX_MV_FILE);
System.out.println("new: " + sizeNew + " old: " + sizeOld);
println("new: " + sizeNew + " old: " + sizeOld);
// assertTrue("new: " + sizeNew + " old: " + sizeOld, sizeNew < sizeOld);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论