提交 f125a8a4 authored 作者: Noel Grandin's avatar Noel Grandin

javadoc in MVStore

上级 b1841c5f
...@@ -529,6 +529,14 @@ public class MVStore implements AutoCloseable { ...@@ -529,6 +529,14 @@ public class MVStore implements AutoCloseable {
} }
} }
/**
* Get map by id.
*
* @param <K> the key type
* @param <V> the value type
* @param id map id
* @return Map
*/
public <K, V> MVMap<K,V> getMap(int id) { public <K, V> MVMap<K,V> getMap(int id) {
checkOpen(); checkOpen();
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
...@@ -609,6 +617,12 @@ public class MVStore implements AutoCloseable { ...@@ -609,6 +617,12 @@ public class MVStore implements AutoCloseable {
return meta.containsKey("name." + name); return meta.containsKey("name." + name);
} }
/**
* Check whether a given map exists and has data.
*
* @param name the map name
* @return true if it exists and has data.
*/
public boolean hasData(String name) { public boolean hasData(String name) {
return hasMap(name) && getRootPos(meta, getMapId(name)) != 0; return hasMap(name) && getRootPos(meta, getMapId(name)) != 0;
} }
...@@ -969,6 +983,13 @@ public class MVStore implements AutoCloseable { ...@@ -969,6 +983,13 @@ public class MVStore implements AutoCloseable {
} }
} }
/**
* Read a page of data into a ByteBuffer.
*
* @param pos page pos
* @param expectedMapId expected map id for the page
* @return ByteBuffer containing page data.
*/
ByteBuffer readBufferForPage(long pos, int expectedMapId) { ByteBuffer readBufferForPage(long pos, int expectedMapId) {
Chunk c = getChunk(pos); Chunk c = getChunk(pos);
long filePos = c.block * BLOCK_SIZE; long filePos = c.block * BLOCK_SIZE;
...@@ -1493,6 +1514,13 @@ public class MVStore implements AutoCloseable { ...@@ -1493,6 +1514,13 @@ public class MVStore implements AutoCloseable {
return new HashSet<>(referencedChunks.keySet()); return new HashSet<>(referencedChunks.keySet());
} }
/**
* Visit a page on a chunk and collect ids for it and its children.
*
* @param page the page to visit
* @param executorService the service to use when doing visit in parallel
* @param executingThreadCounter number of threads currently active
*/
public void visit(Page page, ThreadPoolExecutor executorService, AtomicInteger executingThreadCounter) { public void visit(Page page, ThreadPoolExecutor executorService, AtomicInteger executingThreadCounter) {
long pos = page.getPos(); long pos = page.getPos();
if (DataUtils.isPageSaved(pos)) { if (DataUtils.isPageSaved(pos)) {
...@@ -1515,6 +1543,13 @@ public class MVStore implements AutoCloseable { ...@@ -1515,6 +1543,13 @@ public class MVStore implements AutoCloseable {
cacheCollectedChunkIds(pos, childCollector); cacheCollectedChunkIds(pos, childCollector);
} }
/**
* Visit a page on a chunk and collect ids for it and its children.
*
* @param pos position of the page to visit
* @param executorService the service to use when doing visit in parallel
* @param executingThreadCounter number of threads currently active
*/
public void visit(long pos, ThreadPoolExecutor executorService, AtomicInteger executingThreadCounter) { public void visit(long pos, ThreadPoolExecutor executorService, AtomicInteger executingThreadCounter) {
if (!DataUtils.isPageSaved(pos)) { if (!DataUtils.isPageSaved(pos)) {
return; return;
...@@ -1544,6 +1579,11 @@ public class MVStore implements AutoCloseable { ...@@ -1544,6 +1579,11 @@ public class MVStore implements AutoCloseable {
} }
} }
/**
* Add chunk to list of referenced chunks.
*
* @param chunkId chunk id
*/
void registerChunk(int chunkId) { void registerChunk(int chunkId) {
if (referencedChunks.put(chunkId, 1) == null && parent != null) { if (referencedChunks.put(chunkId, 1) == null && parent != null) {
parent.registerChunk(chunkId); parent.registerChunk(chunkId);
...@@ -2603,6 +2643,12 @@ public class MVStore implements AutoCloseable { ...@@ -2603,6 +2643,12 @@ public class MVStore implements AutoCloseable {
removeMap(map, true); removeMap(map, true);
} }
/**
* Remove a map.
*
* @param map the map to remove
* @param delayed whether to delay deleting the metadata
*/
public void removeMap(MVMap<?, ?> map, boolean delayed) { public void removeMap(MVMap<?, ?> map, boolean delayed) {
storeLock.lock(); storeLock.lock();
try { try {
...@@ -2637,6 +2683,11 @@ public class MVStore implements AutoCloseable { ...@@ -2637,6 +2683,11 @@ public class MVStore implements AutoCloseable {
} }
} }
/**
* Remove map by name.
*
* @param name the map name
*/
public void removeMap(String name) { public void removeMap(String name) {
int id = getMapId(name); int id = getMapId(name);
if(id > 0) { if(id > 0) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论