identt
Public Types | Public Member Functions | Protected Attributes | List of all members
identt::store::StoreTable< T > Class Template Referenceabstract
Inheritance diagram for identt::store::StoreTable< T >:
identt::store::StoreLevel identt::store::StoreBase

Public Types

using KeySetT = std::set< KeyTypeE >
 
using MapT = google::protobuf::Map< uint64_t, T >
 

Public Member Functions

 StoreTable (dbpointer trydb, const KeyTypeE pkey, const KeySetT ukeys, const KeySetT ikeys)
 Constructor. More...
 
virtual ~StoreTable ()
 Destructor. More...
 
 StoreTable ()=delete
 make noncopyable and remove default
 
 StoreTable (const StoreTable &)=delete
 
StoreTableoperator= (const StoreTable &)=delete
 
bool GetOne (T *record, KeyTypeE keytype)
 GetOne: get a record by primary or unique key. More...
 
bool GetMany (T *refer, MapT *records, KeyTypeE keytype, size_t skip, size_t limit)
 GetMany: get all values by non unique key. More...
 
void AddTrans (TransactionT *trans, std::string key, std::string &value, bool to_del)
 AddTrans : add transactions. More...
 
virtual std::string GetKey (T *record, KeyTypeE keytype, bool pre)=0
 GetKey: get a key. More...
 
bool GetSecondaryValue (T *record, KeyTypeE keytype, NodeT *node)
 GetSecondaryValue: get a secondary key value. More...
 
bool AddRecord (T *record, TransactionT *trans, bool upsert)
 AddRecord : get transaction item. More...
 
bool DelRecord (T *record, TransactionT *trans)
 DelRecord : get delete transaction item. More...
 
bool GetKeysFromIndex (KeyTypeE keytype, T *record, NodeListT *nodes, size_t skip, size_t limit)
 GetKeysFromIndex : get primary keys from secondary. More...
 
void ScanTable (uint64_t startid, size_t limit, std::function< void(T *)> Func)
 ScanTable : scan by primary key. More...
 
- Public Member Functions inherited from identt::store::StoreLevel
 StoreLevel (dbpointer trydb)
 Constructor. More...
 
 StoreLevel (const StoreLevel &)=delete
 make noncopyable and remove default
 
StoreLeveloperator= (const StoreLevel &)=delete
 
void Initialize (const std::string datadir, const size_t cache_in_mb, uint64_t &last_pkey, uint64_t &last_lkey)
 Initialize: init main db. More...
 
dbpointer getDB ()
 getDB: Get shared pointer to DB More...
 
- Public Member Functions inherited from identt::store::StoreBase
std::string EncodeKeyType (KeyTypeE keytype)
 EncodeKeyType : make prefix key with keytype. More...
 
std::string EncodePrimaryKey (KeyTypeE keytype, ::google::protobuf::uint64 id)
 EncodePrimaryKey : make primary key with id only. More...
 
std::pair< KeyTypeE, uint64_t > DecodePrimaryKey (std::string &key)
 DecodePrimaryKey : get keytype and id from primary key. More...
 
template<typename T >
std::string EncodeSecondaryKey (KeyTypeE keytype, T key)
 EncodeSecondaryKey : make secondary key with one variable only. More...
 
template<typename T , typename U >
std::string EncodeSecondaryKey (KeyTypeE keytype, T key1, U key2)
 EncodeSecondaryKey : make secondary key with two variables. More...
 
template<typename T , typename U , typename V >
std::string EncodeSecondaryKey (KeyTypeE keytype, T key1, U key2, V key3)
 EncodeSecondaryKey : make secondary key with three variables. More...
 
template<>
std::string EncodeSecondaryKey (KeyTypeE keytype, uint64_t key)
 1 value More...
 
template<>
std::string EncodeSecondaryKey (KeyTypeE keytype, std::string key)
 EncodeSecondaryKey : make secondary key with std::string : always unique. More...
 
template<>
std::string EncodeSecondaryKey (KeyTypeE keytype, uint64_t key1, uint64_t key2)
 2 value More...
 
template<>
std::string EncodeSecondaryKey (KeyTypeE keytype, uint64_t key1, std::string key2)
 EncodeSecondaryKey : make secondary key with two keys uint64_t , std::string : always unique. More...
 
template<>
std::string EncodeSecondaryKey (KeyTypeE keytype, std::string key1, uint64_t key2)
 EncodeSecondaryKey : make secondary key with two keys std::string , uint64_t : always unique : s-u unique , s non unique. More...
 
template<>
std::string EncodeSecondaryKey (KeyTypeE keytype, std::string key1, std::string key2)
 EncodeSecondaryKey : make secondary key with two keys std::string , std::string : always unique. More...
 
template<>
std::string EncodeSecondaryKey (KeyTypeE keytype, uint64_t key1, int32_t key2)
 EncodeSecondaryKey : make secondary key with two keys uint64_t, int32_t : always unique. More...
 
template<>
std::string EncodeSecondaryKey (KeyTypeE keytype, uint64_t key1, uint64_t key2, uint64_t key3)
 3 value More...
 
template<>
std::string EncodeSecondaryKey (KeyTypeE keytype, uint64_t key1, uint64_t key2, std::string key3)
 EncodeSecondaryKey : make secondary key with three keys uint64_t , uint64_t , std::string : always unique. More...
 
