org.apache.hadoop.hbase.filter.FilterList Java Examples

The following examples show how to use org.apache.hadoop.hbase.filter.FilterList. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InboundRunner.java    From BigDataPlatform with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected Filter fetchHbaseFilter() {
  FilterList filterList = new FilterList();
  String[] columns = new String[]{
      EventLogConstants.LOG_COLUMN_NAME_REFERER_URL,
      EventLogConstants.LOG_COLUMN_NAME_UUID,
      EventLogConstants.LOG_COLUMN_NAME_SESSION_ID,
      EventLogConstants.LOG_COLUMN_NAME_SERVER_TIME,
      EventLogConstants.LOG_COLUMN_NAME_PLATFORM,
      EventLogConstants.LOG_COLUMN_NAME_EVENT_NAME,
  };
  //过滤数据
  filterList.addFilter(this.getColumnFilter(columns));
  filterList.addFilter(
      new SingleColumnValueExcludeFilter(Bytes.toBytes(EventLogConstants.EVENT_LOGS_FAMILY_NAME),
          Bytes.toBytes(EventLogConstants.LOG_COLUMN_NAME_EVENT_NAME), CompareOp.EQUAL,
          Bytes.toBytes(
              EventEnum.PAGEVIEW.alias)));
  return filterList;
}
 
Example #2
Source File: CommandAdapter.java    From hbase-tools with Apache License 2.0 6 votes vote down vote up
public static boolean isReallyEmptyRegion(HConnection connection,
    String tableName, HRegionInfo regionInfo) throws IOException {
    boolean emptyRegion = false;
    // verify really empty region by scanning records
    try (HTableInterface table = connection.getTable(tableName)) {
        Scan scan = new Scan(regionInfo.getStartKey(), regionInfo.getEndKey());
        FilterList filterList = new FilterList();
        filterList.addFilter(new KeyOnlyFilter());
        filterList.addFilter(new FirstKeyOnlyFilter());
        scan.setFilter(filterList);
        scan.setCacheBlocks(false);
        scan.setSmall(true);
        scan.setCaching(1);

        try (ResultScanner scanner = table.getScanner(scan)) {
            if (scanner.next() == null) emptyRegion = true;
        }
    }
    return emptyRegion;
}
 
Example #3
Source File: PerformanceEvaluation.java    From hbase with Apache License 2.0 6 votes vote down vote up
protected Scan constructScan(byte[] valuePrefix) throws IOException {
  FilterList list = new FilterList();
  Filter filter = new SingleColumnValueFilter(FAMILY_ZERO, COLUMN_ZERO,
    CompareOperator.EQUAL, new BinaryComparator(valuePrefix));
  list.addFilter(filter);
  if (opts.filterAll) {
    list.addFilter(new FilterAllFilter());
  }
  Scan scan = new Scan().setCaching(opts.caching).setCacheBlocks(opts.cacheBlocks)
      .setAsyncPrefetch(opts.asyncPrefetch).setReadType(opts.scanReadType)
      .setScanMetricsEnabled(true);
  if (opts.addColumns) {
    for (int column = 0; column < opts.columns; column++) {
      byte [] qualifier = column == 0? COLUMN_ZERO: Bytes.toBytes("" + column);
      scan.addColumn(FAMILY_ZERO, qualifier);
    }
  } else {
    scan.addFamily(FAMILY_ZERO);
  }
  scan.setFilter(list);
  return scan;
}
 
Example #4
Source File: RegionLocationCleaner.java    From hbase-tools with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    try (HTableInterface table = connection.getTable(tableName.getBytes())) {
        // Do not use Get not to increase read request count metric.
        // Use Scan.
        Scan scan = new Scan("".getBytes(), "".getBytes());
        FilterList filterList = new FilterList();
        filterList.addFilter(new KeyOnlyFilter());
        filterList.addFilter(new FirstKeyOnlyFilter());
        scan.setFilter(filterList);
        //noinspection EmptyTryBlock
        try(ResultScanner ignored = table.getScanner(scan)) {
        }
        return;
    } catch (IOException ignore) {
    }

    clean(tableName);
}
 
