SingleColumnValueFilterAdapter (Cloud Bigtable HBase Client for Java 1.5.0 API)

com.google.cloud.bigtable.hbase.adapters.filters

Class SingleColumnValueFilterAdapter

    • Constructor Detail

      • SingleColumnValueFilterAdapter

        public SingleColumnValueFilterAdapter(ValueFilterAdapter delegateAdapter)

        Constructor for SingleColumnValueFilterAdapter.

        Parameters:
        delegateAdapter - a ValueFilterAdapter object.
    • Method Detail

      • adapt

        public com.google.bigtable.v2.RowFilter adapt(FilterAdapterContext context,
                                                      SingleColumnValueFilter filter)
                                               throws IOException
        SingleColumnValueFilter is a filter that will return a row if a family/qualifier value matches some condition. Optionally, if SingleColumnValueFilter.getFilterIfMissing() is set to false, then also return the row if the family/column is not present on the row. There's a

        Here's a rough translation of SingleColumnValueFilter.getFilterIfMissing() == true.

         IF a single family/column exists AND
            the value of the family/column meets some condition THEN
               return the ROW
         END
         
        Here's a rough translation of SingleColumnValueFilter.getFilterIfMissing() == false.
         IF a single family/column exists THEN
           IF the value of the family/column meets some condition THEN
             return the ROW
           END
         ELSE IF filter.filter_if_missing == false THEN
           return the ROW
         END
         
        The Cloud Bigtable filter translation for the SingleColumnValueFilter.getFilterIfMissing() true case here's the resulting filter is as follows:
           condition: {
              predicate: {
                chain: {
                   family: [filter.family]
                   qualifier: [filter.qualifier],
                   // if filter.latestOnly, then add
                   // cells_per_column: 1
                   value: // something interesting
                }
              }
              true_filter: {
                 pass_all: true
              }
           }
         
        In addition to the default filter, there's a bit more if SingleColumnValueFilter.getFilterIfMissing() is false. Here's what the filter would look like:
           interleave: [ // either
             {
               // If the family/qualifer exists and matches a value
               // Then return the row
               // Else return nothing
               condition: {
                 predicate: {
                   chain: {
                     family: [filter.family]
                     qualifier: [filter.qualifier],
                     // if filter.latestOnly, then add
                     // cells_per_column: 1
                     value: // something interesting
                   }
                 },
                 true_filter: { pass_all: true }
               }
             }, {
               // If the family/qualifer exists
               // Then return nothing
               // Else return row
               condition: {
                 predicate: {
                   chain: {
                     family: [filter.family]
                     qualifier: [filter.qualifier],
                   }
                 },
                 false_filter: { pass_all: true }
               }
             }
           ]
         
        NOTE: This logic can also be expressed as nested predicates, but that approach creates really poor performance on the server side.

        Parameters:
        context - a FilterAdapterContext object.
        filter - a S object.
        Returns:
        a RowFilter object.
        Throws:
        IOException - if any.


Was this page helpful? Let us know how we did:

Send feedback about...

Cloud Bigtable Documentation