Package org.apache.hadoop.hbase

Examples of org.apache.hadoop.hbase.KeyValue$MetaComparator


   */
  protected void removeNonReplicableEdits(WALEdit edit) {
    NavigableMap<byte[], Integer> scopes = edit.getScopes();
    List<KeyValue> kvs = edit.getKeyValues();
    for (int i = edit.size()-1; i >= 0; i--) {
      KeyValue kv = kvs.get(i);
      // The scope will be null or empty if
      // there's nothing to replicate in that WALEdit
      if (scopes == null || !scopes.containsKey(kv.getFamily())) {
        kvs.remove(i);
      }
    }
  }
View Full Code Here


   * @return number of different row keys
   */
  private int countDistinctRowKeys(WALEdit edit) {
    List<KeyValue> kvs = edit.getKeyValues();
    int distinctRowKeys = 1;
    KeyValue lastKV = kvs.get(0);
    for (int i = 0; i < edit.size(); i++) {
      if (!kvs.get(i).matchingRow(lastKV)) {
        distinctRowKeys++;
      }
    }
View Full Code Here

    startRegionOperation();
    this.readRequestsCount.increment();
    try {
      Store store = getStore(family);
      // get the closest key. (HStore.getRowKeyAtOrBefore can return null)
      KeyValue key = store.getRowKeyAtOrBefore(row);
      Result result = null;
      if (key != null) {
        Get get = new Get(key.getRow());
        get.addFamily(family);
        result = get(get, null);
      }
      if (coprocessorHost != null) {
        coprocessorHost.postGetClosestRowBefore(row, family, result);
View Full Code Here

            continue;
          }
          if (result.size() > count) {
            throw new RuntimeException("Unexpected size: " + result.size());
          }
          KeyValue getkv = result.get(count - 1);
          Bytes.putBytes(kv.getBuffer(), kv.getTimestampOffset(),
              getkv.getBuffer(), getkv.getTimestampOffset(), Bytes.SIZEOF_LONG);
        } else {
          kv.updateLatestStamp(byteNow);
        }
      }
    }
View Full Code Here

          matches = true;
        } else if (result.size() > 0 && result.get(0).getValue().length == 0 &&
            valueIsNull) {
          matches = true;
        } else if (result.size() == 1 && !valueIsNull) {
          KeyValue kv = result.get(0);
          int compareResult = comparator.compareTo(kv.getBuffer(),
              kv.getValueOffset(), kv.getValueLength());
          switch (compareOp) {
          case LESS:
            matches = compareResult <= 0;
            break;
          case LESS_OR_EQUAL:
View Full Code Here

      for (HLog.Entry entry : entries) {
        WALEdit edit = entry.getEdit();
        byte[] table = entry.getKey().getTablename();
        Put put = null;
        Delete del = null;
        KeyValue lastKV = null;
        List<KeyValue> kvs = edit.getKeyValues();
        for (KeyValue kv : kvs) {
          if (lastKV == null || lastKV.getType() != kv.getType() || !lastKV.matchingRow(kv)) {
            if (kv.isDelete()) {
              del = new Delete(kv.getRow());
              del.setClusterId(entry.getKey().getClusterId());
              addToMultiMap(rows, table, del);
            } else {
View Full Code Here

     */
    value = Bytes.toBytes(98L);
    id = 35;
    bldr = new CompleteIndexBuilder(columnDescriptor,
      new IdxIndexDescriptor(QUALIFIER, IdxQualifierType.LONG));
    bldr.addKeyValue(new KeyValue(ROW, FAMILY, QUALIFIER, value), id);
    Assert.assertTrue(
      bldr.finalizeIndex(NUM_KEY_VALUES).lookup(value).contains(id));

    /**
     * Test double type
     */
    value = Bytes.toBytes(9.8D);
    id = 899;
    bldr = new CompleteIndexBuilder(columnDescriptor,
      new IdxIndexDescriptor(QUALIFIER, IdxQualifierType.DOUBLE));
    bldr.addKeyValue(new KeyValue(ROW, FAMILY, QUALIFIER, value), id);
    Assert.assertTrue(
      bldr.finalizeIndex(NUM_KEY_VALUES).lookup(value).contains(id));

    /**
     * Test the byte array type
     */
    value = Bytes.toBytes(this.getClass().getName());
    id = 1016;
    bldr = new CompleteIndexBuilder(columnDescriptor,
      new IdxIndexDescriptor(QUALIFIER, IdxQualifierType.BYTE_ARRAY));
    bldr.addKeyValue(new KeyValue(ROW, FAMILY, QUALIFIER, value), id);
    Assert.assertTrue(
      bldr.finalizeIndex(NUM_KEY_VALUES).lookup(value).contains(id));

  }
View Full Code Here

    HColumnDescriptor columnDescriptor = new HColumnDescriptor(FAMILY);
    CompleteIndexBuilder completeIndex =
      new CompleteIndexBuilder(columnDescriptor,
        new IdxIndexDescriptor(QUALIFIER, IdxQualifierType.LONG));
    for (int i = 0; i < values.length; i++) {
      completeIndex.addKeyValue(new KeyValue(Bytes.toBytes(ids[i]), FAMILY,
        QUALIFIER, Bytes.toBytes(values[i])), ids[i]);
    }
    return (CompleteIndex) completeIndex.finalizeIndex(NUM_KEY_VALUES);
  }
View Full Code Here

      seekNext();
      super.nextRow(currentRow);
    }

    protected void seekNext() throws IOException {
      KeyValue keyValue;
      do {
        keyValue = keyProvider.next();

        if (keyValue == null) {
          // out of results keys, nothing more to process
View Full Code Here

      // this seems a bit pointless because the memstore only ever returns an
      // array with only one element, but just incase...
      KeyValueScanner[] memstorescanners = store.memstore.getScanners();
      // to make sure we don't provide rows that the scan is not interested in
      // we seekTo the scan's startRow
      KeyValue seekTo = KeyValue.createFirstOnRow(startRow);
      for (int i = memstorescanners.length - 1; i >= 0; i--) {
        memstorescanners[i].seek(seekTo);
        scanners.add(memstorescanners[i]);
      }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.KeyValue$MetaComparator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.