Package ai.platon.pulsar.dom.features
Class FeatureBlock
-
- All Implemented Interfaces:
public final class FeatureBlockA contiguous memory block storing numerical feature vectors for all nodes in a FeaturedDocument.
Instead of allocating a separate double array per node (as org.apache.commons.math3.linear.ArrayRealVector does), this class stores all node feature vectors in a single DoubleArray, indexed by
nodeIndex * dimension + featureKey.Benefits:
Single allocation per document instead of N allocations per node
Contiguous memory improves cache locality
Reduced GC pressure from fewer heap objects
-
-
Constructor Summary
Constructors Constructor Description FeatureBlock(Integer nodeCount, Integer dimension)
-
Method Summary
Modifier and Type Method Description final IntegergetNodeCount()final IntegergetDimension()final Doubleget(Integer nodeIndex, Integer featureKey)Get a feature value for a node. final Unitset(Integer nodeIndex, Integer featureKey, Double value)Set a feature value for a node. final FeatureBlockVectorrowVector(Integer nodeIndex)Create a lightweight RealVector view for a specific node, backed by this block. -
-
Method Detail
-
getNodeCount
final Integer getNodeCount()
-
getDimension
final Integer getDimension()
-
get
final Double get(Integer nodeIndex, Integer featureKey)
Get a feature value for a node.
- Parameters:
nodeIndex- The node's index in the document (0-based)featureKey- The feature key (0-based index into the feature vector)- Returns:
The feature value
-
set
final Unit set(Integer nodeIndex, Integer featureKey, Double value)
Set a feature value for a node.
- Parameters:
nodeIndex- The node's index in the document (0-based)featureKey- The feature key (0-based index into the feature vector)value- The feature value to set
-
rowVector
final FeatureBlockVector rowVector(Integer nodeIndex)
Create a lightweight RealVector view for a specific node, backed by this block.
- Parameters:
nodeIndex- The node's index in the document (0-based)- Returns:
A FeatureBlockVector that delegates get/set operations to this block
-
-
-
-