public KeyIterator<K> build() { return new KeyIterator<K>(this); }
private void runQuery(K start, K end) { query.setKeys(start, end); if(!firstRun) { query.setRowCount(rowCount); } rowsIterator = null; QueryResult<OrderedRows<K, String, String>> result = query.execute(); OrderedRows<K, String, String> rows = (result != null) ? result.get() : null; rowsIterator = (rows != null) ? rows.iterator() : null; // we'll skip this first one, since it is the same as the last one from previous time we executed if (!firstRun && rowsIterator != null) rowsIterator.next(); firstRun = false; if (rowsIterator != null && !rowsIterator.hasNext()) { nextValue = null; // all done. our iterator's hasNext() will now return false; } else { findNext(true); } }
private void findNext(boolean fromRunQuery) { nextValue = null; if (rowsIterator == null) { return; } while (rowsIterator.hasNext() && nextValue == null) { Row<K, String, String> row = rowsIterator.next(); lastReadValue = row.getKey(); if (!row.getColumnSlice().getColumns().isEmpty()) { nextValue = lastReadValue; } } if (!rowsIterator.hasNext() && nextValue == null) { runQuery(lastReadValue, endKey); } }
@Override public Iterator<K> keyIterator() { return new Builder<K>(_keyspace, _cf_name, _serializer_k).build().iterator(); }
@Override public Iterator<K> keyIterator() { return new Builder<K>(_keyspace, _cf_name, _serializer_k).build().iterator(); }
@Deprecated /* * When pulling deprecated methods out, do not remove this but change it to private constructor */ public KeyIterator(Keyspace keyspace, String columnFamily, Serializer<K> serializer, K start, K end, int maxRowCount) { query = HFactory .createRangeSlicesQuery(keyspace, serializer, stringSerializer, stringSerializer) .setColumnFamily(columnFamily) .setRange(null, null, false, maxColumnCount) .setRowCount(maxRowCount); endKey = end; if(maxRowCount < Integer.MAX_VALUE) { rowCount = maxRowCount+1; //to compensate the first entry skip (except in first run) } runQuery(start, end); }
private Iterator<byte[]> _rowIter = new Builder<byte[]>(_dataAccessLayerFactory.getKeyspace(), S_POC, BYTE_SERIALIZER).build().iterator(); private byte[] _lastRowkey = null; private ColumnSliceIterator<byte[], Composite, byte[]> _colIter = null;
public KeyIterator<K> build() { return new KeyIterator<K>(this); }
private void runQuery(K start, K end) { query.setKeys(start, end); rowsIterator = null; QueryResult<OrderedRows<K, String, String>> result = query.execute(); OrderedRows<K, String, String> rows = (result != null) ? result.get() : null; rowsIterator = (rows != null) ? rows.iterator() : null; // we'll skip this first one, since it is the same as the last one from previous time we executed if (!firstRun && rowsIterator != null) rowsIterator.next(); firstRun = false; if (!rowsIterator.hasNext()) { nextValue = null; // all done. our iterator's hasNext() will now return false; } else { findNext(true); } }
private void findNext(boolean fromRunQuery) { nextValue = null; if (rowsIterator == null) { return; } while (rowsIterator.hasNext() && nextValue == null) { Row<K, String, String> row = rowsIterator.next(); lastReadValue = row.getKey(); if (!row.getColumnSlice().getColumns().isEmpty()) { nextValue = lastReadValue; } } if (!rowsIterator.hasNext() && nextValue == null) { runQuery(lastReadValue, endKey); } }
private Iterator<byte[]> _rowIter = new Builder<byte[]>(_dataAccessLayerFactory.getKeyspace(), S_POC, BYTE_SERIALIZER).build().iterator(); private byte[] _lastRowkey = null; private ColumnSliceIterator<byte[], Composite, byte[]> _colIter = null;
public static void main(String[] args) { long startTime = System.currentTimeMillis(); init(); ExecutorService exec = Executors.newFixedThreadPool(5); List<Future<Integer>> futures = new ArrayList<Future<Integer>>(); // request 50 invocation of RowInserter // each invocation creates 20 rows, thus we have 1000 rows of 50 columns for ( int x=0; x<50; x++ ) { futures.add(exec.submit(new KeyIteratorExample().new RowInserter())); } int total = 0; try { for ( Future<Integer> f : futures ) { total += f.get().intValue(); } } catch (Exception ex) { ex.printStackTrace(); } int keyCount = 0; KeyIterator<String> keyIterator = new KeyIterator<String>(tutorialKeyspace, "KeyIterableCf", StringSerializer.get()); for ( String key : keyIterator ) { //xSystem.out.printf("Current key: %s \n",key); keyCount++; } System.out.printf("Iterated over %d keys \n", keyCount); exec.shutdown(); }
private void runQuery(K start, K end) { query.setKeys(start, end); if(!firstRun) { query.setRowCount(rowCount); } rowsIterator = null; QueryResult<OrderedRows<K, String, String>> result = query.execute(); OrderedRows<K, String, String> rows = (result != null) ? result.get() : null; rowsIterator = (rows != null) ? rows.iterator() : null; // we'll skip this first one, since it is the same as the last one from previous time we executed if (!firstRun && rowsIterator != null) rowsIterator.next(); firstRun = false; if (rowsIterator != null && !rowsIterator.hasNext()) { nextValue = null; // all done. our iterator's hasNext() will now return false; } else { findNext(true); } }
private void findNext(boolean fromRunQuery) { nextValue = null; if (rowsIterator == null) { return; } while (rowsIterator.hasNext() && nextValue == null) { Row<K, String, String> row = rowsIterator.next(); lastReadValue = row.getKey(); if (!row.getColumnSlice().getColumns().isEmpty()) { nextValue = lastReadValue; } } if (!rowsIterator.hasNext() && nextValue == null) { runQuery(lastReadValue, endKey); } }
@Deprecated /* * When pulling deprecated methods out, do not remove this but change it to private constructor */ public KeyIterator(Keyspace keyspace, String columnFamily, Serializer<K> serializer, K start, K end, int maxRowCount) { query = HFactory .createRangeSlicesQuery(keyspace, serializer, stringSerializer, stringSerializer) .setColumnFamily(columnFamily) .setRange(null, null, false, maxColumnCount) .setRowCount(maxRowCount); endKey = end; if(maxRowCount < Integer.MAX_VALUE) { rowCount = maxRowCount+1; //to compensate the first entry skip (except in first run) } runQuery(start, end); }
public KeyIterator(Keyspace keyspace, String columnFamily, Serializer<K> serializer, K start, K end, int maxRowCount) { query = HFactory .createRangeSlicesQuery(keyspace, serializer, stringSerializer, stringSerializer) .setColumnFamily(columnFamily) .setRange(null, null, false, maxColumnCount) .setRowCount(maxRowCount); endKey = end; runQuery(start, end); }