Package org.neo4j.gds.core.loading
Class RecordsBatchBuffer<Reference>
- java.lang.Object
-
- org.neo4j.gds.core.loading.RecordsBatchBuffer<Reference>
-
- All Implemented Interfaces:
StoreScanner.RecordConsumer<Reference>
- Direct Known Subclasses:
CompositeRelationshipsBatchBuffer
,NodesBatchBuffer
,RelationshipsBatchBuffer
public abstract class RecordsBatchBuffer<Reference> extends java.lang.Object implements StoreScanner.RecordConsumer<Reference>
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_BUFFER_SIZE
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long[]
batch()
int
capacity()
boolean
isFull()
int
length()
void
reset()
org.neo4j.gds.core.loading.RecordsBatchBuffer.ScanState
scan(StoreScanner.ScanCursor<Reference> cursor, boolean reserveNextBatch)
Advances the underlying scan to the next batch of records and immediately consumes the batch into thisRecordsBatchBuffer
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.neo4j.gds.core.loading.StoreScanner.RecordConsumer
offer
-
-
-
-
Field Detail
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
scan
public org.neo4j.gds.core.loading.RecordsBatchBuffer.ScanState scan(StoreScanner.ScanCursor<Reference> cursor, boolean reserveNextBatch)
Advances the underlying scan to the next batch of records and immediately consumes the batch into thisRecordsBatchBuffer
.
There are two scenarios that can happen while consuming a batch of records from the kernel. If we read in fixed-size batches, these batches usually align with the buffer size and once we consumed the whole batch, the buffers can be flushed to the importer tasks. In the second scenario, we read from partitioned index scans which have varying sizes for partitions that might also exceed the size of the buffer. In that scenario, we need to flush the buffer before we advance to the next batch. The two scenarios are indicated by the returnedScanState
.- Parameters:
cursor
- A wrapper around aCursor
that allows us to consume the entity records using this buffer instance.reserveNextBatch
- Indicates if the underlying kernel scan should advance the cursor to the next batch. This needs to be set to false, if theRecordsBatchBuffer
has not read the complete batch yet, but had to be flushed before that.- Returns:
- a
ScanState
that indicates if the consumer needs to be flushed and if another batch can be read from the underlying scan.
-
length
public int length()
-
capacity
public int capacity()
-
isFull
public boolean isFull()
-
reset
public void reset()
-
batch
public long[] batch()
-
-