Skip to content

Commit

Permalink
消除冗余的WT类全限定名
Browse files Browse the repository at this point in the history
  • Loading branch information
codefollower committed May 11, 2015
1 parent 1491544 commit 9752834
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
10 changes: 10 additions & 0 deletions lealone-common/src/main/java/org/lealone/storage/StorageMap.java
Expand Up @@ -52,8 +52,18 @@ public <K, V> StorageMap<K, V> openMap(String name, DataType valueType) {
}

public interface Cursor<K, V> extends Iterator<K> {
/**
* Get the last read key if there was one.
*
* @return the key or null
*/
K getKey();

/**
* Get the last read value if there was one.
*
* @return the value or null
*/
V getValue();
}

Expand Down
Expand Up @@ -20,16 +20,18 @@

import org.lealone.util.DataUtils;

import com.wiredtiger.db.Cursor;

@SuppressWarnings("unchecked")
public class WTCursor<K, V> implements org.lealone.storage.StorageMap.Cursor<K, V> {
public class WTCursor<K, V> implements StorageMap.Cursor<K, V> {

private final com.wiredtiger.db.Cursor wtCursor;
private final Cursor wtCursor;
private final WTMap<K, V> map;
private K from;
private K key;
private V value;

public WTCursor(com.wiredtiger.db.Cursor wtCursor, WTMap<K, V> map, K from) {
public WTCursor(Cursor wtCursor, WTMap<K, V> map, K from) {
this.wtCursor = wtCursor;
this.map = map;
this.from = from;
Expand Down Expand Up @@ -63,21 +65,11 @@ public K next() {
return key;
}

/**
* Get the last read key if there was one.
*
* @return the key or null
*/
@Override
public K getKey() {
return key;
}

/**
* Get the last read value if there was one.
*
* @return the value or null
*/
@Override
public V getValue() {
return value;
Expand Down
Expand Up @@ -30,11 +30,12 @@
import org.lealone.util.DataUtils;

import com.wiredtiger.db.SearchStatus;
import com.wiredtiger.db.Session;

@SuppressWarnings("unchecked")
public class WTMap<K, V> implements StorageMap<K, V> {

private final com.wiredtiger.db.Session wtSession;
private final Session wtSession;
private com.wiredtiger.db.Cursor wtCursor;

private final String name;
Expand All @@ -45,11 +46,11 @@ public class WTMap<K, V> implements StorageMap<K, V> {
private WriteBuffer writeBuffer;
private boolean closed;

public WTMap(com.wiredtiger.db.Session wtSession, String name) {
public WTMap(Session wtSession, String name) {
this(wtSession, name, new ObjectDataType(), new ObjectDataType());
}

public WTMap(com.wiredtiger.db.Session wtSession, String name, DataType keyType, DataType valueType) {
public WTMap(Session wtSession, String name, DataType keyType, DataType valueType) {
this.wtSession = wtSession;
this.name = name;
this.keyType = keyType;
Expand All @@ -66,7 +67,7 @@ private void openWTCursor() {
wtCursor = wtSession.open_cursor("table:" + name, null, "append");
}

private static int getMapId(com.wiredtiger.db.Session wtSession, String name) {
private static int getMapId(Session wtSession, String name) {
wtSession.create("table:lealone_map_id", "key_format=S,value_format=i");
com.wiredtiger.db.Cursor wtCursor = wtSession.open_cursor("table:lealone_map_id", null, "append");

Expand Down
Expand Up @@ -28,6 +28,9 @@
import com.wiredtiger.db.Connection;
import com.wiredtiger.db.wiredtiger;

/**
* A storage engine that internally uses the WiredTiger.
*/
public class WTStorageEngine extends MVStorageEngine implements TransactionStorageEngine {
public static final String NAME = "WT";
private static final HashMap<String, Connection> connections = new HashMap<>(1);
Expand Down

0 comments on commit 9752834

Please sign in to comment.