public final class PartitionedFeatureVectors extends Object implements FeatureVectors
ALSServingModel
or ALSSpeedModel
. This represents many partition of vectors; see FeatureVectorsPartition
for a representation of one partition.Constructor and Description |
---|
PartitionedFeatureVectors(int numPartitions,
ExecutorService executor) |
PartitionedFeatureVectors(int numPartitions,
ExecutorService executor,
ToIntBiFunction<String,float[]> partitioner) |
Modifier and Type | Method and Description |
---|---|
void |
addAllIDsTo(Collection<String> allIDs)
Adds all IDs that are mapped to a feature vector to a given collection
|
void |
addAllRecentTo(Collection<String> allRecent)
Add all recently set IDs to the given collection
|
float[] |
getVector(String item) |
double[] |
getVTV(boolean background) |
<T> Stream<T> |
mapPartitionsParallel(Function<FeatureVectorsPartition,Stream<T>> fn,
boolean background) |
<T> Stream<T> |
mapPartitionsParallel(Function<FeatureVectorsPartition,Stream<T>> fn,
int[] candidateIndices,
boolean background) |
void |
removeAllIDsFrom(Collection<String> allIDs)
Removes all IDs that are mapped to a feature vector from a given collection
|
void |
retainRecentAndIDs(Collection<String> newModelIDs)
Given IDs that are part of a new model, and whose values are going to be sent later,
retain only IDs that are also in the new model (or have been recently seen -- possibly since
last model was built), and remove the rest.
|
void |
setVector(String item,
float[] vector)
Sets the value of a feature vector for an ID.
|
int |
size() |
String |
toString() |
public PartitionedFeatureVectors(int numPartitions, ExecutorService executor)
public PartitionedFeatureVectors(int numPartitions, ExecutorService executor, ToIntBiFunction<String,float[]> partitioner)
public int size()
size
in interface FeatureVectors
public <T> Stream<T> mapPartitionsParallel(Function<FeatureVectorsPartition,Stream<T>> fn, boolean background)
public <T> Stream<T> mapPartitionsParallel(Function<FeatureVectorsPartition,Stream<T>> fn, int[] candidateIndices, boolean background)
public float[] getVector(String item)
getVector
in interface FeatureVectors
item
- ID to get feature vector fornull
if doesn't existpublic void setVector(String item, float[] vector)
FeatureVectors
FeatureVectors.retainRecentAndIDs(Collection)
call.setVector
in interface FeatureVectors
item
- ID to set feature vector forvector
- new feature vectorpublic void addAllIDsTo(Collection<String> allIDs)
FeatureVectors
addAllIDsTo
in interface FeatureVectors
allIDs
- collection to add IDs topublic void removeAllIDsFrom(Collection<String> allIDs)
FeatureVectors
removeAllIDsFrom
in interface FeatureVectors
allIDs
- collection to add IDs topublic void addAllRecentTo(Collection<String> allRecent)
FeatureVectors
addAllRecentTo
in interface FeatureVectors
allRecent
- collection to add IDs topublic void retainRecentAndIDs(Collection<String> newModelIDs)
FeatureVectors
retainRecentAndIDs
in interface FeatureVectors
newModelIDs
- new model IDspublic double[] getVTV(boolean background)
getVTV
in interface FeatureVectors
background
- if true, a hint that this potentially expensive computation may be
deprioritized and need not use all available resources to computeCopyright © 2014–2018. All rights reserved.