use of org.apache.ignite.internal.pagemem.wal.record.MvccDataRecord in project ignite by apache.
the class StandaloneWalRecordsIterator method postProcessDataRecord.
/**
* Performs post processing of lazy data record, converts it to unwrap record.
*
* @param dataRec data record to post process records.
* @param kernalCtx kernal context.
* @param processor processor to convert binary form from WAL into CacheObject/BinaryObject.
* @return post-processed record.
* @throws IgniteCheckedException if failed.
*/
@NotNull
private WALRecord postProcessDataRecord(@NotNull DataRecord dataRec, GridKernalContext kernalCtx, IgniteCacheObjectProcessor processor) throws IgniteCheckedException {
final CacheObjectContext fakeCacheObjCtx = new CacheObjectContext(kernalCtx, null, null, false, false, false, false, false);
final int entryCnt = dataRec.entryCount();
final List<DataEntry> postProcessedEntries = new ArrayList<>(entryCnt);
for (int i = 0; i < entryCnt; i++) {
final DataEntry postProcessedEntry = postProcessDataEntry(processor, fakeCacheObjCtx, dataRec.get(i));
postProcessedEntries.add(postProcessedEntry);
}
DataRecord res = dataRec instanceof MvccDataRecord ? new MvccDataRecord(postProcessedEntries, dataRec.timestamp()) : new DataRecord(postProcessedEntries, dataRec.timestamp());
res.size(dataRec.size());
res.position(dataRec.position());
return res;
}
use of org.apache.ignite.internal.pagemem.wal.record.MvccDataRecord in project ignite by apache.
the class RecordDataV2Serializer method readPlainRecord.
/**
* {@inheritDoc}
*/
@Override
WALRecord readPlainRecord(RecordType type, ByteBufferBackedDataInput in, boolean encrypted, int recordSize) throws IOException, IgniteCheckedException {
switch(type) {
case PAGE_RECORD:
int cacheId = in.readInt();
long pageId = in.readLong();
byte[] arr = new byte[recordSize - 4 - /* cacheId */
8];
in.readFully(arr);
return new PageSnapshot(new FullPageId(pageId, cacheId), arr, encrypted ? realPageSize : pageSize);
case CHECKPOINT_RECORD:
long msb = in.readLong();
long lsb = in.readLong();
boolean hasPtr = in.readByte() != 0;
long idx0 = hasPtr ? in.readLong() : 0;
int off = hasPtr ? in.readInt() : 0;
int len = hasPtr ? in.readInt() : 0;
Map<Integer, CacheState> states = readPartitionStates(in);
boolean end = in.readByte() != 0;
WALPointer walPtr = hasPtr ? new WALPointer(idx0, off, len) : null;
CheckpointRecord cpRec = new CheckpointRecord(new UUID(msb, lsb), walPtr, end);
cpRec.cacheGroupStates(states);
return cpRec;
case DATA_RECORD:
case DATA_RECORD_V2:
int entryCnt = in.readInt();
long timeStamp = in.readLong();
if (entryCnt == 1)
return new DataRecord(readPlainDataEntry(in, type), timeStamp);
else {
List<DataEntry> entries = new ArrayList<>(entryCnt);
for (int i = 0; i < entryCnt; i++) entries.add(readPlainDataEntry(in, type));
return new DataRecord(entries, timeStamp);
}
case MVCC_DATA_RECORD:
entryCnt = in.readInt();
timeStamp = in.readLong();
List<DataEntry> entries = new ArrayList<>(entryCnt);
for (int i = 0; i < entryCnt; i++) entries.add(readMvccDataEntry(in));
return new MvccDataRecord(entries, timeStamp);
case ENCRYPTED_DATA_RECORD:
case ENCRYPTED_DATA_RECORD_V2:
case ENCRYPTED_DATA_RECORD_V3:
entryCnt = in.readInt();
timeStamp = in.readLong();
if (entryCnt == 1)
return new DataRecord(readEncryptedDataEntry(in, type), timeStamp);
else {
entries = new ArrayList<>(entryCnt);
for (int i = 0; i < entryCnt; i++) entries.add(readEncryptedDataEntry(in, type));
return new DataRecord(entries, timeStamp);
}
case SNAPSHOT:
long snpId = in.readLong();
byte full = in.readByte();
return new SnapshotRecord(snpId, full == 1);
case EXCHANGE:
int idx = in.readInt();
short constId = in.readShort();
long ts = in.readLong();
return new ExchangeRecord(constId, ExchangeRecord.Type.values()[idx], ts);
case TX_RECORD:
return txRecordSerializer.readTx(in);
case MVCC_TX_RECORD:
return txRecordSerializer.readMvccTx(in);
case ROLLBACK_TX_RECORD:
int grpId = in.readInt();
int partId = in.readInt();
long start = in.readLong();
long range = in.readLong();
return new RollbackRecord(grpId, partId, start, range);
case TRACKING_PAGE_REPAIR_DELTA:
cacheId = in.readInt();
pageId = in.readLong();
return new TrackingPageRepairDeltaRecord(cacheId, pageId);
default:
return super.readPlainRecord(type, in, encrypted, recordSize);
}
}
Aggregations