/** * Applies the given label to all cells in the output row. This allows the caller to determine * which results were produced from which part of the filter. * * <p>Due to a technical limitation, it is not currently possible to apply multiple labels to a * cell. As a result, a {@link ChainFilter} may have no more than one sub-filter which contains a * label. It is okay for an {@link InterleaveFilter} to contain multiple labels, as they will be * applied to separate copies of the input. This may be relaxed in the future. */ public Filter label(@Nonnull String label) { Preconditions.checkNotNull(label); return new SimpleFilter(RowFilter.newBuilder().setApplyLabelTransformer(label).build()); }
@Test public void labelTest() { RowFilter actualFilter = FILTERS.label("my-label").toProto(); RowFilter expectedFilter = RowFilter.newBuilder().setApplyLabelTransformer("my-label").build(); assertThat(actualFilter).isEqualTo(expectedFilter); } }
@Test public void conditionTest() { RowFilter actualFilter = FILTERS .condition(FILTERS.key().regex(".*")) .then(FILTERS.label("true")) .otherwise(FILTERS.label("false")) .toProto(); RowFilter expectedFilter = RowFilter.newBuilder() .setCondition( Condition.newBuilder() .setPredicateFilter( RowFilter.newBuilder().setRowKeyRegexFilter(ByteString.copyFromUtf8(".*"))) .setTrueFilter(RowFilter.newBuilder().setApplyLabelTransformer("true")) .setFalseFilter(RowFilter.newBuilder().setApplyLabelTransformer("false"))) .build(); assertThat(actualFilter).isEqualTo(expectedFilter); }
/** * Applies the given label to all cells in the output row. This allows the caller to determine * which results were produced from which part of the filter. * * <p>Due to a technical limitation, it is not currently possible to apply multiple labels to a * cell. As a result, a {@link ChainFilter} may have no more than one sub-filter which contains a * label. It is okay for an {@link InterleaveFilter} to contain multiple labels, as they will be * applied to separate copies of the input. This may be relaxed in the future. */ public Filter label(@Nonnull String label) { Preconditions.checkNotNull(label); return new SimpleFilter(RowFilter.newBuilder().setApplyLabelTransformer(label).build()); }
/** * Applies the given label to all cells in the output row. This allows the caller to determine * which results were produced from which part of the filter. * * <p>Due to a technical limitation, it is not currently possible to apply multiple labels to a * cell. As a result, a {@link ChainFilter} may have no more than one sub-filter which contains a * label. It is okay for an {@link InterleaveFilter} to contain multiple labels, as they will be * applied to separate copies of the input. This may be relaxed in the future. */ public Filter label(@Nonnull String label) { Preconditions.checkNotNull(label); return new SimpleFilter(RowFilter.newBuilder().setApplyLabelTransformer(label).build()); }