### Question:
StringIndex implements Storable<StringIndex> { @Override public void flush() { keys.ensureCapacity(2); keys.setShort(0, (short) keysInMem.size()); long keyBytePointer = 2; for (String key : keysInMem.keySet()) { byte[] keyBytes = getBytesForString("key", key); keys.ensureCapacity(keyBytePointer + 2 + keyBytes.length); keys.setShort(keyBytePointer, (short) keyBytes.length); keyBytePointer += 2; keys.setBytes(keyBytePointer, keyBytes, keyBytes.length); keyBytePointer += keyBytes.length; } keys.flush(); vals.setHeader(0, BitUtil.LITTLE.getIntLow(bytePointer)); vals.setHeader(4, BitUtil.LITTLE.getIntHigh(bytePointer)); vals.flush(); } StringIndex(Directory dir);  StringIndex(Directory dir, final int cacheSize); @Override StringIndex create(long initBytes); @Override boolean loadExisting(); long add(Map<String, String> entryMap); Map<String, String> getAll(final long entryPointer); String get(final long entryPointer, String key); @Override void flush(); @Override void close(); @Override boolean isClosed(); void setSegmentSize(int segments); @Override long getCapacity(); void copyTo(StringIndex stringIndex);  }### Answer:
@Test public void testFlush() { String location = "./target/stringindex-store"; Helper.removeDir(new File(location)); StringIndex index = new StringIndex(new RAMDirectory(location, true).create()).create(1000); long pointer = index.add(createMap("", "test")); index.flush(); index.close(); index = new StringIndex(new RAMDirectory(location, true)); assertTrue(index.loadExisting()); assertEquals("test", index.get(pointer, "")); long newPointer = index.add(createMap("", "testing")); assertEquals(newPointer + ">" + pointer, pointer + 1 + 3 + "test".getBytes().length, newPointer); index.close(); Helper.removeDir(new File(location)); }