Class FeatureBlock

  • All Implemented Interfaces:

    
    public final class FeatureBlock
    
                        

    A 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

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Constructor Detail

      • FeatureBlock

        FeatureBlock(Integer nodeCount, Integer dimension)
        Parameters:
        nodeCount - The total number of nodes in the document
        dimension - The number of features per node (e.g.
    • Method Detail

      • 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