def _cols(self, start_col=None, end_col=None): """Yield columns in the view.""" client = self._get_cas() assert isinstance(client, Client), \ "Incorrect client instance: %s" % client.__class__ last_col = start_col or self.start_col or "" end_col = end_col or "" chunk_size = self.chunk_size passes = 0 while True: # When you give Cassandra a start key, it's included in the # results. We want it in the first pass, but subsequent iterations # need to the count adjusted and the first record dropped. fudge = 1 if self.exclusive else int(passes > 0) cols = client.get_slice( self.key.key, self.key, SlicePredicate(slice_range=SliceRange( last_col, end_col, self.reversed, chunk_size + fudge)), self.consistency) if len(cols) == 0: raise StopIteration() for col in unpack(cols[fudge:]): yield col last_col = col.name passes += 1 if len(cols) < self.chunk_size: raise StopIteration()
def get_column(key, column_name, consistency=None): """Get a column.""" consistency = consistency or cas_types.ConsistencyLevel.ONE return unpack( [get_pool(key.keyspace).get( key.key, key.get_path(column=column_name), consistency)]).next()
def get_column(key, column_name, consistency=None): """Get a column.""" consistency = consistency or cas_types.ConsistencyLevel.ONE return unpack([ get_pool(key.keyspace).get(key.key, key.get_path(column=column_name), consistency) ]).next()
def test_unpack(self): """Test unpack.""" columns = self.client.get_slice() unpacked = iterators.unpack(columns) self.assert_(isinstance(unpacked, types.GeneratorType)) for obj in unpacked: self.assert_(isinstance(obj, ttypes.Column))