@Test public void testChecksum() { assertEquals(record.checksum(), record.computeChecksum()); byte attributes = LegacyRecord.computeAttributes(magic, this.compression, TimestampType.CREATE_TIME); assertEquals(record.checksum(), LegacyRecord.computeChecksum( magic, attributes, this.timestamp, this.key == null ? null : this.key.array(), this.value == null ? null : this.value.array() )); assertTrue(record.isValid()); for (int i = LegacyRecord.CRC_OFFSET + LegacyRecord.CRC_LENGTH; i < record.sizeInBytes(); i++) { LegacyRecord 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 ByteUtils.readUnsignedInt(buffer, CRC_OFFSET); }
LegacyRecord { public long checksum() { return ByteUtils.readUnsignedInt(buffer, CRC_OFFSET); } }
LegacyRecord { public long checksum() { return ByteUtils.readUnsignedInt(buffer, CRC_OFFSET); } LegacyRecord(ByteBuffer buffer);  LegacyRecord(ByteBuffer buffer, Long wrapperRecordTimestamp, TimestampType wrapperRecordTimestampType); }
LegacyRecord { public long checksum() { return ByteUtils.readUnsignedInt(buffer, CRC_OFFSET); } LegacyRecord(ByteBuffer buffer);  LegacyRecord(ByteBuffer buffer, Long wrapperRecordTimestamp, TimestampType wrapperRecordTimestampType); long computeChecksum(); long checksum(); boolean isValid(); Long wrapperRecordTimestamp(); TimestampType wrapperRecordTimestampType(); void ensureValid(); int sizeInBytes(); int keySize(); boolean hasKey(); int valueSize(); boolean hasNullValue(); byte magic(); byte attributes(); long timestamp(); TimestampType timestampType(); CompressionType compressionType(); ByteBuffer value(); ByteBuffer key(); ByteBuffer buffer(); String toString(); boolean equals(Object other); int hashCode(); static LegacyRecord create(byte magic,
                                      long timestamp,
                                      byte[] key,
                                      byte[] value,
                                      CompressionType compressionType,
                                      TimestampType timestampType); static LegacyRecord create(byte magic, long timestamp, byte[] key, byte[] value); static void writeCompressedRecordHeader(ByteBuffer buffer,
                                                   byte magic,
                                                   int recordSize,
                                                   long timestamp,
                                                   CompressionType compressionType,
                                                   TimestampType timestampType); static long write(DataOutputStream out,
                             byte magic,
                             long timestamp,
                             byte[] key,
                             byte[] value,
                             CompressionType compressionType,
                             TimestampType timestampType); static long write(DataOutputStream out,
                             byte magic,
                             long timestamp,
                             ByteBuffer key,
                             ByteBuffer value,
                             CompressionType compressionType,
                             TimestampType timestampType); static void write(DataOutputStream out,
                             byte magic,
                             long crc,
                             byte attributes,
                             long timestamp,
                             byte[] key,
                             byte[] value); static int recordSize(byte magic, int keySize, int valueSize); static byte computeAttributes(byte magic, CompressionType type, TimestampType timestampType); static long computeChecksum(byte magic, byte attributes, long timestamp, byte[] key, byte[] value); static TimestampType timestampType(byte magic, TimestampType wrapperRecordTimestampType, byte attributes); }
LegacyRecord { public long checksum() { return ByteUtils.readUnsignedInt(buffer, CRC_OFFSET); } LegacyRecord(ByteBuffer buffer);  LegacyRecord(ByteBuffer buffer, Long wrapperRecordTimestamp, TimestampType wrapperRecordTimestampType); long computeChecksum(); long checksum(); boolean isValid(); Long wrapperRecordTimestamp(); TimestampType wrapperRecordTimestampType(); void ensureValid(); int sizeInBytes(); int keySize(); boolean hasKey(); int valueSize(); boolean hasNullValue(); byte magic(); byte attributes(); long timestamp(); TimestampType timestampType(); CompressionType compressionType(); ByteBuffer value(); ByteBuffer key(); ByteBuffer buffer(); String toString(); boolean equals(Object other); int hashCode(); static LegacyRecord create(byte magic,
                                      long timestamp,
                                      byte[] key,
                                      byte[] value,
                                      CompressionType compressionType,
                                      TimestampType timestampType); static LegacyRecord create(byte magic, long timestamp, byte[] key, byte[] value); static void writeCompressedRecordHeader(ByteBuffer buffer,
                                                   byte magic,
                                                   int recordSize,
                                                   long timestamp,
                                                   CompressionType compressionType,
                                                   TimestampType timestampType); static long write(DataOutputStream out,
                             byte magic,
                             long timestamp,
                             byte[] key,
                             byte[] value,
                             CompressionType compressionType,
                             TimestampType timestampType); static long write(DataOutputStream out,
                             byte magic,
                             long timestamp,
                             ByteBuffer key,
                             ByteBuffer value,
                             CompressionType compressionType,
                             TimestampType timestampType); static void write(DataOutputStream out,
                             byte magic,
                             long crc,
                             byte attributes,
                             long timestamp,
                             byte[] key,
                             byte[] value); static int recordSize(byte magic, int keySize, int valueSize); static byte computeAttributes(byte magic, CompressionType type, TimestampType timestampType); static long computeChecksum(byte magic, byte attributes, long timestamp, byte[] key, byte[] value); static TimestampType timestampType(byte magic, TimestampType wrapperRecordTimestampType, byte attributes); 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 ATTRIBUTES_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_V0; static final int HEADER_SIZE_V1; static final int RECORD_OVERHEAD_V0; static final int RECORD_OVERHEAD_V1; static final long NO_TIMESTAMP; }