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


Java CompareOp.EQUAL属性代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.filter.CompareFilter.CompareOp.EQUAL属性的典型用法代码示例。如果您正苦于以下问题:Java CompareOp.EQUAL属性的具体用法?Java CompareOp.EQUAL怎么用?Java CompareOp.EQUAL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.hadoop.hbase.filter.CompareFilter.CompareOp的用法示例。


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

示例1: QueryByCondition2

public static void QueryByCondition2(String tableName) {

        try {
            HTablePool pool = new HTablePool(configuration, 1000);
            HTable table = (HTable) pool.getTable(tableName);
            Filter filter = new SingleColumnValueFilter(Bytes
                    .toBytes("column1"), null, CompareOp.EQUAL, Bytes
                    .toBytes("aaa")); // 当列column1的值为aaa时进行查询
            Scan s = new Scan();
            s.setFilter(filter);
            ResultScanner rs = table.getScanner(s);
            for (Result r : rs) {
                System.out.println("获得到rowkey:" + new String(r.getRow()));
                for (KeyValue keyValue : r.raw()) {
                    System.out.println("列:" + new String(keyValue.getFamily())
                            + "====值:" + new String(keyValue.getValue()));
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
 
开发者ID:yjp123456,项目名称:SparkDemo,代码行数:23,代码来源:MyClass.java

示例2: printRange

public static String printRange(Range r) {
  StringBuilder sb = new StringBuilder();
  sb.append("[" + Bytes.toString(r.getFamily()) + ":" + Bytes.toString(r.getQualifier())
      + "], values (");
  if (r.getStartValue() != null) {
    sb.append(LCIndexConstant.getStringOfValueAndType(r.getDataType(), r.getStartValue()));
    if (r.getStartType() == CompareOp.EQUAL || r.getStartType() == CompareOp.NOT_EQUAL) {
      sb.append(" <== ").append(r.getStartType()).append(" )");
      return sb.toString();
    }
  } else {
    sb.append("null");
  }
  sb.append(", ");
  if (r.getStopValue() != null) {
    sb.append(LCIndexConstant.getStringOfValueAndType(r.getDataType(), r.getStopValue()));
  } else {
    sb.append("MAX");
  }
  sb.append(")");
  return sb.toString();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:22,代码来源:LCIndexConstant.java

示例3: configure

@Override
public void configure(JobConf job) {
  try {
    HTable exampleTable = new HTable(HBaseConfiguration.create(job),
      Bytes.toBytes("exampleDeprecatedTable"));
    // mandatory
    setHTable(exampleTable);
    byte[][] inputColumns = new byte [][] { Bytes.toBytes("columnA"),
      Bytes.toBytes("columnB") };
    // mandatory
    setInputColumns(inputColumns);
    Filter exampleFilter = new RowFilter(CompareOp.EQUAL, new RegexStringComparator("aa.*"));
    // optional
    setRowFilter(exampleFilter);
  } catch (IOException exception) {
    throw new RuntimeException("Failed to configure for job.", exception);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:TestTableInputFormat.java

示例4: configure

@Override
public void configure(JobConf job) {
  try {
    HTable exampleTable = new HTable(HBaseConfiguration.create(job),
      Bytes.toBytes("exampleDeprecatedTable"));
    // mandatory
    setHTable(exampleTable);
    byte[][] inputColumns = new byte [][] { Bytes.toBytes("columnA"),
      Bytes.toBytes("columnB") };
    // optional
    Scan scan = new Scan();
    for (byte[] family : inputColumns) {
      scan.addFamily(family);
    }
    Filter exampleFilter = new RowFilter(CompareOp.EQUAL, new RegexStringComparator("aa.*"));
    scan.setFilter(exampleFilter);
    setScan(scan);
  } catch (IOException exception) {
    throw new RuntimeException("Failed to configure for job.", exception);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:21,代码来源:TestTableInputFormat.java

示例5: createCompareOp

/**
* Takes a compareOperator symbol as a byte array and returns the corresponding CompareOperator
* <p>
* @param compareOpAsByteArray the comparatorOperator symbol as a byte array
* @return the Compare Operator
*/
 public static CompareFilter.CompareOp createCompareOp (byte [] compareOpAsByteArray) {
   ByteBuffer compareOp = ByteBuffer.wrap(compareOpAsByteArray);
   if (compareOp.equals(ParseConstants.LESS_THAN_BUFFER))
     return CompareOp.LESS;
   else if (compareOp.equals(ParseConstants.LESS_THAN_OR_EQUAL_TO_BUFFER))
     return CompareOp.LESS_OR_EQUAL;
   else if (compareOp.equals(ParseConstants.GREATER_THAN_BUFFER))
     return CompareOp.GREATER;
   else if (compareOp.equals(ParseConstants.GREATER_THAN_OR_EQUAL_TO_BUFFER))
     return CompareOp.GREATER_OR_EQUAL;
   else if (compareOp.equals(ParseConstants.NOT_EQUAL_TO_BUFFER))
     return CompareOp.NOT_EQUAL;
   else if (compareOp.equals(ParseConstants.EQUAL_TO_BUFFER))
     return CompareOp.EQUAL;
   else
     throw new IllegalArgumentException("Invalid compare operator");
 }
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:ParseFilter.java

示例6: initialize

@Override
protected void initialize(JobContext job) throws IOException {
  Connection connection = ConnectionFactory.createConnection(HBaseConfiguration.create(
      job.getConfiguration()));
  TableName tableName = TableName.valueOf("exampleTable");
  // mandatory
  initializeTable(connection, tableName);
  byte[][] inputColumns = new byte [][] { Bytes.toBytes("columnA"),
    Bytes.toBytes("columnB") };
  //optional
  Scan scan = new Scan();
  for (byte[] family : inputColumns) {
    scan.addFamily(family);
  }
  Filter exampleFilter = new RowFilter(CompareOp.EQUAL, new RegexStringComparator("aa.*"));
  scan.setFilter(exampleFilter);
  setScan(scan);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:TestTableInputFormat.java

示例7: buildScanner

private InternalScanner buildScanner(String keyPrefix, String value, HRegion r)
    throws IOException {
  // Defaults FilterList.Operator.MUST_PASS_ALL.
  FilterList allFilters = new FilterList();
  allFilters.addFilter(new PrefixFilter(Bytes.toBytes(keyPrefix)));
  // Only return rows where this column value exists in the row.
  SingleColumnValueFilter filter = new SingleColumnValueFilter(Bytes.toBytes("trans-tags"),
      Bytes.toBytes("qual2"), CompareOp.EQUAL, Bytes.toBytes(value));
  filter.setFilterIfMissing(true);
  allFilters.addFilter(filter);
  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 r.getScanner(scan);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:TestHRegion.java

示例8: setStartType

/**
 * Set start type for start value.
 *
 * @param startType - can only be EQUAL, GREATER or GREATER_OR_EQUAL
 */
public void setStartType(CompareOp startType) {
  if (startType == CompareOp.EQUAL || startType == CompareOp.GREATER
      || startType == CompareOp.GREATER_OR_EQUAL) {
    this.startType = startType;
  } else {
    this.startType = startType;
    //			throw new IllegalArgumentException("Illegal start type: "
    //					+ startType.toString());
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:15,代码来源:Range.java

示例9: initialize

protected void initialize(JobConf job, String table) throws IOException {
  Connection connection = ConnectionFactory.createConnection(HBaseConfiguration.create(job));
  TableName tableName = TableName.valueOf(table);
  // mandatory
  initializeTable(connection, tableName);
  byte[][] inputColumns = new byte [][] { Bytes.toBytes("columnA"),
    Bytes.toBytes("columnB") };
  // mandatory
  setInputColumns(inputColumns);
  Filter exampleFilter = new RowFilter(CompareOp.EQUAL, new RegexStringComparator("aa.*"));
  // optional
  setRowFilter(exampleFilter);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:13,代码来源:TestTableInputFormat.java

示例10: createFilterFromArguments

public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) {
  Preconditions.checkArgument(filterArguments.size() == 4 || filterArguments.size() == 6,
                              "Expected 4 or 6 but got: %s", filterArguments.size());
  byte [] family = ParseFilter.removeQuotesFromByteArray(filterArguments.get(0));
  byte [] qualifier = ParseFilter.removeQuotesFromByteArray(filterArguments.get(1));
  CompareOp compareOp = ParseFilter.createCompareOp(filterArguments.get(2));
  ByteArrayComparable comparator = ParseFilter.createComparator(
    ParseFilter.removeQuotesFromByteArray(filterArguments.get(3)));

  if (comparator instanceof RegexStringComparator ||
      comparator instanceof SubstringComparator) {
    if (compareOp != CompareOp.EQUAL &&
        compareOp != CompareOp.NOT_EQUAL) {
      throw new IllegalArgumentException ("A regexstring comparator and substring comparator " +
                                          "can only be used with EQUAL and NOT_EQUAL");
    }
  }

  SingleColumnValueFilter filter = new SingleColumnValueFilter(family, qualifier,
                                                               compareOp, comparator);

  if (filterArguments.size() == 6) {
    boolean filterIfMissing = ParseFilter.convertByteArrayToBoolean(filterArguments.get(4));
    boolean latestVersionOnly = ParseFilter.convertByteArrayToBoolean(filterArguments.get(5));
    filter.setFilterIfMissing(filterIfMissing);
    filter.setLatestVersionOnly(latestVersionOnly);
  }
  return filter;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:29,代码来源:SingleColumnValueFilter.java

示例11: testBulkDeleteWithConditionBasedDelete

public void testBulkDeleteWithConditionBasedDelete() throws Throwable {
  TableName tableName = TableName.valueOf("testBulkDeleteWithConditionBasedDelete");
  Table ht = createTable(tableName);
  List<Put> puts = new ArrayList<Put>(100);
  for (int j = 0; j < 100; j++) {
    byte[] rowkey = Bytes.toBytes(j);
    String value = (j % 10 == 0) ? "v1" : "v2";
    puts.add(createPut(rowkey, value));
  }
  ht.put(puts);
  Scan scan = new Scan();
  FilterList fl = new FilterList(Operator.MUST_PASS_ALL);
  SingleColumnValueFilter scvf = new SingleColumnValueFilter(FAMILY1, QUALIFIER3,
      CompareOp.EQUAL, Bytes.toBytes("v1"));
  // fl.addFilter(new FirstKeyOnlyFilter());
  fl.addFilter(scvf);
  scan.setFilter(fl);
  // Deleting all the rows where cf1:c1=v1
  long noOfRowsDeleted = invokeBulkDeleteProtocol(tableName, scan, 500, DeleteType.ROW, null);
  assertEquals(10, noOfRowsDeleted);

  int rows = 0;
  for (Result result : ht.getScanner(new Scan())) {
    rows++;
  }
  assertEquals(90, rows);
  ht.close();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:28,代码来源:TestBulkDeleteProtocol.java

示例12: testToStringWithNullComparator

/**
 * Test for HBASE-8794. Avoid NullPointerException in DependentColumnFilter.toString().
 */
@Test
public void testToStringWithNullComparator() {
  // Test constructor that implicitly sets a null comparator
  Filter filter = new DependentColumnFilter(FAMILIES[0], QUALIFIER);
  assertNotNull(filter.toString());
  assertTrue("check string contains 'null' as compatator is null",
    filter.toString().contains("null"));

  // Test constructor with explicit null comparator
  filter = new DependentColumnFilter(FAMILIES[0], QUALIFIER, true, CompareOp.EQUAL, null);
  assertNotNull(filter.toString());
  assertTrue("check string contains 'null' as compatator is null",
    filter.toString().contains("null"));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:TestDependentColumnFilter.java

示例13: testToStringWithNonNullComparator

@Test
public void testToStringWithNonNullComparator() {
  Filter filter =
      new DependentColumnFilter(FAMILIES[0], QUALIFIER, true, CompareOp.EQUAL,
          new BinaryComparator(MATCH_VAL));
  assertNotNull(filter.toString());
  assertTrue("check string contains comparator value", filter.toString().contains("match"));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:8,代码来源:TestDependentColumnFilter.java

示例14: setStopType

/**
 * Set end type for end value.
 * @param stopType - can only be LESS , LESS_OR_EQUAL or NO_OP
 */
public void setStopType(CompareOp stopType) {
  if (stopType == CompareOp.EQUAL || stopType == CompareOp.GREATER
      || stopType == CompareOp.GREATER_OR_EQUAL || stopType == CompareOp.NOT_EQUAL) {
    throw new IllegalArgumentException("Illegal end type: " + stopType.toString());
  }

  this.stopType = stopType;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:12,代码来源:Range.java

示例15: getRangeDistance

/**
 * Get the distance between a range's start value and its end value, represented by the percentage
 * of HRegions which a range spans in all the HRegions of the index table.
 * @param range
 * @return
 * @throws IOException-if index table has no region information
 */
public float getRangeDistance(Range range) throws IOException {
  if (range.getStartType() == CompareOp.EQUAL) {
    return -1.0f;
  }

  byte[] startKey = range.getStartValue();
  byte[] endKey = range.getEndValue();

  List<HRegionInfo> infos = indexRegionMaps.get(range.getColumn());
  if (infos == null || infos.size() == 0) {
    throw new IOException("Index table of " + Bytes.toString(range.getColumn())
        + " has no any HRegionInfo!");
  }

  int startRegion = 0;
  int endRegion = infos.size() - 1;

  for (int m = 0; m < infos.size(); m++) {
    HRegionInfo temp = infos.get(m);
    // TODO region start end key may be null
    if (startKey != null && startKey.length != 0) {
      if (temp.containsRow(startKey)) {
        startRegion = m;
      }
    }
    if (endKey != null && endKey.length != 0) {
      if (temp.containsRow(endKey)) {
        endRegion = m;
      }
    }
  }

  // regions between start region and end region (inclusive)
  int dis = (endRegion - startRegion - 1);

  // region percent between startKey and the region's endKey in the whole region
  float startdis = 1.0f;
  if (startKey != null) {
    startdis =
        1 - getByteArrayDistance(infos.get(startRegion).getStartKey(), infos.get(startRegion)
            .getEndKey(), startKey);
  }

  // region percent between endKey and the region's startKey in the whole region
  float enddis = 1.0f;
  if (endKey != null) {
    enddis =
        getByteArrayDistance(infos.get(endRegion).getStartKey(),
          infos.get(endRegion).getEndKey(), endKey);
  }

  return (dis + startdis + enddis) / infos.size();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:60,代码来源:SimpleIndexChooser.java


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