private void saveDrId(long drId) { // If the drId is <= 255 (max unsigned byte) then // encode it as a single byte. // Otherwise write a byte whose value is the number of bytes // it will be encoded by and then follow it with that many bytes. // Note that drId are not allowed to have a value in the range 1..8 inclusive. if (drId >= 0 && drId <= 255) { this.drIdLength = 1; this.drIdBytes[0] = (byte)drId; } else { byte bytesNeeded = (byte)Oplog.bytesNeeded(drId); this.drIdLength = bytesNeeded+1; this.drIdBytes[0] = bytesNeeded; for (int i=bytesNeeded; i >=1; i--) { this.drIdBytes[i] = (byte)(drId & 0xFF); drId >>=8; } } this.size += this.drIdLength; }
private void saveDrId(long drId) { // If the drId is <= 255 (max unsigned byte) then // encode it as a single byte. // Otherwise write a byte whose value is the number of bytes // it will be encoded by and then follow it with that many bytes. // Note that drId are not allowed to have a value in the range 1..8 // inclusive. if (drId >= 0 && drId <= 255) { this.drIdLength = 1; this.drIdBytes[0] = (byte) drId; } else { byte bytesNeeded = (byte) Oplog.bytesNeeded(drId); this.drIdLength = bytesNeeded + 1; this.drIdBytes[0] = bytesNeeded; for (int i = bytesNeeded; i >= 1; i--) { this.drIdBytes[i] = (byte) (drId & 0xFF); drId >>= 8; } } this.size += this.drIdLength; }
static void writeDiskRegionID(DataOutput dos, long drId) throws IOException { // If the drId is <= 255 (max unsigned byte) then // encode it as a single byte. // Otherwise write a byte whose value is the number of bytes // it will be encoded by and then follow it with that many bytes. // Note that drId are not allowed to have a value in the range 1..8 inclusive. if (drId >= 0 && drId <= 255) { dos.write((byte) drId); } else { byte bytesNeeded = (byte)Oplog.bytesNeeded(drId); dos.write(bytesNeeded); byte[] bytes = new byte[bytesNeeded]; for (int i=bytesNeeded-1; i >=0; i--) { bytes[i] = (byte)(drId & 0xFF); drId >>=8; } dos.write(bytes); } }
private void putDiskRegionID(ByteBuffer bb, long drId) { // If the drId is <= 255 (max unsigned byte) then // encode it as a single byte. // Otherwise write a byte whose value is the number of bytes // it will be encoded by and then follow it with that many bytes. // Note that drId are not allowed to have a value in the range 1..8 inclusive. if (drId >= 0 && drId <= 255) { bb.put((byte)drId); } else { byte bytesNeeded = (byte)Oplog.bytesNeeded(drId); bb.put(bytesNeeded); byte[] bytes = new byte[bytesNeeded]; for (int i=bytesNeeded-1; i >=0; i--) { bytes[i] = (byte)(drId & 0xFF); drId >>=8; } bb.put(bytes); } }
static void writeDiskRegionID(DataOutput dos, long drId) throws IOException { // If the drId is <= 255 (max unsigned byte) then // encode it as a single byte. // Otherwise write a byte whose value is the number of bytes // it will be encoded by and then follow it with that many bytes. // Note that drId are not allowed to have a value in the range 1..8 inclusive. if (drId >= 0 && drId <= 255) { dos.write((byte) drId); } else { byte bytesNeeded = (byte)Oplog.bytesNeeded(drId); dos.write(bytesNeeded); byte[] bytes = new byte[bytesNeeded]; for (int i=bytesNeeded-1; i >=0; i--) { bytes[i] = (byte)(drId & 0xFF); drId >>=8; } dos.write(bytes); } }
private void putDiskRegionID(ByteBuffer bb, long drId) { // If the drId is <= 255 (max unsigned byte) then // encode it as a single byte. // Otherwise write a byte whose value is the number of bytes // it will be encoded by and then follow it with that many bytes. // Note that drId are not allowed to have a value in the range 1..8 inclusive. if (drId >= 0 && drId <= 255) { bb.put((byte)drId); } else { byte bytesNeeded = (byte)Oplog.bytesNeeded(drId); bb.put(bytesNeeded); byte[] bytes = new byte[bytesNeeded]; for (int i=bytesNeeded-1; i >=0; i--) { bytes[i] = (byte)(drId & 0xFF); drId >>=8; } bb.put(bytes); } }
size += 1 + 4 + val.length + Oplog.bytesNeeded(Oplog.abs(opKey)); break; case OP_DEL: size += Oplog.bytesNeeded(Oplog.abs(opKey)); break;
this.deltaIdBytesLength = bytesNeeded(delta); this.size += this.deltaIdBytesLength; this.opCode += this.deltaIdBytesLength - 1;
public void initialize(long oplogKeyId, byte[] keyBytes, byte[] valueBytes, byte userBits, long drId, VersionTag tag, boolean notToUseUserBits) throws IOException { this.opCode = OPLOG_MOD_ENTRY_WITH_KEY_1ID; this.size = 1;// for the opcode saveUserBits(notToUseUserBits, userBits); this.keyBytes = keyBytes; this.value = new DiskEntry.Helper.CompactorValueWrapper(valueBytes, valueBytes.length); if (this.userBits == 1 && this.value.getLength() == 0) { throw new IllegalStateException("userBits==1 and valueLength is 0"); } this.needsValue = EntryBits.isNeedsValue(this.userBits); this.size += (4 + this.keyBytes.length); saveDrId(drId); initVersionsBytes(tag); if (this.needsValue) { this.size += 4 + this.value.getLength(); } this.deltaIdBytesLength = 0; { long delta = calcDelta(oplogKeyId, this.opCode); this.deltaIdBytesLength = bytesNeeded(delta); this.size += this.deltaIdBytesLength; this.opCode += this.deltaIdBytesLength - 1; for (int i = this.deltaIdBytesLength - 1; i >= 0; i--) { this.deltaIdBytes[i] = (byte) (delta & 0xFF); delta >>= 8; } } this.size++; // for END_OF_RECORD_ID }
this.deltaIdBytesLength = bytesNeeded(delta); this.size += this.deltaIdBytesLength; this.opCode += this.deltaIdBytesLength - 1;
this.deltaIdBytesLength = bytesNeeded(delta); this.size += this.deltaIdBytesLength; this.opCode += this.deltaIdBytesLength - 1;