template<>
std::string EncodeSecondaryKey (KeyTypeE keytype, uint64_t key1, std::string key2, uint64_t key3)
 EncodeSecondaryKey : make secondary key with three keys uint64_t , std::string , uint64_t : always unique : u-s-u unique , u-s non unique. More...
 
template<>
std::string EncodeSecondaryKey (KeyTypeE keytype, uint64_t key1, std::string key2, std::string key3)
 EncodeSecondaryKey : make secondary key with three keys uint64_t , std::string , std::string : always unique. More...
 
template<>
std::string EncodeSecondaryKey (KeyTypeE keytype, std::string key1, uint64_t key2, uint64_t key3)
 EncodeSecondaryKey : make secondary key with three keys std::string , uint64_t , uint64_t : s-u-u unique , s-u non unique. More...
 
template<>
std::string EncodeSecondaryKey (KeyTypeE keytype, std::string key1, uint64_t key2, std::string key3)
 EncodeSecondaryKey : make secondary key with three keys std::string , uint64_t , std::string : always unique. More...
 
template<>
std::string EncodeSecondaryKey (KeyTypeE keytype, std::string key1, std::string key2, uint64_t key3)
 EncodeSecondaryKey : make secondary key with three keys std::string , std::string , uint64_t : s-s-u unique , s-s non unique. More...
 
template<>
std::string EncodeSecondaryKey (KeyTypeE keytype, std::string key1, std::string key2, std::string key3)
 EncodeSecondaryKey : make secondary key with three keys std::string , std::string , std::string : always unique. More...
 

Protected Attributes

const KeyTypeE PrimaryKey
 
const KeySetT unique_keys
 
const KeySetT index_keys
 
- Protected Attributes inherited from identt::store::StoreLevel
dbpointer db
 

Constructor & Destructor Documentation

§ StoreTable()

template<class T>
identt::store::StoreTable< T >::StoreTable ( dbpointer  trydb,
const KeyTypeE  pkey,
const KeySetT  ukeys,
const KeySetT  ikeys 
)
inline

Constructor.

Parameters
trydbdbpointer shared pointer to db
pkeyconst KeyTypeE primary key
ukeysconst KeySetT unique keys to initialize
ikeysconst KeySetT non unique keys to initialize

§ ~StoreTable()

template<class T>
virtual identt::store::StoreTable< T >::~StoreTable ( )
inlinevirtual

Destructor.

Member Function Documentation

§ AddRecord()

template<class T>
bool identt::store::StoreTable< T >::AddRecord ( T *  record,
TransactionT *  trans,
bool  upsert 
)
inline

AddRecord : get transaction item.

Parameters
recordT* reference record for update
transTransactionT* transaction to handle
upsertbool upsert if true
Returns
bool true if added

§ AddTrans()

template<class T>
void identt::store::StoreTable< T >::AddTrans ( TransactionT *  trans,
std::string  key,
std::string &  value,
bool  to_del 
)
inline

AddTrans : add transactions.

Parameters
transTransactionT* transaction to handle
keystd::string key to populate
valuestd::string& key to populate
to_delbool to delete

§ DelRecord()

template<class T>
bool identt::store::StoreTable< T >::DelRecord ( T *  record,
TransactionT *  trans 
)
inline

DelRecord : get delete transaction item.

Parameters
recordT* reference record for update
transTransactionT* transaction to handle
Returns
bool true if deleted

§ GetKey()

template<class T>
virtual std::string identt::store::StoreTable< T >::GetKey ( T *  record,
KeyTypeE  keytype,
bool  pre 
)
pure virtual

§ GetKeysFromIndex()

template<class T>
bool identt::store::StoreTable< T >::GetKeysFromIndex ( KeyTypeE  keytype,
T *  record,
NodeListT *  nodes,
size_t  skip,
size_t  limit 
)
inline

GetKeysFromIndex : get primary keys from secondary.

Parameters
keytypeKeyTypeE key type for index
recordT* reference record for keys
nodesNodeListT* node list to fetch
skipsize_t records to skip
limitsize_t records to fetch
Returns
bool true if found

§ GetMany()

template<class T>
bool identt::store::StoreTable< T >::GetMany ( T *  refer,
MapT *  records,
KeyTypeE  keytype,
size_t  skip,
size_t  limit 
)
inline

GetMany: get all values by non unique key.

Parameters
referT* reference record for keys
recordmap MapT* records
keytypeKeyTypeE key type for index
skipsize_t records to skip
limitsize_t records to fetch
Returns
bool if found

§ GetOne()

template<class T>
bool identt::store::StoreTable< T >::GetOne ( T *  record,
KeyTypeE  keytype 
)
inline

GetOne: get a record by primary or unique key.

Parameters
recordT* record
keytypeKeyTypeE key type for index
Returns
bool if found

§ GetSecondaryValue()

template<class T>
bool identt::store::StoreTable< T >::GetSecondaryValue ( T *  record,
KeyTypeE  keytype,
NodeT *  node 
)
inline

GetSecondaryValue: get a secondary key value.

Parameters
recordT* record
keytypeKeyTypeE key type for index
nodeNodeT* node to populate
Returns
bool if exists

§ ScanTable()

template<class T>
void identt::store::StoreTable< T >::ScanTable ( uint64_t  startid,
size_t  limit,
std::function< void(T *)>  Func 
)
inline

ScanTable : scan by primary key.

Parameters
fieldnameconst char* field name
startidsize_t first id to fetch
limitsize_t records to fetch
Funcstd::function<void(T*)> function to act on each record
Returns
none

The documentation for this class was generated from the following file: