private bool CheckSumOK(ByteArrayBuffer buffer, int offset) { var initialOffSet = buffer.Offset(); var length = OwnLength(); length -= ChecksumLength; buffer.Seek(offset); var readCheckSum = buffer.ReadLong(); var checkSumBeginOffset = buffer.Offset(); var bytes = buffer._buffer; var calculatedCheckSum = CRC32.CheckSum(bytes, checkSumBeginOffset, length); buffer.Seek(initialOffSet); return(calculatedCheckSum == readCheckSum); }
private ByteArrayBuffer ReadNextSlot(int length) { ByteArrayBuffer slot = _reader.ReadPayloadReader(_reader.Offset(), length); _reader.Skip(length); return(slot); }
private void WriteIntAt(ByteArrayBuffer target, int offset, int value) { int currentOffset = target.Offset(); target.Seek(offset); target.WriteInt(value); target.Seek(currentOffset); }
private void Marshall(ByteArrayBuffer buffer, bool shuttingDown) { var checkSumOffset = buffer.Offset(); buffer.IncrementOffset(ChecksumLength); var checkSumBeginOffset = buffer.Offset(); WriteBuffer(buffer, shuttingDown); var checkSumEndOffSet = buffer.Offset(); var bytes = buffer._buffer; var length = checkSumEndOffSet - checkSumBeginOffset; var checkSum = CRC32.CheckSum(bytes, checkSumBeginOffset, length); buffer.Seek(checkSumOffset); buffer.WriteLong(checkSum); buffer.Seek(checkSumEndOffSet); }
private void DefragmentWriteMappedClassId(IDefragmentContext context, ArrayInfo info , int classIdOffset) { ByteArrayBuffer targetBuffer = context.TargetBuffer(); int currentOffset = targetBuffer.Offset(); targetBuffer.Seek(classIdOffset); int classID = ClassIDFromInfo(Container(context), info); int mappedID = context.MappedID(classID); int marshalledMappedId = ClassIdToMarshalledClassId(mappedID, info.Primitive()); targetBuffer.WriteInt(marshalledMappedId); targetBuffer.Seek(currentOffset); }
public virtual ByteArrayBuffer Marshall(LocalTransaction transaction, IIntIterator4 ids, int count) { ByteArrayBuffer buffer = new ByteArrayBuffer(Const4.IntLength + count * Const4.IntLength ); int sizeOffset = buffer.Offset(); buffer.WriteInt(0); int written = 0; while (count > 0 && ids.MoveNext()) { buffer.WriteInt(ids.CurrentInt()); ++written; --count; } buffer.Seek(sizeOffset); buffer.WriteInt(written); return(buffer); }
public virtual int Offset() { return(_current.Offset()); }
private bool CheckSumOK(ByteArrayBuffer buffer, int offset) { var initialOffSet = buffer.Offset(); var length = OwnLength(); length -= ChecksumLength; buffer.Seek(offset); var readCheckSum = buffer.ReadLong(); var checkSumBeginOffset = buffer.Offset(); var bytes = buffer._buffer; var calculatedCheckSum = CRC32.CheckSum(bytes, checkSumBeginOffset, length); buffer.Seek(initialOffSet); return calculatedCheckSum == readCheckSum; }