当前位置: 首页>>代码示例>>Java>>正文


Java BinaryComparator类代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.filter.BinaryComparator的典型用法代码示例。如果您正苦于以下问题:Java BinaryComparator类的具体用法?Java BinaryComparator怎么用?Java BinaryComparator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BinaryComparator类属于org.apache.hadoop.hbase.filter包,在下文中一共展示了BinaryComparator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testScanWithFilter

import org.apache.hadoop.hbase.filter.BinaryComparator; //导入依赖的package包/类
@Test
public void testScanWithFilter() throws IOException {
  prepareScanData(TRANSACTION_COLUMNS);
  writeData(COLUMN, lastTs(prewriteTs), ANOTHER_VALUE);
  ValueFilter valueFilter = new ValueFilter(CompareOp.EQUAL, new BinaryComparator(ANOTHER_VALUE));
  PrefixFilter prefixFilter = new PrefixFilter(ANOTHER_ROW);
  FilterList filterList = new FilterList();
  filterList.addFilter(valueFilter);
  filterList.addFilter(prefixFilter);
  ThemisScanner scanner = prepareScanner(TRANSACTION_COLUMNS, filterList);
  checkAndCloseScanner(scanner);
  
  filterList = new FilterList(Operator.MUST_PASS_ONE);
  filterList.addFilter(valueFilter);
  filterList.addFilter(prefixFilter);
  scanner = prepareScanner(TRANSACTION_COLUMNS, filterList);
  checkScanRow(new ColumnCoordinate[]{COLUMN_WITH_ANOTHER_ROW}, scanner.next());
  Assert.assertEquals(1, scanner.next().size());
  checkAndCloseScanner(scanner);
}
 
开发者ID:XiaoMi,项目名称:themis,代码行数:21,代码来源:TestThemisScanner.java

示例2: parseTree

