|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jgit.storage.dht.spi.memory.MemTable
public class MemTable
Tiny in-memory NoSQL style table.
This table is thread-safe, but not very efficient. It uses a single lock to protect its internal data structure from concurrent access, and stores all data as byte arrays. To reduce memory usage, the arrays passed by the caller during put or compareAndSet are used as-is in the internal data structure, and may be returned later. Callers should not modify byte arrays once they are stored in the table, or when obtained from the table.
Nested Class Summary | |
---|---|
static class |
MemTable.Cell
A cell value in a column. |
Constructor Summary | |
---|---|
MemTable()
Initialize an empty table. |
Method Summary | |
---|---|
boolean |
compareAndSet(byte[] row,
byte[] col,
byte[] oldVal,
byte[] newVal)
Compare and put or delete a cell. |
void |
delete(byte[] row,
byte[] col)
Delete a cell. |
void |
deleteRow(byte[] row)
Delete an entire row. |
MemTable.Cell |
get(byte[] row,
byte[] col)
Get a single cell, or null. |
void |
put(byte[] row,
byte[] col,
byte[] val)
Put a value into a cell. |
java.lang.Iterable<MemTable.Cell> |
scanFamily(byte[] row,
ColumnMatcher family)
Scan all cells in a row. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MemTable()
Method Detail |
---|
public void put(byte[] row, byte[] col, byte[] val)
row
- col
- val
- public void deleteRow(byte[] row)
row
- public void delete(byte[] row, byte[] col)
row
- col
- public boolean compareAndSet(byte[] row, byte[] col, byte[] oldVal, byte[] newVal)
This method performs an atomic compare-and-swap operation on the named
cell. If the cell does not yet exist, it will be created. If the cell
exists, it will be replaced, and if newVal
is null, the cell will
be deleted.
row
- col
- oldVal
- if null, the cell must not exist, otherwise the cell's current
value must exactly equal this value for the update to occur.newVal
- if null, the cell will be removed, otherwise the cell will be
created or updated to this value.
oldVal
does not match.public MemTable.Cell get(byte[] row, byte[] col)
row
- col
-
public java.lang.Iterable<MemTable.Cell> scanFamily(byte[] row, ColumnMatcher family)
row
- the row to scan.family
- if not null, the family to filter and return.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |