Exemplo n.º 1
0
/**
 * Get a single row's columns, which columns to get are defined by:
 *
 * @param colfam  The name of the column family
 * @param rowkey   Row key
 * @param start. The column name to start the slice with. This attribute is not required, though there is no default value,
 *               and can be safely set to '', i.e., an empty byte array, to start with the first column name. Otherwise, it
 *               must a valid value under the rules of the Comparator defined for the given ColumnFamily.
 * @param finish. The column name to stop the slice at. This attribute is not required, though there is no default value,
 *                and can be safely set to an empty byte array to not stop until 'count' results are seen. Otherwise, it
 *                must also be a valid value to the ColumnFamily Comparator.
 * @param reversed. Whether the results should be ordered in reversed order. Similar to ORDER BY blah DESC in SQL.
 * @param count. How many columns to return. Similar to LIMIT in SQL. May be arbitrarily large, but Thrift will
 *               materialize the whole result into memory before returning it to the client, so be aware that you may
 *               be better served by iterating through slices by passing the last value of one call in as the 'start'
 *               of the next instead of increasing 'count' arbitrarily large.
 */
func (c *CassandraConnection) GetRange(cf, rowkey, start, finish string, reversed bool, colLimit int) (cassCol []*cassandra.Column, err error) {

	sp := cassandra.NewSlicePredicate()
	cp := NewColumnParent(cf)
	sp.SliceRange = NewSliceRange(start, finish, reversed, colLimit)

	return c.getslice(rowkey, cp, sp)

}
Exemplo n.º 2
0
func (c *CassandraConnection) GetCols(cf, rowkey string, cols []string) (cassCol []*cassandra.Column, err error) {

	sp := cassandra.NewSlicePredicate()
	cp := NewColumnParent(cf)
	//ColumnNames thrift.TList "column_names"; // 1
	l := thrift.NewTList(thrift.STRING, 0) // auto-expands, starting length should be 0

	for i := 0; i < len(cols); i++ {
		l.Push(cols[i])
	}
	sp.ColumnNames = l

	return c.getslice(rowkey, cp, sp)
}