Example #5
Source File: ScanUtil.java    From phoenix with Apache License 2.0 6 votes vote down vote up
public static void andFilterAtBeginning(Scan scan, Filter andWithFilter) {
    if (andWithFilter == null) {
        return;
    }
    Filter filter = scan.getFilter();
    if (filter == null) {
        scan.setFilter(andWithFilter); 
    } else if (filter instanceof FilterList && ((FilterList)filter).getOperator() == FilterList.Operator.MUST_PASS_ALL) {
        FilterList filterList = (FilterList)filter;
        List<Filter> allFilters = new ArrayList<Filter>(filterList.getFilters().size() + 1);
        allFilters.add(andWithFilter);
        allFilters.addAll(filterList.getFilters());
        scan.setFilter(new FilterList(FilterList.Operator.MUST_PASS_ALL,allFilters));
    } else {
        scan.setFilter(new FilterList(FilterList.Operator.MUST_PASS_ALL,Arrays.asList(andWithFilter, filter)));
    }
}
 
Example #6
Source File: ScanUtil.java    From phoenix with Apache License 2.0 6 votes vote down vote up
public static void andFilterAtEnd(Scan scan, Filter andWithFilter) {
    if (andWithFilter == null) {
        return;
    }
    Filter filter = scan.getFilter();
    if (filter == null) {
        scan.setFilter(andWithFilter); 
    } else if (filter instanceof FilterList && ((FilterList)filter).getOperator() == FilterList.Operator.MUST_PASS_ALL) {
        FilterList filterList = (FilterList)filter;
        List<Filter> allFilters = new ArrayList<Filter>(filterList.getFilters().size() + 1);
        allFilters.addAll(filterList.getFilters());
        allFilters.add(andWithFilter);
        scan.setFilter(new FilterList(FilterList.Operator.MUST_PASS_ALL,allFilters));
    } else {
        scan.setFilter(new FilterList(FilterList.Operator.MUST_PASS_ALL,Arrays.asList(filter, andWithFilter)));
    }
}
 
Example #7
Source File: ActiveMemberRunner.java    From BigDataPlatform with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected Filter fetchHbaseFilter() {
  FilterList filterList = new FilterList();
  // 定义mapper中需要获取的列名
  String[] columns = new String[]{EventLogConstants.LOG_COLUMN_NAME_MEMBER_ID, // 会员id
      EventLogConstants.LOG_COLUMN_NAME_SERVER_TIME, // 服务器时间
      EventLogConstants.LOG_COLUMN_NAME_PLATFORM, // 平台名称
      EventLogConstants.LOG_COLUMN_NAME_BROWSER_NAME, // 浏览器名称
      EventLogConstants.LOG_COLUMN_NAME_BROWSER_VERSION, // 浏览器版本号
      EventLogConstants.LOG_COLUMN_NAME_EVENT_NAME
      // 添加一个事件名称获取列,在使用singlecolumnvaluefilter的时候必须指定对应的列是一个返回列
  };
  filterList.addFilter(this.getColumnFilter(columns));
  // 只需要page view事件,所以进行过滤
  filterList.addFilter(new SingleColumnValueFilter(Bytes.toBytes(EventLogConstants.EVENT_LOGS_FAMILY_NAME),
      Bytes.toBytes(EventLogConstants.LOG_COLUMN_NAME_EVENT_NAME), CompareOp.EQUAL,
      Bytes.toBytes(EventEnum.PAGEVIEW.alias)));

  return filterList;
}
 
Example #8
Source File: LocationRunner.java    From BigDataPlatform with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected Filter fetchHbaseFilter() {
  //过滤数据,只分析launch事件
  FilterList filterList = new FilterList();
  filterList.addFilter(
      new SingleColumnValueExcludeFilter(Bytes.toBytes(EventLogConstants.EVENT_LOGS_FAMILY_NAME),
          Bytes.toBytes(EventLogConstants.LOG_COLUMN_NAME_EVENT_NAME), CompareOp.EQUAL,
          Bytes.toBytes(
              EventEnum.PAGEVIEW.alias)));
  String[] columns = new String[]{
      EventLogConstants.LOG_COLUMN_NAME_SESSION_ID, EventLogConstants.LOG_COLUMN_NAME_UUID,
      EventLogConstants.LOG_COLUMN_NAME_SERVER_TIME, EventLogConstants.LOG_COLUMN_NAME_PLATFORM,
      EventLogConstants.LOG_COLUMN_NAME_COUNTRY,
      EventLogConstants.LOG_COLUMN_NAME_PROVINCE,
      EventLogConstants.LOG_COLUMN_NAME_CITY,
      EventLogConstants.LOG_COLUMN_NAME_EVENT_NAME
  };
  filterList.addFilter(this.getColumnFilter(columns));
  return filterList;
}
 
