public final class FeatureVectorsPartition extends Object implements FeatureVectors
ALSServingModel
or ALSSpeedModel
. This represents one partition of vectors; see PartitionedFeatureVectors
for a representation of many partitions.Constructor and Description |
---|
FeatureVectorsPartition() |
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
|
void |
forEach(BiConsumer<String,float[]> action) |
float[] |
getVector(String id) |
double[] |
getVTV(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 id,
float[] vector)
Sets the value of a feature vector for an ID.
|
int |
size() |
String |
toString() |
public int size()
size
in interface FeatureVectors
public float[] getVector(String id)
getVector
in interface FeatureVectors
id
- ID to get feature vector fornull
if doesn't existpublic void setVector(String id, float[] vector)
FeatureVectors
FeatureVectors.retainRecentAndIDs(Collection)
call.setVector
in interface FeatureVectors
id
- 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 void forEach(BiConsumer<String,float[]> action)
action
- function to apply to every ID/vector pairpublic 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.