public class SearchableClassConstraintBuilder<T extends PersistingElement> extends ClassConstraintBuilder<T>
| Constructor and Description |
|---|
SearchableClassConstraintBuilder(Class<T> clazz) |
| Modifier and Type | Method and Description |
|---|---|
SearchableClassConstraintBuilder<T> |
andActivate(String... families)
Requests for some more family activations while executing the query, in addition to simple properties and families marked as
ImplicitActivation. |
SearchableClassConstraintBuilder<T> |
andActivateAllFamilies()
Activate all known families for this class (see
ConstraintBuilder.ofClass(Class)). |
SearchableKeyConstraintBuilder<T> |
andWithKey(String key) |
T |
any()
Runs the query to find an element matching the query.
|
long |
count()
Runs the query to find the number of matching elements.
|
KeyConstraintBuilder<T> |
createKeyBuilder(Field f) |
long |
exportTo(ObjectOutputStream out)
Runs the query to find at most N matching elements and serialize a representation into the output stream.
|
long |
exportTo(String file)
Runs the query to find at most N matching elements and serialize a representation into the output stream.
|
Process.ProcessReport<T> |
forEach(Process<T> action)
Performs an action for each element corresponding to the query.
|
Process.ProcessReport<T> |
forEach(Process<T> action,
int threadNumber,
long timeoutMs)
Performs an action for each element corresponding to the query using parallel threads.
|
Process.ProcessReport<T> |
forEach(Process<T> action,
int threadNumber,
long timeoutMs,
ExecutorService executor)
Performs an action for each element corresponding to the query using parallel threads ; method might return before process is ended.
|
Process.ProcessReport<T> |
forEach(Process<T> action,
int threadNumber,
ProcessCanceller canceller)
Performs an action for each element corresponding to the query using parallel threads.
|
Process.ProcessReport<T> |
forEach(Process<T> action,
int threadNumber,
ProcessCanceller canceller,
ExecutorService executor)
Performs an action for each element corresponding to the query using parallel threads ; method might return before process is ended.
|
Class<T> |
getClazz() |
Constraint |
getConstraint() |
String |
getTablePostfix() |
NavigableSet<T> |
go()
Runs the query to find at most N matching elements.
|
boolean |
hasNoLimit()
Returns whether a limit was set for this query.
|
SearchableClassConstraintBuilder<T> |
inTableWithPostfix(String tablePostfix)
Sets the table to look for.
|
CloseableIterator<T> |
iterate()
Runs the query to find at most N matching elements.
|
void |
remoteForEach(Process<T> action,
Callback callBack,
int threadNumber,
long timeout)
Performs asynchronously an action for each element corresponding to the query.
|
LimitConstraintBuilder<T> |
withAtMost(int limit) |
T |
withId(String id)
Finds the element with the given id.
|
SearchableKeyConstraintBuilder<T> |
withKey(String key) |
withKeyIntpublic boolean hasNoLimit()
public String getTablePostfix()
public KeyConstraintBuilder<T> createKeyBuilder(Field f)
createKeyBuilder in class ClassConstraintBuilder<T extends PersistingElement>public LimitConstraintBuilder<T> withAtMost(int limit)
public SearchableClassConstraintBuilder<T> inTableWithPostfix(String tablePostfix)
federated
table. Element is thus searched from only one sigle table, whose name is
the original table, postfixed by the given parameter.tablePostfix - the table to look for has to have the given postfix (can be ""
for original table)IllegalArgumentException - in case this class is not over a
federated tableIllegalArgumentException - in case this table cannot be part of the federation for
searched class (i.e.
it does not starts with original table name)IllegalArgumentException - in case a different table was already set in the querypublic Constraint getConstraint()
getConstraint in class ClassConstraintBuilder<T extends PersistingElement>public SearchableClassConstraintBuilder<T> andActivate(String... families)
ImplicitActivation.public SearchableClassConstraintBuilder<T> andActivateAllFamilies()
ConstraintBuilder.ofClass(Class)).
Please note that only column families for this class (or inherited)
are activated, and not families for subclasses, even if found elements are instance of a subclass for this class.
This remark does not hold for properties, which are all
activated, regardless of the fact they are declared in this class or in a subclass.public T withId(String id) throws DatabaseNotReachedException
withAtMost(int) will be ignored.
Specified column families are activated if not already (i.e. this element is already known by this thread) (see PersistingElement.activateIfNotAlready(String...)) ; you should rather perform an PersistingElement.activate(String...) without specifying any column family with andActivate(String...) to force activation.id - non printable character stringDatabaseNotReachedExceptionpublic NavigableSet<T> go() throws DatabaseNotReachedException
withAtMost(int).
Elements activated (see andActivate(String...)), and their keys are all loaded into memory.DatabaseNotReachedExceptionpublic CloseableIterator<T> iterate() throws DatabaseNotReachedException
withAtMost(int).
Elements activated (see andActivate(String...)). Instead of this function, you should consider using forEach(Process).DatabaseNotReachedExceptionpublic T any() throws DatabaseNotReachedException
withAtMost(int) will be ignored (as it is considered to be 1).
The element is activated according to declared column families (see andActivate(String...)).DatabaseNotReachedExceptionpublic long count()
throws DatabaseNotReachedException
withAtMost(int) will be ignored.DatabaseNotReachedExceptionpublic SearchableKeyConstraintBuilder<T> withKey(String key)
public SearchableKeyConstraintBuilder<T> andWithKey(String key)
public Process.ProcessReport<T> forEach(Process<T> action) throws DatabaseNotReachedException, InterruptedException, ProcessException
withAtMost(int).action - the action to be performed over each element of the query.DatabaseNotReachedExceptionInterruptedException - in case threads are interrupted or timeout is reachedProcessException - in case some process sent an exception while runningpublic Process.ProcessReport<T> forEach(Process<T> action, int threadNumber, long timeoutMs) throws DatabaseNotReachedException, InterruptedException, ProcessException
withAtMost(int).
Invoking this method is blocking until execution is completed.PersistingElement.activate(String...) elements stored in the process to see changes.action - the action to be performed over each element of the query.threadNumber - the maximum number of concurrent threadstimeoutMs - the max allowed time to execute this task ; useless in case threadNumber is 1DatabaseNotReachedExceptionInterruptedException - in case threads are interrupted or timeout is reachedProcessException - in case some process sent an exception while runningpublic Process.ProcessReport<T> forEach(Process<T> action, int threadNumber, ProcessCanceller canceller) throws DatabaseNotReachedException, InterruptedException, ProcessException
withAtMost(int).
Invoking this method is blocking until execution is completed.PersistingElement.activate(String...) elements stored in the process to see changes.action - the action to be performed over each element of the query.threadNumber - the maximum number of concurrent threadscanceller - a canceller object regularly observed while performing request ; in case this object responds false after invoked ProcessCanceller.isCancelled(), this methods returns a ProcessException with message found by ProcessCanceller.getErrorMessage(Process)DatabaseNotReachedExceptionInterruptedException - in case threads are interrupted or canceler responds false to ProcessCanceller.isCancelled()ProcessException - in case some process sent an exception while runningpublic Process.ProcessReport<T> forEach(Process<T> action, int threadNumber, long timeoutMs, ExecutorService executor) throws DatabaseNotReachedException, InterruptedException, ProcessException
withAtMost(int).
Invoking this method can be blocking as long as threadNumber is less that the number of elements to be treated.PersistingElement.activate(String...) elements stored in the process to see changes.action - the action to be performed over each element of the query.threadNumber - the maximum number of concurrent threadstimeoutMs - the max allowed time to execute this task ; useless in case threadNumber is 1executor - the executor to run process ; you need to call ExecutorService.awaitTermination(long, java.util.concurrent.TimeUnit) to be sure that all elements are processed ; if null, this method is equivalent to forEach(Process, int, long)DatabaseNotReachedExceptionInterruptedException - in case threads are interrupted or timeout is reachedProcessException - in case some process sent an exception while runningpublic Process.ProcessReport<T> forEach(Process<T> action, int threadNumber, ProcessCanceller canceller, ExecutorService executor) throws DatabaseNotReachedException, InterruptedException, ProcessException
withAtMost(int).
Invoking this method can be blocking as long as threadNumber is less that the number of elements to be treated.PersistingElement.activate(String...) elements stored in the process to see changes.action - the action to be performed over each element of the query.threadNumber - the maximum number of concurrent threadscanceller - a canceller object regularly observed while performing request ; in case this object responds false after invoked ProcessCanceller.isCancelled(), this methods returns a ProcessException with message found by ProcessCanceller.getErrorMessage(Process)executor - the executor to run process ; you need to call ExecutorService.awaitTermination(long, java.util.concurrent.TimeUnit) to be sure that all elements are processed ; if null, this method is equivalent to forEach(Process, int, long)DatabaseNotReachedExceptionInterruptedException - in case threads are interrupted or canceler responds false to ProcessCanceller.isCancelled()ProcessException - in case some process sent an exception while runningpublic void remoteForEach(Process<T> action, Callback callBack, int threadNumber, long timeout) throws DatabaseNotReachedException, InstantiationException, IllegalAccessException
ActionnableStore, this action is equivalent to an asynchronous call to forEach(Process), and the maximum limit N must be set before using withAtMost(int).
Otherwise, the action is performed directly using the data store server process, and the limit is useless.
In order to wait for process completion, you can use WaitingCallBack.action - class of the action to be performed over each element of the query ; must have a default constructorcallBack - a callback to be invoked as soon as the process completes ; can be nulltimeout - in case store does not support ActionnableStoreDatabaseNotReachedExceptionIllegalAccessExceptionInstantiationExceptionpublic long exportTo(ObjectOutputStream out) throws IOException, DatabaseNotReachedException
withAtMost(int), but is not mandatory.
Dependencies are not serialized. Consider carefully setting families to be activated before ; it is advised to use andActivateAllFamilies().
Implementation tries to optimize as much as possible memory impact.out - an output stream that must support InputStream.markSupported() ; note that only one ObjectOutputStream must be created for a given OutputStreamIOExceptionDatabaseNotReachedExceptionpublic long exportTo(String file) throws IOException, DatabaseNotReachedException
withAtMost(int), but is not mandatory.
Dependencies are not serialized. Consider carefully setting families to be activated before ; it is advised to use andActivateAllFamilies().
Implementation tries to optimize as much as possible memory impact.file - the file where elements are to be stored ; overwritten if existsIOExceptionDatabaseNotReachedExceptionCopyright © 2016. All Rights Reserved.