Package org.apache.cassandra.thrift

Examples of org.apache.cassandra.thrift.Column$ColumnStandardSchemeFactory


    private static Column thriftify(IColumn c)
    {
        ByteBuffer value = (c instanceof CounterColumn)
                           ? ByteBufferUtil.bytes(CounterContext.instance().total(c.value()))
                           : c.value();
        return new Column(c.name()).setValue(value).setTimestamp(c.timestamp());
    }
View Full Code Here


        {
            result.schema = new CqlMetadata(Collections.<ByteBuffer, String>emptyMap(),
                                            Collections.<ByteBuffer, String>emptyMap(),
                                            "AsciiType",
                                            "LongType");
            List<Column> columns = Collections.singletonList(new Column(countColumn).setValue(ByteBufferUtil.bytes((long) cqlRows.size())));
            result.rows = Collections.singletonList(new CqlRow(countColumn, columns));
            return result;
        }
        else
        {
View Full Code Here

             : c.value();
    }

    private Column makeReturnColumn(Selector s, IColumn c)
    {
        Column cqlCol;
        if (s.hasFunction())
        {
            cqlCol = new Column(ByteBufferUtil.bytes(s.toString()));
            if (c == null || c.isMarkedForDelete())
                return cqlCol;

            switch (s.function())
            {
                case WRITE_TIME:
                    cqlCol.setValue(ByteBufferUtil.bytes(c.timestamp()));
                    break;
                case TTL:
                    if (c instanceof ExpiringColumn)
                    {
                        int ttl = ((ExpiringColumn)c).getLocalDeletionTime() - (int) (System.currentTimeMillis() / 1000);
                        cqlCol.setValue(ByteBufferUtil.bytes(ttl));
                    }
                    break;
            }
        }
        else
        {
            cqlCol = new Column(s.id().key);
            if (c == null || c.isMarkedForDelete())
                return cqlCol;
            cqlCol.setValue(value(c)).setTimestamp(c.timestamp());
        }
        return cqlCol;
    }
