public CqlResult toThriftResult() { 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 (ColumnSpecification name : metadata.names) { ByteBuffer colName = ByteBufferUtil.bytes(name.toString()); schema.name_types.put(colName, UTF8); AbstractType<?> normalizedType = name.type instanceof ReversedType ? ((ReversedType)name.type).baseType : name.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.names.size()); for (int i = 0; i < metadata.names.size(); i++) { Column col = new Column(ByteBufferUtil.bytes(metadata.names.get(i).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; }
public CqlResult toThriftResult() { return new CqlResult(CqlResultType.VOID); }