UUID segmentId, byte[] data, int offset, int length,
Collection<UUID> referencedSegmentIds,
Map<String, RecordId> strings, Map<Template, RecordId> templates) {
byte[] buffer = new byte[length];
System.arraycopy(data, offset, buffer, 0, length);
Segment segment = new Segment(
this, segmentId, ByteBuffer.wrap(buffer),
referencedSegmentIds, strings, templates);
if (segments.putIfAbsent(segment.getSegmentId(), segment) != null) {
throw new IllegalStateException(
"Segment override: " + segment.getSegmentId());
}
}