@Override
 public QueryResult<OrderedRows<String, String, String>> execute() {
   RangeSlicesQuery<String, String, String> rangeSlicesQuery =
       HFactory.createRangeSlicesQuery(
           keyspace, stringSerializer, stringSerializer, stringSerializer);
   rangeSlicesQuery.setColumnFamily("Npanxx");
   rangeSlicesQuery.setColumnNames("city", "state", "lat", "lng");
   rangeSlicesQuery.setKeys("512202", "512205");
   rangeSlicesQuery.setRowCount(5);
   QueryResult<OrderedRows<String, String, String>> results = rangeSlicesQuery.execute();
   return results;
 }
예제 #2
0
  public Map<String, Map<String, String>> getRows(
      String keyspace,
      String cf,
      String startKey,
      String colRange,
      int numRows,
      boolean reverse,
      int numCols) {
    Keyspace ks = getKeyspaceForName(keyspace);
    RangeSlicesQuery<String, String, String> rowsQuery =
        HFactory.createRangeSlicesQuery(ks, s, s, s);
    rowsQuery.setColumnFamily(cf);
    rowsQuery.setKeys(startKey, "");
    if (colRange != null) {
      // String[] cols = colRange.split(",");
      // rowsQuery.setRange(cols[0], cols[1], reverse, numCols);

      String[] cols = colRange.split("-");
      if (colRange.equals(cols[0])) {
        cols = colRange.split(",");
        Arrays.sort(cols);
        rowsQuery.setColumnNames(cols);
      } else {
        Arrays.sort(cols);
        // TODO Check size, throw invalid request trigger
        rowsQuery.setRange(cols[0], cols[1], reverse, numCols);
      }
    } else {
      rowsQuery.setRange("", "", reverse, numCols);
    }

    rowsQuery.setRowCount(numRows + 1);

    OrderedRows<String, String, String> result = rowsQuery.execute().get();
    return resultToMap(keyspace, cf, null, numRows, colRange, result);
  }