/** * Creates a new instance of IndexedChronicle as specified by the provided {@link * net.openhft.chronicle.ChronicleQueueBuilder} and having the specified <tt>basePath</tt> (the * base name of the two backing files). * * @param builder the builder u * @throws FileNotFoundException if the <tt>basePath</tt> string does not denote an existing, * writable regular file and a new regular file of that name * cannot be created, or if some other error occurs while opening * or creating the file */ IndexedChronicle(@NotNull ChronicleQueueBuilder.IndexedChronicleQueueBuilder builder) throws IOException { this.builder = builder.clone(); this.basePath = builder.path().getAbsolutePath(); File parentFile = builder.path().getParentFile(); if (parentFile != null) { parentFile.mkdirs(); } this.indexFileCache = VanillaMappedBlocks.readWrite(new File(basePath + ".index"), builder.indexBlockSize(), builder.fileLifecycleListener()); this.dataFileCache = VanillaMappedBlocks.readWrite(new File(basePath + ".data"), builder.dataBlockSize(), builder.fileLifecycleListener()); findTheLastIndex(); }
public void startExcerpt(long capacity) { checkNotClosed(); // in case there is more than one appender :P if (index != size()) { super.toEndForAppend0(); } if (capacity >= IndexedChronicle.this.builder.dataBlockSize()) { throw new IllegalArgumentException( "Capacity too large " + capacity + " >= " + IndexedChronicle.this.builder.dataBlockSize()); } // if the capacity is to large, roll the previous entry, and there was one if (positionAddr + capacity > dataStartAddr + dataBlockSize) { // check we are the start of a block. checkNewIndexLine(); writePaddedEntry(); try { loadNextDataBuffer(); } catch (IOException e) { throw new IllegalStateException(e); } } // check we are the start of a block. checkNewIndexLine(); // update the soft limitAddr startAddr = positionAddr; limitAddr = positionAddr + capacity; finished = false; nextSynchronous = IndexedChronicle.this.builder.synchronous(); }
protected AbstractIndexedExcerpt() throws IOException { //super(new VanillaBytesMarshallerFactory(), NO_PAGE, NO_PAGE, null); super( BytesMarshallableSerializer.create( new VanillaBytesMarshallerFactory(), builder.useCompressedObjectSerializer() ? JDKZObjectSerializer.INSTANCE : JDKObjectSerializer.INSTANCE), NO_PAGE, NO_PAGE, null ); cacheLineSize = IndexedChronicle.this.builder.cacheLineSize(); cacheLineMask = (cacheLineSize - 1); dataBlockSize = IndexedChronicle.this.builder.dataBlockSize(); indexBlockSize = IndexedChronicle.this.builder.indexBlockSize(); indexEntriesPerLine = (cacheLineSize - 8) / 4; indexEntriesPerBlock = indexBlockSize * indexEntriesPerLine / cacheLineSize; loadIndexBuffer(); loadDataBuffer(); finished = true; }
/** * A pre-defined ChronicleBuilder for test {@link net.openhft.chronicle.Chronicle} * instances. * <p> * It has the following params: <ul> <li>data block size <b>8k</b></li> </ul> */ IndexedChronicleQueueBuilder test() { dataBlockSize(8 * 1024); return this; }
/** * A pre-defined ChronicleBuilder for medium {@link net.openhft.chronicle.Chronicle} * instances. * <p> * It has the following params: <ul> <li>data block size <b>128M</b></li> </ul> */ public IndexedChronicleQueueBuilder medium() { dataBlockSize(128 * 1024 * 1024); return this; }
/** * A pre-defined ChronicleBuilder for large {@link net.openhft.chronicle.Chronicle} * instances. * <p> * It has the following params: <ul> <li>data block size <b>512M</b></li> </ul> */ public IndexedChronicleQueueBuilder large() { dataBlockSize(512 * 1024 * 1024); return this; }
/** * A pre-defined ChronicleBuilder for small {@link net.openhft.chronicle.Chronicle} * instances. * <p> * It has the following params: <ul> <li>data block size <b>16M</b></li> </ul> */ public IndexedChronicleQueueBuilder small() { dataBlockSize(16 * 1024 * 1024); return this; }