Example #9
Source File: CubeHBaseRPC.java    From kylin with Apache License 2.0 6 votes vote down vote up
public static void applyFuzzyFilter(Scan scan, List<org.apache.kylin.common.util.Pair<byte[], byte[]>> fuzzyKeys) {
    if (fuzzyKeys != null && fuzzyKeys.size() > 0) {
        FuzzyRowFilter rowFilter = new FuzzyRowFilter(convertToHBasePair(fuzzyKeys));

        Filter filter = scan.getFilter();
        if (filter != null) {
            // may have existed InclusiveStopFilter, see buildScan
            FilterList filterList = new FilterList();
            filterList.addFilter(filter);
            filterList.addFilter(rowFilter);
            scan.setFilter(filterList);
        } else {
            scan.setFilter(rowFilter);
        }
    }
}
 
Example #10
Source File: HBaseReader.java    From geowave with Apache License 2.0 6 votes vote down vote up
private static <T> void setLimit(
    final RangeReaderParams<T> readerParams,
    final FilterList filterList) {
  if ((readerParams.getLimit() != null) && (readerParams.getLimit() > 0)) {
    // @formatter:off
    // TODO in hbase 1.4.x there is a scan.getLimit() and
    // scan.setLimit() which is perfectly suited for this
    //			if (readerParams.getLimit() < scanner.getLimit() || scanner.getLimit() <= 0) {
    // also in hbase 1.4.x readType.PREAD would make sense for
    // limits
    // 				scanner.setReadType(ReadType.PREAD);
    //				scanner.setLimit(
    //						readerParams.getLimit());
    //			}
    // @formatter:on
    // however, to be compatible with earlier versions of hbase, for now
    // we are using a page filter
    filterList.addFilter(new PageFilter(readerParams.getLimit()));
  }
}
 
Example #11
Source File: LocationRunner.java    From BigDataArchitect with Apache License 2.0 6 votes vote down vote up
@Override
protected Filter fetchHbaseFilter() {
    FilterList list = new FilterList();
    String[] columns = new String[] { EventLogConstants.LOG_COLUMN_NAME_PLATFORM, // 平台
            EventLogConstants.LOG_COLUMN_NAME_SERVER_TIME, // 服务器时间戳
            EventLogConstants.LOG_COLUMN_NAME_UUID, // 用户id
            EventLogConstants.LOG_COLUMN_NAME_SESSION_ID, // 会话id
            EventLogConstants.LOG_COLUMN_NAME_COUNTRY, // 国家
            EventLogConstants.LOG_COLUMN_NAME_PROVINCE, // 省份
            EventLogConstants.LOG_COLUMN_NAME_CITY, // 城市
            EventLogConstants.LOG_COLUMN_NAME_EVENT_NAME, // 事件名称
    };
    list.addFilter(this.getColumnFilter(columns));
    // 过滤只需要pageview事件
    list.addFilter(new SingleColumnValueFilter(LocationMapper.family, Bytes.toBytes(EventLogConstants.LOG_COLUMN_NAME_EVENT_NAME), CompareOp.EQUAL, Bytes.toBytes(EventEnum.PAGEVIEW.alias)));
    return list;
}
 
Example #12
Source File: FromClientSideBase.java    From hbase with Apache License 2.0 6 votes vote down vote up
protected ResultScanner buildScanner(String keyPrefix, String value, Table ht)
  throws IOException {
  // OurFilterList allFilters = new OurFilterList();
  FilterList allFilters = new FilterList(/* FilterList.Operator.MUST_PASS_ALL */);
  allFilters.addFilter(new PrefixFilter(Bytes.toBytes(keyPrefix)));
  SingleColumnValueFilter filter = new SingleColumnValueFilter(Bytes
    .toBytes("trans-tags"), Bytes.toBytes("qual2"), CompareOperator.EQUAL, Bytes
    .toBytes(value));
  filter.setFilterIfMissing(true);
  allFilters.addFilter(filter);

  // allFilters.addFilter(new
  // RowExcludingSingleColumnValueFilter(Bytes.toBytes("trans-tags"),
  // Bytes.toBytes("qual2"), CompareOp.EQUAL, Bytes.toBytes(value)));

  Scan scan = new Scan();
  scan.addFamily(Bytes.toBytes("trans-blob"));
  scan.addFamily(Bytes.toBytes("trans-type"));
  scan.addFamily(Bytes.toBytes("trans-date"));
  scan.addFamily(Bytes.toBytes("trans-tags"));
  scan.addFamily(Bytes.toBytes("trans-group"));
  scan.setFilter(allFilters);

  return ht.getScanner(scan);
}
 
