@Test public void testContinue() throws Exception { SortedMap<Key,Value> map1 = new TreeMap<>(); pkv(map1, "row1", "cf1", "cq1", "cv1", 5, "foo"); pkv(map1, "row1", "cf1", "cq2", "cv1", 6, "bar"); SortedMap<Key,Value> map2 = new TreeMap<>(); pkv(map2, "row2", "cf1", "cq1", "cv1", 5, "foo"); pkv(map2, "row2", "cf1", "cq2", "cv1", 6, "bar"); SortedMap<Key,Value> map3 = new TreeMap<>(); pkv(map3, "row3", "cf1", "cq1", "cv1", 5, "foo"); pkv(map3, "row3", "cf1", "cq2", "cv1", 6, "bar"); SortedMap<Key,Value> map = new TreeMap<>(); map.putAll(map1); map.putAll(map2); map.putAll(map3); SortedMapIterator source = new SortedMapIterator(map); WholeRowIterator iter = new WholeRowIterator(source); Range range = new Range(new Text("row1"), true, new Text("row2"), true); iter.seek(range, new ArrayList<>(), false); assertTrue(iter.hasTop()); assertEquals(map1, WholeRowIterator.decodeRow(iter.getTopKey(), iter.getTopValue())); range = new Range(iter.getTopKey(), false, range.getEndKey(), range.isEndKeyInclusive()); iter.seek(range, new ArrayList<>(), false); assertTrue(iter.hasTop()); assertEquals(map2, WholeRowIterator.decodeRow(iter.getTopKey(), iter.getTopValue())); iter.next(); assertFalse(iter.hasTop()); }
public static final SortedMap<Key,Value> decodeRow(Key rowKey, Value rowValue) throws IOException { SortedMap<Key,Value> map = new TreeMap<>(); ByteArrayInputStream in = new ByteArrayInputStream(rowValue.get()); DataInputStream din = new DataInputStream(in); int numKeys = din.readInt(); for (int i = 0; i < numKeys; i++) { byte[] cf = readField(din); byte[] cq = readField(din); byte[] cv = readField(din); long timestamp = din.readLong(); byte[] valBytes = readField(din); map.put(new Key(rowKey.getRowData().toArray(), cf, cq, cv, timestamp, false, false), new Value(valBytes, false)); } return map; }
WholeRowIterator extends RowEncodingIterator { public static final SortedMap<Key,Value> decodeRow(Key rowKey, Value rowValue) throws IOException { SortedMap<Key,Value> map = new TreeMap<>(); ByteArrayInputStream in = new ByteArrayInputStream(rowValue.get()); DataInputStream din = new DataInputStream(in); int numKeys = din.readInt(); for (int i = 0; i < numKeys; i++) { byte[] cf = readField(din); byte[] cq = readField(din); byte[] cv = readField(din); long timestamp = din.readLong(); byte[] valBytes = readField(din); map.put(new Key(rowKey.getRowData().toArray(), cf, cq, cv, timestamp, false, false), new Value(valBytes, false)); } return map; } }
WholeRowIterator extends RowEncodingIterator { public static final SortedMap<Key,Value> decodeRow(Key rowKey, Value rowValue) throws IOException { SortedMap<Key,Value> map = new TreeMap<>(); ByteArrayInputStream in = new ByteArrayInputStream(rowValue.get()); DataInputStream din = new DataInputStream(in); int numKeys = din.readInt(); for (int i = 0; i < numKeys; i++) { byte[] cf = readField(din); byte[] cq = readField(din); byte[] cv = readField(din); long timestamp = din.readLong(); byte[] valBytes = readField(din); map.put(new Key(rowKey.getRowData().toArray(), cf, cq, cv, timestamp, false, false), new Value(valBytes, false)); } return map; } WholeRowIterator();   WholeRowIterator(SortedKeyValueIterator<Key,Value> source); }
WholeRowIterator extends RowEncodingIterator { public static final SortedMap<Key,Value> decodeRow(Key rowKey, Value rowValue) throws IOException { SortedMap<Key,Value> map = new TreeMap<>(); ByteArrayInputStream in = new ByteArrayInputStream(rowValue.get()); DataInputStream din = new DataInputStream(in); int numKeys = din.readInt(); for (int i = 0; i < numKeys; i++) { byte[] cf = readField(din); byte[] cq = readField(din); byte[] cv = readField(din); long timestamp = din.readLong(); byte[] valBytes = readField(din); map.put(new Key(rowKey.getRowData().toArray(), cf, cq, cv, timestamp, false, false), new Value(valBytes, false)); } return map; } WholeRowIterator();   WholeRowIterator(SortedKeyValueIterator<Key,Value> source); @Override SortedMap<Key,Value> rowDecoder(Key rowKey, Value rowValue); @Override Value rowEncoder(List<Key> keys, List<Value> values); static final SortedMap<Key,Value> decodeRow(Key rowKey, Value rowValue); static final Value encodeRow(List<Key> keys, List<Value> values); }
WholeRowIterator extends RowEncodingIterator { public static final SortedMap<Key,Value> decodeRow(Key rowKey, Value rowValue) throws IOException { SortedMap<Key,Value> map = new TreeMap<>(); ByteArrayInputStream in = new ByteArrayInputStream(rowValue.get()); DataInputStream din = new DataInputStream(in); int numKeys = din.readInt(); for (int i = 0; i < numKeys; i++) { byte[] cf = readField(din); byte[] cq = readField(din); byte[] cv = readField(din); long timestamp = din.readLong(); byte[] valBytes = readField(din); map.put(new Key(rowKey.getRowData().toArray(), cf, cq, cv, timestamp, false, false), new Value(valBytes, false)); } return map; } WholeRowIterator();   WholeRowIterator(SortedKeyValueIterator<Key,Value> source); @Override SortedMap<Key,Value> rowDecoder(Key rowKey, Value rowValue); @Override Value rowEncoder(List<Key> keys, List<Value> values); static final SortedMap<Key,Value> decodeRow(Key rowKey, Value rowValue); static final Value encodeRow(List<Key> keys, List<Value> values);  }