Class CassandraFilter.Translator

  • Enclosing class:
    CassandraFilter

    static class CassandraFilter.Translator
    extends java.lang.Object
    Translates RexNode expressions into Cassandra expression strings.
    • Field Detail

      • fieldNames

        private final java.util.List<java.lang.String> fieldNames
      • partitionKeys

        private final java.util.Set<java.lang.String> partitionKeys
      • clusteringKeys

        private final java.util.List<java.lang.String> clusteringKeys
      • restrictedClusteringKeys

        private int restrictedClusteringKeys
      • implicitFieldCollations

        private final java.util.List<RelFieldCollation> implicitFieldCollations
    • Constructor Detail

      • Translator

        Translator​(RelDataType rowType,
                   java.util.List<java.lang.String> partitionKeys,
                   java.util.List<java.lang.String> clusteringKeys,
                   java.util.List<RelFieldCollation> implicitFieldCollations)
    • Method Detail

      • isSinglePartition

        public boolean isSinglePartition()
        Check if the query spans only one partition.
        Returns:
        True if the matches translated so far have resulted in a single partition
      • getImplicitCollation

        public RelCollation getImplicitCollation()
        Infer the implicit correlation from the unrestricted clustering keys.
        Returns:
        The collation of the filtered results
      • translateMatch

        private java.lang.String translateMatch​(RexNode condition)
        Produce the CQL predicate string for the given condition.
        Parameters:
        condition - Condition to translate
        Returns:
        CQL predicate string
      • literalValue

        private static java.lang.String literalValue​(RexLiteral literal)
        Convert the value of a literal to a string.
        Parameters:
        literal - Literal to translate
        Returns:
        String representation of the literal
      • translateAnd

        private java.lang.String translateAnd​(RexNode condition)
        Translate a conjunctive predicate to a CQL string.
        Parameters:
        condition - A conjunctive predicate
        Returns:
        CQL string for the predicate
      • translateMatch2

        private java.lang.String translateMatch2​(RexNode node)
        Translate a binary relation.
      • translateBinary

        private java.lang.String translateBinary​(java.lang.String op,
                                                 java.lang.String rop,
                                                 RexCall call)
        Translates a call to a binary operator, reversing arguments if necessary.
      • translateBinary2

        private java.lang.String translateBinary2​(java.lang.String op,
                                                  RexNode left,
                                                  RexNode right)
        Translates a call to a binary operator. Returns null on failure.
      • translateOp2

        private java.lang.String translateOp2​(java.lang.String op,
                                              java.lang.String name,
                                              RexLiteral right)
        Combines a field name, operator, and literal to produce a predicate string.