Class GraphSnapshot
java.lang.Object
org.impulsegraph.storage.csr.GraphSnapshot
- All Implemented Interfaces:
AutoCloseable, ImpulseGraphSnapshot, StatisticsView
public class GraphSnapshot
extends Object
implements ImpulseGraphSnapshot, AutoCloseable, StatisticsView
High-performance off-heap multi-relation graph container holding relation
snapshots across domain types.
-
Field Summary
Fields inherited from interface ImpulseGraphSnapshot
MAGIC, SPEC_VERSION_MAJOR, SPEC_VERSION_MINOR -
Constructor Summary
ConstructorsConstructorDescriptionGraphSnapshot(Arena arena, Map<String, RelationSnapshot> snapshots) GraphSnapshot(Arena arena, Map<String, RelationSnapshot> snapshots, Map<String, String> metadata) GraphSnapshot(Arena arena, Map<String, RelationSnapshot> snapshots, Map<String, String> metadata, Map<String, RelationSnapshot> aliases) GraphSnapshot(Arena arena, Map<String, RelationSnapshot> snapshots, Map<String, String> metadata, Map<String, RelationSnapshot> aliases, Map<String, BinarySnapshotLoader.LoadedDomain> domains) -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitDrained(long timeout, TimeUnit unit) Awaits all in-flight queries executing against this snapshot to drain, up to the specified timeout.voidclose()voiddrainAndClose(long timeout, TimeUnit unit) Awaits all in-flight queries to drain and closes the underlying off-heap graph resources.voidvoidlongReturns the count of queries currently executing against this graph snapshot.Returns a map of all relation snapshots.getDomain(int domainId) getDomainAttributeNames(String domainName) Returns the list of attribute names defined for the given domain.getDomainAttributeSegment(String domainName, String attrName) Returns the off-heapMemorySegmentfor the given domain attribute.getDomainAttributeSegments(String domainName) Returns the list of off-heapMemorySegments for all attributes in the given domain.intgetDomainKeyAttrIndex(String domainName) Returns the 0-indexed attribute index holding the primary key column for the given domain, or 0xFFFF if none.getDomainName(int domainId) Looks up a domain name by its numeric identifier.Returns the set of all domain names present in this snapshot.longgetEdgeCount(String relationName) Returns the edge count for a specific relation.longgetEstimatedDomainCount(int domainId) intgetEstimatedOutDegreePercentile(int relationId, double percentile) intReturns the maximum node count across all domains/relations in this snapshot.getMetadata(String key) Returns the value for a custom metadata key, or null if not present.Returns an unmodifiable map of all custom metadata key-value pairs stored in this snapshot.longgetNodeCount(String domainName) Returns the node count for a specific entity/domain type.longReturns the total off-heap memory footprint of this snapshot in bytes.getRawStatisticJson(String metadataKey) Returns the full JSON metadata string for a given key, if the caller needs to perform custom parsing for Equi-Depth histograms or Heavy Hitters.intReturns the total count of relations stored in this snapshot.Returns the set of all relation names present in this snapshot.getRelationSnapshot(int relationId) Obtains theRelationSnapshotfor the given 0-indexed physical relation ID without string allocation or map lookup.getRelationSnapshot(String relationName) Obtains theRelationSnapshotfor the given relation.getRelationTargetsSegment(String relationName) Obtains the off-heapMemorySegmentfor the given relation's target array.Returns the schema/metadata for a given domain, or null if not present.Returns the SHA-256 checksum hex string calculated over the snapshot sections.booleanChecks if all queries executing against this snapshot have drained (active count == 0).Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ImpulseGraphSnapshot
domain, getRelationSourceDomainName, getRelationTargetDomainName, prepare, traverse, traverse
-
Constructor Details
-
GraphSnapshot
-
GraphSnapshot
-
GraphSnapshot
public GraphSnapshot(Arena arena, Map<String, RelationSnapshot> snapshots, Map<String, String> metadata, Map<String, RelationSnapshot> aliases) -
GraphSnapshot
public GraphSnapshot(Arena arena, Map<String, RelationSnapshot> snapshots, Map<String, String> metadata, Map<String, RelationSnapshot> aliases, Map<String, BinarySnapshotLoader.LoadedDomain> domains)
-
-
Method Details
-
getEstimatedOutDegreePercentile
public int getEstimatedOutDegreePercentile(int relationId, double percentile) - Specified by:
getEstimatedOutDegreePercentilein interfaceStatisticsView- Parameters:
relationId- The internal relation ID.percentile- The percentile (0.0 to 1.0), e.g. 0.99 for P99.- Returns:
- The estimated out-degree at the given percentile, or -1 if missing.
-
getEstimatedDomainCount
public long getEstimatedDomainCount(int domainId) - Specified by:
getEstimatedDomainCountin interfaceStatisticsView- Parameters:
domainId- The internal domain ID.- Returns:
- The estimated distinct node count, or -1 if missing.
-
getRawStatisticJson
Description copied from interface:StatisticsViewReturns the full JSON metadata string for a given key, if the caller needs to perform custom parsing for Equi-Depth histograms or Heavy Hitters.- Specified by:
getRawStatisticJsonin interfaceStatisticsView- Parameters:
metadataKey- The specific metadata key (e.g. "stats.out_degree.1").- Returns:
- The JSON string, or null if not present.
-
getRelationSnapshot
Description copied from interface:ImpulseGraphSnapshotObtains theRelationSnapshotfor the given relation.- Specified by:
getRelationSnapshotin interfaceImpulseGraphSnapshot
-
getRelationSnapshot
Description copied from interface:ImpulseGraphSnapshotObtains theRelationSnapshotfor the given 0-indexed physical relation ID without string allocation or map lookup.- Specified by:
getRelationSnapshotin interfaceImpulseGraphSnapshot
-
getMaxNodeCount
public int getMaxNodeCount()Description copied from interface:ImpulseGraphSnapshotReturns the maximum node count across all domains/relations in this snapshot.- Specified by:
getMaxNodeCountin interfaceImpulseGraphSnapshot
-
getAllRelationSnapshots
Description copied from interface:ImpulseGraphSnapshotReturns a map of all relation snapshots.- Specified by:
getAllRelationSnapshotsin interfaceImpulseGraphSnapshot
-
getOffHeapMemorySizeBytes
public long getOffHeapMemorySizeBytes()Description copied from interface:ImpulseGraphSnapshotReturns the total off-heap memory footprint of this snapshot in bytes.- Specified by:
getOffHeapMemorySizeBytesin interfaceImpulseGraphSnapshot
-
getGraphStatistics
- Specified by:
getGraphStatisticsin interfaceImpulseGraphSnapshot
-
getRelationCount
public int getRelationCount()Description copied from interface:ImpulseGraphSnapshotReturns the total count of relations stored in this snapshot.- Specified by:
getRelationCountin interfaceImpulseGraphSnapshot
-
getRelationNames
Description copied from interface:ImpulseGraphSnapshotReturns the set of all relation names present in this snapshot.- Specified by:
getRelationNamesin interfaceImpulseGraphSnapshot
-
getDomain
-
getDomain
-
getDomainNames
Description copied from interface:ImpulseGraphSnapshotReturns the set of all domain names present in this snapshot.- Specified by:
getDomainNamesin interfaceImpulseGraphSnapshot
-
getDomainName
Description copied from interface:ImpulseGraphSnapshotLooks up a domain name by its numeric identifier.- Specified by:
getDomainNamein interfaceImpulseGraphSnapshot- Returns:
- the domain name, or null if not found
-
getDomainAttributeNames
Description copied from interface:ImpulseGraphSnapshotReturns the list of attribute names defined for the given domain.- Specified by:
getDomainAttributeNamesin interfaceImpulseGraphSnapshot
-
getDomainAttributeSegments
Description copied from interface:ImpulseGraphSnapshotReturns the list of off-heapMemorySegments for all attributes in the given domain.- Specified by:
getDomainAttributeSegmentsin interfaceImpulseGraphSnapshot
-
getDomainAttributeSegment
Description copied from interface:ImpulseGraphSnapshotReturns the off-heapMemorySegmentfor the given domain attribute.- Specified by:
getDomainAttributeSegmentin interfaceImpulseGraphSnapshot
-
getDomainKeyAttrIndex
Description copied from interface:ImpulseGraphSnapshotReturns the 0-indexed attribute index holding the primary key column for the given domain, or 0xFFFF if none.- Specified by:
getDomainKeyAttrIndexin interfaceImpulseGraphSnapshot
-
getSchema
Description copied from interface:ImpulseGraphSnapshotReturns the schema/metadata for a given domain, or null if not present.- Specified by:
getSchemain interfaceImpulseGraphSnapshot
-
getNodeCount
Description copied from interface:ImpulseGraphSnapshotReturns the node count for a specific entity/domain type.- Specified by:
getNodeCountin interfaceImpulseGraphSnapshot
-
getEdgeCount
Description copied from interface:ImpulseGraphSnapshotReturns the edge count for a specific relation.- Specified by:
getEdgeCountin interfaceImpulseGraphSnapshot
-
getRelationTargetsSegment
Description copied from interface:ImpulseGraphSnapshotObtains the off-heapMemorySegmentfor the given relation's target array.- Specified by:
getRelationTargetsSegmentin interfaceImpulseGraphSnapshot
-
getSha256Checksum
Description copied from interface:ImpulseGraphSnapshotReturns the SHA-256 checksum hex string calculated over the snapshot sections.- Specified by:
getSha256Checksumin interfaceImpulseGraphSnapshot
-
getMetadata
Description copied from interface:ImpulseGraphSnapshotReturns the value for a custom metadata key, or null if not present.- Specified by:
getMetadatain interfaceImpulseGraphSnapshot
-
getMetadataMap
Description copied from interface:ImpulseGraphSnapshotReturns an unmodifiable map of all custom metadata key-value pairs stored in this snapshot.- Specified by:
getMetadataMapin interfaceImpulseGraphSnapshot
-
enterQuery
public void enterQuery()- Specified by:
enterQueryin interfaceImpulseGraphSnapshot
-
exitQuery
public void exitQuery()- Specified by:
exitQueryin interfaceImpulseGraphSnapshot
-
getActiveQueryCount
public long getActiveQueryCount()Description copied from interface:ImpulseGraphSnapshotReturns the count of queries currently executing against this graph snapshot.- Specified by:
getActiveQueryCountin interfaceImpulseGraphSnapshot
-
isDrained
public boolean isDrained()Description copied from interface:ImpulseGraphSnapshotChecks if all queries executing against this snapshot have drained (active count == 0).- Specified by:
isDrainedin interfaceImpulseGraphSnapshot
-
awaitDrained
Description copied from interface:ImpulseGraphSnapshotAwaits all in-flight queries executing against this snapshot to drain, up to the specified timeout.- Specified by:
awaitDrainedin interfaceImpulseGraphSnapshot- Returns:
- true if all queries drained; false if timeout expired
- Throws:
InterruptedException
-
drainAndClose
Description copied from interface:ImpulseGraphSnapshotAwaits all in-flight queries to drain and closes the underlying off-heap graph resources.- Specified by:
drainAndClosein interfaceImpulseGraphSnapshot- Throws:
InterruptedException
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceImpulseGraphSnapshot
-