@@ -0,0 +1,2172 @@
+%0A/*%0A * Copyright (C) 2015 Archie L. Cobbs. All rights reserved.%0A */%0A%0Apackage org.jsimpledb.kv.array;%0A%0Aimport com.google.common.collect.Lists;%0A%0Aimport java.io.ByteArrayOutputStream;%0Aimport java.nio.ByteBuffer;%0A%0Aimport org.jsimpledb.TestSupport;%0Aimport org.jsimpledb.kv.KeyRanges;%0Aimport org.jsimpledb.kv.mvcc.Writes;%0Aimport org.jsimpledb.kv.util.NavigableMapKVStore;%0Aimport org.jsimpledb.util.ByteUtil;%0Aimport org.testng.Assert;%0Aimport org.testng.annotations.Test;%0A%0Apublic class WriteMergedTest extends TestSupport %7B%0A%0A    @Test%0A    private void testWriteMerged() throws Exception %7B%0A%0A        // Setup k/v store%0A        final NavigableMapKVStore kvstore = new NavigableMapKVStore();%0A        kvstore.put(ByteUtil.parse(%220001%22), ByteUtil.parse(%22aaaa%22));%0A        kvstore.put(ByteUtil.parse(%22000101%22), ByteUtil.parse(%22bbbb%22));%0A        kvstore.put(ByteUtil.parse(%22000102%22), ByteUtil.parse(%22cccc%22));%0A        kvstore.put(ByteUtil.parse(%220002%22), ByteUtil.parse(%22dddd%22));%0A%0A        // Setup mutations%0A        final Writes writes = new Writes();%0A        writes.getPuts().put(ByteUtil.parse(%22000101%22), ByteUtil.parse(%22eeee%22));%0A        writes.getPuts().put(ByteUtil.parse(%22000102%22), ByteUtil.parse(%22ffff%22));%0A        writes.setRemoves(new KeyRanges(ByteUtil.parse(%220001%22), ByteUtil.parse(%220002%22)));%0A%0A        // Merge%0A        final ByteArrayOutputStream indxBuf = new ByteArrayOutputStream();%0A        final ByteArrayOutputStream keysBuf = new ByteArrayOutputStream();%0A        final ByteArrayOutputStream valsBuf = new ByteArrayOutputStream();%0A        final ArrayKVWriter writer = new ArrayKVWriter(indxBuf, keysBuf, valsBuf);%0A        writer.writeMerged(kvstore, kvstore.getRange(null, null, false), writes);%0A        writer.close();%0A        final ArrayKVStore actual = new ArrayKVStore(%0A          ByteBuffer.wrap(indxBuf.toByteArray()),%0A          ByteBuffer.wrap(keysBuf.toByteArray()),%0A          ByteBuffer.wrap(valsBuf.toByteArray()));%0A%0A        // Verify result%0A        writes.applyTo(kvstore);%0A        Assert.assertEquals(%0A          Lists.newArrayList(actual.getRange(null, null, false)).toString(),%0A          Lists.newArrayList(kvstore.getRange(null, null, false)).toString());%0A    %7D%0A%7D%0A%0A

Add unit test.