public class BEncodedHeap extends java.lang.Object implements MapStore
Modifier and Type | Class and Description |
---|---|
private static class |
BEncodedHeap.b2mEntry |
private static class |
BEncodedHeap.EntryIter |
Modifier and Type | Field and Description |
---|---|
private java.util.LinkedHashSet<java.lang.String> |
columnames |
private Heap |
table |
Constructor and Description |
---|
BEncodedHeap(java.io.File location,
int keylength)
convenience method to open a properies table
|
BEncodedHeap(java.io.File location,
int keylength,
ByteOrder ordering,
int buffermax)
produce or open a properties table
|
Modifier and Type | Method and Description |
---|---|
private static java.util.Map<java.lang.String,byte[]> |
b2m(byte[] b) |
void |
clear()
remove all entries from the map; possibly removes the backend-file
|
void |
close()
close the backen-file.
|
java.util.ArrayList<java.lang.String> |
columns()
Produce a list of column names from this table This method may be useful if the table shall be
displayed as a table in GUIs.
|
private boolean |
containsKey(byte[] pk)
check if a row with given key exists in the table
|
boolean |
containsKey(java.lang.Object key)
check if a row with given key exists in the table This method is here to implement the Map interface
|
boolean |
containsValue(java.lang.Object value)
the containsValue method cannot be used in this method and is only here to implement the Map interface
|
void |
delete(byte[] pk)
delete a map from the table
|
byte[] |
encodedKey(java.lang.String key) |
java.util.Set<java.util.Map.Entry<byte[],java.util.Map<java.lang.String,byte[]>>> |
entrySet()
The abstract method entrySet() from AbstractMap must be implemented, but never used because that is not
useful for this file-based storage class.
|
java.util.Map<java.lang.String,byte[]> |
get(byte[] pk)
get a map from the table
|
java.util.Map<java.lang.String,byte[]> |
get(java.lang.Object key)
get a map from the table this method is here to implement the Map interface
|
java.io.File |
getFile()
the map is stored inside a file; this method may return the file
|
ByteOrder |
getOrdering()
the map should have an ordering on the key elements
|
byte[] |
getProp(byte[] pk,
java.lang.String key)
convenience method to get a value from a map
|
int |
hashCode()
a hashcode for the object
|
void |
insert(byte[] pk,
java.util.Map<java.lang.String,byte[]> map)
insert a map into the table this method shall be used in exchange of the get method if the previous
entry value is not needed.
|
void |
insert(byte[] pk,
java.lang.String key,
byte[] value) |
boolean |
isEmpty()
return true if the table is empty
|
java.util.Iterator<java.util.Map.Entry<byte[],java.util.Map<java.lang.String,byte[]>>> |
iterator()
iterate all rows of the table.
|
static java.util.Iterator<java.util.Map.Entry<byte[],java.util.Map<java.lang.String,byte[]>>> |
iterator(java.io.File location,
int keylen)
iterate all rows of the table.
|
CloneableIterator<byte[]> |
keyIterator()
the keys of the map should be iterable
|
java.util.Iterator<byte[]> |
keys()
iterate all keys of the table
|
java.util.Iterator<byte[]> |
keys(boolean up,
boolean rotating)
iterate all keys of the table
|
java.util.Set<byte[]> |
keySet()
Return a Set of the keys contained in this map.
|
static void |
main(java.lang.String[] args) |
java.util.Map<java.lang.String,byte[]> |
put(byte[] pk,
java.util.Map<java.lang.String,byte[]> map)
insert a map into the table
|
void |
putAll(java.util.Map<? extends byte[],? extends java.util.Map<java.lang.String,byte[]>> map)
Copy all the mappings from the specified map to this map.
|
java.util.Map<java.lang.String,byte[]> |
remove(byte[] key)
delete a map from the table
|
java.util.Map<java.lang.String,byte[]> |
remove(java.lang.Object key) |
java.util.Set<byte[]> |
select(java.lang.String columnName,
java.util.regex.Pattern columnMatcher)
select all rows from a table where a given matcher matches with elements in a given row this method
makes a full-table scan of the whole table
|
java.util.Map.Entry<byte[],java.util.Map<java.lang.String,byte[]>> |
selectOne(java.lang.String columnName,
java.util.regex.Pattern columnMatcher)
select one row from a table where a given matcher matches with elements in a given row this method
stops the full-table scan as soon as a first matcher was found
|
int |
size()
Retur the number of key-value mappings in this map.
|
void |
update(byte[] pk,
java.util.Map<java.lang.String,byte[]> map) |
void |
update(byte[] pk,
java.lang.String key,
byte[] value) |
java.util.Collection<java.util.Map<java.lang.String,byte[]>> |
values()
the values() method is not implemented in this class because it does not make sense to use such a
method for file-based data structures.
|
private Heap table
private final java.util.LinkedHashSet<java.lang.String> columnames
public BEncodedHeap(java.io.File location, int keylength, ByteOrder ordering, int buffermax) throws java.io.IOException
location
- the filekeylength
- length of access keysordering
- ordering on the keysbuffermax
- maximum number of lines that shall be buffered for writingjava.io.IOException
public BEncodedHeap(java.io.File location, int keylength) throws java.io.IOException
location
- the filekeylength
- length of access keysjava.io.IOException
public ByteOrder getOrdering()
MapStore
getOrdering
in interface MapStore
public CloneableIterator<byte[]> keyIterator()
MapStore
keyIterator
in interface MapStore
public byte[] encodedKey(java.lang.String key)
private static java.util.Map<java.lang.String,byte[]> b2m(byte[] b)
public java.io.File getFile()
public int size()
size
in interface java.util.Map<byte[],java.util.Map<java.lang.String,byte[]>>
public boolean isEmpty()
isEmpty
in interface java.util.Map<byte[],java.util.Map<java.lang.String,byte[]>>
private boolean containsKey(byte[] pk)
name
- public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map<byte[],java.util.Map<java.lang.String,byte[]>>
name
- public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map<byte[],java.util.Map<java.lang.String,byte[]>>
public java.util.Map<java.lang.String,byte[]> get(byte[] pk) throws java.io.IOException, SpaceExceededException
name
- SpaceExceededException
java.io.IOException
public java.util.Map<java.lang.String,byte[]> get(java.lang.Object key)
get
in interface java.util.Map<byte[],java.util.Map<java.lang.String,byte[]>>
name
- public byte[] getProp(byte[] pk, java.lang.String key) throws java.io.IOException, SpaceExceededException
pk
- key
- java.io.IOException
SpaceExceededException
public java.util.Set<byte[]> select(java.lang.String columnName, java.util.regex.Pattern columnMatcher)
columnName
- the name of the column where the matcher shall matchcolumnMatcher
- the matcher for the elements of the columnpublic java.util.Map.Entry<byte[],java.util.Map<java.lang.String,byte[]>> selectOne(java.lang.String columnName, java.util.regex.Pattern columnMatcher)
columnName
- the name of the column where the matcher shall matchcolumnMatcher
- the matcher for the elements of the columnpublic void insert(byte[] pk, java.util.Map<java.lang.String,byte[]> map) throws SpaceExceededException, java.io.IOException
name
- map
- SpaceExceededException
java.io.IOException
public void insert(byte[] pk, java.lang.String key, byte[] value) throws java.io.IOException
java.io.IOException
public void update(byte[] pk, java.util.Map<java.lang.String,byte[]> map) throws SpaceExceededException, java.io.IOException
SpaceExceededException
java.io.IOException
public void update(byte[] pk, java.lang.String key, byte[] value) throws SpaceExceededException, java.io.IOException
SpaceExceededException
java.io.IOException
public java.util.Map<java.lang.String,byte[]> put(byte[] pk, java.util.Map<java.lang.String,byte[]> map)
put
in interface java.util.Map<byte[],java.util.Map<java.lang.String,byte[]>>
name
- map
- public void delete(byte[] pk) throws java.io.IOException
name
- java.io.IOException
public java.util.Map<java.lang.String,byte[]> remove(byte[] key) throws java.io.IOException, SpaceExceededException
name
- SpaceExceededException
java.io.IOException
public java.util.Map<java.lang.String,byte[]> remove(java.lang.Object key)
remove
in interface java.util.Map<byte[],java.util.Map<java.lang.String,byte[]>>
public void putAll(java.util.Map<? extends byte[],? extends java.util.Map<java.lang.String,byte[]>> map)
putAll
in interface java.util.Map<byte[],java.util.Map<java.lang.String,byte[]>>
m
- mappings to be stored in this mappublic void clear()
clear
in interface java.util.Map<byte[],java.util.Map<java.lang.String,byte[]>>
public void close()
public java.util.Set<byte[]> keySet()
keySet
in interface java.util.Map<byte[],java.util.Map<java.lang.String,byte[]>>
public java.util.Iterator<byte[]> keys() throws java.io.IOException
java.io.IOException
public java.util.Iterator<byte[]> keys(boolean up, boolean rotating) throws java.io.IOException
up
- rotating
- java.io.IOException
public java.util.Collection<java.util.Map<java.lang.String,byte[]>> values()
values
in interface java.util.Map<byte[],java.util.Map<java.lang.String,byte[]>>
public java.util.Set<java.util.Map.Entry<byte[],java.util.Map<java.lang.String,byte[]>>> entrySet()
entrySet
in interface java.util.Map<byte[],java.util.Map<java.lang.String,byte[]>>
public java.util.Iterator<java.util.Map.Entry<byte[],java.util.Map<java.lang.String,byte[]>>> iterator()
iterator
in interface java.lang.Iterable<java.util.Map.Entry<byte[],java.util.Map<java.lang.String,byte[]>>>
public static java.util.Iterator<java.util.Map.Entry<byte[],java.util.Map<java.lang.String,byte[]>>> iterator(java.io.File location, int keylen) throws java.io.IOException
location
- keylen
- java.io.IOException
public int hashCode()
hashCode
in interface java.util.Map<byte[],java.util.Map<java.lang.String,byte[]>>
hashCode
in class java.lang.Object
public java.util.ArrayList<java.lang.String> columns()
public static void main(java.lang.String[] args)