public interface Index<T>
Modifier and Type | Interface and Description |
---|---|
static interface |
Index.Builder<T> |
static interface |
Index.Factory
To provide suitable defaults for the endpoint/credProvider/proxy/keyProvider,
it is recommended to implement a custom Factory implementation.
|
Modifier and Type | Method and Description |
---|---|
<N> Index.Builder<N> |
clone(Class<N> clazz)
Clone this index, use the builder methods to customize the clone.
|
int |
countItems(PageIterator pageIterator)
Count all items in the table.
|
default void |
deleteItem(Object hk,
Object rk)
Shortcut method to always delete an item (no condition specified).
|
void |
deleteItem(Object hk,
Object rk,
FilterCondFn filterCondFn)
Delete an item from the table with the specified hash key and range key, optionally
specify a filter condition that if evaluated to false causes a RollbackException
to be thrown (and no item deleted).
|
void |
deleteItems(IndexKey... keys)
Batch delete all items with the specified hash key and range key in the IndexKey object.
|
default Object |
getDynamoDBUnsafe()
Obtain the underlying DynamoDB object for this table.
|
String |
getHashKeyName() |
default T |
getItem(Object hk)
Same as getItem(hk, null).
|
T |
getItem(Object hk,
Object rk)
Obtain an item stored with the specified hash key and range key.
|
default <V> V |
getItem(Object hk,
Object rk,
Class<V> type)
Shortcut method to getItem() with all attributes.
|
<V> V |
getItem(Object hk,
Object rk,
Collection<String> attributes,
Class<V> type)
Obtain an item stored with the specified hash key and range key, but
convert to a different class type, and only select the specified
attributes.
|
default T |
getItemOrThrow(Object hk,
Object rk)
Obtain a specific item, but instead of returning null, throw EntityNotFoundException
NOTE: This only works on "main" indexes.
|
Map<IndexKey,T> |
getItems(IndexKey... keys)
Do a batch get of items with the specified hash key and range keys.
|
default Object |
getMySQLDataSourceUnsafe()
Obtain the underlaying DataSource object for this table.
|
String |
getRangeKeyName() |
String |
getTableName() |
Set<IndexKey> |
itemsExist(IndexKey... keys)
Test if a set of DB keys exist, if so those IndexKeys are returned in the set.
|
T |
putItem(T item)
Overwrite or create a new item in the table.
|
default boolean |
putItemIfNotExists(T item)
Shortcut method to catch EntityExistsException and return true/false instead.
|
void |
putItemOrThrow(T item)
Create a new item in the table, but if an item already exists, throw EntityExistsException.
|
void |
putItems(T... items)
Batch put items, overwriting any items in the table that have the same hash key
and range key.
|
QueryItemsBuilder<T> |
queryItems(Object hk,
PageIterator pageIterator) |
List<T> |
scanItems(PageIterator pageIterator)
Iterate over all items in the table.
|
String |
toMarker(T item,
boolean hasHashKey)
Call the configured ConvertMarker.toMarker() implementation.
|
UpdateItemBuilder<T> |
updateItem(Object hk,
Object rk)
Update or create the item identified with the specified hash key and range key.
|
String getHashKeyName()
String getRangeKeyName()
String getTableName()
default Object getDynamoDBUnsafe()
default Object getMySQLDataSourceUnsafe()
String toMarker(T item, boolean hasHashKey)
item
- is an item for which we desire to obtain a marker for.hasHashKey
- should be set to true only if we are guaranteed
to call fromMarker() with a non-null hash key parameter.<N> Index.Builder<N> clone(Class<N> clazz)
N
- is the type of elements we plan to store/retrieve.clazz
- is the type of elements we plan to store/retrieve
from the Index created by the returned builder.QueryItemsBuilder<T> queryItems(Object hk, PageIterator pageIterator)
hk
- is the hash key to query on.pageIterator
- is the page iterator to use for iterating over multiple
result sets.List<T> scanItems(PageIterator pageIterator)
pageIterator
- is the page iterator to use.int countItems(PageIterator pageIterator)
pageIterator
- is the page iterator to use.T getItem(Object hk, Object rk)
hk
- is the hash key.rk
- is the range key, or null if this table does not have a range
key name.default T getItem(Object hk)
hk
- is the hash key.<V> V getItem(Object hk, Object rk, Collection<String> attributes, Class<V> type)
V
- is the alternative item type to retrieve.hk
- is the hash key.rk
- is the range key (or null if this table has no range key).attributes
- is the set of attribute names to obtain.type
- is the class of the alternative item type to retrieve.default <V> V getItem(Object hk, Object rk, Class<V> type)
V
- is the alternative item type to retrieve.hk
- is the hash key.rk
- is the range key.type
- is the class of the alternative item type to retrieve.default T getItemOrThrow(Object hk, Object rk) throws javax.persistence.EntityNotFoundException
hk
- is the hash key.rk
- is the range key.javax.persistence.EntityNotFoundException
- if no such item exists.Map<IndexKey,T> getItems(IndexKey... keys)
keys
- is an array of index keys to obtain in a single batch call.Set<IndexKey> itemsExist(IndexKey... keys)
keys
- is an array of index keys to check for existance of.T putItem(T item)
item
- is the item to put.void putItemOrThrow(T item) throws javax.persistence.EntityExistsException
item
- is the item to put.javax.persistence.EntityExistsException
- if the primary key of item already exists in this
table.default boolean putItemIfNotExists(T item)
item
- is the item to put.void putItems(T... items)
items
- are the items to put in the table.UpdateItemBuilder<T> updateItem(Object hk, Object rk)
hk
- is the hash key.rk
- is the range key, or null if this table has no range key name.void deleteItem(Object hk, Object rk, FilterCondFn filterCondFn) throws javax.persistence.RollbackException
hk
- is the hash key.rk
- is the range key, or null if this table has no range key name.filterCondFn
- is used to describe under what condition this item may be
deleted.javax.persistence.RollbackException
- if the filterCondFn condition was not met.default void deleteItem(Object hk, Object rk)
hk
- is the hash key.rk
- is the range key, or null if this table has no range key name.void deleteItems(IndexKey... keys)
keys
- is an array of index keys that should be unconditionally deleted if they exist.Copyright © 2018. All rights reserved.