Java 类org.apache.hadoop.hbase.filter.NullComparator 实例源码

项目:ditb    文件:ScannerModel.java   
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);
  }
}
项目:HIndex    文件:ScannerModel.java   
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);
  }
}
项目:hbase    文件:ScannerModel.java   
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);
  }
}
项目:PyroDB    文件:ScannerModel.java   
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);
  }
}
项目:LCIndex-HBase-0.94.16    文件:TestHRegion.java   
public void testCheckAndMutate_WithEmptyRowValue() throws IOException {
  byte [] tableName = Bytes.toBytes("testtable");
  byte [] row1 = Bytes.toBytes("row1");
  byte [] fam1 = Bytes.toBytes("fam1");
  byte [] qf1  = Bytes.toBytes("qualifier");
  byte [] emptyVal  = new byte[] {};
  byte [] val1  = Bytes.toBytes("value1");
  byte [] val2  = Bytes.toBytes("value2");
  Integer lockId = null;

  //Setting up region
  String method = this.getName();
  this.region = initHRegion(tableName, method, conf, fam1);
  try {
    //Putting empty data in key
    Put put = new Put(row1);
    put.add(fam1, qf1, emptyVal);

    //checkAndPut with empty value
    boolean res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), put, lockId, true);
    assertTrue(res);

    //Putting data in key
    put = new Put(row1);
    put.add(fam1, qf1, val1);

    //checkAndPut with correct value
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), put, lockId, true);
    assertTrue(res);

    // not empty anymore
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), put, lockId, true);
    assertFalse(res);

    Delete delete = new Delete(row1);
    delete.deleteColumn(fam1, qf1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), delete, lockId, true);
    assertFalse(res);

    put = new Put(row1);
    put.add(fam1, qf1, val2);
    //checkAndPut with correct value
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(val1), put, lockId, true);
    assertTrue(res);

    //checkAndDelete with correct value
    delete = new Delete(row1);
    delete.deleteColumn(fam1, qf1);
    delete.deleteColumn(fam1, qf1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(val2), delete, lockId, true);
    assertTrue(res);

    delete = new Delete(row1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), delete, lockId, true);
    assertTrue(res);

    //checkAndPut looking for a null value
    put = new Put(row1);
    put.add(fam1, qf1, val1);

    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new NullComparator(), put, lockId, true);
    assertTrue(res);
  } finally {
    HRegion.closeHRegion(this.region);
    this.region = null;
  }
}
项目:pbase    文件:TestHRegion.java   
@Test
public void testCheckAndMutate_WithEmptyRowValue() throws IOException {
  byte[] row1 = Bytes.toBytes("row1");
  byte[] fam1 = Bytes.toBytes("fam1");
  byte[] qf1 = Bytes.toBytes("qualifier");
  byte[] emptyVal = new byte[] {};
  byte[] val1 = Bytes.toBytes("value1");
  byte[] val2 = Bytes.toBytes("value2");

  // Setting up region
  String method = this.getName();
  this.region = initHRegion(tableName, method, CONF, fam1);
  try {
    // Putting empty data in key
    Put put = new Put(row1);
    put.add(fam1, qf1, emptyVal);

    // checkAndPut with empty value
    boolean res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(
        emptyVal), put, true);
    assertTrue(res);

    // Putting data in key
    put = new Put(row1);
    put.add(fam1, qf1, val1);

    // checkAndPut with correct value
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(emptyVal),
        put, true);
    assertTrue(res);

    // not empty anymore
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(emptyVal),
        put, true);
    assertFalse(res);

    Delete delete = new Delete(row1);
    delete.deleteColumn(fam1, qf1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(emptyVal),
        delete, true);
    assertFalse(res);

    put = new Put(row1);
    put.add(fam1, qf1, val2);
    // checkAndPut with correct value
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(val1),
        put, true);
    assertTrue(res);

    // checkAndDelete with correct value
    delete = new Delete(row1);
    delete.deleteColumn(fam1, qf1);
    delete.deleteColumn(fam1, qf1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(val2),
        delete, true);
    assertTrue(res);

    delete = new Delete(row1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(emptyVal),
        delete, true);
    assertTrue(res);

    // checkAndPut looking for a null value
    put = new Put(row1);
    put.add(fam1, qf1, val1);

    res = region
        .checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new NullComparator(), put, true);
    assertTrue(res);
  } finally {
    HRegion.closeHRegion(this.region);
    this.region = null;
  }
}
项目:HIndex    文件:TestHRegion.java   
@Test
public void testCheckAndMutate_WithEmptyRowValue() throws IOException {
  byte[] row1 = Bytes.toBytes("row1");
  byte[] fam1 = Bytes.toBytes("fam1");
  byte[] qf1 = Bytes.toBytes("qualifier");
  byte[] emptyVal = new byte[] {};
  byte[] val1 = Bytes.toBytes("value1");
  byte[] val2 = Bytes.toBytes("value2");

  // Setting up region
  String method = this.getName();
  this.region = initHRegion(tableName, method, CONF, fam1);
  try {
    // Putting empty data in key
    Put put = new Put(row1);
    put.add(fam1, qf1, emptyVal);

    // checkAndPut with empty value
    boolean res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(
        emptyVal), put, true);
    assertTrue(res);

    // Putting data in key
    put = new Put(row1);
    put.add(fam1, qf1, val1);

    // checkAndPut with correct value
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(emptyVal),
        put, true);
    assertTrue(res);

    // not empty anymore
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(emptyVal),
        put, true);
    assertFalse(res);

    Delete delete = new Delete(row1);
    delete.deleteColumn(fam1, qf1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(emptyVal),
        delete, true);
    assertFalse(res);

    put = new Put(row1);
    put.add(fam1, qf1, val2);
    // checkAndPut with correct value
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(val1),
        put, true);
    assertTrue(res);

    // checkAndDelete with correct value
    delete = new Delete(row1);
    delete.deleteColumn(fam1, qf1);
    delete.deleteColumn(fam1, qf1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(val2),
        delete, true);
    assertTrue(res);

    delete = new Delete(row1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(emptyVal),
        delete, true);
    assertTrue(res);

    // checkAndPut looking for a null value
    put = new Put(row1);
    put.add(fam1, qf1, val1);

    res = region
        .checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new NullComparator(), put, true);
    assertTrue(res);
  } finally {
    HRegion.closeHRegion(this.region);
    this.region = null;
  }
}
项目:IRIndex    文件:TestHRegion.java   
public void testCheckAndMutate_WithEmptyRowValue() throws IOException {
  byte [] tableName = Bytes.toBytes("testtable");
  byte [] row1 = Bytes.toBytes("row1");
  byte [] fam1 = Bytes.toBytes("fam1");
  byte [] qf1  = Bytes.toBytes("qualifier");
  byte [] emptyVal  = new byte[] {};
  byte [] val1  = Bytes.toBytes("value1");
  byte [] val2  = Bytes.toBytes("value2");
  Integer lockId = null;

  //Setting up region
  String method = this.getName();
  this.region = initHRegion(tableName, method, conf, fam1);
  try {
    //Putting empty data in key
    Put put = new Put(row1);
    put.add(fam1, qf1, emptyVal);

    //checkAndPut with empty value
    boolean res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), put, lockId, true);
    assertTrue(res);

    //Putting data in key
    put = new Put(row1);
    put.add(fam1, qf1, val1);

    //checkAndPut with correct value
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), put, lockId, true);
    assertTrue(res);

    // not empty anymore
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), put, lockId, true);
    assertFalse(res);

    Delete delete = new Delete(row1);
    delete.deleteColumn(fam1, qf1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), delete, lockId, true);
    assertFalse(res);

    put = new Put(row1);
    put.add(fam1, qf1, val2);
    //checkAndPut with correct value
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(val1), put, lockId, true);
    assertTrue(res);

    //checkAndDelete with correct value
    delete = new Delete(row1);
    delete.deleteColumn(fam1, qf1);
    delete.deleteColumn(fam1, qf1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(val2), delete, lockId, true);
    assertTrue(res);

    delete = new Delete(row1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), delete, lockId, true);
    assertTrue(res);

    //checkAndPut looking for a null value
    put = new Put(row1);
    put.add(fam1, qf1, val1);

    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new NullComparator(), put, lockId, true);
    assertTrue(res);
  } finally {
    HRegion.closeHRegion(this.region);
    this.region = null;
  }
}
项目:hbase    文件:TestHRegion.java   
@Test
public void testCheckAndMutate_WithEmptyRowValue() throws IOException {
  byte[] row1 = Bytes.toBytes("row1");
  byte[] fam1 = Bytes.toBytes("fam1");
  byte[] qf1 = Bytes.toBytes("qualifier");
  byte[] emptyVal = new byte[] {};
  byte[] val1 = Bytes.toBytes("value1");
  byte[] val2 = Bytes.toBytes("value2");

  // Setting up region
  this.region = initHRegion(tableName, method, CONF, fam1);
  try {
    // Putting empty data in key
    Put put = new Put(row1);
    put.addColumn(fam1, qf1, emptyVal);

    // checkAndPut with empty value
    boolean res = region.checkAndMutate(row1, fam1, qf1, CompareOperator.EQUAL, new BinaryComparator(
        emptyVal), put, true);
    assertTrue(res);

    // Putting data in key
    put = new Put(row1);
    put.addColumn(fam1, qf1, val1);

    // checkAndPut with correct value
    res = region.checkAndMutate(row1, fam1, qf1, CompareOperator.EQUAL, new BinaryComparator(emptyVal),
        put, true);
    assertTrue(res);

    // not empty anymore
    res = region.checkAndMutate(row1, fam1, qf1, CompareOperator.EQUAL, new BinaryComparator(emptyVal),
        put, true);
    assertFalse(res);

    Delete delete = new Delete(row1);
    delete.addColumn(fam1, qf1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOperator.EQUAL, new BinaryComparator(emptyVal),
        delete, true);
    assertFalse(res);

    put = new Put(row1);
    put.addColumn(fam1, qf1, val2);
    // checkAndPut with correct value
    res = region.checkAndMutate(row1, fam1, qf1, CompareOperator.EQUAL, new BinaryComparator(val1),
        put, true);
    assertTrue(res);

    // checkAndDelete with correct value
    delete = new Delete(row1);
    delete.addColumn(fam1, qf1);
    delete.addColumn(fam1, qf1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOperator.EQUAL, new BinaryComparator(val2),
        delete, true);
    assertTrue(res);

    delete = new Delete(row1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOperator.EQUAL, new BinaryComparator(emptyVal),
        delete, true);
    assertTrue(res);

    // checkAndPut looking for a null value
    put = new Put(row1);
    put.addColumn(fam1, qf1, val1);

    res = region
        .checkAndMutate(row1, fam1, qf1, CompareOperator.EQUAL, new NullComparator(), put, true);
    assertTrue(res);
  } finally {
    HBaseTestingUtility.closeRegionAndWAL(this.region);
    this.region = null;
  }
}
项目:PyroDB    文件:TestHRegion.java   
@Test
public void testCheckAndMutate_WithEmptyRowValue() throws IOException {
  byte[] row1 = Bytes.toBytes("row1");
  byte[] fam1 = Bytes.toBytes("fam1");
  byte[] qf1 = Bytes.toBytes("qualifier");
  byte[] emptyVal = new byte[] {};
  byte[] val1 = Bytes.toBytes("value1");
  byte[] val2 = Bytes.toBytes("value2");

  // Setting up region
  String method = this.getName();
  this.region = initHRegion(tableName, method, CONF, fam1);
  try {
    // Putting empty data in key
    Put put = new Put(row1);
    put.add(fam1, qf1, emptyVal);

    // checkAndPut with empty value
    boolean res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(
        emptyVal), put, true);
    assertTrue(res);

    // Putting data in key
    put = new Put(row1);
    put.add(fam1, qf1, val1);

    // checkAndPut with correct value
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(emptyVal),
        put, true);
    assertTrue(res);

    // not empty anymore
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(emptyVal),
        put, true);
    assertFalse(res);

    Delete delete = new Delete(row1);
    delete.deleteColumn(fam1, qf1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(emptyVal),
        delete, true);
    assertFalse(res);

    put = new Put(row1);
    put.add(fam1, qf1, val2);
    // checkAndPut with correct value
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(val1),
        put, true);
    assertTrue(res);

    // checkAndDelete with correct value
    delete = new Delete(row1);
    delete.deleteColumn(fam1, qf1);
    delete.deleteColumn(fam1, qf1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(val2),
        delete, true);
    assertTrue(res);

    delete = new Delete(row1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(emptyVal),
        delete, true);
    assertTrue(res);

    // checkAndPut looking for a null value
    put = new Put(row1);
    put.add(fam1, qf1, val1);

    res = region
        .checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new NullComparator(), put, true);
    assertTrue(res);
  } finally {
    HRegion.closeHRegion(this.region);
    this.region = null;
  }
}
项目:c5    文件:TestHRegion.java   
@Test
public void testCheckAndMutate_WithEmptyRowValue() throws IOException {
  byte[] row1 = Bytes.toBytes("row1");
  byte[] fam1 = Bytes.toBytes("fam1");
  byte[] qf1 = Bytes.toBytes("qualifier");
  byte[] emptyVal = new byte[] {};
  byte[] val1 = Bytes.toBytes("value1");
  byte[] val2 = Bytes.toBytes("value2");

  // Setting up region
  String method = this.getName();
  this.region = initHRegion(tableName, method, conf, fam1);
  try {
    // Putting empty data in key
    Put put = new Put(row1);
    put.add(fam1, qf1, emptyVal);

    // checkAndPut with empty value
    boolean res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(
        emptyVal), put, true);
    assertTrue(res);

    // Putting data in key
    put = new Put(row1);
    put.add(fam1, qf1, val1);

    // checkAndPut with correct value
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(emptyVal),
        put, true);
    assertTrue(res);

    // not empty anymore
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(emptyVal),
        put, true);
    assertFalse(res);

    Delete delete = new Delete(row1);
    delete.deleteColumn(fam1, qf1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(emptyVal),
        delete, true);
    assertFalse(res);

    put = new Put(row1);
    put.add(fam1, qf1, val2);
    // checkAndPut with correct value
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(val1),
        put, true);
    assertTrue(res);

    // checkAndDelete with correct value
    delete = new Delete(row1);
    delete.deleteColumn(fam1, qf1);
    delete.deleteColumn(fam1, qf1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(val2),
        delete, true);
    assertTrue(res);

    delete = new Delete(row1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new BinaryComparator(emptyVal),
        delete, true);
    assertTrue(res);

    // checkAndPut looking for a null value
    put = new Put(row1);
    put.add(fam1, qf1, val1);

    res = region
        .checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new NullComparator(), put, true);
    assertTrue(res);
  } finally {
    HRegion.closeHRegion(this.region);
    this.region = null;
  }
}
项目:HBase-Research    文件:TestHRegion.java   
public void testCheckAndMutate_WithEmptyRowValue() throws IOException {
  byte [] tableName = Bytes.toBytes("testtable");
  byte [] row1 = Bytes.toBytes("row1");
  byte [] fam1 = Bytes.toBytes("fam1");
  byte [] qf1  = Bytes.toBytes("qualifier");
  byte [] emptyVal  = new byte[] {};
  byte [] val1  = Bytes.toBytes("value1");
  byte [] val2  = Bytes.toBytes("value2");
  Integer lockId = null;

  //Setting up region
  String method = this.getName();
  this.region = initHRegion(tableName, method, conf, fam1);
  try {
    //Putting empty data in key
    Put put = new Put(row1);
    put.add(fam1, qf1, emptyVal);

    //checkAndPut with empty value
    boolean res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), put, lockId, true);
    assertTrue(res);

    //Putting data in key
    put = new Put(row1);
    put.add(fam1, qf1, val1);

    //checkAndPut with correct value
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), put, lockId, true);
    assertTrue(res);

    // not empty anymore
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), put, lockId, true);
    assertFalse(res);

    Delete delete = new Delete(row1);
    delete.deleteColumn(fam1, qf1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), delete, lockId, true);
    assertFalse(res);

    put = new Put(row1);
    put.add(fam1, qf1, val2);
    //checkAndPut with correct value
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(val1), put, lockId, true);
    assertTrue(res);

    //checkAndDelete with correct value
    delete = new Delete(row1);
    delete.deleteColumn(fam1, qf1);
    delete.deleteColumn(fam1, qf1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(val2), delete, lockId, true);
    assertTrue(res);

    delete = new Delete(row1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), delete, lockId, true);
    assertTrue(res);

    //checkAndPut looking for a null value
    put = new Put(row1);
    put.add(fam1, qf1, val1);

    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new NullComparator(), put, lockId, true);
    assertTrue(res);
  } finally {
    HRegion.closeHRegion(this.region);
    this.region = null;
  }
}
项目:hbase-0.94.8-qod    文件:TestHRegion.java   
public void testCheckAndMutate_WithEmptyRowValue() throws IOException {
  byte [] tableName = Bytes.toBytes("testtable");
  byte [] row1 = Bytes.toBytes("row1");
  byte [] fam1 = Bytes.toBytes("fam1");
  byte [] qf1  = Bytes.toBytes("qualifier");
  byte [] emptyVal  = new byte[] {};
  byte [] val1  = Bytes.toBytes("value1");
  byte [] val2  = Bytes.toBytes("value2");
  Integer lockId = null;

  //Setting up region
  String method = this.getName();
  this.region = initHRegion(tableName, method, conf, fam1);
  try {
    //Putting empty data in key
    Put put = new Put(row1);
    put.add(fam1, qf1, emptyVal);

    //checkAndPut with empty value
    boolean res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), put, lockId, true);
    assertTrue(res);

    //Putting data in key
    put = new Put(row1);
    put.add(fam1, qf1, val1);

    //checkAndPut with correct value
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), put, lockId, true);
    assertTrue(res);

    // not empty anymore
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), put, lockId, true);
    assertFalse(res);

    Delete delete = new Delete(row1);
    delete.deleteColumn(fam1, qf1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), delete, lockId, true);
    assertFalse(res);

    put = new Put(row1);
    put.add(fam1, qf1, val2);
    //checkAndPut with correct value
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(val1), put, lockId, true);
    assertTrue(res);

    //checkAndDelete with correct value
    delete = new Delete(row1);
    delete.deleteColumn(fam1, qf1);
    delete.deleteColumn(fam1, qf1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(val2), delete, lockId, true);
    assertTrue(res);

    delete = new Delete(row1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), delete, lockId, true);
    assertTrue(res);

    //checkAndPut looking for a null value
    put = new Put(row1);
    put.add(fam1, qf1, val1);

    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new NullComparator(), put, lockId, true);
    assertTrue(res);
  } finally {
    HRegion.closeHRegion(this.region);
    this.region = null;
  }
}
项目:hbase-0.94.8-qod    文件:TestHRegion.java   
public void testCheckAndMutate_WithEmptyRowValue() throws IOException {
  byte [] tableName = Bytes.toBytes("testtable");
  byte [] row1 = Bytes.toBytes("row1");
  byte [] fam1 = Bytes.toBytes("fam1");
  byte [] qf1  = Bytes.toBytes("qualifier");
  byte [] emptyVal  = new byte[] {};
  byte [] val1  = Bytes.toBytes("value1");
  byte [] val2  = Bytes.toBytes("value2");
  Integer lockId = null;

  //Setting up region
  String method = this.getName();
  this.region = initHRegion(tableName, method, conf, fam1);
  try {
    //Putting empty data in key
    Put put = new Put(row1);
    put.add(fam1, qf1, emptyVal);

    //checkAndPut with empty value
    boolean res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), put, lockId, true);
    assertTrue(res);

    //Putting data in key
    put = new Put(row1);
    put.add(fam1, qf1, val1);

    //checkAndPut with correct value
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), put, lockId, true);
    assertTrue(res);

    // not empty anymore
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), put, lockId, true);
    assertFalse(res);

    Delete delete = new Delete(row1);
    delete.deleteColumn(fam1, qf1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), delete, lockId, true);
    assertFalse(res);

    put = new Put(row1);
    put.add(fam1, qf1, val2);
    //checkAndPut with correct value
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(val1), put, lockId, true);
    assertTrue(res);

    //checkAndDelete with correct value
    delete = new Delete(row1);
    delete.deleteColumn(fam1, qf1);
    delete.deleteColumn(fam1, qf1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(val2), delete, lockId, true);
    assertTrue(res);

    delete = new Delete(row1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), delete, lockId, true);
    assertTrue(res);

    //checkAndPut looking for a null value
    put = new Put(row1);
    put.add(fam1, qf1, val1);

    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new NullComparator(), put, lockId, true);
    assertTrue(res);
  } finally {
    HRegion.closeHRegion(this.region);
    this.region = null;
  }
}
项目:DominoHBase    文件:TestHRegion.java   
public void testCheckAndMutate_WithEmptyRowValue() throws IOException {
  byte [] tableName = Bytes.toBytes("testtable");
  byte [] row1 = Bytes.toBytes("row1");
  byte [] fam1 = Bytes.toBytes("fam1");
  byte [] qf1  = Bytes.toBytes("qualifier");
  byte [] emptyVal  = new byte[] {};
  byte [] val1  = Bytes.toBytes("value1");
  byte [] val2  = Bytes.toBytes("value2");
  Integer lockId = null;

  //Setting up region
  String method = this.getName();
  this.region = initHRegion(tableName, method, conf, fam1);
  try {
    //Putting empty data in key
    Put put = new Put(row1);
    put.add(fam1, qf1, emptyVal);

    //checkAndPut with empty value
    boolean res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), put, lockId, true);
    assertTrue(res);

    //Putting data in key
    put = new Put(row1);
    put.add(fam1, qf1, val1);

    //checkAndPut with correct value
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), put, lockId, true);
    assertTrue(res);

    // not empty anymore
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), put, lockId, true);
    assertFalse(res);

    Delete delete = new Delete(row1);
    delete.deleteColumn(fam1, qf1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), delete, lockId, true);
    assertFalse(res);

    put = new Put(row1);
    put.add(fam1, qf1, val2);
    //checkAndPut with correct value
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(val1), put, lockId, true);
    assertTrue(res);

    //checkAndDelete with correct value
    delete = new Delete(row1);
    delete.deleteColumn(fam1, qf1);
    delete.deleteColumn(fam1, qf1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(val2), delete, lockId, true);
    assertTrue(res);

    delete = new Delete(row1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), delete, lockId, true);
    assertTrue(res);

    //checkAndPut looking for a null value
    put = new Put(row1);
    put.add(fam1, qf1, val1);

    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new NullComparator(), put, lockId, true);
    assertTrue(res);
  } finally {
    HRegion.closeHRegion(this.region);
    this.region = null;
  }
}
项目:hindex    文件:TestHRegion.java   
public void testCheckAndMutate_WithEmptyRowValue() throws IOException {
  byte [] tableName = Bytes.toBytes("testtable");
  byte [] row1 = Bytes.toBytes("row1");
  byte [] fam1 = Bytes.toBytes("fam1");
  byte [] qf1  = Bytes.toBytes("qualifier");
  byte [] emptyVal  = new byte[] {};
  byte [] val1  = Bytes.toBytes("value1");
  byte [] val2  = Bytes.toBytes("value2");
  Integer lockId = null;

  //Setting up region
  String method = this.getName();
  this.region = initHRegion(tableName, method, conf, fam1);
  try {
    //Putting empty data in key
    Put put = new Put(row1);
    put.add(fam1, qf1, emptyVal);

    //checkAndPut with empty value
    boolean res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), put, lockId, true);
    assertTrue(res);

    //Putting data in key
    put = new Put(row1);
    put.add(fam1, qf1, val1);

    //checkAndPut with correct value
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), put, lockId, true);
    assertTrue(res);

    // not empty anymore
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), put, lockId, true);
    assertFalse(res);

    Delete delete = new Delete(row1);
    delete.deleteColumn(fam1, qf1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), delete, lockId, true);
    assertFalse(res);

    put = new Put(row1);
    put.add(fam1, qf1, val2);
    //checkAndPut with correct value
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(val1), put, lockId, true);
    assertTrue(res);

    //checkAndDelete with correct value
    delete = new Delete(row1);
    delete.deleteColumn(fam1, qf1);
    delete.deleteColumn(fam1, qf1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(val2), delete, lockId, true);
    assertTrue(res);

    delete = new Delete(row1);
    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new BinaryComparator(emptyVal), delete, lockId, true);
    assertTrue(res);

    //checkAndPut looking for a null value
    put = new Put(row1);
    put.add(fam1, qf1, val1);

    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
        new NullComparator(), put, lockId, true);
    assertTrue(res);
  } finally {
    HRegion.closeHRegion(this.region);
    this.region = null;
  }
}