Java 类org.apache.cassandra.thrift.CqlMetadata 实例源码

项目:Cassandra-Wasef    文件:ResultSet.java   
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;
}
项目:wso2-cassandra    文件:ResultSet.java   
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;
}
项目:cassandra-1.2.16    文件:ResultSet.java   
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;
}