Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 5A0AE200D24 for ; Tue, 10 Oct 2017 03:57:32 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 5896C160BE0; Tue, 10 Oct 2017 01:57:32 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 9DB741609CE for ; Tue, 10 Oct 2017 03:57:31 +0200 (CEST) Received: (qmail 3240 invoked by uid 500); 10 Oct 2017 01:57:30 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 3222 invoked by uid 99); 10 Oct 2017 01:57:30 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Oct 2017 01:57:30 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 89A35F5D5E; Tue, 10 Oct 2017 01:57:30 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: busbey@apache.org To: commits@hbase.apache.org Date: Tue, 10 Oct 2017 01:57:30 -0000 Message-Id: <74663f3208b442cebc249a83478e1cbe@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] hbase git commit: HBASE-18957 add test that confirms 2 FamilyFilters in a FilterList using MUST_PASS_ONE operator will return results that match either of the FamilyFilters archived-at: Tue, 10 Oct 2017 01:57:32 -0000 Repository: hbase Updated Branches: refs/heads/branch-1.4 ab8b0a366 -> 968eea84a HBASE-18957 add test that confirms 2 FamilyFilters in a FilterList using MUST_PASS_ONE operator will return results that match either of the FamilyFilters Amending-Author: Sean Busbey Signed-off-by: Michael Stack Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/171cb0f1 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/171cb0f1 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/171cb0f1 Branch: refs/heads/branch-1.4 Commit: 171cb0f174872766ace2dc8a4ac8ce9941f86e56 Parents: ab8b0a3 Author: Peter Somogyi Authored: Fri Oct 6 09:26:42 2017 -0500 Committer: Sean Busbey Committed: Mon Oct 9 20:48:14 2017 -0500 ---------------------------------------------------------------------- .../hbase/filter/TestFilterListOnMini.java | 88 ++++++++++++++++++++ 1 file changed, 88 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/171cb0f1/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterListOnMini.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterListOnMini.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterListOnMini.java new file mode 100644 index 0000000..dd2399f --- /dev/null +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterListOnMini.java @@ -0,0 +1,88 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.filter; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.hbase.HBaseTestingUtility; +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.client.*; +import org.apache.hadoop.hbase.testclassification.FilterTests; +import org.apache.hadoop.hbase.testclassification.MediumTests; +import org.apache.hadoop.hbase.util.Bytes; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; + +/** + * Tests filter Lists in ways that rely on a MiniCluster. + * Where possible, favor tests in TestFilterList and TestFilterFromRegionSide instead. + */ +@Category({MediumTests.class, FilterTests.class}) +public class TestFilterListOnMini { + + private static final Log LOG = LogFactory.getLog(TestFilterListOnMini.class); + private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); + + @Rule + public TestName name = new TestName(); + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + TEST_UTIL.startMiniCluster(1); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + TEST_UTIL.shutdownMiniCluster(); + } + + @Test + public void testFiltersWithOR() throws Exception { + TableName tn = TableName.valueOf(name.getMethodName()); + Table table = TEST_UTIL.createTable(tn, new String[] { "cf1", "cf2" }); + byte[] CF1 = Bytes.toBytes("cf1"); + byte[] CF2 = Bytes.toBytes("cf2"); + Put put1 = new Put(Bytes.toBytes("0")); + put1.addColumn(CF1, Bytes.toBytes("col_a"), Bytes.toBytes(0)); + table.put(put1); + Put put2 = new Put(Bytes.toBytes("0")); + put2.addColumn(CF2, Bytes.toBytes("col_b"), Bytes.toBytes(0)); + table.put(put2); + FamilyFilter filterCF1 = + new FamilyFilter(CompareFilter.CompareOp.EQUAL, new BinaryComparator(CF1)); + FamilyFilter filterCF2 = + new FamilyFilter(CompareFilter.CompareOp.EQUAL, new BinaryComparator(CF2)); + FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ONE); + filterList.addFilter(filterCF1); + filterList.addFilter(filterCF2); + Scan scan = new Scan(); + scan.setFilter(filterList); + ResultScanner scanner = table.getScanner(scan); + LOG.info("Filter list: " + filterList); + for (Result rr = scanner.next(); rr != null; rr = scanner.next()) { + Assert.assertEquals(2, rr.size()); + } + } +}