Segment implements Itemizable, Syncable { @Override public void fsync(Path file) { Preconditions.checkState(mutable, "Cannot fsync an immutable Segment"); readLock.lock(); try { this.mutable = false; this.syncTs = Time.now(); this.count = index.count(); Folio tableFolio = table.serialize(); Folio indexFolio = index.serialize(); Folio corpusFolio = corpus.serialize(); int size = METADATA_LENGTH + table.filter().size() + index.filter().size() + corpus.filter().size() + tableFolio.manifest().size() + indexFolio.manifest().size() + corpusFolio.manifest().size() + table.size() + index.size() + corpus.size() ; if(size <= MMAP_WRITE_UPPER_LIMIT) { mmap(file, size, tableFolio, indexFolio, corpusFolio); } else { write(file, size, tableFolio, indexFolio, corpusFolio); } } finally { readLock.unlock(); } } private  Segment(int expectedInsertions); private  Segment(Path file); static Segment create(); static Segment create(int expectedInsertions); static Segment load(Path file); CorpusChunk corpus(); @Override long count(); @Override boolean equals(Object other); @Override void fsync(Path file); @Override int hashCode(); String id(); IndexChunk index(); String label(); boolean isMutable(); Segment reindex(); double similarityWith(Segment other); long size(); TableChunk table(); @Override String toString(); Receipt transfer(Write write); Receipt transfer(Write write, AwaitableExecutorService executor); Stream<Write> writes(); static Comparator<Segment> TEMPORAL_COMPARATOR; }
@Test(expected = IllegalStateException.class) public void testCannotSyncEmptySegment() { Path file = Paths.get(TestData.getTemporaryTestFile()); segment.fsync(file); }