Class RecordV1Serializer
- java.lang.Object
-
- org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordV1Serializer
-
- All Implemented Interfaces:
RecordSerializer
public class RecordV1Serializer extends Object implements RecordSerializer
Record V1 serializer. Stores records in following format:- Record type from
WALRecord.RecordType.index()incremented by 1 - WAL pointer to double check consistency
- Data
- CRC or zero padding
-
-
Field Summary
Fields Modifier and Type Field Description static intCRC_SIZELength of CRC valuestatic intFILE_WAL_POINTER_SIZELength of WAL Pointer: Index (8) + File offset (4).static intHEADER_RECORD_SIZETotal length of HEADER record.static intREC_TYPE_SIZELength of Typestatic booleanskipCrcSkip CRC calculation/check flag
-
Constructor Summary
Constructors Constructor Description RecordV1Serializer(RecordDataV1Serializer dataSerializer, boolean writePointer, boolean marshalledMode, boolean skipPositionCheck, IgniteBiPredicate<WALRecord.RecordType,WALPointer> recordFilter)Create an instance of V1 serializer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidputPosition(ByteBuffer buf, WALPointer ptr)Saves position, WAL pointer (requiresFILE_WAL_POINTER_SIZEbytes)static WALPointerreadPosition(DataInput in)WALRecordreadRecord(FileInput in0, WALPointer expPtr)Loads record from inputstatic SegmentHeaderreadSegmentHeader(SegmentIO io, SegmentFileInputFactory segmentFileInputFactory)Reads stored record from providedio.intsize(WALRecord record)Calculates record size in byte including expected wal pointer, CRC and type fieldintversion()booleanwritePointer()Flag to write (or not) wal pointer to recordvoidwriteRecord(WALRecord rec, ByteBuffer buf)
-
-
-
Field Detail
-
REC_TYPE_SIZE
public static final int REC_TYPE_SIZE
Length of Type- See Also:
- Constant Field Values
-
FILE_WAL_POINTER_SIZE
public static final int FILE_WAL_POINTER_SIZE
Length of WAL Pointer: Index (8) + File offset (4).- See Also:
- Constant Field Values
-
CRC_SIZE
public static final int CRC_SIZE
Length of CRC value- See Also:
- Constant Field Values
-
HEADER_RECORD_SIZE
public static final int HEADER_RECORD_SIZE
Total length of HEADER record.- See Also:
- Constant Field Values
-
skipCrc
public static boolean skipCrc
Skip CRC calculation/check flag
-
-
Constructor Detail
-
RecordV1Serializer
public RecordV1Serializer(RecordDataV1Serializer dataSerializer, boolean writePointer, boolean marshalledMode, boolean skipPositionCheck, IgniteBiPredicate<WALRecord.RecordType,WALPointer> recordFilter)
Create an instance of V1 serializer.- Parameters:
dataSerializer- V1 data serializer.writePointer- Write pointer.marshalledMode- Marshalled mode.skipPositionCheck- Skip position check mode.recordFilter- Record type filter.FilteredRecordis deserialized instead of original record
-
-
Method Detail
-
version
public int version()
- Specified by:
versionin interfaceRecordSerializer- Returns:
- serializer version
-
writePointer
public boolean writePointer()
Flag to write (or not) wal pointer to record- Specified by:
writePointerin interfaceRecordSerializer
-
writeRecord
public void writeRecord(WALRecord rec, ByteBuffer buf) throws IgniteCheckedException
- Specified by:
writeRecordin interfaceRecordSerializer- Parameters:
rec- Entry to write.buf- Buffer.- Throws:
IgniteCheckedException
-
readRecord
public WALRecord readRecord(FileInput in0, WALPointer expPtr) throws IOException, IgniteCheckedException
Loads record from input- Specified by:
readRecordin interfaceRecordSerializer- Parameters:
in0- Data input to read data from.expPtr- expected WAL pointer for record. Used to validate actual position against expected from the file- Returns:
- Read entry.
- Throws:
IOExceptionIgniteCheckedException
-
size
public int size(WALRecord record) throws IgniteCheckedException
Calculates record size in byte including expected wal pointer, CRC and type field- Specified by:
sizein interfaceRecordSerializer- Parameters:
record- Record.- Returns:
- Size in bytes.
- Throws:
IgniteCheckedException
-
putPosition
public static void putPosition(ByteBuffer buf, WALPointer ptr)
Saves position, WAL pointer (requiresFILE_WAL_POINTER_SIZEbytes)- Parameters:
buf- Byte buffer to serialize version to.ptr- File WAL pointer to write.
-
readSegmentHeader
public static SegmentHeader readSegmentHeader(SegmentIO io, SegmentFileInputFactory segmentFileInputFactory) throws IgniteCheckedException, IOException
Reads stored record from providedio. NOTE: Method mutates position ofio.- Parameters:
io- I/O interface for file.segmentFileInputFactory- File input factory.- Returns:
- Instance of
SegmentHeaderextracted from the file. - Throws:
IgniteCheckedException- If failed to read serializer version.IOException
-
readPosition
public static WALPointer readPosition(DataInput in) throws IOException
- Parameters:
in- Data input to read pointer from.- Returns:
- Read file WAL pointer.
- Throws:
IOException- If failed to write.
-
-