@Test public void testChecksum() { assertEquals(record.checksum(), record.computeChecksum()); assertEquals(record.checksum(), Record.computeChecksum( this.timestamp, this.key == null ? null : this.key.array(), this.value == null ? null : this.value.array(), this.compression, 0, -1)); assertTrue(record.isValid()); for (int i = Record.CRC_OFFSET + Record.CRC_LENGTH; i < record.size(); i++) { Record copy = copyOf(record); copy.buffer().put(i, (byte) 69); assertFalse(copy.isValid()); try { copy.ensureValid(); fail("Should fail the above test."); } catch (InvalidRecordException e) { } } }
public long checksum() { return Utils.readUnsignedInt(buffer, CRC_OFFSET); }
Record { public long checksum() { return Utils.readUnsignedInt(buffer, CRC_OFFSET); } }
Record { public long checksum() { return Utils.readUnsignedInt(buffer, CRC_OFFSET); } Record(ByteBuffer buffer);   Record(ByteBuffer buffer, Long wrapperRecordTimestamp, TimestampType wrapperRecordTimestampType);  Record(long timestamp, byte[] key, byte[] value, CompressionType type, int valueOffset, int valueSize);  Record(long timestamp, byte[] key, byte[] value, CompressionType type);  Record(long timestamp, byte[] value, CompressionType type);  Record(long timestamp, byte[] key, byte[] value);  Record(long timestamp, byte[] value); }
Record { public long checksum() { return Utils.readUnsignedInt(buffer, CRC_OFFSET); } Record(ByteBuffer buffer);   Record(ByteBuffer buffer, Long wrapperRecordTimestamp, TimestampType wrapperRecordTimestampType);  Record(long timestamp, byte[] key, byte[] value, CompressionType type, int valueOffset, int valueSize);  Record(long timestamp, byte[] key, byte[] value, CompressionType type);  Record(long timestamp, byte[] value, CompressionType type);  Record(long timestamp, byte[] key, byte[] value);  Record(long timestamp, byte[] value); static void write(ByteBuffer buffer, long timestamp, byte[] key, byte[] value, CompressionType type, int valueOffset, int valueSize); static void write(Compressor compressor, long crc, byte attributes, long timestamp, byte[] key, byte[] value, int valueOffset, int valueSize); static int recordSize(byte[] key, byte[] value); static int recordSize(int keySize, int valueSize); ByteBuffer buffer(); static byte computeAttributes(CompressionType type); static long computeChecksum(ByteBuffer buffer, int position, int size); static long computeChecksum(long timestamp, byte[] key, byte[] value, CompressionType type, int valueOffset, int valueSize); long computeChecksum(); long checksum(); boolean isValid(); void ensureValid(); int size(); int keySize(); boolean hasKey(); int valueSize(); byte magic(); byte attributes(); long timestamp(); TimestampType timestampType(); CompressionType compressionType(); ByteBuffer value(); ByteBuffer key(); String toString(); boolean equals(Object other); int hashCode(); }
Record { public long checksum() { return Utils.readUnsignedInt(buffer, CRC_OFFSET); } Record(ByteBuffer buffer);   Record(ByteBuffer buffer, Long wrapperRecordTimestamp, TimestampType wrapperRecordTimestampType);  Record(long timestamp, byte[] key, byte[] value, CompressionType type, int valueOffset, int valueSize);  Record(long timestamp, byte[] key, byte[] value, CompressionType type);  Record(long timestamp, byte[] value, CompressionType type);  Record(long timestamp, byte[] key, byte[] value);  Record(long timestamp, byte[] value); static void write(ByteBuffer buffer, long timestamp, byte[] key, byte[] value, CompressionType type, int valueOffset, int valueSize); static void write(Compressor compressor, long crc, byte attributes, long timestamp, byte[] key, byte[] value, int valueOffset, int valueSize); static int recordSize(byte[] key, byte[] value); static int recordSize(int keySize, int valueSize); ByteBuffer buffer(); static byte computeAttributes(CompressionType type); static long computeChecksum(ByteBuffer buffer, int position, int size); static long computeChecksum(long timestamp, byte[] key, byte[] value, CompressionType type, int valueOffset, int valueSize); long computeChecksum(); long checksum(); boolean isValid(); void ensureValid(); int size(); int keySize(); boolean hasKey(); int valueSize(); byte magic(); byte attributes(); long timestamp(); TimestampType timestampType(); CompressionType compressionType(); ByteBuffer value(); ByteBuffer key(); String toString(); boolean equals(Object other); int hashCode(); static final int CRC_OFFSET; static final int CRC_LENGTH; static final int MAGIC_OFFSET; static final int MAGIC_LENGTH; static final int ATTRIBUTES_OFFSET; static final int ATTRIBUTE_LENGTH; static final int TIMESTAMP_OFFSET; static final int TIMESTAMP_LENGTH; static final int KEY_SIZE_OFFSET_V0; static final int KEY_SIZE_OFFSET_V1; static final int KEY_SIZE_LENGTH; static final int KEY_OFFSET_V0; static final int KEY_OFFSET_V1; static final int VALUE_SIZE_LENGTH; static final int HEADER_SIZE; static final int RECORD_OVERHEAD; static final byte MAGIC_VALUE_V0; static final byte MAGIC_VALUE_V1; static final byte CURRENT_MAGIC_VALUE; static final int COMPRESSION_CODEC_MASK; static final byte TIMESTAMP_TYPE_MASK; static final int TIMESTAMP_TYPE_ATTRIBUTE_OFFSET; static final int NO_COMPRESSION; static final long NO_TIMESTAMP; }