提交 13f10ade authored 作者: Thomas Mueller's avatar Thomas Mueller

A persistent multi-version map: r-tree queries (intersect and contain)

上级 e2f96581
......@@ -51,22 +51,19 @@ public class FilePathCache extends FilePathWrapper {
}
public FileChannel position(long newPosition) throws IOException {
throw new UnsupportedOperationException();
// base.position(newPosition);
// return this;
base.position(newPosition);
return this;
}
public long position() throws IOException {
throw new UnsupportedOperationException();
// return base.position();
return base.position();
}
public int read(ByteBuffer dst) throws IOException {
throw new UnsupportedOperationException();
// return base.read(dst);
return base.read(dst);
}
public synchronized int read(ByteBuffer dst, long position) throws IOException {
public int read(ByteBuffer dst, long position) throws IOException {
long cachePos = getCachePos(position);
int off = (int) (position - cachePos);
int len = CACHE_BLOCK_SIZE - off;
......
......@@ -15,14 +15,14 @@ import java.util.Iterator;
*/
public class Cursor<K> implements Iterator<K> {
private final MVMap<K, ?> map;
private final K from;
protected final MVMap<K, ?> map;
protected final K from;
protected CursorPos pos;
protected K current;
private final Page root;
private boolean initialized;
private CursorPos pos;
private K current;
Cursor(MVMap<K, ?> map, Page root, K from) {
protected Cursor(MVMap<K, ?> map, Page root, K from) {
this.map = map;
this.root = root;
this.from = from;
......@@ -64,7 +64,7 @@ public class Cursor<K> implements Iterator<K> {
throw new UnsupportedOperationException();
}
private void min(Page p, K from) {
protected void min(Page p, K from) {
while (true) {
if (p.isLeaf()) {
int x = from == null ? 0 : p.binarySearch(from);
......@@ -86,7 +86,7 @@ public class Cursor<K> implements Iterator<K> {
}
@SuppressWarnings("unchecked")
private void fetchNext() {
protected void fetchNext() {
while (pos != null) {
if (pos.index < pos.page.getKeyCount()) {
current = (K) pos.page.getKey(pos.index++);
......
......@@ -37,18 +37,15 @@ header:
H:3,...
TODO:
- support custom fields in the file header (auto-server ip address,...)
- support stores that span multiple files (chunks stored in other files)
- triggers
- r-tree: add missing features (NN search for example)
- pluggable cache (specially for in-memory file systems)
- maybe store the factory class in the file header
- use comma separated format for map metadata
- auto-server: store port in the header
- recovery: keep some old chunks; don't overwritten for 1 minute
- pluggable caching (specially for in-memory file systems)
- store store creation in file header, and seconds since creation in chunk header (plus a counter)
- recovery: keep some old chunks; don't overwritten for 5 minutes (configurable)
- allocate memory with Utils.newBytes and so on
- unified exception handling
- check if locale specific string comparison can make data disappear
- concurrent map; avoid locking during IO (pre-load pages)
- maybe split database into multiple files, to speed up compact operation
- automated 'kill process' and 'power failure' test
......@@ -58,19 +55,25 @@ TODO:
- support background writes (concurrent modification & store)
- limited support for writing to old versions (branches)
- support concurrent operations (including file I/O)
- on insert, if the child page is already full, don't load and modify it - split directly
- on insert, if the child page is already full, don't load and modify it - split directly (for leaves with 1 entry)
- performance test with encrypting file system
- possibly split chunk data into immutable and mutable
- compact: avoid processing pages using a counting bloom filter
- defragment (re-creating maps, specially those with small pages)
- write using ByteArrayOutputStream; remove DataType.getMaxLength
- file header: check versionRead and versionWrite (and possibly rename; or rename version)
- file header: check formatRead and format (is formatRead needed if equal to format?)
- chunk header: store changed chunk data as row; maybe after the root
- chunk checksum (header, last page, 2 bytes per page?)
- allow renaming maps
- file locking: solve problem that locks are shared for a VM
- online backup
- MapFactory is the wrong name (StorePlugin?) or is too flexible
- MapFactory is the wrong name (StorePlugin?) or is too flexible: remove?
- store file "header" at the end of each chunk; at the end of the file
- is there a better name for the file header, if it's no longer always at the beginning of a file?
- maybe let a chunk point to possible next chunks (so no fixed location header is needed)
- support stores that span multiple files (chunks stored in other files)
- triggers (can be implemented with a custom map)
- store write operations per page (maybe defragment if much different than count)
*/
......@@ -1227,6 +1230,17 @@ public class MVStore {
return fileHeader;
}
/**
* Get the file instance in use, if a file is used. The application may read
* from the file (for example for online backup), but not write to it or
* truncate it.
*
* @return the file, or null
*/
public FileChannel getFile() {
return file;
}
public String toString() {
return DataUtils.appendMap(new StringBuilder(), config).toString();
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论