Example #13
Source File: RegionLocationCleaner.java    From hbase-tools with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    try (HTableInterface table = connection.getTable(tableName.getBytes())) {
        // Do not use Get not to increase read request count metric.
        // Use Scan.
        Scan scan = new Scan("".getBytes(), "".getBytes());
        FilterList filterList = new FilterList();
        filterList.addFilter(new KeyOnlyFilter());
        filterList.addFilter(new FirstKeyOnlyFilter());
        scan.setFilter(filterList);
        //noinspection EmptyTryBlock
        try(ResultScanner ignored = table.getScanner(scan)) {
        }
        return;
    } catch (IOException ignore) {
    }

    clean(tableName);
}
 
Example #14
Source File: CubeHBaseRPC.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
public static void applyFuzzyFilter(Scan scan, List<org.apache.kylin.common.util.Pair<byte[], byte[]>> fuzzyKeys) {
    if (fuzzyKeys != null && fuzzyKeys.size() > 0) {
        FuzzyRowFilter rowFilter = new FuzzyRowFilter(convertToHBasePair(fuzzyKeys));

        Filter filter = scan.getFilter();
        if (filter != null) {
            // may have existed InclusiveStopFilter, see buildScan
            FilterList filterList = new FilterList();
            filterList.addFilter(filter);
            filterList.addFilter(rowFilter);
            scan.setFilter(filterList);
        } else {
            scan.setFilter(rowFilter);
        }
    }
}
 
Example #15
Source File: CommandAdapter.java    From hbase-tools with Apache License 2.0 6 votes vote down vote up
public static boolean isReallyEmptyRegion(HConnection connection,
    String tableName, HRegionInfo regionInfo) throws IOException {
    boolean emptyRegion = false;
    // verify really empty region by scanning records
    try (HTableInterface table = connection.getTable(tableName)) {
        Scan scan = new Scan(regionInfo.getStartKey(), regionInfo.getEndKey());
        FilterList filterList = new FilterList();
        filterList.addFilter(new KeyOnlyFilter());
        filterList.addFilter(new FirstKeyOnlyFilter());
        scan.setFilter(filterList);
        scan.setCacheBlocks(false);
        scan.setSmall(true);
        scan.setCaching(1);

        try (ResultScanner scanner = table.getScanner(scan)) {
            if (scanner.next() == null) emptyRegion = true;
        }
    }
    return emptyRegion;
}
 
Example #16
Source File: JobHistoryService.java    From hraven with Apache License 2.0 6 votes vote down vote up
/**
 * creates a scan for flow data
 * @param rowPrefix - start row prefix
 * @param limit - limit on scanned results
 * @param version - version to match
 * @return Scan
 */
private Scan createFlowScan(byte[] rowPrefix, int limit, String version) {
  Scan scan = new Scan();
  scan.setStartRow(rowPrefix);

  // using a large scanner caching value with a small limit can mean we scan a
  // lot more data than necessary, so lower the caching for low limits
  scan.setCaching(Math.min(limit, defaultScannerCaching));
  // require that all rows match the prefix we're looking for
  Filter prefixFilter = new WhileMatchFilter(new PrefixFilter(rowPrefix));
  // if version is passed, restrict the rows returned to that version
  if (version != null && version.length() > 0) {
    FilterList filters = new FilterList(FilterList.Operator.MUST_PASS_ALL);
    filters.addFilter(prefixFilter);
    filters.addFilter(new SingleColumnValueFilter(Constants.INFO_FAM_BYTES,
        Constants.VERSION_COLUMN_BYTES, CompareFilter.CompareOp.EQUAL,
        Bytes.toBytes(version)));
    scan.setFilter(filters);
  } else {
    scan.setFilter(prefixFilter);
  }
  return scan;
}
 
