You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2022/12/01 21:17:22 UTC
[GitHub] [cassandra] josh-mckenzie commented on a diff in pull request #1954: Cassandra 17998
josh-mckenzie commented on code in PR #1954:
URL: https://github.com/apache/cassandra/pull/1954#discussion_r1037568084
##########
src/java/org/apache/cassandra/io/util/DataOutputBuffer.java:
##########
@@ -61,32 +61,62 @@ private enum AllocationType { DIRECT, ONHEAP }
@Override
protected DataOutputBuffer initialValue()
{
- return new DataOutputBuffer()
- {
- @Override
- public void close()
- {
- if (buffer != null && buffer.capacity() <= MAX_RECYCLE_BUFFER_SIZE)
- {
- buffer.clear();
- }
- else
- {
- setBuffer(allocate(DEFAULT_INITIAL_BUFFER_SIZE));
- }
- }
-
- @Override
- protected ByteBuffer allocate(int size)
- {
- return ALLOCATION_TYPE == AllocationType.DIRECT ?
- ByteBuffer.allocateDirect(size) :
- ByteBuffer.allocate(size);
- }
- };
+ return new LimitingScratchBuffer();
}
};
+ /**
+ * Returns a {@link DataOutputBuffer} that is limited to a capacity of {@code limit} bytes.
+ * A {@code limit} of 0 means unlimited.
+ */
+ public static DataOutputBuffer limitedScratchBuffer(long limit)
+ {
+ LimitingScratchBuffer dob = (LimitingScratchBuffer) scratchBuffer.get();
Review Comment:
Been chewing on this - given the advice is to close out this DOB quickly to prevent heap pressure, what's the point of using the FastThreadLocal scratchBuffer instead of just a new DOB?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org