View Full Code Here

                    {
                        CFDefinition.Name name = p.left;
                        Selector selector = p.right;

                        addToSchema(schema, p);
                        Column col;
                        switch (name.kind)
                        {
                            case KEY_ALIAS:
                                col = new Column(selector.id().key);
                                col.setValue(row.key.key).setTimestamp(-1L);
                                break;
                            case COLUMN_ALIAS:
                                col = new Column(selector.id().key);
                                col.setTimestamp(c.timestamp());
                                if (cfDef.isComposite)
                                {
                                    if (name.position < components.length)
                                        col.setValue(components[name.position]);
                                    else
                                        col.setValue(ByteBufferUtil.EMPTY_BYTE_BUFFER);
                                }
                                else
                                {
                                    col.setValue(c.name());
                                }
                                break;
                            case VALUE_ALIAS:
                                col = makeReturnColumn(selector, c);
                                break;
                            case COLUMN_METADATA:
                                // This should not happen for compact CF
                                throw new AssertionError();
                            default:
                                throw new AssertionError();
                        }
                        thriftColumns.add(col);
                    }
                    cqlRows.add(new CqlRow(row.key.key, thriftColumns));
                }
            }
            else if (cfDef.isComposite)
            {
                // Sparse case: group column in cqlRow when composite prefix is equal
                CompositeType composite = (CompositeType)cfDef.cfm.comparator;
                int last = composite.types.size() - 1;

                ByteBuffer[] previous = null;
                Map<ByteBuffer, IColumn> group = new HashMap<ByteBuffer, IColumn>();
                for (IColumn c : row.cf)
                {
                    if (c.isMarkedForDelete())
                        continue;

                    ByteBuffer[] current = composite.split(c.name());
                    // If current differs from previous, we've just finished a group
                    if (previous != null && !isSameRow(previous, current))
                    {
                        cqlRows.add(handleGroup(selection, row.key.key, previous, group, schema));
                        group = new HashMap<ByteBuffer, IColumn>();
                    }

                    // Accumulate the current column
                    group.put(current[last], c);
                    previous = current;
                }
                // Handle the last group
                if (previous != null)
                    cqlRows.add(handleGroup(selection, row.key.key, previous, group, schema));
            }
            else
            {
                if (row.cf.getLiveColumnCount() == 0)
                    continue;

                // Static case: One cqlRow for all columns
                thriftColumns = new ArrayList<Column>(selection.size());

                // Respect selection order
                for (Pair<CFDefinition.Name, Selector> p : selection)
                {
                    CFDefinition.Name name = p.left;
                    Selector selector = p.right;

                    if (name.kind == CFDefinition.Name.Kind.KEY_ALIAS)
                    {
                        thriftColumns.add(new Column(selector.id().key).setValue(row.key.key).setTimestamp(-1L));
                        continue;
                    }

                    IColumn c = row.cf.getColumn(name.name.key);
                    thriftColumns.add(makeReturnColumn(selector, c));
View Full Code Here

        for (Pair<CFDefinition.Name, Selector> p : selection)
        {
            CFDefinition.Name name = p.left;
            Selector selector = p.right;

            Column col;
            switch (name.kind)
            {
                case KEY_ALIAS:
                    col = new Column(selector.id().key);
                    col.setValue(key).setTimestamp(-1L);
                    break;
                case COLUMN_ALIAS:
                    col = new Column(selector.id().key);
                    col.setValue(components[name.position]);
                    col.setTimestamp(-1L);
                    break;
                case VALUE_ALIAS:
                    // This should not happen for SPARSE
                    throw new AssertionError();
                case COLUMN_METADATA:
View Full Code Here

            comparator = orderer;
        }

        public int compare(CqlRow a, CqlRow b)
        {
            Column columnA = a.getColumns().get(index);
            Column columnB = b.getColumns().get(index);

            return comparator.compare(columnA.bufferForValue(), columnB.bufferForValue());
        }
View Full Code Here

        this.cfName = cfName;
    }

    public void insert(ByteBuffer key, ByteBuffer name, ByteBuffer value) throws Exception
    {
        Column col = new Column(name).setValue(value).setTimestamp(System.nanoTime());
        ColumnParent cp = new ColumnParent(cfName);
        client.insert(key, cp, col, cl);
    }
View Full Code Here

        client.insert(key, cp, col, cl);
    }

    public Writer prepareAdd(ByteBuffer name, ByteBuffer value) throws Exception
    {
        Column col = new Column(name).setValue(value).setTimestamp(System.nanoTime());
        columns.add(col);
        return this;
    }
View Full Code Here

    for(int i = 0; i < eventBody.length; i++) {
      finalBytes[i + eventInfoBytes.length] = eventBody[i];
    }

    Column identColumn = new Column();
        identColumn.setName(IDENT_NAME);
        identColumn.setValue("ident".getBytes());
        identColumn.setTimestamp(timestamp);

    Column sourceColumn = new Column();
            sourceColumn.setName(SOURCE_NAME);
            sourceColumn.setValue(host.getBytes());
            sourceColumn.setTimestamp(timestamp);

    Column dateColumn = new Column();
            dateColumn.setName(DATE_NAME);
            dateColumn.setValue(date.getBytes());
            dateColumn.setTimestamp(timestamp);

    Column entryColumn = new Column();
            entryColumn.setName(ENTRY_NAME);
            entryColumn.setValue(finalBytes);
            entryColumn.setTimestamp(timestamp);

    Column[] entryColumns = {identColumn, sourceColumn, dateColumn, entryColumn};


    Column timeColumn = new Column();
            timeColumn.setName(toBytes(timestamp));
            timeColumn.setValue(uuid.toString().getBytes());
            timeColumn.setTimestamp(timestamp);

    Column[] byDateColumns = {timeColumn};

    // Insert the entry
    this.cClient.insert(uuid.toString().getBytes(), ENTRIES, entryColumns, ConsistencyLevel.QUORUM);
View Full Code Here

        {
            result.schema = new CqlMetadata(Collections.<ByteBuffer, String>emptyMap(),
                                            Collections.<ByteBuffer, String>emptyMap(),
                                            "AsciiType",
                                            "LongType");
            List<Column> columns = Collections.singletonList(new Column(countColumn).setValue(ByteBufferUtil.bytes((long) cqlRows.size())));
            result.rows = Collections.singletonList(new CqlRow(countColumn, columns));
            return result;
        }
        else
        {
View Full Code Here

TOP

Related Classes of org.apache.cassandra.thrift.Column$ColumnStandardSchemeFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.