org.apache.cassandra.thrift.CqlResult Java Examples
The following examples show how to use
org.apache.cassandra.thrift.CqlResult.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QueryProcessor.java From stratio-cassandra with Apache License 2.0 | 6 votes |
public static CqlResult processPrepared(CQLStatement statement, ThriftClientState clientState, List<ByteBuffer> variables) throws RequestValidationException, RequestExecutionException { // Check to see if there are any bound variables to verify if (!(variables.isEmpty() && (statement.boundTerms == 0))) { if (variables.size() != statement.boundTerms) throw new InvalidRequestException(String.format("there were %d markers(?) in CQL but %d bound variables", statement.boundTerms, variables.size())); // at this point there is a match in count between markers and variables that is non-zero if (logger.isTraceEnabled()) for (int i = 0; i < variables.size(); i++) logger.trace("[{}] '{}'", i+1, variables.get(i)); } return processStatement(statement, new ExecutionContext(clientState, null, variables)); }
Example #2
Source File: CqlOperation.java From stratio-cassandra with Apache License 2.0 | 6 votes |
@Override public Function<CqlResult, Integer> simpleNativeHandler() { return new Function<CqlResult, Integer>() { @Override public Integer apply(CqlResult result) { switch (result.getType()) { case ROWS: return result.getRows().size(); default: return 1; } } }; }
Example #3
Source File: CqlOperation.java From stratio-cassandra with Apache License 2.0 | 6 votes |
@Override public Function<CqlResult, ByteBuffer[][]> simpleNativeHandler() { return new Function<CqlResult, ByteBuffer[][]>() { @Override public ByteBuffer[][] apply(CqlResult result) { ByteBuffer[][] r = new ByteBuffer[result.getRows().size()][]; for (int i = 0 ; i < r.length ; i++) { CqlRow row = result.getRows().get(i); r[i] = new ByteBuffer[row.getColumns().size()]; for (int j = 0 ; j < r[i].length ; j++) r[i][j] = ByteBuffer.wrap(row.getColumns().get(j).getValue()); } return r; } }; }
Example #4
Source File: CqlOperation.java From stratio-cassandra with Apache License 2.0 | 6 votes |
@Override public Function<CqlResult, byte[][]> simpleNativeHandler() { return new Function<CqlResult, byte[][]>() { @Override public byte[][] apply(CqlResult result) { byte[][] r = new byte[result.getRows().size()][]; for (int i = 0 ; i < r.length ; i++) r[i] = result.getRows().get(i).getKey(); return r; } }; }
Example #5
Source File: ResultSet.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public CqlResult toThriftResult() { assert metadata.names != null; String UTF8 = "UTF8Type"; CqlMetadata schema = new CqlMetadata(new HashMap<ByteBuffer, String>(), new HashMap<ByteBuffer, String>(), // The 2 following ones shouldn't be needed in CQL3 UTF8, UTF8); for (int i = 0; i < metadata.columnCount; i++) { ColumnSpecification spec = metadata.names.get(i); ByteBuffer colName = ByteBufferUtil.bytes(spec.name.toString()); schema.name_types.put(colName, UTF8); AbstractType<?> normalizedType = spec.type instanceof ReversedType ? ((ReversedType)spec.type).baseType : spec.type; schema.value_types.put(colName, normalizedType.toString()); } List<CqlRow> cqlRows = new ArrayList<CqlRow>(rows.size()); for (List<ByteBuffer> row : rows) { List<Column> thriftCols = new ArrayList<Column>(metadata.columnCount); for (int i = 0; i < metadata.columnCount; i++) { Column col = new Column(ByteBufferUtil.bytes(metadata.names.get(i).name.toString())); col.setValue(row.get(i)); thriftCols.add(col); } // The key of CqlRow shoudn't be needed in CQL3 cqlRows.add(new CqlRow(ByteBufferUtil.EMPTY_BYTE_BUFFER, thriftCols)); } CqlResult res = new CqlResult(CqlResultType.ROWS); res.setRows(cqlRows).setSchema(schema); return res; }
Example #6
Source File: QueryProcessor.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public static CqlResult process(String queryString, ThriftClientState clientState) throws RequestValidationException, RequestExecutionException { logger.trace("CQL QUERY: {}", queryString); return processStatement(getStatement(queryString), new ExecutionContext(clientState, queryString, Collections.<ByteBuffer>emptyList())); }
Example #7
Source File: CFMetaData.java From stratio-cassandra with Apache License 2.0 | 5 votes |
/** * Create CFMetaData from thrift {@link CqlRow} that contains columns from schema_columnfamilies. * * @param columnsRes CqlRow containing columns from schema_columnfamilies. * @return CFMetaData derived from CqlRow */ public static CFMetaData fromThriftCqlRow(CqlRow cf, CqlResult columnsRes) { UntypedResultSet.Row cfRow = new UntypedResultSet.Row(convertThriftCqlRow(cf)); List<Map<String, ByteBuffer>> cols = new ArrayList<>(columnsRes.rows.size()); for (CqlRow row : columnsRes.rows) cols.add(convertThriftCqlRow(row)); UntypedResultSet colsRow = UntypedResultSet.create(cols); return fromSchemaNoTriggers(cfRow, colsRow); }
Example #8
Source File: SchemaStatement.java From stratio-cassandra with Apache License 2.0 | 5 votes |
void validate(CqlResult rs) { switch (validationType) { case NOT_FAIL: return; case NON_ZERO: if (rs.getRowsSize() == 0) throw new IllegalStateException("Expected non-zero results"); break; default: throw new IllegalStateException("Unsupported validation type"); } }
Example #9
Source File: SchemaQuery.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public boolean run() throws Exception { CqlResult rs = client.execute_prepared_cql3_query(thriftId, partitions.get(0).getToken(), thriftArgs(), ThriftConversion.toThrift(cl)); validate(rs); rowCount = rs.getRowsSize(); partitionCount = Math.min(1, rowCount); return true; }
Example #10
Source File: ResultMessage.java From stratio-cassandra with Apache License 2.0 | 4 votes |
public CqlResult toThriftResult() { return new CqlResult(CqlResultType.VOID); }
Example #11
Source File: ResultMessage.java From stratio-cassandra with Apache License 2.0 | 4 votes |
public CqlResult toThriftResult() { return new CqlResult(CqlResultType.VOID); }
Example #12
Source File: ResultMessage.java From stratio-cassandra with Apache License 2.0 | 4 votes |
public CqlResult toThriftResult() { return result.toThriftResult(); }
Example #13
Source File: ResultMessage.java From stratio-cassandra with Apache License 2.0 | 4 votes |
public CqlResult toThriftResult() { throw new UnsupportedOperationException(); }
Example #14
Source File: ResultMessage.java From stratio-cassandra with Apache License 2.0 | 4 votes |
public CqlResult toThriftResult() { return new CqlResult(CqlResultType.VOID); }
Example #15
Source File: ResultMessage.java From stratio-cassandra with Apache License 2.0 | votes |
public abstract CqlResult toThriftResult();
Example #16
Source File: CqlOperation.java From stratio-cassandra with Apache License 2.0 | votes |
Function<CqlResult, V> simpleNativeHandler();