public BlurResultSetRecords(Iface client, Parser parser) throws SQLException { this.client = client; this.parser = parser; String tName = parser.getTableName(); int lastIndexOf = tName.lastIndexOf('.'); tableName = tName.substring(0, lastIndexOf); columnFamily = tName.substring(lastIndexOf + 1); columnNames = parser.getColumnNames(); runSearch(0, 100); }
private void runSearch(int start, int fetch) throws SQLException { currentStart = start; currentFetch = fetch; BlurQuery blurQuery = new BlurQuery(); blurQuery.minimumNumberOfResults = Long.MAX_VALUE; blurQuery.maxQueryTime = Long.MAX_VALUE; blurQuery.uuid = UUID.randomUUID().toString(); blurQuery.fetch = fetch; blurQuery.start = start; blurQuery.query = new Query(); blurQuery.query.query = parser.getWhere(); blurQuery.query.rowQuery = false; try { schema = client.schema(tableName); } catch (BlurException e) { e.printStackTrace(); throw new SQLException(e); } catch (TException e) { e.printStackTrace(); throw new SQLException(e); } selector = new Selector(); setupSelector(selector, schema, columnNames); selector.recordOnly = !blurQuery.query.rowQuery; Map<String, Map<String, ColumnDefinition>> columnFamilies = schema.getFamilies(); Map<String, ColumnDefinition> cfSet = columnFamilies.get(columnFamily); columnFamilies.clear(); columnFamilies.put(columnFamily, cfSet); blurResultSetMetaData = new BlurResultSetMetaData(columnNames, columnFamilies); try { results = client.query(tableName, blurQuery); } catch (BlurException e) { e.printStackTrace(); throw new SQLException(e); } catch (TException e) { e.printStackTrace(); throw new SQLException(e); } if (results.totalResults > 0) { size = results.results.size(); } totalResults = results.totalResults; }