/** * Creates a new Excerpt containing and index which will be 1L << 17L bytes long, This method is * used for creating both the primary and secondary indexes. Chronicle Queue uses a root primary * index ( each entry in the primary index points to a unique a secondary index. The secondary * index only records the addressForRead of every 64th except, the except are linearly scanned from * there on. ) * * @param wire the current wire * @return the addressForRead of the Excerpt containing the usable index, just after the header */ long newIndex(@NotNull WireOut wire, boolean index2index) throws StreamCorruptedException { long writePosition = this.writePosition.getVolatileValue(); Bytes<?> bytes = wire.bytes(); bytes.writePosition(writePosition); long position = wire.enterHeader(indexCount * 8 + 128); WriteMarshallable writer = index2index ? index2IndexTemplate : indexTemplate; writer.writeMarshallable(wire); wire.updateHeader(position, true, 0); return position; }
/** * Creates a new Excerpt containing and index which will be 1L << 17L bytes long, This method is * used for creating both the primary and secondary indexes. Chronicle Queue uses a root primary * index ( each entry in the primary index points to a unique a secondary index. The secondary * index only records the addressForRead of every 64th except, the except are linearly scanned from * there on. ) * * @param wire the current wire * @return the addressForRead of the Excerpt containing the usable index, just after the header */ long newIndex(@NotNull WireOut wire, boolean index2index) throws StreamCorruptedException { long writePosition = this.writePosition.getVolatileValue(); Bytes<?> bytes = wire.bytes(); bytes.writePosition(writePosition); long position = wire.enterHeader(indexCount * 8 + 128); WriteMarshallable writer = index2index ? index2IndexTemplate : indexTemplate; writer.writeMarshallable(wire); wire.updateHeader(position, true, 0); return position; }