private List<ColumnOrSuperColumn> getNextSlice(String lastName) { // TODO: Why aren't we passed the slide predicate? What if the column order is reversed? SlicePredicate slicePredicate = CassandraDefs.slicePredicateStartCol(Utils.toBytes(lastName)); DBConn dbConn = ThriftService.instance().getDBConnection(m_keyspace); try { return dbConn.getSlice(m_columnParent, slicePredicate, ByteBuffer.wrap(m_rowKey)); } finally { ThriftService.instance().returnDBConnection(dbConn); } } // getNextSlice
/** * Create a column batch and fetch the first set of columns using the given predicate. If no * columns are found for the given row key and slice predicate, the first call to {@link * #hasNext()} will return false. * * @param thisConn {@link DBConn} that provides the connection to perform the fetch. It also tells * us what keyspace to use for subsequent column slices. * @param columnParent Defines the column family to fetch columns from. * @param rowKey Row of key to fetch columns from. * @param slicePredicate Predicate that defines which columns to select. */ public CassandraColumnBatch( DBConn thisConn, ColumnParent columnParent, byte[] rowKey, SlicePredicate slicePredicate) { m_keyspace = thisConn.getKeyspace(); m_columnParent = columnParent; m_rowKey = rowKey; List<ColumnOrSuperColumn> columns = thisConn.getSlice(m_columnParent, slicePredicate, ByteBuffer.wrap(m_rowKey)); m_sliceSize = 0; m_iColumns = columns.iterator(); if (!m_iColumns.hasNext()) { // tombstone? no columns to iterate return; } // The slice is not empty, so we can simply get the first column shiftColumn(); } // constructor