Class RelationSnapshot

java.lang.Object
org.impulsegraph.storage.csr.RelationSnapshot
All Implemented Interfaces:
AutoCloseable, RelationSnapshot

public class RelationSnapshot extends Object implements RelationSnapshot, AutoCloseable
High-performance off-heap CSR relation snapshot container holding edge targets for a single relation. Backed by Java 25 Foreign Function and Memory (FFM) Arena and off-heap MemorySegments.
  • Constructor Details

  • Method Details

    • setAttributeNames

      public void setAttributeNames(List<String> names)
    • setAttributeTypeCodes

      public void setAttributeTypeCodes(List<Byte> typeCodes)
    • getAttributeName

      public String getAttributeName(int index)
    • getAttributeTypeCode

      public byte getAttributeTypeCode(int index)
    • setTargetNodeCount

      public void setTargetNodeCount(int targetNodeCount)
    • getTargetNodeCount

      public int getTargetNodeCount()
    • setCatalogMetadata

      public void setCatalogMetadata(int relationId, int srcDomainId, int tgtDomainId, byte encodingId, long sectionFeatures, int[] componentIds)
    • setLoadedAttributes

      public void setLoadedAttributes(List<BinarySnapshotLoader.LoadedAttribute> attrs, List<MemorySegment> attrOffsets)
    • getLoadedAttributes

      public List<BinarySnapshotLoader.LoadedAttribute> getLoadedAttributes()
    • getOffsetsSegments

      public List<MemorySegment> getOffsetsSegments()
    • getComponentIds

      public int[] getComponentIds()
    • setComponentRelations

      public void setComponentRelations(RelationSnapshot[] componentRelations)
    • getComponentRelations

      public RelationSnapshot[] getComponentRelations()
    • getRelationId

      public int getRelationId()
      Specified by:
      getRelationId in interface RelationSnapshot
    • getSrcDomainId

      public int getSrcDomainId()
      Specified by:
      getSrcDomainId in interface RelationSnapshot
    • getTgtDomainId

      public int getTgtDomainId()
      Specified by:
      getTgtDomainId in interface RelationSnapshot
    • getEncodingId

      public byte getEncodingId()
    • getSectionFeatures

      public long getSectionFeatures()
    • isVirtual

      public boolean isVirtual()
      Specified by:
      isVirtual in interface RelationSnapshot
    • isFlatForward

      public boolean isFlatForward()
    • isFlatReverse

      public boolean isFlatReverse()
    • isSentinelNodeId

      public static boolean isSentinelNodeId(int rawId, byte widthBytes)
    • getCscNodeCount

      public int getCscNodeCount()
      Specified by:
      getCscNodeCount in interface RelationSnapshot
    • findAttributeIndex

      public int findAttributeIndex(String name)
    • getSrcNodeIdWidth

      public byte getSrcNodeIdWidth()
      Specified by:
      getSrcNodeIdWidth in interface RelationSnapshot
    • getNodeIdWidth

      public byte getNodeIdWidth()
      Specified by:
      getNodeIdWidth in interface RelationSnapshot
    • getEdgeIndexWidth

      public byte getEdgeIndexWidth()
      Specified by:
      getEdgeIndexWidth in interface RelationSnapshot
    • setCscSegments

      public void setCscSegments(MemorySegment rowOffsets, MemorySegment columnTargets)
      Specified by:
      setCscSegments in interface RelationSnapshot
    • hasCsc

      public boolean hasCsc()
      Specified by:
      hasCsc in interface RelationSnapshot
    • getCscRowOffsetsSegment

      public MemorySegment getCscRowOffsetsSegment()
      Specified by:
      getCscRowOffsetsSegment in interface RelationSnapshot
    • getCscColumnTargetsSegment

      public MemorySegment getCscColumnTargetsSegment()
      Specified by:
      getCscColumnTargetsSegment in interface RelationSnapshot
    • hasCsr

      public boolean hasCsr()
      Specified by:
      hasCsr in interface RelationSnapshot
    • injectMetadata

      public void injectMetadata(String metadataJson)
    • getStatistics

      public RelationStatistics getStatistics()
      Specified by:
      getStatistics in interface RelationSnapshot
    • getAttributeSegments

      public List<MemorySegment> getAttributeSegments()
      Specified by:
      getAttributeSegments in interface RelationSnapshot
    • getValiditySegments

      public List<MemorySegment> getValiditySegments()
    • getNodeCount

      public int getNodeCount()
      Specified by:
      getNodeCount in interface RelationSnapshot
    • getEdgeCount

      public long getEdgeCount()
      Specified by:
      getEdgeCount in interface RelationSnapshot
    • readEdgeIndex

      public long readEdgeIndex(MemorySegment segment, long nodeId)
      Specified by:
      readEdgeIndex in interface RelationSnapshot
    • readNodeId

      public int readNodeId(MemorySegment segment, long index)
      Specified by:
      readNodeId in interface RelationSnapshot
    • readSrcNodeId

      public int readSrcNodeId(MemorySegment segment, long index)
      Specified by:
      readSrcNodeId in interface RelationSnapshot
    • readNodeId

      public static int readNodeId(MemorySegment segment, long index, byte width)
    • getRowOffsets

      public int[] getRowOffsets()
    • getColumnIndices

      public int[] getColumnIndices()
    • getRowOffsetsSegment

      public MemorySegment getRowOffsetsSegment()
      Specified by:
      getRowOffsetsSegment in interface RelationSnapshot
    • getColumnTargetsSegment

      public MemorySegment getColumnTargetsSegment()
      Specified by:
      getColumnTargetsSegment in interface RelationSnapshot
    • getDegree

      public int getDegree(int nodeId)
      Gets the out-degree for a specific node ID zero-copy directly from off-heap memory.
      Specified by:
      getDegree in interface RelationSnapshot
    • getFlatForwardTarget

      public int getFlatForwardTarget(int nodeId)
      Zero-allocation read of the single outgoing target for Flat (1:1 / N:1) relations, returning -1 when unbound/sentinel/out-of-range.
    • getFlatReverseSource

      public int getFlatReverseSource(int nodeId)
      Zero-allocation read of the single incoming source for Flat Reverse (1:1 / 1:N) relations, returning -1 when unbound/sentinel/out-of-range.
    • getTargetAt

      public int getTargetAt(int nodeId, int index)
      Specified by:
      getTargetAt in interface RelationSnapshot
    • getTargets

      public int[] getTargets(int nodeId)
      Returns the array slice of target node IDs for a specific source node ID zero-copy from off-heap memory.
      Specified by:
      getTargets in interface RelationSnapshot
    • getInDegree

      public int getInDegree(int nodeId)
      Gets the in-degree for a specific destination node ID zero-copy directly from off-heap memory.
      Specified by:
      getInDegree in interface RelationSnapshot
    • getInTargets

      public int[] getInTargets(int nodeId)
      Returns the array slice of incoming source node IDs for a specific destination node ID zero-copy from off-heap memory.
      Specified by:
      getInTargets in interface RelationSnapshot
    • copyTargetsSimd

      public void copyTargetsSimd(int nodeId, ImpulseBitSet outBs)
      SIMD vectorized target node traversal into a destination ImpulseBitSet. Uses Java 25 Vector API (AVX-512 / AVX2 / ARM Neon) to load vector tiles of target IDs directly off-heap.
      Specified by:
      copyTargetsSimd in interface RelationSnapshot
    • copyTargetsSimdFilteredFloat

      public void copyTargetsSimdFilteredFloat(int nodeId, MemorySegment attrSegment, float threshold, byte cmpOp, ImpulseBitSet outBs)
      SIMD Vector API fused edge attribute predicate filter during CSR traversal. When count >= OptimizerConfig.SIMD_PREDICATE_EVAL_MIN_DEGREE_THRESHOLD (64), loads 512-bit vector tiles of edge attribute values, compares using SIMD masks, and streams matching column targets directly into outBs.
      Specified by:
      copyTargetsSimdFilteredFloat in interface RelationSnapshot
    • copyInTargetsSimd

      public void copyInTargetsSimd(int nodeId, ImpulseBitSet outBs)
      SIMD vectorized incoming target node traversal into a destination ImpulseBitSet zero-allocation.
      Specified by:
      copyInTargetsSimd in interface RelationSnapshot
    • getOrBuildCscToCsrEdgeMap

      public int[] getOrBuildCscToCsrEdgeMap()
      Lazily builds an exact bijection from CSC slot k (0..edgeCount-1) to CSR edge index e (0..edgeCount-1), preserving parallel multi-edge attribute alignment.
    • getOrBuildFlatForwardEdgeMap

      public int[] getOrBuildFlatForwardEdgeMap()
    • findCsrEdgeIndex

      public int findCsrEdgeIndex(int srcU, int dstV)
    • getMemoryFootprintBytes

      public long getMemoryFootprintBytes()
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable