Java Code Examples for org.apache.hadoop.hbase.filter.CompareFilter#CompareOp

The following examples show how to use org.apache.hadoop.hbase.filter.CompareFilter#CompareOp . 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: TransactionAwareHTable.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public boolean checkAndDelete(byte[] bytes, byte[] bytes1, byte[] bytes2, CompareFilter.CompareOp compareOp,
                              byte[] bytes3, Delete delete) throws IOException {
  if (allowNonTransactional) {
    return hTable.checkAndDelete(bytes, bytes1, bytes2, compareOp, bytes3, delete);
  } else {
    throw new UnsupportedOperationException("Operation is not supported transactionally");
  }
}
 
Example 2
Source File: TransactionAwareHTable.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public boolean checkAndMutate(byte[] row, byte[] family, byte[] qualifier,
                              CompareFilter.CompareOp compareOp, byte[] value, RowMutations rowMutations)
    throws IOException {
  if (allowNonTransactional) {
    return hTable.checkAndMutate(row, family, qualifier, compareOp, value, rowMutations);
  }

  throw new UnsupportedOperationException("checkAndMutate operation is not supported transactionally");
}
 
Example 3
Source File: TransactionAwareHTable.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public boolean checkAndDelete(byte[] bytes, byte[] bytes1, byte[] bytes2, CompareFilter.CompareOp compareOp,
                              byte[] bytes3, Delete delete) throws IOException {
  if (allowNonTransactional) {
    return hTable.checkAndDelete(bytes, bytes1, bytes2, compareOp, bytes3, delete);
  } else {
    throw new UnsupportedOperationException("Operation is not supported transactionally");
  }
}
 
Example 4
Source File: MockHTable.java    From hgraphdb with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, byte[] value, Delete delete) throws IOException {
    if (check(row, family, qualifier, compareOp, value)) {
        delete(delete);
        return true;
    }
    return false;
}
 
Example 5
Source File: TransactionAwareHTable.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public boolean checkAndMutate(byte[] row, byte[] family, byte[] qualifier,
    CompareFilter.CompareOp compareOp, byte[] value, RowMutations rowMutations)
    throws IOException {
  if (allowNonTransactional) {
    return hTable.checkAndMutate(row, family, qualifier, compareOp, value, rowMutations);
  }

  throw new UnsupportedOperationException(
      "checkAndMutate operation is not supported transactionally");
}
 
Example 6
Source File: TestHBaseStorageFiltering.java    From spork with Apache License 2.0 5 votes vote down vote up
private FamilyFilter assertFamilyFilter(Filter filter, CompareFilter.CompareOp compareOp) {
    assertTrue("Filter is not a FamilyFilter: " + filter.getClass().getSimpleName(),
            filter instanceof FamilyFilter);
    FamilyFilter familyFilter = (FamilyFilter)filter;
    assertEquals("Unexpected compareOp", compareOp, familyFilter.getOperator());
    return familyFilter;
}
 
Example 7
Source File: TransactionAwareHTable.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public boolean checkAndDelete(byte[] bytes, byte[] bytes1, byte[] bytes2, CompareFilter.CompareOp compareOp,
                              byte[] bytes3, Delete delete) throws IOException {
  if (allowNonTransactional) {
    return hTable.checkAndDelete(bytes, bytes1, bytes2, compareOp, bytes3, delete);
  } else {
    throw new UnsupportedOperationException("Operation is not supported transactionally");
  }
}
 
Example 8
Source File: TransactionAwareHTable.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public boolean checkAndMutate(byte[] row, byte[] family, byte[] qualifier,
                              CompareFilter.CompareOp compareOp, byte[] value, RowMutations rowMutations)
    throws IOException {
  if (allowNonTransactional) {
    return hTable.checkAndMutate(row, family, qualifier, compareOp, value, rowMutations);
  }

  throw new UnsupportedOperationException("checkAndMutate operation is not supported transactionally");
}
 
Example 9
Source File: TransactionAwareHTable.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public boolean checkAndDelete(byte[] bytes, byte[] bytes1, byte[] bytes2, CompareFilter.CompareOp compareOp,
                              byte[] bytes3, Delete delete) throws IOException {
  if (allowNonTransactional) {
    return hTable.checkAndDelete(bytes, bytes1, bytes2, compareOp, bytes3, delete);
  } else {
    throw new UnsupportedOperationException("Operation is not supported transactionally");
  }
}
 
Example 10
Source File: MockHTable.java    From foxtrot with Apache License 2.0 4 votes vote down vote up
@Override
public boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, byte[] value,
                              Delete delete) throws IOException {
    return false;
}
 
Example 11
Source File: MockHTable.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
@Override
public boolean checkAndPut(byte[] bytes, byte[] bytes1, byte[] bytes2, CompareFilter.CompareOp compareOp,
        byte[] bytes3, Put put) throws IOException {
    return false;
}
 
