org.apache.hadoop.hbase.client.Put#size ( )源码实例Demo

下面列出了org.apache.hadoop.hbase.client.Put#size ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: phoenix   文件: IndexUpdateManager.java
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;
}
 
源代码2 项目: phoenix   文件: IndexUpdateManager.java
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;
}
 
源代码3 项目: phoenix   文件: IndexUpdateManager.java
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;
}
 
源代码4 项目: antsdb   文件: HBaseStorageService.java
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();
}