T
- Unguarded form of the descriptorspublic final class UnguardedPagedOverlap<T extends Serializable> extends Object implements Serializable
This class is an immutable similarity query engine implementation. The query works on unguarded descriptors for storage and computational efficiency.
Licensing: this class can be used with valid LicenseGlobals.MADFAST
license.
Modifier and Type | Field and Description |
---|---|
static int |
MAX_QUEUE_SIZE
Max queue size to avoid filling up the completion queue.
|
Constructor and Description |
---|
UnguardedPagedOverlap(Function<D,T> extractor,
UnguardedDissimilarityCalculator<T> comparator,
List<ImmutableList<D>> pages,
List<D> page)
Construct new immutable reference from pages of
Descriptor instances. |
UnguardedPagedOverlap(UnguardedDissimilarityCalculator<T> comparator,
ImmutableList<ImmutableList<T>> pages)
Construct new immutable reference from prepared storage.
|
UnguardedPagedOverlap(UnguardedDissimilarityCalculator<T> comparator,
ImmutableList<ImmutableList<T>> pages,
int size)
|
UnguardedPagedOverlap(UnguardedDissimilarityCalculator<T> comparator,
UnguardedPagedStorage<T> storage)
Construct new immutable reference from prepared storage.
|
Modifier and Type | Method and Description |
---|---|
LinearHistogram |
calculateDissimilarityDistribution(T query,
double l,
double h,
int bincount,
SubProgressObserver po,
PartialResultConsumer<LinearHistogram> partialResultConsumer,
ExecutorService ex)
Calculate dissimilarity distribution.
|
ImmutableList<double[]> |
calculateFullMatrix(List<T> queries,
SubProgressObserver po,
ExecutorService ex,
boolean managed)
Calculate full dissimilarity matrix.
|
KnnResults |
calculateSelfKnn(int k,
int queriesGroup,
SubProgressObserver po,
ExecutorService ex)
Brute force find kNN among the contents of the represented descriptors.
|
ImmutableList<SimilarityResult> |
findMostSimilar(List<T> queries,
SubProgressObserver po,
ExecutorService ex)
Brute force find most similar structure for a set of structures.
|
KnnResults |
findMostSimilar(UnguardedPagedStorage<T> queries,
int queriesGroup,
SubProgressObserver po,
ExecutorService ex)
Brute force find most similar structure for a set of structures.
|
KnnResults |
findMostSimilarOnSingleThread(List<T> queries,
SubProgressObserver po)
Single threaded reference for multi query most similar lookup.
|
SimilarityResult |
findMostSimilarOnSingleThread(T query,
SubProgressObserver po)
Find most similar for a given query structure.
|
KnnResults |
findMostSimilars(int count,
UnguardedPagedStorage<T> queries,
SubProgressObserver po,
ExecutorService ex)
Brute force find k-most similar structures for a set of queries.
|
ImmutableList<SimilarityResult> |
findMostSimilars(T query,
int count,
ProgressObserver progressObserver,
PartialResultConsumer<List<SimilarityResult>> partialResultConsumer,
ExecutorService executorService)
Find most similar structures for a single query.
|
ImmutableList<ImmutableList<SimilarityResult>> |
findMostSimilarsForMultipleQueries(List<T> queries,
int count,
SubProgressObserver po,
ExecutorService ex)
Find most multiple similar structures for multiple queries.
|
ImmutableList<SimilarityResult> |
findMostSimilarsOnSingleThread(T query,
SubProgressObserver po,
int maxCount)
Find most similars for a given query structure.
|
UnguardedDissimilarityCalculator<T> |
getDissimilarityComparator()
Get represented dissimilarity comparison.
|
UnguardedPagedStorage<T> |
getStorage()
Get represented unguarded storage.
|
UnguardedPagedOverlap<T> |
withComparator(UnguardedDissimilarityCalculator<T> comparator)
Construct another
BruteForcePagedSimilarity instance representing a different comparator. |
public static final int MAX_QUEUE_SIZE
public UnguardedPagedOverlap(UnguardedDissimilarityCalculator<T> comparator, ImmutableList<ImmutableList<T>> pages)
comparator
- Comparator to be usedpages
- List of pagesLicenseException
- when appropriate license is not available@Deprecated public UnguardedPagedOverlap(UnguardedDissimilarityCalculator<T> comparator, ImmutableList<ImmutableList<T>> pages, int size)
UnguardedPagedOverlap(com.chemaxon.descriptors.common.unguarded.UnguardedDissimilarityCalculator, com.google.common.collect.ImmutableList)
comparator
- Comparator to be usedpages
- List of pagessize
- Total number of descriptorsLicenseException
- when appropriate license is not availablepublic UnguardedPagedOverlap(UnguardedDissimilarityCalculator<T> comparator, UnguardedPagedStorage<T> storage)
comparator
- Comparator to be usedstorage
- New storageLicenseException
- when appropriate license is not availablepublic UnguardedPagedOverlap(Function<D,T> extractor, UnguardedDissimilarityCalculator<T> comparator, List<ImmutableList<D>> pages, List<D> page)
Descriptor
instances.D
- Type of descriptors to transformextractor
- Function
to extract unguarded descriptor content for storagecomparator
- Unguarded comparator to be represented by the constructed instancepages
- List of descriptor pages. This parameter can not be null
.page
- Additional descriptor page, considered as last page. Ignored if null
given.LicenseException
- when appropriate license is not availablepublic UnguardedPagedOverlap<T> withComparator(UnguardedDissimilarityCalculator<T> comparator)
BruteForcePagedSimilarity
instance representing a different comparator.
This operation is memory efficient, since page storage is immutable thus reused.
comparator
- Comparator to be usedpublic UnguardedPagedStorage<T> getStorage()
public UnguardedDissimilarityCalculator<T> getDissimilarityComparator()
public ImmutableList<SimilarityResult> findMostSimilars(T query, int count, ProgressObserver progressObserver, PartialResultConsumer<List<SimilarityResult>> partialResultConsumer, ExecutorService executorService)
This method utilizes concurrent execution and blocks until completion. ProgressObserver callback is invoked from the calling thread only.
\query
- Query descriptorcount
- Number of expected most similar structurespartialResultConsumer
- executionMonitoring
- ProgressObserver to track progress. Upon completion ProgressObserver.done()
will be invoked.executorService
- ExecutorService to run workersCancellationException
- when cancelled through supplied progress observerpublic ImmutableList<ImmutableList<SimilarityResult>> findMostSimilarsForMultipleQueries(List<T> queries, int count, SubProgressObserver po, ExecutorService ex)
This method utilizes concurrent execution and blocks until completion. ProgressObserver callback is invoked from the calling thread only.
Note that ProgressObserver.subTask(java.lang.String, long)
is invoked on the supplied
ProgressObserver
.
queries
- Query descriptorscount
- Number of expected most similar structurespo
- ProgressObserver to track progress. Upon completion ProgressObserver.done()
will be invoked.ex
- ExecutorService to run workersCancellationException
- when cancelled through supplied progress observerpublic ImmutableList<double[]> calculateFullMatrix(List<T> queries, SubProgressObserver po, ExecutorService ex, boolean managed)
Calculate full dissimilarity matrix between the represented targets and the given queries. Note that the resulting matrix might have be excessively large size.
The resulting structure is allocated upon startup.
queries
- Query descriptorspo
- ProgressObserver to track progress. Upon completion ProgressObserver.done()
will be invoked.ex
- ExecutorService to run workersmanaged
- if true, use JMX for monitoringi
will contain the dissimilarity vector
for query i
. The dissimilarity vector contains the dissimilarities of targets. *CancellationException
- when cancelled through supplied progress observerIllegalStateException
- possible exceptions due to JMX connection are wrapped to
IllegalStateException
public LinearHistogram calculateDissimilarityDistribution(T query, double l, double h, int bincount, SubProgressObserver po, PartialResultConsumer<LinearHistogram> partialResultConsumer, ExecutorService ex)
query
- Query descriptorl
- Lowest boundh
- Highest boundbincount
- Bun countpo
- ProgressObserver to track progress. Upon completion ProgressObserver.done()
will be invoked.partialResultConsumer
- ex
- ExecutorService to run workerspublic KnnResults calculateSelfKnn(int k, int queriesGroup, SubProgressObserver po, ExecutorService ex) throws ExecutionException
k
- Number of nearest neighbors to findqueriesGroup
- Number of queries to grouppo
- ProgressObserver to track progress.ex
- ExecutorService to run workers. Upon completion ProgressObserver.done()
will be invoked.ExecutionException
- Re-theownpublic KnnResults findMostSimilars(int count, UnguardedPagedStorage<T> queries, SubProgressObserver po, ExecutorService ex)
count
- Most similars count to findqueries
- Query descriptorspo
- ProgressObserver to track progress. Upon completion ProgressObserver.done()
will be invoked.ex
- ExecutorService to run workerspublic KnnResults findMostSimilar(UnguardedPagedStorage<T> queries, int queriesGroup, SubProgressObserver po, ExecutorService ex)
queries
- Query descriptorsqueriesGroup
- Number of queries to grouppo
- ProgressObserver to track progress. Upon completion ProgressObserver.done()
will be invoked.ex
- ExecutorService to run workerspublic ImmutableList<SimilarityResult> findMostSimilar(List<T> queries, SubProgressObserver po, ExecutorService ex)
This method utilizes concurrent execution and blocks until completion. ProgressObserver callback is invoked from the calling thread only.
Note that when the best dissimilarity score is associated for multiple queries one of them is picked. The selection in this case is non deterministic.
queries
- Query descriptors (in the unguarded form)po
- ProgressObserver to track progress. Upon completion ProgressObserver.done()
will be invoked.ex
- ExecutorService to run workersCancellationException
- when cancelled through supplied progress observerpublic KnnResults findMostSimilarOnSingleThread(List<T> queries, SubProgressObserver po) throws CancellationException
queries
- Queries to searchpo
- Observer; will be closed upon finish/abort/error. One work unit is assigned to one comparison.CancellationException
- When cancelled through supplied progress observerpublic SimilarityResult findMostSimilarOnSingleThread(T query, SubProgressObserver po) throws CancellationException
This method is intended only for test/diagnostincs. Users of this API usually need to invoke
findMostSimilar(java.util.List, com.chemaxon.calculations.common.SubProgressObserver, java.util.concurrent.ExecutorService)
instead.
This method blocks until ready and uses a single (the calling) thread to do the calculation.
query
- Query descriptorpo
- Progress observer to track progress. Completion is reported by invoking
ProgressObserver.done()
upon completion, cancellation or errorCancellationException
- upon cancellation through the given progress observerpublic ImmutableList<SimilarityResult> findMostSimilarsOnSingleThread(T query, SubProgressObserver po, int maxCount) throws CancellationException
This method is intended only for test/diagnostincs. Users of this API usually need to invoke
findMostSimilar(java.util.List, com.chemaxon.calculations.common.SubProgressObserver, java.util.concurrent.ExecutorService)
instead.
This method blocks until ready and uses a single (the calling) thread to do the calculation.
query
- Query descriptorpo
- Progress observer to track progress. Completion is reported by invoking
ProgressObserver.done()
upon completion, cancellation or errormaxCount
- Max results countCancellationException
- upon cancellation through the given progress observer