Example #17
Source File: VertexIndexModel.java    From hgraphdb with Apache License 2.0 6 votes vote down vote up
private Scan getVertexIndexScanWithLimit(String label, boolean isUnique, String key, Object from, int limit, boolean reversed) {
    byte[] prefix = serializeForRead(label, isUnique, key, null);
    byte[] startRow = from != null
            ? serializeForRead(label, isUnique, key, from)
            : prefix;
    byte[] stopRow = HConstants.EMPTY_END_ROW;
    if (graph.configuration().getInstanceType() == HBaseGraphConfiguration.InstanceType.BIGTABLE) {
        if (reversed) {
            throw new UnsupportedOperationException("Reverse scans not supported by Bigtable");
        } else {
            // PrefixFilter in Bigtable does not automatically stop
            // See https://github.com/GoogleCloudPlatform/cloud-bigtable-client/issues/1087
            stopRow = HBaseGraphUtils.incrementBytes(prefix);
        }
    }
    if (reversed) startRow = HBaseGraphUtils.incrementBytes(startRow);
    Scan scan = new Scan(startRow, stopRow);
    FilterList filterList = new FilterList();
    filterList.addFilter(new PrefixFilter(prefix));
    filterList.addFilter(new PageFilter(limit));
    scan.setFilter(filterList);
    scan.setReversed(reversed);
    return scan;
}
 
Example #18
Source File: TestThriftConnection.java    From hbase with Apache License 2.0 6 votes vote down vote up
private void testScanWithFilters(Connection connection, String tableName) throws IOException {
  createTable(thriftAdmin, tableName);
  try (Table table = connection.getTable(TableName.valueOf(tableName))){
    FilterList filterList = new FilterList();
    PrefixFilter prefixFilter = new PrefixFilter(Bytes.toBytes("testrow"));
    ColumnValueFilter columnValueFilter = new ColumnValueFilter(FAMILYA, QUALIFIER_1,
        CompareOperator.EQUAL, VALUE_1);
    filterList.addFilter(prefixFilter);
    filterList.addFilter(columnValueFilter);
    Scan scan = new Scan();
    scan.readVersions(2);
    scan.setFilter(filterList);
    ResultScanner scanner = table.getScanner(scan);
    Iterator<Result> iterator = scanner.iterator();
    assertTrue(iterator.hasNext());
    int counter = 0;
    while (iterator.hasNext()) {
      Result result = iterator.next();
      counter += result.size();
    }
    assertEquals(2, counter);
  }
}
 
Example #19
Source File: RowCountVisitor.java    From phoenix with Apache License 2.0 6 votes vote down vote up
public static Filter stripSkipScanFilter(Filter filter) {
    if (filter == null) {
        return null;
    }
    if (!(filter instanceof FilterList)) {
        return filter instanceof BooleanExpressionFilter ? filter : null;
    }
    FilterList filterList = (FilterList) filter;
    if (filterList.getOperator() != FilterList.Operator.MUST_PASS_ALL) {
        return filter;
    }
    List<Filter> list = new ArrayList<>();
    for (Filter f : filterList.getFilters()) {
        Filter stripped = stripSkipScanFilter(f);
        if (stripped != null) {
            list.add(stripped);
        }
    }
    return list.isEmpty() ? null : (list.size() == 1 ? list.get(0) : new FilterList(FilterList.Operator.MUST_PASS_ALL, list));
}
 
Example #20
Source File: HBaseFilterBuilder.java    From pxf with Apache License 2.0 6 votes vote down vote up
/**
 * If the result is of type {@link FilterList}, add the {@link Filter} to
 * the filter list. Otherwise, set it as the resulting {@link Filter}
 *
 * @param filter the filter to process
 */
private void processFilter(Filter filter) {
    Filter head = filterQueue.peek();
    if (head instanceof FilterList) {
        /*
         * Handles operation between already calculated expressions.
         * Currently only {@code AND}, in the future {@code OR} can be added.
         * Four cases here:
         *  - Both are simple filters.
         *  - Left is a FilterList and right is a filter.
         *  - Left is a filter and right is a FilterList.
         *  - Both are FilterLists.
         */
        ((FilterList) head).addFilter(filter);
    }
    currentFilter = filter;
}
 
