public class Page extends Object
For b-tree nodes, the key at a given index is larger than the largest key of the child at the same index.
File format: page length (including length): int check value: short map id: varInt number of keys: varInt type: byte (0: leaf, 1: node; +2: compressed) compressed: bytes saved (varInt) keys leaf: values (one for each key) node: children (1 more than keys)
| 限定符和类型 | 类和说明 |
|---|---|
static class |
Page.PageChildren
Contains information about which other pages are referenced (directly or
indirectly) by the given page.
|
static class |
Page.PageReference
A pointer to a page, either in-memory or using a page position.
|
| 限定符和类型 | 字段和说明 |
|---|---|
static Object[] |
EMPTY_OBJECT_ARRAY
An empty object array.
|
| 限定符和类型 | 方法和说明 |
|---|---|
int |
binarySearch(Object key)
Search the key in this page using a binary search.
|
Page |
copy(long version)
Create a copy of this page.
|
static Page |
create(MVMap<?,?> map,
long version,
Object[] keys,
Object[] values,
Page.PageReference[] children,
long totalCount,
int memory)
Create a new page.
|
static Page |
create(MVMap<?,?> map,
long version,
Page source)
Create a copy of a page.
|
boolean |
equals(Object other) |
Page |
getChildPage(int index)
Get the child page at the given index.
|
long |
getChildPagePos(int index)
Get the position of the child.
|
Object |
getKey(int index)
Get the key at the given index.
|
int |
getKeyCount()
Get the number of keys in this page.
|
int |
getMemory() |
long |
getPos()
Get the position of the page
|
int |
getRawChildPageCount() |
long |
getTotalCount()
Get the total number of key-value pairs, including child pages.
|
Object |
getValue(int index)
Get the value at the given index.
|
int |
hashCode() |
void |
insertLeaf(int index,
Object key,
Object value)
Insert a key-value pair into this leaf.
|
void |
insertNode(int index,
Object key,
Page childPage)
Insert a child page into this node.
|
boolean |
isLeaf()
Check whether this is a leaf page.
|
void |
remove(int index)
Remove the key and value (or child) at the given index.
|
void |
removePage()
Remove the page.
|
void |
setChild(int index,
Page c)
Replace the child page.
|
void |
setKey(int index,
Object key)
Replace the key at an index in this page.
|
Object |
setValue(int index,
Object value)
Replace the value at an index in this page.
|
String |
toString() |
public static final Object[] EMPTY_OBJECT_ARRAY
public static Page create(MVMap<?,?> map, long version, Object[] keys, Object[] values, Page.PageReference[] children, long totalCount, int memory)
map - the mapversion - the versionkeys - the keysvalues - the valueschildren - the child page positionstotalCount - the total number of keysmemory - the memory used in bytespublic static Page create(MVMap<?,?> map, long version, Page source)
map - the mapversion - the versionsource - the source pagepublic Object getKey(int index)
index - the indexpublic Page getChildPage(int index)
index - the indexpublic long getChildPagePos(int index)
index - the indexpublic Object getValue(int index)
index - the indexpublic int getKeyCount()
public boolean isLeaf()
public long getPos()
public Page copy(long version)
version - the new versionpublic int binarySearch(Object key)
If the key was found, the returned value is the index in the key array. If not found, the returned value is negative, where -1 means the provided key is smaller than any keys in this page. See also Arrays.binarySearch.
key - the keypublic long getTotalCount()
public void setChild(int index,
Page c)
index - the indexc - the new child pagepublic void setKey(int index,
Object key)
index - the indexkey - the new keypublic Object setValue(int index, Object value)
index - the indexvalue - the new valuepublic void insertLeaf(int index,
Object key,
Object value)
index - the indexkey - the keyvalue - the valuepublic void insertNode(int index,
Object key,
Page childPage)
index - the indexkey - the keychildPage - the child pagepublic void remove(int index)
index - the indexpublic int getRawChildPageCount()
public int getMemory()
public void removePage()
Copyright © 2017. All rights reserved.