Package org.apache.hadoop.hbase.client

Examples of org.apache.hadoop.hbase.client.HTableInterface.incrementColumnValue()


       byte[] row = randomRowKey();
       Put put = new Put(row);
       put.add(cf, row, Bytes.toBytes(10L));
       hTable.put(put);

       hTable.incrementColumnValue(row, cf, row, 5);

       Result result = hTable.get(new Get(row));
       Assert.assertEquals(15L, Bytes.toLong(result.value()));
       assertMetricsUpdated(OpType.PUT, OpType.INCREMENT, OpType.GET);
View Full Code Here


       byte[] row = randomRowKey();
       Put put = new Put(row);
       put.add(cf, row, Bytes.toBytes(10L));
       hTable.put(put);

       hTable.incrementColumnValue(row, cf, row, 5, true);

       Result result = hTable.get(new Get(row));
       Assert.assertEquals(15L, Bytes.toLong(result.value()));
       assertMetricsUpdated(OpType.PUT, OpType.INCREMENT, OpType.GET);
View Full Code Here

    }

    public long incrementColumnValue(ByteBuffer table, ByteBuffer row, ByteBuffer family, ByteBuffer qualifier, long amount, boolean writeToWAL) throws AIOError {
      HTableInterface htable = htablePool.getTable(Bytes.toBytes(table));
      try {
  return htable.incrementColumnValue(Bytes.toBytes(row), Bytes.toBytes(family), Bytes.toBytes(qualifier), amount, writeToWAL);
      } catch (IOException e) {
        AIOError ioe = new AIOError();
        ioe.message = new Utf8(e.getMessage());
        throw ioe;
      } finally {
View Full Code Here

    }

    public long incrementColumnValue(ByteBuffer table, ByteBuffer row, ByteBuffer family, ByteBuffer qualifier, long amount, boolean writeToWAL) throws AIOError {
      HTableInterface htable = htablePool.getTable(Bytes.toBytes(table));
      try {
  return htable.incrementColumnValue(Bytes.toBytes(row), Bytes.toBytes(family), Bytes.toBytes(qualifier), amount, writeToWAL);
      } catch (IOException e) {
        AIOError ioe = new AIOError();
        ioe.message = new Utf8(e.getMessage());
        throw ioe;
      } finally {
View Full Code Here

    }

    public long incrementColumnValue(ByteBuffer table, ByteBuffer row, ByteBuffer family, ByteBuffer qualifier, long amount, boolean writeToWAL) throws AIOError {
      HTableInterface htable = htablePool.getTable(Bytes.toBytes(table));
      try {
  return htable.incrementColumnValue(Bytes.toBytes(row), Bytes.toBytes(family), Bytes.toBytes(qualifier), amount, writeToWAL);
      } catch (IOException e) {
        AIOError ioe = new AIOError();
        ioe.message = new Utf8(e.getMessage());
        throw ioe;
      } finally {
View Full Code Here

        if(docId != null) {
          // we've indexed this doc previously
          docNumber = Bytes.toInt(docId);
          doc.addField("edit", true);
        } else {
          docNumber = new Long(seqTable.incrementColumnValue(Bytes.toBytes("sequence"), Bytes.toBytes("id"), Bytes.toBytes(""), 1, true)).intValue();
        }
       
        doc.addField("docId", docNumber);
        doc.addField("global_uniq_id", id);
        doc.addField("cat", cat);
View Full Code Here

    // mainly used for chunking with pristine indexing
    public static int generateUniqId() throws IOException {
      HTableInterface sequence = SolbaseUtil.getSequenceTable();
     
      try {
        int docId = new Long(sequence.incrementColumnValue(Bytes.toBytes("sequence"), Bytes.toBytes("id"), Bytes.toBytes(""), SolbaseUtil.UNIQ_ID_CHUNK, true)).intValue();
     
        return docId;
      } finally {
        SolbaseUtil.releaseTable(sequence);
      }
View Full Code Here

      Get get = new Get(Bytes.toBytes("sequence"));
      try {
      Result result = sequence.get(get);
     
      if(result == null || result.isEmpty()){
        int docId = new Long(sequence.incrementColumnValue(Bytes.toBytes("sequence"), Bytes.toBytes("id"), Bytes.toBytes(""), 1, true)).intValue();
        return docId;
      } else {
        byte[] val = result.getValue(Bytes.toBytes("id"), Bytes.toBytes(""));
        return new Long(Bytes.toLong(val)).intValue();
      }
View Full Code Here

    @Override
    public Long generate(TableGeneratorDiscriptor discriptor) {
        try {
            HTableInterface hTable = ((HBaseDataHandler) handler).gethTable(discriptor.getSchema());
            Long latestCount =
                hTable.incrementColumnValue(discriptor.getPkColumnValue().getBytes(), discriptor.getTable().getBytes(),
                    discriptor.getValueColumnName().getBytes(), 1);
            if (latestCount == 1) {
                return (long) discriptor.getInitialValue();
            } else if (discriptor.getAllocationSize() == 1) {
                return latestCount;
View Full Code Here

  }

  public long incTweetCount(String user) throws IOException {
    HTableInterface users = pool.getTable(TABLE_NAME);

    long ret = users.incrementColumnValue(Bytes.toBytes(user),
                                          INFO_FAM,
                                          TWEETS_COL,
                                          1L);

    users.close();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.