D
- Represented descriptor typepublic class BruteForcePagedSimilarity<D extends Descriptor> extends Object
This class is an immutable similarity query engine implementation. Note that this class operates on
Descriptor
instances. For the most use cases using unguarded representations with class
UnguardedPagedOverlap
is recommended to use.
Licensing: this class can be used with valid LicenseGlobals.MADFAST
license.
Constructor and Description |
---|
BruteForcePagedSimilarity(DescriptorComparator<D> comparator,
List<ImmutableList<D>> pages,
List<D> page)
Construct new immutable reference.
|
Modifier and Type | Method and Description |
---|---|
ImmutableList<SimilarityResult> |
findMostSimilar(List<D> queries,
SubProgressObserver po,
ExecutorService ex)
Brute force find most similar structure for a set of structures.
|
SimilarityResult |
findMostSimilarOnSingleThread(D query,
SubProgressObserver po)
Find most similar for a given query structure.
|
ImmutableList<SimilarityResult> |
findMostSimilarOnSingleThread(List<D> queries,
SubProgressObserver po)
Single threaded reference for multi query most similar lookup.
|
ImmutableList<SimilarityResult> |
findMostSimilarsOnSingleThread(D query,
SubProgressObserver po,
int maxCount)
Find most similars for a given query structure.
|
int |
size()
Total number of descriptors stored.
|
BruteForcePagedSimilarity<D> |
withComparator(DescriptorComparator<D> comparator)
Construct another
BruteForcePagedSimilarity instance representing a different comparator. |
public BruteForcePagedSimilarity(DescriptorComparator<D> comparator, List<ImmutableList<D>> pages, List<D> page)
comparator
- Comparator to be usedpages
- 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 BruteForcePagedSimilarity<D> withComparator(DescriptorComparator<D> comparator)
BruteForcePagedSimilarity
instance representing a different comparator.
This operation is memory efficient, since page storage is immutable thus reusable.
comparator
- Comparator to be usedpublic int size()
public ImmutableList<SimilarityResult> findMostSimilar(List<D> queries, SubProgressObserver po, ExecutorService ex)
This method utilizes concurrent execution and blocks until completion. ProgressObserver callback is invoked from the calling thread only.
queries
- Query descriptorspo
- ProgressObserver to track progressex
- ExecutorService to run workerspublic ImmutableList<SimilarityResult> findMostSimilarOnSingleThread(List<D> 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(D query, SubProgressObserver po) throws CancellationException
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(D query, SubProgressObserver po, int maxCount) throws CancellationException
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