当前位置: 首页>>代码示例>>Java>>正文


Java IndexOperator.EQ属性代码示例

本文整理汇总了Java中org.apache.cassandra.thrift.IndexOperator.EQ属性的典型用法代码示例。如果您正苦于以下问题:Java IndexOperator.EQ属性的具体用法?Java IndexOperator.EQ怎么用?Java IndexOperator.EQ使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.cassandra.thrift.IndexOperator的用法示例。


在下文中一共展示了IndexOperator.EQ属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getIndexOperator

/**
 * Returns IndexOperator from string representation
 * @param operator - string representing IndexOperator (=, >=, >, <, <=)
 * @return IndexOperator - enum value of IndexOperator or null if not found
 */
public static IndexOperator getIndexOperator(String operator)
{
    if (operator.equals("="))
    {
        return IndexOperator.EQ;
    }
    else if (operator.equals(">="))
    {
        return IndexOperator.GTE;
    }
    else if (operator.equals(">"))
    {
        return IndexOperator.GT;
    }
    else if (operator.equals("<"))
    {
        return IndexOperator.LT;
    }
    else if (operator.equals("<="))
    {
        return IndexOperator.LTE;
    }

    return null;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:30,代码来源:CliUtils.java

示例2: testSatisfiedByWithMultipleTerms

@Test
public void testSatisfiedByWithMultipleTerms()
{
    final ByteBuffer comment = UTF8Type.instance.decompose("comment");
    final ColumnFamilyStore store = Keyspace.open("sasecondaryindex").getColumnFamilyStore("saindexed1");
    final IPartitioner<?> partitioner = StorageService.getPartitioner();

    ColumnFamily cf = ArrayBackedSortedColumns.factory.create(store.metadata);
    cf.addColumn(new Column(comment, UTF8Type.instance.decompose("software engineer is working on a project"), System.currentTimeMillis()));

    Operation.Builder builder = new Operation.Builder(OperationType.AND, UTF8Type.instance, controller,
                                        new IndexExpression(comment, IndexOperator.EQ, UTF8Type.instance.decompose("eng is a work")));
    Operation op = builder.complete();

    Assert.assertTrue(op.satisfiedBy(new Row(partitioner.decorateKey(UTF8Type.instance.decompose("key1")), cf), null, false));

    builder = new Operation.Builder(OperationType.AND, UTF8Type.instance, controller,
                                        new IndexExpression(comment, IndexOperator.EQ, UTF8Type.instance.decompose("soft works fine")));
    op = builder.complete();

    Assert.assertTrue(op.satisfiedBy(new Row(partitioner.decorateKey(UTF8Type.instance.decompose("key1")), cf), null, false));
}
 
开发者ID:xedin,项目名称:sasi,代码行数:22,代码来源:OperationTest.java

示例3: analyzeGroup

@VisibleForTesting
protected static ListMultimap<ByteBuffer, Expression> analyzeGroup(QueryController controller,
                                                                   final AbstractType<?> comparator,
                                                                   OperationType op,
                                                                   List<IndexExpression> expressions)
{
    ListMultimap<ByteBuffer, Expression> analyzed = ArrayListMultimap.create();

    // sort all of the expressions in the operation by name and priority of the logical operator
    // this gives us an efficient way to handle inequality and combining into ranges without extra processing
    // and converting expressions from one type to another.
    Collections.sort(expressions, new Comparator<IndexExpression>()
    {
        @Override
        public int compare(IndexExpression a, IndexExpression b)
        {
            int cmp = comparator.compare(ByteBuffer.wrap(a.getColumn_name()), ByteBuffer.wrap(b.getColumn_name()));
            return cmp == 0 ? -Integer.compare(getPriority(a.getOp()), getPriority(b.getOp())) : cmp;
        }
    });

    for (final IndexExpression e : expressions)
    {
        if (e.isSetLogicalOp())
            continue;

        ByteBuffer name = ByteBuffer.wrap(e.getColumn_name());
        ColumnIndex columnIndex = controller.getIndex(name);

        List<Expression> perColumn = analyzed.get(name);

        if (columnIndex == null)
        {
            ColumnDefinition nonIndexedColumn = controller.getColumn(name);
            columnIndex = new ColumnIndex(controller.getKeyValidator(),
                                          nonIndexedColumn,
                                          controller.getComparator(nonIndexedColumn));
        }

        AbstractAnalyzer analyzer = columnIndex.getAnalyzer();
        analyzer.reset(ByteBuffer.wrap(e.getValue()));

        // EQ/NOT_EQ can have multiple expressions e.g. text = "Hello World",
        // becomes text = "Hello" OR text = "World" because "space" is always interpreted as a split point (by analyzer),
        // NOT_EQ is made an independent expression only in case of pre-existing multiple EQ expressions, or
        // if there is no EQ operations and NOT_EQ is met or a single NOT_EQ expression present,
        // in such case we know exactly that there would be no more EQ/RANGE expressions for given column
        // since NOT_EQ has the lowest priority.
        if (e.getOp() == IndexOperator.EQ
                || (e.getOp() == IndexOperator.NOT_EQ
                   && (perColumn.size() == 0 || perColumn.size() > 1
                       || (perColumn.size() == 1 && perColumn.get(0).getOp() == Op.NOT_EQ))))
        {
            while (analyzer.hasNext())
            {
                final ByteBuffer token = analyzer.next();
                perColumn.add(new Expression(controller, columnIndex)
                {{
                        add(e.op, token);
                }});
            }
        }
        else
        // "range" or not-equals operator, combines both bounds together into the single expression,
        // iff operation of the group is AND, otherwise we are forced to create separate expressions,
        // not-equals is combined with the range iff operator is AND.
        {
            Expression range;
            if (perColumn.size() == 0 || op != OperationType.AND)
                perColumn.add((range = new Expression(controller, columnIndex)));
            else
                range = Iterables.getLast(perColumn);

            while (analyzer.hasNext())
                range.add(e.op, analyzer.next());
        }
    }

    return analyzed;
}
 
开发者ID:xedin,项目名称:sasi,代码行数:80,代码来源:Operation.java


注:本文中的org.apache.cassandra.thrift.IndexOperator.EQ属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。