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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]