Example #21
Source File: IndexLogReader.java    From eagle with Apache License 2.0 6 votes vote down vote up
protected static void workaroundHBASE2198(Get get, Filter filter, byte[][] qualifiers) {
    if (filter instanceof SingleColumnValueFilter) {
        if (qualifiers == null) {
            get.addFamily(((SingleColumnValueFilter)filter).getFamily());
        } else {
            get.addColumn(((SingleColumnValueFilter)filter).getFamily(),
                          ((SingleColumnValueFilter)filter).getQualifier());
        }
        return;
    }
    if (filter instanceof FilterList) {
        for (Filter f : ((FilterList)filter).getFilters()) {
            workaroundHBASE2198(get, f, qualifiers);
        }
    }
}
 
Example #22
Source File: Filters.java    From java-docs-samples with Apache License 2.0 6 votes vote down vote up
public static void filterLimitValueRange(String projectId, String instanceId, String tableId) {
  // A filter that matches cells whose values are between the given values
  ValueFilter valueGreaterFilter =
      new ValueFilter(
          CompareFilter.CompareOp.GREATER_OR_EQUAL,
          new BinaryComparator(Bytes.toBytes("PQ2A.190405")));
  ValueFilter valueLesserFilter =
      new ValueFilter(
          CompareFilter.CompareOp.LESS_OR_EQUAL,
          new BinaryComparator(Bytes.toBytes("PQ2A.190406")));

  FilterList filter = new FilterList(FilterList.Operator.MUST_PASS_ALL);
  filter.addFilter(valueGreaterFilter);
  filter.addFilter(valueLesserFilter);

  Scan scan = new Scan().setFilter(filter);
  readWithFilter(projectId, instanceId, tableId, scan);
}
 
Example #23
Source File: MetaBrowser.java    From hbase with Apache License 2.0 6 votes vote down vote up
private Filter buildScanFilter() {
  if (scanTable == null && scanRegionState == null) {
    return null;
  }

  final List<Filter> filters = new ArrayList<>(2);
  if (scanTable != null) {
    filters.add(buildTableFilter(scanTable));
  }
  if (scanRegionState != null) {
    filters.add(buildScanRegionStateFilter(scanRegionState));
  }
  if (filters.size() == 1) {
    return filters.get(0);
  }
  return new FilterList(FilterList.Operator.MUST_PASS_ALL, filters);
}
 
Example #24
Source File: ScanUtil.java    From phoenix with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static void andFilterAtEnd(Scan scan, Filter andWithFilter) {
    if (andWithFilter == null) {
        return;
    }
    Filter filter = scan.getFilter();
    if (filter == null) {
        scan.setFilter(andWithFilter); 
    } else if (filter instanceof FilterList && ((FilterList)filter).getOperator() == FilterList.Operator.MUST_PASS_ALL) {
        FilterList filterList = (FilterList)filter;
        List<Filter> allFilters = new ArrayList<Filter>(filterList.getFilters().size() + 1);
        allFilters.addAll(filterList.getFilters());
        allFilters.add(andWithFilter);
        scan.setFilter(new FilterList(FilterList.Operator.MUST_PASS_ALL,allFilters));
    } else {
        scan.setFilter(new FilterList(FilterList.Operator.MUST_PASS_ALL,Arrays.asList(filter, andWithFilter)));
    }
}
 
Example #25
Source File: ActiveMemberRunner.java    From BigDataArchitect with Apache License 2.0 6 votes vote down vote up
@Override
protected Filter fetchHbaseFilter() {
    FilterList filterList = new FilterList();
    // 定义mapper中需要获取的列名
    String[] columns = new String[] { EventLogConstants.LOG_COLUMN_NAME_MEMBER_ID, // 会员id
            EventLogConstants.LOG_COLUMN_NAME_SERVER_TIME, // 服务器时间
            EventLogConstants.LOG_COLUMN_NAME_PLATFORM, // 平台名称
            EventLogConstants.LOG_COLUMN_NAME_BROWSER_NAME, // 浏览器名称
            EventLogConstants.LOG_COLUMN_NAME_BROWSER_VERSION, // 浏览器版本号
            EventLogConstants.LOG_COLUMN_NAME_EVENT_NAME // 添加一个事件名称获取列,在使用singlecolumnvaluefilter的时候必须指定对应的列是一个返回列
    };
    filterList.addFilter(this.getColumnFilter(columns));
    // 只需要page view事件,所以进行过滤
    filterList.addFilter(new SingleColumnValueFilter(ActiveMemberMapper.family, Bytes.toBytes(EventLogConstants.LOG_COLUMN_NAME_EVENT_NAME), CompareOp.EQUAL, Bytes.toBytes(EventEnum.PAGEVIEW.alias)));

    return filterList;
}
 
