public class MemRepository extends DBSRepositoryBase
Repository
.
Internally, the repository is a map from id to document object.
A document object is a JSON-like document stored as a Map recursively containing the data, see DBSDocument
for the description of the document.
DBSRepositoryBase.DBSSessionInvoker, DBSRepositoryBase.TransactionContext
transactionContexts, TYPE_ROOT
Constructor and Description |
---|
MemRepository(String repositoryName) |
Modifier and Type | Method and Description |
---|---|
static Serializable |
applyDiff(Serializable value,
State.ListDiff listDiff)
Applies a
State.ListDiff onto an array or List , and returns the resulting value. |
static void |
applyDiff(State state,
State.StateDiff stateDiff)
Applies a
State.StateDiff in-place onto a base State . |
void |
createState(State state)
Creates a document.
|
void |
deleteStates(Set<String> ids)
Deletes a set of document.
|
String |
generateNewId()
Generates a new id for a document.
|
boolean |
hasChild(String parentId,
String name,
Set<String> ignored)
Checks if a document has a child with the given name
|
PartialList<State> |
queryAndFetch(Expression expression,
DBSExpressionEvaluator evaluator,
OrderByClause orderByClause,
int limit,
int offset,
int countUpTo,
boolean deepCopy,
boolean fulltextScore)
Queries the repository for documents matching a query.
|
List<State> |
queryKeyValue(String key,
String value,
Set<String> ignored)
Queries the repository for documents having key = value.
|
void |
queryKeyValueArray(String key,
Object value,
Set<String> ids,
Map<String,String> proxyTargets,
Map<String,Object[]> targetProxies)
Queries the repository for document ids having value in key (an array).
|
boolean |
queryKeyValuePresence(String key,
String value,
Set<String> ignored)
Queries the repository to check if there are documents having key = value.
|
State |
readChildState(String parentId,
String name,
Set<String> ignored)
Reads the state of a child document.
|
State |
readState(String id)
Reads the state of a document.
|
List<State> |
readStates(List<String> ids)
Reads the states of several documents.
|
void |
shutdown() |
void |
updateState(String id,
State.StateDiff diff)
Updates a document.
|
getActiveSessionsCount, getBlobManager, getName, getRootId, getSession, initRoot, isFulltextDisabled, newBinaryManager
public MemRepository(String repositoryName)
public void shutdown()
shutdown
in interface Repository
shutdown
in class DBSRepositoryBase
public String generateNewId()
DBSRepository
public State readState(String id)
DBSRepository
id
- the document idnull
if not foundpublic List<State> readStates(List<String> ids)
DBSRepository
The returned states may be in a different order than the ids.
ids
- the document idsnull
if not foundpublic void createState(State state) throws DocumentException
DBSRepository
state
- the document stateDocumentException
- if the document already existspublic void updateState(String id, State.StateDiff diff) throws DocumentException
DBSRepository
id
- the document iddiff
- the diff to applyDocumentException
- if the document does not existpublic void deleteStates(Set<String> ids) throws DocumentException
DBSRepository
ids
- the document idsDocumentException
public State readChildState(String parentId, String name, Set<String> ignored)
DBSRepository
parentId
- the parent document idname
- the name of the childignored
- a set of document ids that should not be considerednull
if not foundpublic boolean hasChild(String parentId, String name, Set<String> ignored)
DBSRepository
parentId
- the parent document idname
- the name of the childignored
- a set of document ids that should not be consideredtrue
if the child exists, false
if notpublic List<State> queryKeyValue(String key, String value, Set<String> ignored)
DBSRepository
key
- the keyvalue
- the valueignored
- a set of document ids that should not be consideredpublic void queryKeyValueArray(String key, Object value, Set<String> ids, Map<String,String> proxyTargets, Map<String,Object[]> targetProxies)
DBSRepository
key
- the keyvalue
- the valueids
- the set which receives the documents idsproxyTargets
- returns a map of proxy to target among the documents foundtargetProxies
- returns a map of target to proxies among the document foundpublic boolean queryKeyValuePresence(String key, String value, Set<String> ignored)
DBSRepository
key
- the keyvalue
- the valueignored
- a set of document ids that should not be consideredtrue
if the query matches at least one document, false
if the query matches nothingpublic PartialList<State> queryAndFetch(Expression expression, DBSExpressionEvaluator evaluator, OrderByClause orderByClause, int limit, int offset, int countUpTo, boolean deepCopy, boolean fulltextScore)
DBSRepository
expression
- the query expressionevaluator
- the map-based evaluator for the queryorderByClause
- an ORDER BY clauselimit
- the limit on the number of documents to returnoffset
- the offset in the list of documents to returncountUpTo
- if -1
, count the total size without offset/limit.0
, don't count the total size, set it to -1
.n
, count the total number if there are less than n documents otherwise set the total size
to -2
.deepCopy
- whether returned state should be a copyfulltextScore
- whether returned state should include the fulltext scorepublic static void applyDiff(State state, State.StateDiff stateDiff)
public static Serializable applyDiff(Serializable value, State.ListDiff listDiff)
State.ListDiff
onto an array or List
, and returns the resulting value.
Uses thread-safe datastructures.
Copyright © 2015 Nuxeo SA. All rights reserved.