public void writeSegment(
UUID segmentId, byte[] data, int offset, int length) {
ByteBuffer buffer = ByteBuffer.allocate(length);
buffer.put(data, offset, length);
buffer.rewind();
Segment segment = new Segment(this, segmentId, buffer);
if (segments.putIfAbsent(segment.getSegmentId(), segment) != null) {
throw new IllegalStateException(
"Segment override: " + segment.getSegmentId());
}
}