@Override protected SortedReader<ByteBuffer> createReader(NavigableMap<byte[], byte[]> data) throws IOException { SortedOplogConfiguration config = new SortedOplogConfiguration("test"); hfile = new HFileSortedOplog(new File("test.soplog"), config); SortedOplogWriter wtr = hfile.createWriter(); for (Entry<byte[], byte[]> entry : data.entrySet()) { wtr.append(entry.getKey(), entry.getValue()); } wtr.close(null); return hfile.createReader(); } }
@Override protected SortedReader<ByteBuffer> createReader(NavigableMap<byte[], byte[]> data) throws IOException { mfile = new NoFileSortedOplog(new SortedOplogConfiguration("nofile")); SortedOplogWriter wtr = mfile.createWriter(); for (Entry<byte[], byte[]> entry : data.entrySet()) { wtr.append(entry.getKey(), entry.getValue()); } wtr.close(null); return mfile.createReader(); } }
public void testReadAndWrite() throws Exception { SortedOplogConfiguration config = new SortedOplogConfiguration("lex") .setComparator(new LexicographicalComparator()); hfile = new HFileSortedOplog(new File("lexi.soplog"), config); SortedOplogWriter wtr = hfile.createWriter(); for (int i = -100; i < 100; i++) { wtr.append(ComparisonTestCase.convert(i), ComparisonTestCase.convert(i)); } wtr.close(null); SortedReader<ByteBuffer> rdr = hfile.createReader(); for (int i = -100; i < 100; i++) { byte[] key = ComparisonTestCase.convert(i); assertTrue(rdr.mightContain(key)); ByteBuffer val = rdr.read(key); assertEquals(i, ComparisonTestCase.recover(val.array(), val.arrayOffset(), val.remaining())); } rdr.close(); }
wtr.close(metadata); return soplog;
wtr.close(null);
wtr.close(null);
writer.close(buffer.getMetadata()); return so;
wtr.append(key, subkey); wtr.close(null);
protected SortedOplog createSoplog(int start, int count, int id) throws IOException { SortedOplog soplog = factory.createSortedOplog(new File("test-" + id + ".soplog")); SortedOplogWriter wtr = soplog.createWriter(); try { for (int i = start; i < start + count; i++) { wtr.append(SortedReaderTestCase.wrapInt(i), SortedReaderTestCase.wrapInt(i)); } } finally { wtr.close(null); } return soplog; }