void finish(final SBIIndex.Header header, final long finalVirtualOffset) { // complete writing the temp offsets file writeVirtualOffset(finalVirtualOffset); tempOffsetsCodec.close(); try (BinaryCodec binaryCodec = new BinaryCodec(out); InputStream tempOffsets = new BufferedInputStream(Files.newInputStream(tempOffsetsFile))) { // header binaryCodec.writeBytes(SBIIndex.SBI_MAGIC); binaryCodec.writeLong(header.getFileLength()); binaryCodec.writeBytes(header.getMd5()); binaryCodec.writeBytes(header.getUuid()); binaryCodec.writeLong(header.getTotalNumberOfRecords()); binaryCodec.writeLong(header.getGranularity()); binaryCodec.writeLong(virtualOffsetCount); // offsets IOUtil.copyStream(tempOffsets, out); } catch (IOException e) { throw new RuntimeIOException(e); } finally { try { Files.delete(tempOffsetsFile); } catch (IOException e) { throw new RuntimeIOException(e); } } } }
void finish(final SBIIndex.Header header, final long finalVirtualOffset) { // complete writing the temp offsets file writeVirtualOffset(finalVirtualOffset); tempOffsetsCodec.close(); try (BinaryCodec binaryCodec = new BinaryCodec(out); InputStream tempOffsets = new BufferedInputStream(Files.newInputStream(tempOffsetsFile))) { // header binaryCodec.writeBytes(SBIIndex.SBI_MAGIC); binaryCodec.writeLong(header.getFileLength()); binaryCodec.writeBytes(header.getMd5()); binaryCodec.writeBytes(header.getUuid()); binaryCodec.writeLong(header.getTotalNumberOfRecords()); binaryCodec.writeLong(header.getGranularity()); binaryCodec.writeLong(virtualOffsetCount); // offsets IOUtil.copyStream(tempOffsets, out); } catch (IOException e) { throw new RuntimeIOException(e); } finally { try { Files.delete(tempOffsetsFile); } catch (IOException e) { throw new RuntimeIOException(e); } } } }
/** * Returns the length of the data file in bytes. * * @return the length of the data file in bytes */ public long dataFileLength() { return header.getFileLength(); }
/** * Returns the length of the data file in bytes. * * @return the length of the data file in bytes */ public long dataFileLength() { return header.getFileLength(); }