Java Code Examples for org.apache.hadoop.hbase.client.Put#size()

The following examples show how to use org.apache.hadoop.hbase.client.Put#size() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IndexUpdateManager.java    From phoenix with Apache License 2.0 5 votes vote down vote up
private int comparePuts(Put p1, Put p2) {
  int p1Size = p1.size();
  int p2Size = p2.size();
  int compare = p1Size - p2Size;
  if (compare == 0) {
    // TODO: make this a real comparison
    // this is a little cheating, but we don't really need to worry too much about this being
    // the same - chances are that exact matches here are really the same update.
    return Longs.compare(p1.heapSize(), p2.heapSize());
  }
  return compare;
}
 
Example 2
Source File: IndexUpdateManager.java    From phoenix with Apache License 2.0 5 votes vote down vote up
private int comparePuts(Put p1, Put p2) {
  int p1Size = p1.size();
  int p2Size = p2.size();
  int compare = p1Size - p2Size;
  if (compare == 0) {
    // TODO: make this a real comparison
    // this is a little cheating, but we don't really need to worry too much about this being
    // the same - chances are that exact matches here are really the same update.
    return Longs.compare(p1.heapSize(), p2.heapSize());
  }
  return compare;
}
 
Example 3
Source File: IndexUpdateManager.java    From phoenix with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private int comparePuts(Put p1, Put p2) {
  int p1Size = p1.size();
  int p2Size = p2.size();
  int compare = p1Size - p2Size;
  if (compare == 0) {
    // TODO: make this a real comparison
    // this is a little cheating, but we don't really need to worry too much about this being
    // the same - chances are that exact matches here are really the same update.
    return Longs.compare(p1.heapSize(), p2.heapSize());
  }
  return compare;
}
 
Example 4
Source File: HBaseStorageService.java    From antsdb with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void put1(int tableId, List<Row> rows) throws IOException  {        
    if (!this.isMutable) {
        throw new OrcaHBaseException("hbase storage is in read-only mode");
    }
    
    TableName tableName = getTableName(tableId);
    
    // skip data from already dropped table        
    if (tableName == null) {
        return;
    }

    this.tableColumnQualifierList.clear();
    this.tableColumnTypes = null;

    Table htable = this.hbaseConnection.getTable(tableName);
    int totalColumns = 0;
    ArrayList<Put> puts = new ArrayList<Put>(100);
    
    for (Row row : rows) {

        // update column info
        updateColumnInfo(tableId, row);
        
        // populate row key        
        byte[] key = Helper.antsKeyToHBase(row.getKeyAddress());
        Put put = new Put(key);

        // populate version
        
        // long version = this.humpback.getTrxMan().getTimestamp(Row.getVersion(row.getAddress()));
        long version = this.humpback.getTrxMan().getTimestamp(row.getVersion());
        if (version < 0) {
            throw new OrcaHBaseException("invalid version {}", version);
        }
        put.addColumn(Helper.DATA_COLUMN_FAMILY_BYTES, Helper.SYS_COLUMN_VERSION_BYTES, version, Bytes.toBytes(version));
        
        // populate size
        
        put.addColumn(Helper.DATA_COLUMN_FAMILY_BYTES, Helper.SYS_COLUMN_SIZE_BYTES, version, Bytes.toBytes(row.getLength()));
        
        // populate fields
        
        int maxColumnId = row.getMaxColumnId();
        byte[] types = new byte[maxColumnId+1];
        for (int i=0; i<=maxColumnId; i++) {
            byte[] qualifier = tableColumnQualifierList.get(i);
            if (qualifier == null) {
                continue;
            }
            long pValue = row.getFieldAddress(i); 
            types[i] = Helper.getType(pValue);
            byte[] value = Helper.toBytes(pValue);
            put.addColumn(Helper.DATA_COLUMN_FAMILY_BYTES, qualifier, version, value);
        }

        // populate data types
        put.addColumn(Helper.DATA_COLUMN_FAMILY_BYTES, Helper.SYS_COLUMN_DATATYPE_BYTES, version, types);
        puts.add(put);
        totalColumns += put.size();
        
        // if total columns exceeds define maxColumnCount, we'll do one put
        if (totalColumns >= this.maxColumnPerPut) {
            htable.put(puts);
            puts.clear();
            totalColumns = 0;
        }
    }

    // do last put
    if (puts.size() > 0) {
        htable.put(puts);
        puts.clear();
        totalColumns = 0;
    }
    htable.close();
}