public class Memory extends Object implements SimpleStore
ConcurrentSkipListMap.
This store entirely resides into memory, and is only available for the current JVM.
It is well suited for testing.
This store is thread-safe.
This store does not supports mixing incrementing and absolute values.| Modifier and Type | Class and Description |
|---|---|
class |
Memory.Table
An map to store rows within tables.
|
| Modifier and Type | Method and Description |
|---|---|
long |
count(String table,
Constraint c)
Counts the number of element satisfying the constraint.
|
void |
delete(String table,
String id)
Deletes the given row
|
boolean |
exists(String table,
String row)
Tests for a row.
|
boolean |
exists(String table,
String row,
String family)
Tests whether a column family is empty.
|
CloseableKeyIterator |
get(String table,
Constraint c,
int limit,
Set<String> families)
Rows matching constraint sorted according to their key in ascending order.
|
Row.ColumnFamilyData |
get(String table,
String id,
Set<String> families)
Returns all elements in families ; no side-effect.
|
Map<String,byte[]> |
get(String table,
String id,
String family)
Returns all elements in a family ; no side-effect.
|
Map<String,byte[]> |
get(String table,
String id,
String family,
Constraint c)
Returns all elements in a family ; no side-effect.
|
byte[] |
get(String table,
String id,
String family,
String qualifer)
Returns an element from a family.
|
Memory.Table.Row.ColumnFamily |
getFamily(String table,
String id,
String family,
boolean createIfNecessary)
Returns the in-memory column family for a given row from a table.
|
Memory.Table.Row |
getRow(String table,
String id,
boolean createIfNecessary)
Returns the in-memory row (compatible with
Row) from a table. |
Memory.Table |
getTable(String table,
boolean createIfNecessary)
Returns the in-memory table.
|
boolean |
hasTable(String tableName)
Checks whether the given table exists in this store.
|
void |
reset() |
void |
start()
Called once the store is created ; only one store is instanciated with the same properties.
|
void |
storeChanges(String table,
String id,
Row.ColumnFamilyData changed,
Map<String,Set<String>> removed,
Map<String,Map<String,Number>> incremented)
Stores given piece of information.
|
protected static <T> NavigableMap<String,T> |
subMap(NavigableMap<String,T> map,
String fromIncl,
String toIncl)
Utility method used internally to find a sub-map with inclusive nullable start and stop keys.
|
public static final Memory INSTANCE
protected static <T> NavigableMap<String,T> subMap(NavigableMap<String,T> map, String fromIncl, String toIncl)
map - the map to be searched-infromIncl - the start key ; can be null to state the start of the maptoIncl - the last key ; can be null to state the end of the mappublic void start()
SimpleStorestart in interface SimpleStorepublic Memory.Table getTable(String table, boolean createIfNecessary)
table - the name of the expected tablecreateIfNecessary - whether to create the table if it does not existpublic Memory.Table.Row getRow(String table, String id, boolean createIfNecessary)
Row) from a table.table - the name of the table in which to find the rowid - the unique identifier for the row within the tablecreateIfNecessary - whether to create the row if it does not exist (including in case table does not exists)public Memory.Table.Row.ColumnFamily getFamily(String table, String id, String family, boolean createIfNecessary)
table - the name of the table in which to find the column family for the rowid - the unique identifier for the row within the tablefamily - the name of the column family to be found within the rowcreateIfNecessary - whether to create the row if it does not exist (including in case table or row does not exists)public boolean hasTable(String tableName) throws DatabaseNotReachedException
SimpleStorehasTable in interface SimpleStoreDatabaseNotReachedExceptionpublic byte[] get(String table, String id, String family, String qualifer)
SimpleStoreget in interface SimpleStorepublic Map<String,byte[]> get(String table, String id, String family)
SimpleStoreget in interface SimpleStorepublic Map<String,byte[]> get(String table, String id, String family, Constraint c) throws DatabaseNotReachedException
SimpleStoreget in interface SimpleStoreDatabaseNotReachedExceptionpublic void storeChanges(String table, String id, Row.ColumnFamilyData changed, Map<String,Set<String>> removed, Map<String,Map<String,Number>> incremented)
SimpleStorestoreChanges in interface SimpleStorepublic long count(String table, Constraint c) throws DatabaseNotReachedException
SimpleStorecount in interface SimpleStoreDatabaseNotReachedExceptionpublic void reset()
public void delete(String table, String id)
SimpleStoredelete in interface SimpleStorepublic boolean exists(String table, String row, String family) throws DatabaseNotReachedException
SimpleStoreexists in interface SimpleStoreDatabaseNotReachedExceptionpublic boolean exists(String table, String row) throws DatabaseNotReachedException
SimpleStoreexists in interface SimpleStoreDatabaseNotReachedExceptionpublic Row.ColumnFamilyData get(String table, String id, Set<String> families) throws DatabaseNotReachedException
SimpleStoreget in interface SimpleStoretable - the table from which to find the elementid - the unique identifier (i.e. the key) with which the element was storedfamilies - the set of column families to be activated ; should never be null or emptyDatabaseNotReachedExceptionpublic CloseableKeyIterator get(String table, Constraint c, int limit, Set<String> families) throws DatabaseNotReachedException
SimpleStoreget in interface SimpleStorefamilies - TODODatabaseNotReachedExceptionCopyright © 2016. All Rights Reserved.