Package org.apache.cassandra.db.filter

Examples of org.apache.cassandra.db.filter.NamesQueryFilter


        SliceRange sr = sp.slice_range;
        if (sr == null)
        {
            SortedSet<ByteBuffer> ss = new TreeSet<ByteBuffer>(comparator);
            ss.addAll(sp.column_names);
            return new NamesQueryFilter(ss);
        }
        else
        {
            return new SliceQueryFilter(sr.start, sr.finish, sr.reversed, sr.count);
        }
View Full Code Here


            }

            // avoid changing the filter columns of the original filter
            // (reduceNameFilter removes columns that are known to be irrelevant)
            TreeSet<ByteBuffer> filterColumns = new TreeSet<ByteBuffer>(((NamesQueryFilter) filter.filter).columns);
            QueryFilter reducedFilter = new QueryFilter(filter.key, filter.path, new NamesQueryFilter(filterColumns));

            /* add the SSTables on disk */
            Collections.sort(view.sstables, SSTable.maxTimestampComparator);

            // read sorted sstables
View Full Code Here

        cfs.forceBlockingFlush();

        // fetch by the first column name; we should get the second version of the column value
        SliceByNamesReadCommand cmd = new SliceByNamesReadCommand(
            "Keyspace1", ByteBufferUtil.bytes("k1"), cfname, System.currentTimeMillis(),
            new NamesQueryFilter(FBUtilities.singleton(column1, cfs.getComparator())));

        ColumnFamily cf = cmd.getRow(keyspace).cf;
        assertEquals(1, cf.getColumnCount());
        Cell cell = cf.getColumn(column1);
        assertEquals("data2", ByteBufferUtil.string(cell.value()));
        assertEquals(column2, cell.name());

        // fetch by the second column name; we should get the second version of the column value
        cmd = new SliceByNamesReadCommand(
            "Keyspace1", ByteBufferUtil.bytes("k1"), cfname, System.currentTimeMillis(),
            new NamesQueryFilter(FBUtilities.singleton(column2, cfs.getComparator())));

        cf = cmd.getRow(keyspace).cf;
        assertEquals(1, cf.getColumnCount());
        cell = cf.getColumn(column2);
        assertEquals("data2", ByteBufferUtil.string(cell.value()));
View Full Code Here

        // Now do the SliceByNamesCommand on the supercolumn, passing both subcolumns in as columns to get
        SortedSet<CellName> sliceColNames = new TreeSet<CellName>(cfs.metadata.comparator);
        sliceColNames.add(CellNames.compositeDense(superColName, ByteBufferUtil.bytes("a")));
        sliceColNames.add(CellNames.compositeDense(superColName, ByteBufferUtil.bytes("b")));
        SliceByNamesReadCommand cmd = new SliceByNamesReadCommand(keyspaceName, key.getKey(), cfName, System.currentTimeMillis(), new NamesQueryFilter(sliceColNames));
        ColumnFamily cfSliced = cmd.getRow(keyspace).cf;

        // Make sure the slice returns the same as the straight get
        assertEquals(ByteBufferUtil.bytes("A"), cfSliced.getColumn(CellNames.compositeDense(superColName, ByteBufferUtil.bytes("a"))).value());
        assertEquals(ByteBufferUtil.bytes("B"), cfSliced.getColumn(CellNames.compositeDense(superColName, ByteBufferUtil.bytes("b"))).value());
View Full Code Here

        // Add another cell with a lower timestamp
        putColsStandard(cfs, key, new BufferCell(cname, ByteBufferUtil.bytes("b"), 1));

        // Test fetching the cell by name returns the first cell
        SliceByNamesReadCommand cmd = new SliceByNamesReadCommand(keyspaceName, key.getKey(), cfName, System.currentTimeMillis(), new NamesQueryFilter(FBUtilities.singleton(cname, cfs.getComparator())));
        ColumnFamily cf = cmd.getRow(keyspace).cf;
        Cell cell = cf.getColumn(cname);
        assert cell.value().equals(ByteBufferUtil.bytes("a")) : "expecting a, got " + ByteBufferUtil.string(cell.value());
    }
View Full Code Here

                }
            }

            // avoid changing the filter columns of the original filter
            // (reduceNameFilter removes columns that are known to be irrelevant)
            NamesQueryFilter namesFilter = (NamesQueryFilter) filter.filter;
            TreeSet<CellName> filterColumns = new TreeSet<>(namesFilter.columns);
            QueryFilter reducedFilter = new QueryFilter(filter.key, filter.cfName, namesFilter.withUpdatedColumns(filterColumns), filter.timestamp);

            /* add the SSTables on disk */
            Collections.sort(view.sstables, SSTableReader.maxTimestampComparator);

            // read sorted sstables
View Full Code Here

    public static NamesQueryFilter namesFilter(ColumnFamilyStore cfs, String... names)
    {
        SortedSet<CellName> s = new TreeSet<CellName>(cfs.getComparator());
        for (String str : names)
            s.add(cellname(str));
        return new NamesQueryFilter(s);
    }
View Full Code Here

        SortedSet<CellName> names = new TreeSet<>(cfs.metadata.comparator);
        for (int i = 0; i < currentValues.length; i++)
            if (currentValues[i] == null)
                names.add(counterUpdateCells.get(i).name());

        ReadCommand cmd = new SliceByNamesReadCommand(getKeyspaceName(), key(), cfs.metadata.cfName, Long.MIN_VALUE, new NamesQueryFilter(names));
        Row row = cmd.getRow(cfs.keyspace);
        ColumnFamily cf = row == null ? null : row.cf;

        for (int i = 0; i < currentValues.length; i++)
        {
View Full Code Here

            {
                CellNameType columnType = new SimpleDenseCellNameType(metadata.comparator.subtype(parent.isSetSuper_column() ? 1 : 0));
                SortedSet<CellName> s = new TreeSet<CellName>(columnType);
                for (ByteBuffer bb : predicate.column_names)
                    s.add(columnType.cellFromByteBuffer(bb));
                filter = SuperColumns.fromSCNamesFilter(metadata.comparator, parent.bufferForSuper_column(), new NamesQueryFilter(s));
            }
            else
            {
                SortedSet<CellName> s = new TreeSet<CellName>(metadata.comparator);
                for (ByteBuffer bb : predicate.column_names)
                    s.add(metadata.comparator.cellFromByteBuffer(bb));
                filter = new NamesQueryFilter(s);
            }
        }
        else
        {
            filter = toInternalFilter(metadata, parent, predicate.slice_range);
View Full Code Here

            if (metadata.isSuper())
            {
                CellNameType columnType = new SimpleDenseCellNameType(metadata.comparator.subtype(column_path.column == null ? 0 : 1));
                SortedSet<CellName> names = new TreeSet<CellName>(columnType);
                names.add(columnType.cellFromByteBuffer(column_path.column == null ? column_path.super_column : column_path.column));
                filter = SuperColumns.fromSCNamesFilter(metadata.comparator, column_path.column == null ? null : column_path.bufferForSuper_column(), new NamesQueryFilter(names));
            }
            else
            {
                SortedSet<CellName> names = new TreeSet<CellName>(metadata.comparator);
                names.add(metadata.comparator.cellFromByteBuffer(column_path.column));
                filter = new NamesQueryFilter(names);
            }

            long now = System.currentTimeMillis();
            ReadCommand command = ReadCommand.create(keyspace, key, column_path.column_family, now, filter);
View Full Code Here

TOP

Related Classes of org.apache.cassandra.db.filter.NamesQueryFilter

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.