Package org.apache.hadoop.hbase.client

Examples of org.apache.hadoop.hbase.client.Result


              +qualStr);
        }
        final byte[] qualBytes = Bytes.toBytes(qualStr);
        Get get = new Get(rowKey);
        get.addColumn(CF_BYTES, qualBytes);
        Result result = region.get(get);
        assertEquals(1, result.size());
        byte[] value = result.getValue(CF_BYTES, qualBytes);
        assertTrue(LoadTestKVGenerator.verify(value, rowKey, qualBytes));
      }
    }
  }
View Full Code Here


          }
          else {
            get.addFamily(family);
          }
        }
        Result result = htable.get(get);
        return mapper.mapRow(result, 0);
      }
    });
  }
View Full Code Here

    // Skip nulls
    if (key == null || value == null) { return true; }

    ImmutableBytesWritable keyWritable = (ImmutableBytesWritable) key;
    Result row = (Result) value;
    result.add(keyWritable);

    for (int i = 0; i < this.familyNames.length; i++) {
      String familyName = this.familyNames[i];
      byte[] familyNameBytes = Bytes.toBytes(familyName);
      Fields fields = this.valueFields[i];
      for (int k = 0; k < fields.size(); k++) {
        String fieldName = (String) fields.get(k);
        byte[] fieldNameBytes = Bytes.toBytes(fieldName);
        byte[] cellValue = row.getValue(familyNameBytes, fieldNameBytes);
        if (cellValue == null) {
            cellValue = new byte[0];
        }
        result.add(new ImmutableBytesWritable(cellValue));
      }
View Full Code Here

   }
  
   public List<WordCount> getWordCount(String word) throws IOException {
     HTableInterface words = pool.getTable(TABLE_NAME);
     Get g = mkGet(word);
     Result result = words.get(g);
     if (result.isEmpty()) {
          log.info(String.format("word %s not found.", word));
          return null;
     }

     List<WordCount> wordCounts = WordCount.GetWordCountFromResults(result);
View Full Code Here

    List<T> rtn = new ArrayList<T>(keys.size());

    for (int i = 0; i < keys.size(); i++) {
      cf = Bytes.toBytes((String) keys.get(i).get(1));
      cq = Bytes.toBytes((String) keys.get(i).get(2));
      Result r = results[i];
      if (r.isEmpty()) {
        rtn.add(null);
      } else {
        rtn.add((T) serializer.deserialize(r.getValue(cf, cq)));
      }
    }

    return rtn;
  }
View Full Code Here

    Get getTxid = new Get(row);
    getTxid.addColumn(fam, qual);
    BigInteger latestTxid = null;

    try {
      Result res = connector.getTable().get(getTxid);
      if (!res.isEmpty()) {
        latestTxid = new BigInteger(res.getValue(fam, qual));
      }
    } catch (IOException e) {
      throw new RuntimeException("Unable to get txid for " + getTxid.toString(), e);
    }
View Full Code Here

      HTable table = new HTable(config, info.tableName);
      Field id = ClassInfo.getIdField(clazz);
      id.setAccessible(true);
     
      Get g = new Get(Bytes.toBytes(id.get(obj).toString()));     
      Result rowResult = table.get(g);
      if(rowResult.isEmpty()) throw new SienaException("No such object");
      mapObject(clazz, obj, rowResult);
    } catch(Exception e) {
      throw new SienaException(e);
    }
  }
View Full Code Here

    tableScan.setCaching(1024);
    clientScanner = new ClientScanner(conf, tableScan, queueName);
  }

  public KeyValue next() throws IOException {
    Result result = clientScanner.next();
    if (null == result || result.isEmpty()) {
      return null;
    }
    return result.list().get(0);
  }
View Full Code Here

    public void execute(Tuple tuple) {
        byte[] rowKey = this.mapper.rowKey(tuple);
        Get get = hBaseClient.constructGetRequests(rowKey, projectionCriteria);

        try {
            Result result = hBaseClient.batchGet(Lists.newArrayList(get))[0];
            for(Values values : rowToTupleMapper.toValues(tuple, result)) {
                this.collector.emit(values);
            }
            this.collector.ack(tuple);
        } catch (Exception e) {
View Full Code Here

     * an iterator, we don't know which regions we touched until the iterator returns Results. Each result has
     * a key, from which we can figure out the region that it came from.
     */
    private Result timedExecuteIterator(List<OpType> opTypes, Callable<Result> callable) throws Exception {
        long beforeNanos = System.nanoTime();
        Result result = callable.call();
        long durationNanos = System.nanoTime() - beforeNanos;
       
        List<byte[]> keys = new ArrayList<byte[]>(1);
        // If the iterator returned very quickly, we assume it's reading from a local cache
        // and not doing an RPC. We don't update the stats in this case because they skew the results
        // and make actual HBase problems harder to find. This is a nasty hack that will often be wrong,
        // but hopefully it will at least point in the direction of a problem if one exists.
        if(durationNanos > IGNORE_ITERATOR_THRESHOLD_NANOS) {
            if(result != null) {
                byte[] row = result.getRow();
                if(row != null) {
                    keys.add(row);
                    updateStats(opTypes, keys, durationNanos);
                }
            }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.client.Result

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.