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 FeatureVectorspublic <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 FeatureVectorsitem - ID to get feature vector fornull if doesn't existpublic void setVector(String item, float[] vector)
FeatureVectorsFeatureVectors.retainRecentAndIDs(Collection) call.setVector in interface FeatureVectorsitem - ID to set feature vector forvector - new feature vectorpublic void addAllIDsTo(Collection<String> allIDs)
FeatureVectorsaddAllIDsTo in interface FeatureVectorsallIDs - collection to add IDs topublic void removeAllIDsFrom(Collection<String> allIDs)
FeatureVectorsremoveAllIDsFrom in interface FeatureVectorsallIDs - collection to add IDs topublic void addAllRecentTo(Collection<String> allRecent)
FeatureVectorsaddAllRecentTo in interface FeatureVectorsallRecent - collection to add IDs topublic void retainRecentAndIDs(Collection<String> newModelIDs)
FeatureVectorsretainRecentAndIDs in interface FeatureVectorsnewModelIDs - new model IDspublic double[] getVTV(boolean background)
getVTV in interface FeatureVectorsbackground - 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.