Examples of Increment


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

    List<Increment> increments = Lists.newArrayList();
    String body = new String(event.getBody(), Charsets.UTF_8);
    String[] pieces = body.split(":");
    String row = pieces[0];
    String qualifier = pieces[1];
    Increment inc = new Increment(row.getBytes(Charsets.UTF_8));
    inc.addColumn(family, qualifier.getBytes(Charsets.UTF_8), 1L);
    increments.add(inc);
    return increments;
  }
View Full Code Here

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

  }

  /** {@inheritDoc} */
  @Override
  public void execute(Tuple tuple) {
    Increment newInc = conf.getIncrementFromTuple(tuple, TupleTableConfig.DEFAULT_INCREMENT);
    Increment extInc = counters.get(newInc.getRow());

    if (extInc != null) {
      // Increment already exists for row, add newInc to extInc
      for (Entry<byte[], NavigableMap<byte[], Long>> families : newInc.getFamilyMap().entrySet()) {

View Full Code Here

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

   * @return {@link Increment}
   */
  public Increment getIncrementFromTuple(final Tuple tuple, final long increment) {
    byte[] rowKey = Bytes.toBytes(tuple.getStringByField(tupleRowKeyField));

    Increment inc = new Increment(rowKey);
    inc.setWriteToWAL(writeToWAL);

    if (columnFamilies.size() > 0) {
      for (String cf : columnFamilies.keySet()) {
        byte[] cfBytes = Bytes.toBytes(cf);
        for (String cq : columnFamilies.get(cf)) {
          byte[] val;
          try {
            val = Bytes.toBytes(tuple.getStringByField(cq));
          } catch (IllegalArgumentException ex) {
            // if cq isn't a tuple field, use cq for counter instead of tuple
            // value
            val = Bytes.toBytes(cq);
          }
          inc.addColumn(cfBytes, val, increment);
        }
      }
    }

    return inc;
View Full Code Here

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

  private static final byte[] CQ1 = "20120816".getBytes();
  private static final byte[] CQ2 = "20120817".getBytes();

  @Test
  public void testAddIncrement() {
    Increment i = new Increment(KEY);
    i.addColumn(CF, CQ1, 1); // set counter to 1
    i.addColumn(CF, CQ1, 1); // overrides counter, so its still 1

    Assert.assertEquals(1L, (long) i.getFamilyMap().get(CF).get(CQ1));

    TupleTableConfig.addIncrement(i, CF, CQ1, 2L); // increment counter by 2
    TupleTableConfig.addIncrement(i, CF, CQ2, 2L); // increment different
                                                   // qualifier by 2

    Assert.assertEquals(3L, (long) i.getFamilyMap().get(CF).get(CQ1));
    Assert.assertEquals(2L, (long) i.getFamilyMap().get(CF).get(CQ2));
  }
View Full Code Here

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

     
   
     
      if(inc!=null)
      {
        Increment incment=new Increment();
        for(Entry<String, Object> e:inc.getMap().entrySet())
        {
          incment.addColumn(MdrillRealTimeHbaseImpl.DATA_FAMILY,  Bytes.toBytes(e.getKey()), Long.parseLong(String.valueOf(e.getValue())));
        }
        table.increment(incment);
      }
     
      this.queue.put(Message.INSTANCE(shard, partion, long2Bytes(higo_uuid), this.hbase.getConfig()));
View Full Code Here

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

    // Reconstruct list of Increments per unique row/family/qualifier.
    List<Increment> coalesced = Lists.newLinkedList();
    for (Map.Entry<byte[], Map<byte[],NavigableMap<byte[], Long>>> rowEntry : counters.entrySet()) {
      byte[] row = rowEntry.getKey();
      Map <byte[], NavigableMap<byte[], Long>> families = rowEntry.getValue();
      Increment inc = new Increment(row);
      for (Map.Entry<byte[], NavigableMap<byte[], Long>> familyEntry : families.entrySet()) {
        byte[] family = familyEntry.getKey();
        NavigableMap<byte[], Long> qualifiers = familyEntry.getValue();
        for (Map.Entry<byte[], Long> qualifierEntry : qualifiers.entrySet()) {
          byte[] qualifier = qualifierEntry.getKey();
          long count = qualifierEntry.getValue();
          inc.addColumn(family, qualifier, count);
        }
      }
      coalesced.add(inc);
    }
View Full Code Here

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

        return;
      }

      try {
        HTable table = getTable(tincrement.getTable());
        Increment inc = ThriftUtilities.incrementFromThrift(tincrement);
        table.increment(inc);
      } catch (IOException e) {
        LOG.warn(e.getMessage(), e);
        throw new IOError(e.getMessage());
      }
View Full Code Here

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

    }
    requestCount.incrementAndGet();
    try {
      HRegion region = getRegion(regionName);
      Integer lock = getLockFromId(increment.getLockId());
      Increment incVal = increment;
      Result resVal;
      if (region.getCoprocessorHost() != null) {
        resVal = region.getCoprocessorHost().preIncrement(incVal);
        if (resVal != null) {
          return resVal;
View Full Code Here

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

    @Override
    public void run() {
      int count = 0;
      while (count < incCounter) {
        Increment inc = new Increment(incRow);
        inc.addColumn(family, qualifier, ONE);
        count++;
        try {
          region.increment(inc, null, true);
        } catch (IOException e) {
          e.printStackTrace();
View Full Code Here

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

  public void testIncrWithReadOnlyTable() throws Exception {
    byte[] TABLE = Bytes.toBytes("readOnlyTable");
    this.region = initHRegion(TABLE, getName(), conf, true, Bytes.toBytes("somefamily"));
    boolean exceptionCaught = false;   
    Increment inc = new Increment(Bytes.toBytes("somerow"));
    inc.addColumn(Bytes.toBytes("somefamily"), Bytes.toBytes("somequalifier"), 1L);
    try {
      region.increment(inc, false);
    } catch (IOException e) {
      exceptionCaught = true;
    } finally {
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.