Cassandra Hector: How to retrieve all rows of a column family?

后端 未结 2 1413
温柔的废话
温柔的废话 2020-12-24 15:33

I am looking for a code example to retrieve all rows and all columns of a column family. Something like:

SELECT * FROM MyTable

I see that t

2条回答
  •  我在风中等你
    2020-12-24 16:24

    Try this out:

        int rowCount = MAX;
        RangeSlicesQuery rangeSlicesQuery = HFactory
                .createRangeSlicesQuery(keyspace2, STRINGSERIALIZER,
                        STRINGSERIALIZER, STRINGSERIALIZER)
                .setColumnFamily(columnFamily)
                .setRange(null, null, false, rowCount).setRowCount(rowCount);
        String lastKey = null;
        // Query to iterate over all rows of cassandra Column Family
        rangeSlicesQuery.setKeys(lastKey, null);
        QueryResult> result = rangeSlicesQuery
                .execute();
        OrderedRows rows = result.get();
        for (Row row : rows) {
            String cassandra_key = row.getKey();
        }
    
    }
    

提交回复
热议问题