Example #26
Source File: StatementHintsCompilationTest.java    From phoenix with Apache License 2.0 5 votes vote down vote up
private static boolean usingSkipScan(Scan scan) {
    Filter filter = scan.getFilter();
    if (filter instanceof FilterList) {
        FilterList filterList = (FilterList) filter;
        for (Filter childFilter : filterList.getFilters()) {
            if (childFilter instanceof SkipScanFilter) {
                return true;
            }
        }
        return false;
    }
    return filter instanceof SkipScanFilter;
}
 
Example #27
Source File: VisibilityController.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> e, Get get,
    List<Cell> results) throws IOException {
  if (!initialized) {
    throw new VisibilityControllerNotReadyException("VisibilityController not yet initialized");
  }
  // Nothing useful to do if authorization is not enabled
  if (!authorizationEnabled) {
    return;
  }
  Region region = e.getEnvironment().getRegion();
  Authorizations authorizations = null;
  try {
    authorizations = get.getAuthorizations();
  } catch (DeserializationException de) {
    throw new IOException(de);
  }
  if (authorizations == null) {
    // No Authorizations present for this scan/Get!
    // In case of system tables other than "labels" just scan with out visibility check and
    // filtering. Checking visibility labels for META and NAMESPACE table is not needed.
    TableName table = region.getRegionInfo().getTable();
    if (table.isSystemTable() && !table.equals(LABELS_TABLE_NAME)) {
      return;
    }
  }
  Filter visibilityLabelFilter = VisibilityUtils.createVisibilityLabelFilter(e.getEnvironment()
      .getRegion(), authorizations);
  if (visibilityLabelFilter != null) {
    Filter filter = get.getFilter();
    if (filter != null) {
      get.setFilter(new FilterList(filter, visibilityLabelFilter));
    } else {
      get.setFilter(visibilityLabelFilter);
    }
  }
}
 
Example #28
Source File: TestHBaseStorageFiltering.java    From spork with Apache License 2.0 5 votes vote down vote up
@Test
public void testPrefix() throws Exception {
    Filter filter = getHBaseStorageFilter("cf1:foo*");
    List<Filter> childFilters = assertFilterList(filter, FilterList.Operator.MUST_PASS_ALL, 1);
    childFilters = assertFilterList(childFilters.get(0), FilterList.Operator.MUST_PASS_ONE, 1);
    childFilters = assertFilterList(childFilters.get(0), FilterList.Operator.MUST_PASS_ALL, 2);
    assertFamilyFilter(childFilters.get(0), CompareFilter.CompareOp.EQUAL, "cf1");
    childFilters = assertFilterList(childFilters.get(1), FilterList.Operator.MUST_PASS_ONE, 1);
    assertPrefixFilter(childFilters.get(0), "foo");
}
 
Example #29
Source File: HBaseResourceStore.java    From kylin with Apache License 2.0 5 votes vote down vote up
private FilterList generateTimeFilterList(VisitFilter visitFilter) {
    FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ALL);
    if (visitFilter.lastModStart >= 0) { // NOTE: Negative value does not work in its binary form
        SingleColumnValueFilter timeStartFilter = new SingleColumnValueFilter(B_FAMILY, B_COLUMN_TS,
                CompareFilter.CompareOp.GREATER_OR_EQUAL, Bytes.toBytes(visitFilter.lastModStart));
        filterList.addFilter(timeStartFilter);
    }
    if (visitFilter.lastModEndExclusive != Long.MAX_VALUE) {
        SingleColumnValueFilter timeEndFilter = new SingleColumnValueFilter(B_FAMILY, B_COLUMN_TS,
                CompareFilter.CompareOp.LESS, Bytes.toBytes(visitFilter.lastModEndExclusive));
        filterList.addFilter(timeEndFilter);
    }
    return filterList.getFilters().isEmpty() ? null : filterList;
}
 
Example #30
Source File: HbaseTraceDaoV2.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
private Filter getFilter(Filter filter1, Filter filter2) {
    if (filter1 != null && filter2 != null) {
        FilterList filterList = new FilterList();
        filterList.addFilter(filter1);
        filterList.addFilter(filter2);
        return filterList;
    }
    if (filter1 != null) {
        return filter1;
    }
    if (filter2 != null) {
        return filter2;
    }
    return null;
}