RecordFile implements Iterable<byte[]> { public void write(long record, byte[] bytes) throws IOException { if (readonly) { throw new UnsupportedOperationException(RO_MSG); } if (bytes.length != recordSize) { final String fmt = "invalid write of %d bytes, expected %d"; final String msg = format(fmt, bytes.length, recordSize); throw new InvalidArgument(msg); } long pos = record * recordSize + recordSize; if (pos >= size) { final String fmt = "bad seek to position: %d (size is %d)"; final String msg = format(fmt, pos, size); throw new InvalidArgument(msg); } raf.seek(pos); raf.write(bytes); } RecordFile(final File path, final RecordMode mode,
            final Column<?>... columns); byte[] read(long record); void read(long record, byte[] bytes); byte[] read(long record, int column); void read(long record, int column, byte[] bytes); void write(long record, byte[] bytes); void write(long record, int column, byte[] bytes); void append(byte[] bytes); byte[] readMetadata(); void readMetadata(byte[] bytes); @Deprecated void writeMetadata(byte[] bytes); @Override Iterator<byte[]> iterator(); final String getPath(); final Column<?>[] getColumns(); final int getRecordSize(); final boolean isReadOnly(); final boolean isReadWrite(); final long getRecordCount(); final long getSize();  }
@Test public void testWrite() { testAppend(); assertFalse(test.size == 0); assertFalse(test.size == test.mocksize); assertTrue(test.recordCt == 1); long size = test.size; byte[] buffer = new byte[test.recordSize]; random.nextBytes(buffer); try { test.write(0, buffer); } catch (IOException e) { e.printStackTrace(); fail("unexpected exception: " + e); } assertEquals(size, test.size); assertTrue(test.recordCt == 1); int column = 0; buffer = new byte[columns[column].size]; random.nextBytes(buffer); try { test.write(0, column, buffer); } catch (IOException e) { e.printStackTrace(); fail("unexpected exception: " + e); } assertEquals(size, test.size); assertTrue(test.recordCt == 1); }