Skip to content

Commit

Permalink
IGNITE-21041 Make FilteredRecord local for RecordSerializer (#11082)
Browse files Browse the repository at this point in the history
  • Loading branch information
timoninmaxim authored Dec 8, 2023
1 parent 27d9298 commit dbe7e25
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
* {@link AbstractWalRecordsIterator}.
*/
public class FilteredRecord extends WALRecord {
/** Instance. */
public static final FilteredRecord INSTANCE = new FilteredRecord();

/** {@inheritDoc} */
@Override public RecordType type() {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ class StandaloneWalRecordsIterator extends AbstractWalRecordsIterator {
/** Replay from bound include. */
private final WALPointer lowBound;

/** Singleton instance of {@link FilteredRecord} */
private final WALRecord filteredRecord = new FilteredRecord();

/**
* Creates iterator in file-by-file iteration mode. Directory
*
Expand Down Expand Up @@ -286,7 +289,7 @@ private void init(List<FileDescriptor> walFiles) {
return tup;

if (!checkBounds(tup.get1()))
return new T2<>(tup.get1(), FilteredRecord.INSTANCE); // FilteredRecord for mark as filtered.
return new T2<>(tup.get1(), filteredRecord); // FilteredRecord for mark as filtered.

return tup;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ public class RecordV1Serializer implements RecordSerializer {
*/
private final boolean marshalledMode;

/** Singleton instance of {@link FilteredRecord} */
private final FilteredRecord filteredRecord = new FilteredRecord();

/** Thread-local heap byte buffer. */
private final ThreadLocal<ByteBuffer> heapTlb = new ThreadLocal<ByteBuffer>() {
@Override protected ByteBuffer initialValue() {
Expand Down Expand Up @@ -148,7 +151,7 @@ public class RecordV1Serializer implements RecordSerializer {

if (recType.purpose() != WALRecord.RecordPurpose.INTERNAL
&& recordFilter != null && !recordFilter.apply(rec.type(), ptr))
return FilteredRecord.INSTANCE;
return filteredRecord;
else if (marshalledMode) {
ByteBuffer buf = heapTlb.get();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ public class RecordV2Serializer implements RecordSerializer {
/** Skip position check flag. Should be set for reading compacted wal file with skipped physical records. */
private final boolean skipPositionCheck;

/** Singleton instance of {@link FilteredRecord} */
private final FilteredRecord filteredRecord = new FilteredRecord();

/** Thread-local heap byte buffer. */
private final ThreadLocal<ByteBuffer> heapTlb =
ThreadLocal.withInitial(() -> ByteBuffer.allocate(4096).order(GridUnsafe.NATIVE_BYTE_ORDER));
Expand Down Expand Up @@ -143,7 +146,7 @@ public class RecordV2Serializer implements RecordSerializer {
if (in.skipBytes(toSkip) < toSkip)
throw new EOFException("Reached end of file while reading record: " + ptr);

return FilteredRecord.INSTANCE;
return filteredRecord;
}
else if (marshalledMode) {
ByteBuffer buf = heapTlb.get();
Expand Down

0 comments on commit dbe7e25

Please sign in to comment.