org.mapdb
Class BTreeKeySerializer<KEY,KEYS>
- java.lang.Object
-
- org.mapdb.BTreeKeySerializer<KEY,KEYS>
-
- Type Parameters:
KEY- type of keyKEYS- type of object which holds multiple keys (
- Direct Known Subclasses:
- BTreeKeySerializer.ArrayKeySerializer, BTreeKeySerializer.BasicKeySerializer, BTreeKeySerializer.Compress
public abstract class BTreeKeySerializer<KEY,KEYS> extends java.lang.ObjectCustom serializer for BTreeMap keys which enables [Delta encoding](https://en.wikipedia.org/wiki/Delta_encoding). Keys in BTree Nodes are sorted, this enables number of tricks to save disk space. For example for numbers we may store only difference between subsequent numbers, for string we can only take suffix, etc...
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classBTreeKeySerializer.ArrayKeySerializerstatic classBTreeKeySerializer.BasicKeySerializerBasic Key Serializer which just writes data without applying any compression.static classBTreeKeySerializer.ByteArrayKeysstatic classBTreeKeySerializer.CharArrayKeysstatic classBTreeKeySerializer.Compressstatic interfaceBTreeKeySerializer.StringArrayKeys
-
Field Summary
Fields Modifier and Type Field and Description static BTreeKeySerializerARRAY2static BTreeKeySerializerARRAY3static BTreeKeySerializerARRAY4static BTreeKeySerializer<java.lang.Object,java.lang.Object[]>BASICstatic BTreeKeySerializer<byte[],BTreeKeySerializer.ByteArrayKeys>BYTE_ARRAYstatic BTreeKeySerializer<byte[],byte[][]>BYTE_ARRAY2static BTreeKeySerializer<java.lang.Integer,int[]>INTEGERApplies delta packing onjava.lang.Integer.static BTreeKeySerializer<java.lang.Long,long[]>LONGApplies delta packing onjava.lang.Long.static BTreeKeySerializer<java.lang.String,BTreeKeySerializer.StringArrayKeys>STRINGstatic BTreeKeySerializer<java.lang.String,char[][]>STRING2static BTreeKeySerializer<java.util.UUID,long[]>UUIDstatic BTreeKeySerializerZERO_OR_POSITIVE_INTDeprecated.useINTEGERstatic BTreeKeySerializerZERO_OR_POSITIVE_LONGDeprecated.useLONG
-
Constructor Summary
Constructors Constructor and Description BTreeKeySerializer()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description abstract KEYSarrayToKeys(java.lang.Object[] keys)abstract java.util.Comparator<?>comparator()abstract intcompare(KEYS keys, int pos1, int pos2)abstract intcompare(KEYS keys, int pos, KEY key)booleancompareIsSmaller(KEYS keys, int pos, KEY key)abstract KEYScopyOfRange(KEYS keys, int from, int to)abstract KEYSdeleteKey(KEYS keys, int pos)abstract KEYSdeserialize(java.io.DataInput in, int nodeSize)Deserializes keys for single BTree Node.abstract KEYSemptyKeys()intfindChildren(BTreeMap.BNode node, java.lang.Object key)Find the first children node with a key equal or greater than the given key.intfindChildren2(BTreeMap.BNode node, java.lang.Object key)abstract KEYgetKey(KEYS keys, int pos)booleanisTrusted()java.lang.Object[]keysToArray(KEYS keys)abstract intlength(KEYS keys)abstract KEYSputKey(KEYS keys, int pos, KEY newKey)expand keys array by one and putnewKeyat positionposabstract voidserialize(java.io.DataOutput out, KEYS keys)Serialize keys from single BTree Node.
-
-
-
Field Detail
-
BASIC
public static final BTreeKeySerializer<java.lang.Object,java.lang.Object[]> BASIC
-
LONG
public static final BTreeKeySerializer<java.lang.Long,long[]> LONG
Applies delta packing onjava.lang.Long. Difference between consequential numbers is also packed itself, so for small diffs it takes only single byte per number.
-
ZERO_OR_POSITIVE_LONG
public static final BTreeKeySerializer ZERO_OR_POSITIVE_LONG
Deprecated. useLONG
-
INTEGER
public static final BTreeKeySerializer<java.lang.Integer,int[]> INTEGER
Applies delta packing onjava.lang.Integer. Difference between consequential numbers is also packed itself, so for small diffs it takes only single byte per number.
-
ZERO_OR_POSITIVE_INT
public static final BTreeKeySerializer ZERO_OR_POSITIVE_INT
Deprecated. useINTEGER
-
ARRAY2
public static final BTreeKeySerializer ARRAY2
-
ARRAY3
public static final BTreeKeySerializer ARRAY3
-
ARRAY4
public static final BTreeKeySerializer ARRAY4
-
UUID
public static final BTreeKeySerializer<java.util.UUID,long[]> UUID
-
STRING2
public static final BTreeKeySerializer<java.lang.String,char[][]> STRING2
-
STRING
public static final BTreeKeySerializer<java.lang.String,BTreeKeySerializer.StringArrayKeys> STRING
-
BYTE_ARRAY2
public static final BTreeKeySerializer<byte[],byte[][]> BYTE_ARRAY2
-
BYTE_ARRAY
public static final BTreeKeySerializer<byte[],BTreeKeySerializer.ByteArrayKeys> BYTE_ARRAY
-
-
Method Detail
-
serialize
public abstract void serialize(java.io.DataOutput out, KEYS keys) throws java.io.IOExceptionSerialize keys from single BTree Node.- Parameters:
out- output stream where to put atakeys- An object which represents keys- Throws:
java.io.IOException- in case of an writting error
-
deserialize
public abstract KEYS deserialize(java.io.DataInput in, int nodeSize) throws java.io.IOException
Deserializes keys for single BTree Node. To- Parameters:
in- input stream to read data fromnodeSize- number of keys in deserialized node- Returns:
- an object which represents keys
- Throws:
java.io.IOException- in case of an reading error
-
compare
public abstract int compare(KEYS keys, int pos1, int pos2)
-
comparator
public abstract java.util.Comparator<?> comparator()
-
emptyKeys
public abstract KEYS emptyKeys()
-
length
public abstract int length(KEYS keys)
-
putKey
public abstract KEYS putKey(KEYS keys, int pos, KEY newKey)
expand keys array by one and putnewKeyat positionpos- Parameters:
keys- array of keys to put new key intopos- of new keynewKey- new key to insert- Returns:
- array of keys with new key at given position
-
findChildren
public int findChildren(BTreeMap.BNode node, java.lang.Object key)
Find the first children node with a key equal or greater than the given key. If all items are smaller it returnskeyser.length(keys)- Parameters:
node- BTree Node to find position inkey- key whose position needs to be find- Returns:
- position of key in node
-
findChildren2
public int findChildren2(BTreeMap.BNode node, java.lang.Object key)
-
arrayToKeys
public abstract KEYS arrayToKeys(java.lang.Object[] keys)
-
keysToArray
public java.lang.Object[] keysToArray(KEYS keys)
-
isTrusted
public boolean isTrusted()
-
-
DataMelt 3.0 © DataMelt by jWork.ORG