import org.apache.hadoop.hbase.filter.BinaryComparator; //导入依赖的package包/类
public HBaseScanSpec parseTree() {
  HBaseScanSpec parsedSpec = le.accept(this, null);
  if (parsedSpec != null) {
    parsedSpec = mergeScanSpecs("booleanAnd", this.groupScan.getHBaseScanSpec(), parsedSpec);
    /*
     * If RowFilter is THE filter attached to the scan specification,
     * remove it since its effect is also achieved through startRow and stopRow.
     */
    Filter parsedFilter = HBaseUtils.deserializeFilter(parsedSpec.filter);
    if (parsedFilter instanceof RowFilter &&
        ((RowFilter)parsedFilter).getComparator() instanceof BinaryComparator) {
      parsedSpec.filter = null;
    }
  }
  return parsedSpec;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:17,代码来源:HBaseFilterBuilder.java

示例3: constructScan

import org.apache.hadoop.hbase.filter.BinaryComparator; //导入依赖的package包/类
protected Scan constructScan(byte[] valuePrefix) throws IOException {
  FilterList list = new FilterList();
  Filter filter = new SingleColumnValueFilter(
      FAMILY_NAME, COLUMN_ZERO, CompareFilter.CompareOp.EQUAL,
      new BinaryComparator(valuePrefix)
  );
  list.addFilter(filter);
  if(opts.filterAll) {
    list.addFilter(new FilterAllFilter());
  }
  Scan scan = new Scan();
  scan.setCaching(opts.caching);
  if (opts.addColumns) {
    scan.addColumn(FAMILY_NAME, QUALIFIER_NAME);
  } else {
    scan.addFamily(FAMILY_NAME);
  }
  scan.setFilter(list);
  return scan;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:21,代码来源:PerformanceEvaluation.java

示例4: testJira6912

import org.apache.hadoop.hbase.filter.BinaryComparator; //导入依赖的package包/类
@Test
public void testJira6912() throws Exception {
  TableName TABLE = TableName.valueOf("testJira6912");
  Table foo = TEST_UTIL.createTable(TABLE, new byte[][] {FAMILY}, 10);

  List<Put> puts = new ArrayList<Put>();
  for (int i=0;i !=100; i++){
    Put put = new Put(Bytes.toBytes(i));
    put.add(FAMILY, FAMILY, Bytes.toBytes(i));
    puts.add(put);
  }
  foo.put(puts);
  // If i comment this out it works
  TEST_UTIL.flush();

  Scan scan = new Scan();
  scan.setStartRow(Bytes.toBytes(1));
  scan.setStopRow(Bytes.toBytes(3));
  scan.addColumn(FAMILY, FAMILY);
  scan.setFilter(new RowFilter(CompareFilter.CompareOp.NOT_EQUAL, new BinaryComparator(Bytes.toBytes(1))));

  ResultScanner scanner = foo.getScanner(scan);
  Result[] bar = scanner.next(100);
  assertEquals(1, bar.length);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:26,代码来源:TestFromClientSide.java

示例5: testCheckAndPut_wrongRowInPut

import org.apache.hadoop.hbase.filter.BinaryComparator; //导入依赖的package包/类
@Test
public void testCheckAndPut_wrongRowInPut() throws IOException {
  TableName tableName = TableName.valueOf(name.getMethodName());
  this.region = initHRegion(tableName, this.getName(), CONF, COLUMNS);
  try {
    Put put = new Put(row2);
    put.add(fam1, qual1, value1);
    try {
      region.checkAndMutate(row, fam1, qual1, CompareOp.EQUAL,
          new BinaryComparator(value2), put, false);
      fail();
    } catch (org.apache.hadoop.hbase.DoNotRetryIOException expected) {
      // expected exception.
    }
  } finally {
    HRegion.closeHRegion(this.region);
    this.region = null;
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:TestHRegion.java

示例6: fromFilter

import org.apache.hadoop.hbase.filter.BinaryComparator; //导入依赖的package包/类
public static Range[] fromFilter(SingleColumnValueFilter filter) {
  if (!(filter.getComparator() instanceof BinaryComparator)) {
    return new Range[0];
  }

  byte[] column = KeyValue.makeColumn(filter.getFamily(), filter.getQualifier());
  CompareOp compareOp = filter.getOperator();
  byte[] value = filter.getComparator().getValue();

  if (compareOp == CompareOp.NOT_EQUAL) {
    return new Range[] { new Range(column, null, CompareOp.NO_OP, value, CompareOp.LESS),
        new Range(column, value, CompareOp.GREATER, null, CompareOp.NO_OP) };
  } else {
    switch (compareOp) {
    case EQUAL:
    case GREATER_OR_EQUAL:
    case GREATER:
      return new Range[] { new Range(column, value, compareOp, null, CompareOp.NO_OP) };
    case LESS:
    case LESS_OR_EQUAL:
      return new Range[] { new Range(column, null, CompareOp.NO_OP, value, compareOp) };
    default:
      return new Range[0];
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:27,代码来源:Range.java

示例7: checkAndPut

import org.apache.hadoop.hbase.filter.BinaryComparator; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public boolean checkAndPut(final byte [] row,
    final byte [] family, final byte [] qualifier, final byte [] value,
    final Put put)
throws IOException {
  RegionServerCallable<Boolean> callable =
    new RegionServerCallable<Boolean>(connection, getName(), row) {
      @Override
      public Boolean call(int callTimeout) throws IOException {
        PayloadCarryingRpcController controller = rpcControllerFactory.newController();
        controller.setPriority(tableName);
        controller.setCallTimeout(callTimeout);
        try {
          MutateRequest request = RequestConverter.buildMutateRequest(
              getLocation().getRegionInfo().getRegionName(), row, family, qualifier,
              new BinaryComparator(value), CompareType.EQUAL, put);
          MutateResponse response = getStub().mutate(controller, request);
          return Boolean.valueOf(response.getProcessed());
        } catch (ServiceException se) {
          throw ProtobufUtil.getRemoteException(se);
        }
      }
    };
  return rpcCallerFactory.<Boolean> newCaller().callWithRetries(callable, this.operationTimeout);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:29,代码来源:HTable.java

示例8: checkAndDelete

import org.apache.hadoop.hbase.filter.BinaryComparator; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public boolean checkAndDelete(final byte [] row,
    final byte [] family, final byte [] qualifier, final byte [] value,
    final Delete delete)
throws IOException {
  RegionServerCallable<Boolean> callable =
    new RegionServerCallable<Boolean>(connection, getName(), row) {
      @Override
      public Boolean call(int callTimeout) throws IOException {
        PayloadCarryingRpcController controller = rpcControllerFactory.newController();
        controller.setPriority(tableName);
        controller.setCallTimeout(callTimeout);
        try {
          MutateRequest request = RequestConverter.buildMutateRequest(
            getLocation().getRegionInfo().getRegionName(), row, family, qualifier,
              new BinaryComparator(value), CompareType.EQUAL, delete);
          MutateResponse response = getStub().mutate(controller, request);
          return Boolean.valueOf(response.getProcessed());
        } catch (ServiceException se) {
          throw ProtobufUtil.getRemoteException(se);
        }
      }
    };
  return rpcCallerFactory.<Boolean> newCaller().callWithRetries(callable, this.operationTimeout);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:29,代码来源:HTable.java

示例9: ByteArrayComparableModel

import org.apache.hadoop.hbase.filter.BinaryComparator; //导入依赖的package包/类
public ByteArrayComparableModel(
    ByteArrayComparable comparator) {
  String typeName = comparator.getClass().getSimpleName();
  ComparatorType type = ComparatorType.valueOf(typeName);
  this.type = typeName;
  switch (type) {
    case BinaryComparator:
    case BinaryPrefixComparator:
      this.value = Base64.encodeBytes(comparator.getValue());
      break;
    case BitComparator:
      this.value = Base64.encodeBytes(comparator.getValue());
      this.op = ((BitComparator)comparator).getOperator().toString();
      break;
    case NullComparator:
      break;
    case RegexStringComparator:
    case SubstringComparator:
      this.value = Bytes.toString(comparator.getValue());
      break;
    default:
      throw new RuntimeException("unhandled filter type: " + type);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:25,代码来源:ScannerModel.java

示例10: parseTree

import org.apache.hadoop.hbase.filter.BinaryComparator; //导入依赖的package包/类
public HBaseScanSpec parseTree() {
  HBaseScanSpec parsedSpec = le.accept(this, null);
  if (parsedSpec != null) {
    parsedSpec = mergeScanSpecs("booleanAnd", this.groupScan.getHBaseScanSpec(), parsedSpec);
    /*
     * If RowFilter is THE filter attached to the scan specification,
     * remove it since its effect is also achieved through startRow and stopRow.
     */
    Filter filter = parsedSpec.getFilter();
    if (filter instanceof RowFilter &&
        ((RowFilter)filter).getOperator() != CompareOp.NOT_EQUAL &&
        ((RowFilter)filter).getComparator() instanceof BinaryComparator) {
      parsedSpec = new HBaseScanSpec(parsedSpec.getTableName(), parsedSpec.getStartRow(), parsedSpec.getStopRow(), null);
    }
  }
  return parsedSpec;
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:18,代码来源:MapRDBFilterBuilder.java

示例11: testJira6912

import org.apache.hadoop.hbase.filter.BinaryComparator; //导入依赖的package包/类
@Test
public void testJira6912() throws Exception {
  byte [] TABLE = Bytes.toBytes("testJira6912");
  HTable foo = TEST_UTIL.createTable(TABLE, new byte[][] {FAMILY}, 10);

  List<Put> puts = new ArrayList<Put>();
  for (int i=0;i !=100; i++){
    Put put = new Put(Bytes.toBytes(i));
    put.add(FAMILY, FAMILY, Bytes.toBytes(i));
    puts.add(put);
  }
  foo.put(puts);
  // If i comment this out it works
  TEST_UTIL.flush();

  Scan scan = new Scan();
  scan.setStartRow(Bytes.toBytes(1));
  scan.setStopRow(Bytes.toBytes(3));
  scan.addColumn(FAMILY, FAMILY);
  scan.setFilter(new RowFilter(CompareFilter.CompareOp.NOT_EQUAL, new BinaryComparator(Bytes.toBytes(1))));

  ResultScanner scanner = foo.getScanner(scan);
  Result[] bar = scanner.next(100);
  assertEquals(1, bar.length);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:26,代码来源:TestFromClientSide.java

示例12: testCheckAndPut_wrongRowInPut

import org.apache.hadoop.hbase.filter.BinaryComparator; //导入依赖的package包/类
public void testCheckAndPut_wrongRowInPut() throws IOException {
  this.region = initHRegion(tableName, this.getName(), conf, COLUMNS);
  try {
    Put put = new Put(row2);
    put.add(fam1, qual1, value1);
    try {
      boolean res = region.checkAndMutate(row, fam1, qual1, CompareOp.EQUAL,
          new BinaryComparator(value2), put, null, false);
      fail();
    } catch (DoNotRetryIOException expected) {
      // expected exception.
    }
  } finally {
    HRegion.closeHRegion(this.region);
    this.region = null;
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:18,代码来源:TestHRegion.java

示例13: getEdges

import org.apache.hadoop.hbase.filter.BinaryComparator; //导入依赖的package包/类
public Iterable<Edge> getEdges(String key, Object value) {
	try {
		Scan scan = new Scan(Bytes.toBytes(this.graphName+"_"+key), this.getEndKey(Bytes.toBytes(this.graphName+"_"+key)));
		scan.addFamily(Bytes.toBytes("edge"));
		scan.setFilter(new ValueFilter(CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes(String.valueOf(value)))));

		return new HbaseIterable<Edge>(scan, HbaseGraphUtils.PROPERTIESTABLENAME, hbaseConf) {
			@Override
			public Edge next(Result result) {			
				for(Cell cell : result.listCells()) {
					String id = Bytes.toString(CellUtil.cloneQualifier(cell));
					return new HbaseEdge(id, graphName, hbaseConf);
				}
				return null;
			}
		};		
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:dpv91788,项目名称:HBaseTinkerGraph,代码行数:23,代码来源:HbaseGraph.java

示例14: getVertices

import org.apache.hadoop.hbase.filter.BinaryComparator; //导入依赖的package包/类
public Iterable<Vertex> getVertices(String key, Object value) {
	try {
		Scan scan = new Scan(Bytes.toBytes(this.graphName+"_"+key), this.getEndKey(Bytes.toBytes(this.graphName+"_"+key)));
		scan.addFamily(Bytes.toBytes("vertex"));
		scan.setFilter(new ValueFilter(CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes(String.valueOf(value)))));

		return new HbaseIterable<Vertex>(scan, HbaseGraphUtils.PROPERTIESTABLENAME, hbaseConf) {
			@Override
			public Vertex next(Result result) {			
				for(Cell cell : result.listCells()) {
					String id = Bytes.toString(CellUtil.cloneQualifier(cell));
					return new HbaseVertex(id, graphName, hbaseConf);
				}
				return null;
			}
		};		
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:dpv91788,项目名称:HBaseTinkerGraph,代码行数:23,代码来源:HbaseGraph.java

示例15: isFilterSupported

import org.apache.hadoop.hbase.filter.BinaryComparator; //导入依赖的package包/类
@Override
public FilterSupportStatus isFilterSupported(
    FilterAdapterContext context, QualifierFilter filter) {
  // For range filters, we only support a single family:
  if (!CompareOp.EQUAL.equals(filter.getOperator())
      && filter.getComparator() instanceof BinaryComparator
      && context.getScan().numFamilies() != 1) {
    return SINGLE_FAMILY_REQUIRED;
  }
  // Support binary comparators and regex comparators with equal compare op:
  if ( !(filter.getComparator() instanceof BinaryComparator)
      && !isRegexAndSupported(filter)) {
    return UNSUPPORTED_COMPARABLE;
  }
  return FilterSupportStatus.SUPPORTED;
}
 
开发者ID:dmmcerlean,项目名称:cloud-bigtable-client,代码行数:17,代码来源:QualifierFilterAdapter.java


注:本文中的org.apache.hadoop.hbase.filter.BinaryComparator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。