Example 12
Source File: MockHTable.java    From kylin with Apache License 2.0 4 votes vote down vote up
public boolean checkAndMutate(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp,
        byte[] value, RowMutations mutation) throws IOException {
    throw new NotImplementedException();

}
 
Example 13
Source File: MockHTable.java    From foxtrot with Apache License 2.0 4 votes vote down vote up
@Override
public boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, byte[] value, Put put)
        throws IOException {
    return false;
}
 
Example 14
Source File: HBaseCLI.java    From cloud-bigtable-examples with Apache License 2.0 4 votes vote down vote up
public void run(Connection connection, List<String> args) throws InvalidArgsException, IOException {
    if (args.size() < 1 || args.size() > 2) {
        throw new InvalidArgsException(args);
    }
    String tableName = args.get(0);
    String filterVal = null;
    if (args.size() > 1) {
        filterVal = args.get(1);
    }

    Table table = connection.getTable(TableName.valueOf(tableName));

    // Create a new Scan instance.
    Scan scan = new Scan();

    // This command supports using a columnvalue filter.
    // The filter takes the form of <columnfamily>:<column><operator><value>
    // An example would be cf:col>=10
    if (filterVal != null) {
        String splitVal = "=";
        CompareFilter.CompareOp op = CompareFilter.CompareOp.EQUAL;

        if (filterVal.contains(">=")) {
             op = CompareFilter.CompareOp.GREATER_OR_EQUAL;
             splitVal = ">=";
        } else if (filterVal.contains("<=")) {
             op = CompareFilter.CompareOp.LESS_OR_EQUAL;
             splitVal = "<=";
        } else if (filterVal.contains(">")) {
             op = CompareFilter.CompareOp.GREATER;
             splitVal = ">";
        } else if (filterVal.contains("<")) {
             op = CompareFilter.CompareOp.LESS;
             splitVal = "<";
        }
        String[] filter = filterVal.split(splitVal);
        String[] filterCol = filter[0].split(":");
        scan.setFilter(new SingleColumnValueFilter(filterCol[0].getBytes(), filterCol[1].getBytes(), op, filter[1].getBytes()));
    }
    ResultScanner resultScanner = table.getScanner(scan);
    for (Result result : resultScanner) {
        for (Cell cell : result.listCells()) {
            String row = new String(CellUtil.cloneRow(cell));
            String family = new String(CellUtil.cloneFamily(cell));
            String column = new String(CellUtil.cloneQualifier(cell));
            String value = new String(CellUtil.cloneValue(cell));
            long timestamp = cell.getTimestamp();
            System.out.printf("%-20s column=%s:%s, timestamp=%s, value=%s\n", row, family, column, timestamp, value);
        }
    }
}
 
Example 15
Source File: MockHTable.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
@Override
public boolean checkAndDelete(byte[] bytes, byte[] bytes1, byte[] bytes2, CompareFilter.CompareOp compareOp,
        byte[] bytes3, Delete delete) throws IOException {
    return false;
}
 
Example 16
Source File: ComparisonParseNode.java    From phoenix with Apache License 2.0 2 votes vote down vote up
/**
 * Return the comparison operator associated with the given comparison expression node
 */
public abstract CompareFilter.CompareOp getFilterOp();
 
Example 17
Source File: MockHTable.java    From metron with Apache License 2.0 2 votes vote down vote up
/**
 * Atomically checks if a row/family/qualifier value matches the expected
 * value. If it does, it adds the delete.  If the passed value is null, the
 * check is for the lack of column (ie: non-existance)
 *
 * @param row       to check
 * @param family    column family to check
 * @param qualifier column qualifier to check
 * @param compareOp comparison operator to use
 * @param value     the expected value
 * @param delete    data to delete if check succeeds
 * @return true if the new delete was executed, false otherwise
 * @throws IOException e
 */
@Override
public boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, byte[] value, Delete delete) throws IOException {
  return false;
}
 
Example 18
Source File: ComparisonParseNode.java    From phoenix with Apache License 2.0 2 votes vote down vote up
/**
 * Return the inverted operator for the CompareOp
 */
public abstract CompareFilter.CompareOp getInvertFilterOp();
 
Example 19
Source File: MockHTable.java    From metron with Apache License 2.0 2 votes vote down vote up
/**
 * Atomically checks if a row/family/qualifier value matches the expected
 * value. If it does, it adds the put.  If the passed value is null, the check
 * is for the lack of column (ie: non-existance)
 *
 * @param row       to check
 * @param family    column family to check
 * @param qualifier column qualifier to check
 * @param compareOp comparison operator to use
 * @param value     the expected value
 * @param put       data to put if check succeeds
 * @return true if the new put was executed, false otherwise
 * @throws IOException e
 */
@Override
public boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, byte[] value, Put put) throws IOException {
  return false;
}
 
Example 20
Source File: ComparisonParseNode.java    From phoenix with Apache License 2.0 2 votes vote down vote up
/**
 * Return the inverted operator for the CompareOp
 */
public abstract CompareFilter.CompareOp getInvertFilterOp();