Class RelationSnapshot
java.lang.Object
org.impulsegraph.storage.csr.RelationSnapshot
- All Implemented Interfaces:
AutoCloseable, RelationSnapshot
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.-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionRelationSnapshot(Arena arena, int nodeCount, int edgeCount, int[] rowOffsetsData, int[] columnIndicesData) RelationSnapshot(Arena arena, int nodeCount, int edgeCount, MemorySegment rowOffsetsSegment, MemorySegment columnTargetsSegment) RelationSnapshot(Arena arena, int nodeCount, int edgeCount, MemorySegment rowOffsetsSegment, MemorySegment columnTargetsSegment, MemorySegment cscRowOffsetsSegment, MemorySegment cscColumnTargetsSegment) RelationSnapshot(Arena arena, int nodeCount, int edgeCount, MemorySegment rowOffsetsSegment, MemorySegment columnTargetsSegment, MemorySegment cscRowOffsetsSegment, MemorySegment cscColumnTargetsSegment, List<MemorySegment> attributeSegments, List<MemorySegment> validitySegments, byte nodeIdWidth, byte edgeIndexWidth) RelationSnapshot(Arena arena, int nodeCount, int edgeCount, MemorySegment rowOffsetsSegment, MemorySegment columnTargetsSegment, MemorySegment cscRowOffsetsSegment, MemorySegment cscColumnTargetsSegment, List<MemorySegment> attributeSegments, List<MemorySegment> validitySegments, byte srcNodeIdWidth, byte dstNodeIdWidth, byte edgeIndexWidth) RelationSnapshot(Arena arena, int nodeCount, int edgeCount, MemorySegment rowOffsetsSegment, MemorySegment columnTargetsSegment, List<MemorySegment> attributeSegments) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidcopyInTargetsSimd(int nodeId, ImpulseBitSet outBs) SIMD vectorized incoming target node traversal into a destination ImpulseBitSet zero-allocation.voidcopyTargetsSimd(int nodeId, ImpulseBitSet outBs) SIMD vectorized target node traversal into a destination ImpulseBitSet.voidcopyTargetsSimdFilteredFloat(int nodeId, MemorySegment attrSegment, float threshold, byte cmpOp, ImpulseBitSet outBs) SIMD Vector API fused edge attribute predicate filter during CSR traversal.intfindAttributeIndex(String name) intfindCsrEdgeIndex(int srcU, int dstV) getAttributeName(int index) bytegetAttributeTypeCode(int index) int[]int[]intintgetDegree(int nodeId) Gets the out-degree for a specific node ID zero-copy directly from off-heap memory.longbytebyteintgetFlatForwardTarget(int nodeId) Zero-allocation read of the single outgoing target for Flat (1:1 / N:1) relations, returning-1when unbound/sentinel/out-of-range.intgetFlatReverseSource(int nodeId) Zero-allocation read of the single incoming source for Flat Reverse (1:1 / 1:N) relations, returning-1when unbound/sentinel/out-of-range.intgetInDegree(int nodeId) Gets the in-degree for a specific destination node ID zero-copy directly from off-heap memory.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.longintbyteint[]Lazily builds an exact bijection from CSC slotk(0..edgeCount-1) to CSR edge indexe(0..edgeCount-1), preserving parallel multi-edge attribute alignment.int[]intint[]longintbyteintgetTargetAt(int nodeId, int index) intint[]getTargets(int nodeId) Returns the array slice of target node IDs for a specific source node ID zero-copy from off-heap memory.intbooleanhasCsc()booleanhasCsr()voidinjectMetadata(String metadataJson) booleanbooleanstatic booleanisSentinelNodeId(int rawId, byte widthBytes) booleanlongreadEdgeIndex(MemorySegment segment, long nodeId) intreadNodeId(MemorySegment segment, long index) static intreadNodeId(MemorySegment segment, long index, byte width) intreadSrcNodeId(MemorySegment segment, long index) voidsetAttributeNames(List<String> names) voidsetAttributeTypeCodes(List<Byte> typeCodes) voidsetCatalogMetadata(int relationId, int srcDomainId, int tgtDomainId, byte encodingId, long sectionFeatures, int[] componentIds) voidsetComponentRelations(RelationSnapshot[] componentRelations) voidsetCscSegments(MemorySegment rowOffsets, MemorySegment columnTargets) voidsetLoadedAttributes(List<BinarySnapshotLoader.LoadedAttribute> attrs, List<MemorySegment> attrOffsets) voidsetTargetNodeCount(int targetNodeCount)
-
Constructor Details
-
RelationSnapshot
public RelationSnapshot(Arena arena, int nodeCount, int edgeCount, int[] rowOffsetsData, int[] columnIndicesData) -
RelationSnapshot
public RelationSnapshot(Arena arena, int nodeCount, int edgeCount, MemorySegment rowOffsetsSegment, MemorySegment columnTargetsSegment, List<MemorySegment> attributeSegments) -
RelationSnapshot
public RelationSnapshot(Arena arena, int nodeCount, int edgeCount, MemorySegment rowOffsetsSegment, MemorySegment columnTargetsSegment) -
RelationSnapshot
public RelationSnapshot(Arena arena, int nodeCount, int edgeCount, MemorySegment rowOffsetsSegment, MemorySegment columnTargetsSegment, MemorySegment cscRowOffsetsSegment, MemorySegment cscColumnTargetsSegment, List<MemorySegment> attributeSegments, List<MemorySegment> validitySegments, byte nodeIdWidth, byte edgeIndexWidth) -
RelationSnapshot
public RelationSnapshot(Arena arena, int nodeCount, int edgeCount, MemorySegment rowOffsetsSegment, MemorySegment columnTargetsSegment, MemorySegment cscRowOffsetsSegment, MemorySegment cscColumnTargetsSegment, List<MemorySegment> attributeSegments, List<MemorySegment> validitySegments, byte srcNodeIdWidth, byte dstNodeIdWidth, byte edgeIndexWidth) -
RelationSnapshot
public RelationSnapshot(Arena arena, int nodeCount, int edgeCount, MemorySegment rowOffsetsSegment, MemorySegment columnTargetsSegment, MemorySegment cscRowOffsetsSegment, MemorySegment cscColumnTargetsSegment)
-
-
Method Details
-
setAttributeNames
-
setAttributeTypeCodes
-
getAttributeName
-
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
-
getOffsetsSegments
-
getComponentIds
public int[] getComponentIds() -
setComponentRelations
-
getComponentRelations
-
getRelationId
public int getRelationId()- Specified by:
getRelationIdin interfaceRelationSnapshot
-
getSrcDomainId
public int getSrcDomainId()- Specified by:
getSrcDomainIdin interfaceRelationSnapshot
-
getTgtDomainId
public int getTgtDomainId()- Specified by:
getTgtDomainIdin interfaceRelationSnapshot
-
getEncodingId
public byte getEncodingId() -
getSectionFeatures
public long getSectionFeatures() -
isVirtual
public boolean isVirtual()- Specified by:
isVirtualin interfaceRelationSnapshot
-
isFlatForward
public boolean isFlatForward() -
isFlatReverse
public boolean isFlatReverse() -
isSentinelNodeId
public static boolean isSentinelNodeId(int rawId, byte widthBytes) -
getCscNodeCount
public int getCscNodeCount()- Specified by:
getCscNodeCountin interfaceRelationSnapshot
-
findAttributeIndex
-
getSrcNodeIdWidth
public byte getSrcNodeIdWidth()- Specified by:
getSrcNodeIdWidthin interfaceRelationSnapshot
-
getNodeIdWidth
public byte getNodeIdWidth()- Specified by:
getNodeIdWidthin interfaceRelationSnapshot
-
getEdgeIndexWidth
public byte getEdgeIndexWidth()- Specified by:
getEdgeIndexWidthin interfaceRelationSnapshot
-
setCscSegments
- Specified by:
setCscSegmentsin interfaceRelationSnapshot
-
hasCsc
public boolean hasCsc()- Specified by:
hasCscin interfaceRelationSnapshot
-
getCscRowOffsetsSegment
- Specified by:
getCscRowOffsetsSegmentin interfaceRelationSnapshot
-
getCscColumnTargetsSegment
- Specified by:
getCscColumnTargetsSegmentin interfaceRelationSnapshot
-
hasCsr
public boolean hasCsr()- Specified by:
hasCsrin interfaceRelationSnapshot
-
injectMetadata
-
getStatistics
- Specified by:
getStatisticsin interfaceRelationSnapshot
-
getAttributeSegments
- Specified by:
getAttributeSegmentsin interfaceRelationSnapshot
-
getValiditySegments
-
getNodeCount
public int getNodeCount()- Specified by:
getNodeCountin interfaceRelationSnapshot
-
getEdgeCount
public long getEdgeCount()- Specified by:
getEdgeCountin interfaceRelationSnapshot
-
readEdgeIndex
- Specified by:
readEdgeIndexin interfaceRelationSnapshot
-
readNodeId
- Specified by:
readNodeIdin interfaceRelationSnapshot
-
readSrcNodeId
- Specified by:
readSrcNodeIdin interfaceRelationSnapshot
-
readNodeId
-
getRowOffsets
public int[] getRowOffsets() -
getColumnIndices
public int[] getColumnIndices() -
getRowOffsetsSegment
- Specified by:
getRowOffsetsSegmentin interfaceRelationSnapshot
-
getColumnTargetsSegment
- Specified by:
getColumnTargetsSegmentin interfaceRelationSnapshot
-
getDegree
public int getDegree(int nodeId) Gets the out-degree for a specific node ID zero-copy directly from off-heap memory.- Specified by:
getDegreein interfaceRelationSnapshot
-
getFlatForwardTarget
public int getFlatForwardTarget(int nodeId) Zero-allocation read of the single outgoing target for Flat (1:1 / N:1) relations, returning-1when 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-1when unbound/sentinel/out-of-range. -
getTargetAt
public int getTargetAt(int nodeId, int index) - Specified by:
getTargetAtin interfaceRelationSnapshot
-
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:
getTargetsin interfaceRelationSnapshot
-
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:
getInDegreein interfaceRelationSnapshot
-
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:
getInTargetsin interfaceRelationSnapshot
-
copyTargetsSimd
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:
copyTargetsSimdin interfaceRelationSnapshot
-
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:
copyTargetsSimdFilteredFloatin interfaceRelationSnapshot
-
copyInTargetsSimd
SIMD vectorized incoming target node traversal into a destination ImpulseBitSet zero-allocation.- Specified by:
copyInTargetsSimdin interfaceRelationSnapshot
-
getOrBuildCscToCsrEdgeMap
public int[] getOrBuildCscToCsrEdgeMap()Lazily builds an exact bijection from CSC slotk(0..edgeCount-1) to CSR edge indexe(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:
closein interfaceAutoCloseable
-