@Test public void testIterator() throws Exception { System.out.println("start iterator table"); long start = System.currentTimeMillis(); Iterator<String[]> iter = lookupTable.iterator(); int count = 0; while (iter.hasNext()) { iter.next(); count++; } long take = System.currentTimeMillis() - start; System.out.println("scan " + count + " rows, take " + take + " ms"); }
@Override public Iterator<String[]> iterator() { final RocksIterator rocksIterator = getRocksIterator(); rocksIterator.seekToFirst(); return new Iterator<String[]>() { int counter; @Override public boolean hasNext() { boolean valid = rocksIterator.isValid(); if (!valid) { rocksIterator.close(); } return valid; } @Override public String[] next() { counter++; if (counter % 100000 == 0) { logger.info("scanned {} rows from rocksDB", counter); } String[] result = rowEncoder.decode(new KV(rocksIterator.key(), rocksIterator.value())); rocksIterator.next(); return result; } @Override public void remove() { throw new UnsupportedOperationException("not support operation"); } }; }
RocksDBLookupTable implements ILookupTable { @Override public Iterator<String[]> iterator() { final RocksIterator rocksIterator = getRocksIterator(); rocksIterator.seekToFirst(); return new Iterator<String[]>() { int counter; @Override public boolean hasNext() { boolean valid = rocksIterator.isValid(); if (!valid) { rocksIterator.close(); } return valid; } @Override public String[] next() { counter++; if (counter % 100000 == 0) { logger.info("scanned {} rows from rocksDB", counter); } String[] result = rowEncoder.decode(new KV(rocksIterator.key(), rocksIterator.value())); rocksIterator.next(); return result; } @Override public void remove() { throw new UnsupportedOperationException("not support operation"); } }; } }
RocksDBLookupTable implements ILookupTable { @Override public Iterator<String[]> iterator() { final RocksIterator rocksIterator = getRocksIterator(); rocksIterator.seekToFirst(); return new Iterator<String[]>() { int counter; @Override public boolean hasNext() { boolean valid = rocksIterator.isValid(); if (!valid) { rocksIterator.close(); } return valid; } @Override public String[] next() { counter++; if (counter % 100000 == 0) { logger.info("scanned {} rows from rocksDB", counter); } String[] result = rowEncoder.decode(new KV(rocksIterator.key(), rocksIterator.value())); rocksIterator.next(); return result; } @Override public void remove() { throw new UnsupportedOperationException("not support operation"); } }; } RocksDBLookupTable(TableDesc tableDesc, String[] keyColumns, String dbPath); }
RocksDBLookupTable implements ILookupTable { @Override public Iterator<String[]> iterator() { final RocksIterator rocksIterator = getRocksIterator(); rocksIterator.seekToFirst(); return new Iterator<String[]>() { int counter; @Override public boolean hasNext() { boolean valid = rocksIterator.isValid(); if (!valid) { rocksIterator.close(); } return valid; } @Override public String[] next() { counter++; if (counter % 100000 == 0) { logger.info("scanned {} rows from rocksDB", counter); } String[] result = rowEncoder.decode(new KV(rocksIterator.key(), rocksIterator.value())); rocksIterator.next(); return result; } @Override public void remove() { throw new UnsupportedOperationException("not support operation"); } }; } RocksDBLookupTable(TableDesc tableDesc, String[] keyColumns, String dbPath); @Override String[] getRow(Array<String> key); @Override Iterator<String[]> iterator(); @Override void close(); }
RocksDBLookupTable implements ILookupTable { @Override public Iterator<String[]> iterator() { final RocksIterator rocksIterator = getRocksIterator(); rocksIterator.seekToFirst(); return new Iterator<String[]>() { int counter; @Override public boolean hasNext() { boolean valid = rocksIterator.isValid(); if (!valid) { rocksIterator.close(); } return valid; } @Override public String[] next() { counter++; if (counter % 100000 == 0) { logger.info("scanned {} rows from rocksDB", counter); } String[] result = rowEncoder.decode(new KV(rocksIterator.key(), rocksIterator.value())); rocksIterator.next(); return result; } @Override public void remove() { throw new UnsupportedOperationException("not support operation"); } }; } RocksDBLookupTable(TableDesc tableDesc, String[] keyColumns, String dbPath); @Override String[] getRow(Array<String> key); @Override Iterator<String[]> iterator(); @Override void close();  }