Package ai.preferred.cerebro.index.store
Class Container<T>
- java.lang.Object
-
- ai.preferred.cerebro.index.store.Container<T>
-
- Type Parameters:
T
- Type of object to be scored and retrieved.
- All Implemented Interfaces:
java.lang.Iterable<T>
- Direct Known Subclasses:
DocArray
public abstract class Container<T> extends java.lang.Object implements java.lang.Iterable<T>
Base class to contain, rank and retrieve top K objects based on their score. This implementation use a modified version of the Quickselect algorithm.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
add(T element)
abstract void
calculateScore(T target)
void
clear()
Removes all entries from the Container.T
get(int index)
protected java.lang.Object[]
getArray()
T
insertWithOverflow(T element)
java.util.Iterator<T>
iterator()
protected abstract boolean
lessThan(T a, T b)
protected void
orderStatistic(int start, int end, int i)
protected int
partition(int start, int end)
protected int
pivotScheme(int start, int end)
T
pop()
void
pullTopK(int k, boolean ordered, boolean trim)
protected void
quicksort(int start, int end)
boolean
remove(T element)
int
size()
Returns the number of elements currently stored in the Container.protected void
swap(int a, int b)
T
top()
-
-
-
Field Detail
-
arr
protected T[] arr
-
-
Method Detail
-
calculateScore
public abstract void calculateScore(T target)
-
add
public final void add(T element)
-
get
public final T get(int index)
-
top
public final T top()
-
pop
public final T pop()
-
size
public final int size()
Returns the number of elements currently stored in the Container.
-
clear
public final void clear()
Removes all entries from the Container.
-
remove
public final boolean remove(T element)
-
pullTopK
public void pullTopK(int k, boolean ordered, boolean trim)
-
quicksort
protected void quicksort(int start, int end)
-
orderStatistic
protected void orderStatistic(int start, int end, int i)
-
pivotScheme
protected int pivotScheme(int start, int end)
-
partition
protected int partition(int start, int end)
-
swap
protected void swap(int a, int b)
-
getArray
protected final java.lang.Object[] getArray()
-
-