Commit 25a362ec by aquilescanta Committed by Ian Baker

Remove last SampleQueue.release allocation

By making AllocationNode fields non-final

PiperOrigin-RevId: 422403816
parent bb0a6415
...@@ -66,7 +66,7 @@ import java.util.Arrays; ...@@ -66,7 +66,7 @@ import java.util.Arrays;
/** Clears all sample data. */ /** Clears all sample data. */
public void reset() { public void reset() {
clearAllocationNodes(firstAllocationNode); clearAllocationNodes(firstAllocationNode);
firstAllocationNode = new AllocationNode(0, allocationLength); firstAllocationNode.reset(/* startPosition= */ 0, allocationLength);
readAllocationNode = firstAllocationNode; readAllocationNode = firstAllocationNode;
writeAllocationNode = firstAllocationNode; writeAllocationNode = firstAllocationNode;
totalBytesWritten = 0; totalBytesWritten = 0;
...@@ -462,9 +462,9 @@ import java.util.Arrays; ...@@ -462,9 +462,9 @@ import java.util.Arrays;
private static final class AllocationNode implements Allocator.AllocationNode { private static final class AllocationNode implements Allocator.AllocationNode {
/** The absolute position of the start of the data (inclusive). */ /** The absolute position of the start of the data (inclusive). */
public final long startPosition; public long startPosition;
/** The absolute position of the end of the data (exclusive). */ /** The absolute position of the end of the data (exclusive). */
public final long endPosition; public long endPosition;
/** /**
* The {@link Allocation}, or {@code null} if the node is not {@link #initialize initialized}. * The {@link Allocation}, or {@code null} if the node is not {@link #initialize initialized}.
*/ */
...@@ -481,6 +481,17 @@ import java.util.Arrays; ...@@ -481,6 +481,17 @@ import java.util.Arrays;
* initialized. * initialized.
*/ */
public AllocationNode(long startPosition, int allocationLength) { public AllocationNode(long startPosition, int allocationLength) {
reset(startPosition, allocationLength);
}
/**
* Sets the {@link #startPosition} and the {@link Allocation} length.
*
* <p>Must only be called for uninitialized instances, where {@link #allocation} is {@code
* null}.
*/
public void reset(long startPosition, int allocationLength) {
Assertions.checkState(allocation == null);
this.startPosition = startPosition; this.startPosition = startPosition;
this.endPosition = startPosition + allocationLength; this.endPosition = startPosition + allocationLength;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment