org.apache.hadoop.hbase.client.Result

Here are the examples of the java api org.apache.hadoop.hbase.client.Result taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

693 Examples 7

19 Source : HBaseRecordReader.java
with Apache License 2.0
from zpochen

@Override
public int next() {
    Stopwatch watch = Stopwatch.createStarted();
    if (rowKeyVector != null) {
        rowKeyVector.clear();
        rowKeyVector.allocateNew();
    }
    for (ValueVector v : familyVectorMap.values()) {
        v.clear();
        v.allocateNew();
    }
    int rowCount = 0;
    // if allocated memory for the first row is larger than allowed max in batch, it will be added anyway
    do {
        Result result = null;
        final OperatorStats operatorStats = operatorContext == null ? null : operatorContext.getStats();
        try {
            if (operatorStats != null) {
                operatorStats.startWait();
            }
            try {
                result = resultScanner.next();
            } finally {
                if (operatorStats != null) {
                    operatorStats.stopWait();
                }
            }
        } catch (IOException e) {
            throw new DrillRuntimeException(e);
        }
        if (result == null) {
            break;
        }
        // parse the result and populate the value vectors
        Cell[] cells = result.rawCells();
        if (rowKeyVector != null) {
            rowKeyVector.getMutator().setSafe(rowCount, cells[0].getRowArray(), cells[0].getRowOffset(), cells[0].getRowLength());
        }
        if (!rowKeyOnly) {
            for (final Cell cell : cells) {
                final int familyOffset = cell.getFamilyOffset();
                final int familyLength = cell.getFamilyLength();
                final byte[] familyArray = cell.getFamilyArray();
                final MapVector mv = getOrCreateFamilyVector(new String(familyArray, familyOffset, familyLength), true);
                final int qualifierOffset = cell.getQualifierOffset();
                final int qualifierLength = cell.getQualifierLength();
                final byte[] qualifierArray = cell.getQualifierArray();
                final NullableVarBinaryVector v = getOrCreateColumnVector(mv, new String(qualifierArray, qualifierOffset, qualifierLength));
                final int valueOffset = cell.getValueOffset();
                final int valueLength = cell.getValueLength();
                final byte[] valueArray = cell.getValueArray();
                v.getMutator().setSafe(rowCount, valueArray, valueOffset, valueLength);
            }
        }
        rowCount++;
    } while (canAddNewRow(rowCount));
    setOutputRowCount(rowCount);
    logger.debug("Took {} ms to get {} records", watch.elapsed(TimeUnit.MILLISECONDS), rowCount);
    return rowCount;
}

19 Source : HBasePersistentStore.java
with Apache License 2.0
from zpochen

protected synchronized V get(String key, byte[] family) {
    try {
        Get get = new Get(row(key));
        get.addColumn(family, QUALIFIER);
        Result r = hbaseTable.get(get);
        if (r.isEmpty()) {
            return null;
        }
        return value(r);
    } catch (IOException e) {
        throw UserException.dataReadError(e).message("Caught error while getting row '%s' from for table '%s'", key, hbaseTableName).build(logger);
    }
}

19 Source : HBasePersistentStore.java
with Apache License 2.0
from zpochen

private V value(Result result) {
    try {
        return config.getSerializer().deserialize(result.value());
    } catch (IOException e) {
        throw UserException.dataReadError(e).build(logger);
    }
}

19 Source : HBaseUtil.java
with Apache License 2.0
from xuwujing

/**
 * 查询该表中的所有数据
 *
 * @param tableName
 *            表名
 */
public static void select(String tableName) {
    if (null == tableName || tableName.length() == 0) {
        return;
    }
    Table t = null;
    List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
    try {
        t = getConnection().getTable(TableName.valueOf(tableName));
        // 读取操作
        Scan scan = new Scan();
        // 得到扫描的结果集
        ResultScanner rs = t.getScanner(scan);
        if (null == rs) {
            return;
        }
        for (Result result : rs) {
            // 得到单元格集合
            List<Cell> cs = result.listCells();
            if (null == cs || cs.size() == 0) {
                continue;
            }
            for (Cell cell : cs) {
                Map<String, Object> map = new HashMap<String, Object>();
                // 取行健
                map.put("rowKey", Bytes.toString(CellUtil.cloneRow(cell)));
                // 取到时间戳
                map.put("timestamp", cell.getTimestamp());
                // 取到列族
                map.put("family", Bytes.toString(CellUtil.cloneFamily(cell)));
                // 取到列
                map.put("qualifier", Bytes.toString(CellUtil.cloneQualifier(cell)));
                // 取到值
                map.put("value", Bytes.toString(CellUtil.cloneValue(cell)));
                list.add(map);
            }
        }
        System.out.println("查询的数据:" + list);
    } catch (IOException e) {
        System.out.println("查询失败!");
        e.printStackTrace();
    } finally {
        close();
    }
}

19 Source : HBaseUtil.java
with Apache License 2.0
from xuwujing

/**
 * 根据条件明细查询
 *
 * @param tableName
 *            表名
 * @param rowKey
 *            行健 (主键)
 * @param family
 *            列族
 * @param qualifier
 *            列
 */
public static void select(String tableName, String rowKey, String family, String qualifier) {
    Table t = null;
    List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
    try {
        t = getConnection().getTable(TableName.valueOf(tableName));
        // 通过HBase中的 get来进行查询
        Get get = new Get(Bytes.toBytes(rowKey));
        // 如果列族不为空
        if (null != family && family.length() > 0) {
            // 如果列不为空
            if (null != qualifier && qualifier.length() > 0) {
                get.addColumn(Bytes.toBytes(family), Bytes.toBytes(qualifier));
            } else {
                get.addFamily(Bytes.toBytes(family));
            }
        }
        Result r = t.get(get);
        List<Cell> cs = r.listCells();
        if (null == cs || cs.size() == 0) {
            return;
        }
        for (Cell cell : cs) {
            Map<String, Object> map = new HashMap<String, Object>();
            // 取行健
            map.put("rowKey", Bytes.toString(CellUtil.cloneRow(cell)));
            // 取到时间戳
            map.put("timestamp", cell.getTimestamp());
            // 取到列族
            map.put("family", Bytes.toString(CellUtil.cloneFamily(cell)));
            // 取到列
            map.put("qualifier", Bytes.toString(CellUtil.cloneQualifier(cell)));
            // 取到值
            map.put("value", Bytes.toString(CellUtil.cloneValue(cell)));
            list.add(map);
        }
        System.out.println("查询的数据:" + list);
    } catch (IOException e) {
        System.out.println("查询失败!");
        e.printStackTrace();
    } finally {
        close();
    }
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 公用方法,提取value中的column列的值
 *
 * @param value
 * @param column
 * @return
 */
private String fetchValue(Result value, String column) {
    return Bytes.toString(value.getValue(family, Bytes.toBytes(column)));
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取订单名称
 *
 * @param value
 * @return
 */
public String getOrderName(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_ORDER_NAME);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取浏览器语言信息
 *
 * @param value
 * @return
 */
public String getLanguage(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_LANGUAGE);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取前一个页面
 *
 * @param value
 * @return
 */
public String getReferrerUrl(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_REFERER_URL);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取浏览器分辨率大小
 *
 * @param value
 * @return
 */
public String getBrowserResolution(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_RESOLUTION);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取会员id
 *
 * @param value
 * @return
 */
public String getMemberId(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_MEMBER_ID);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取事件名称
 *
 * @param value
 * @return
 */
public String getEventName(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_EVENT_NAME);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取os版本号
 *
 * @param value
 * @return
 */
public String getOsVersion(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_OS_VERSION);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取事件持续时间
 *
 * @param value
 * @return
 */
public String getEventDuration(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_EVENT_DURATION);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取订单id
 *
 * @param value
 * @return
 */
public String getOrderId(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_ORDER_ID);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取服务器时间戳
 *
 * @param value
 * @return
 */
public String getServerTime(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_SERVER_TIME);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取事件action
 *
 * @param value
 * @return
 */
public String getEventAction(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_EVENT_ACTION);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取浏览器名称
 *
 * @param value
 * @return
 */
public String getBrowserName(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_BROWSER_NAME);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取浏览器版本号
 *
 * @param value
 * @return
 */
public String getBrowserVersion(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_BROWSER_VERSION);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取地域城市
 *
 * @param value
 * @return
 */
public String getCity(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_CITY);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取os名称
 *
 * @param value
 * @return
 */
public String getOsName(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_OS_NAME);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取事件category值
 *
 * @param value
 * @return
 */
public String getEventCategory(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_EVENT_CATEGORY);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取订单货币类型
 *
 * @param value
 * @return
 */
public String getOrderCurrencyType(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_ORDER_CURRENCY_TYPE);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取平台名称对应的value
 *
 * @param value
 * @return
 */
public String getPlatform(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_PLATFORM);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取事件传递的map对象
 *
 * @param value
 * @return
 */
public Map<String, String> getEventMap(Result value) {
    Map<String, String> map = new HashMap<String, String>();
    for (Map.Entry<byte[], byte[]> entry : value.getFamilyMap(family).entrySet()) {
        String column = Bytes.toString(entry.getKey());
        if (column.startsWith(EventLogConstants.LOG_COLUMN_NAME_EVENT_KV_START)) {
            map.put(column, Bytes.toString(entry.getValue()));
        }
    }
    return map;
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取会话时间
 *
 * @param value
 * @return
 */
public String getSessionId(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_SESSION_ID);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取ip地址
 *
 * @param value
 * @return
 */
public String getIp(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_IP);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取版本号
 *
 * @param value
 * @return
 */
public String getVersion(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_VERSION);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取定义金额
 *
 * @param value
 * @return
 */
public String getOrderCurrencyAmount(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_ORDER_CURRENCY_AMOUNT);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取地域国家
 *
 * @param value
 * @return
 */
public String getCountry(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_COUNTRY);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取当前页面url
 *
 * @param value
 * @return
 */
public String getCurrentUrl(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_CURRENT_URL);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取客户端时间
 *
 * @param value
 * @return
 */
public String getClientTime(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_CLIENT_TIME);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取地域省份
 *
 * @param value
 * @return
 */
public String getProvince(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_PROVINCE);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取订单支付方式
 *
 * @param value
 * @return
 */
public String getOrderPaymentType(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_ORDER_PAYMENT_TYPE);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取uuid
 *
 * @param value
 * @return
 */
public String getUuid(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_UUID);
}

19 Source : TransformerBaseMapper.java
with GNU General Public License v3.0
from wlhbdp

/**
 * 获取网页replacedle
 *
 * @param value
 * @return
 */
public String getreplacedle(Result value) {
    return this.fetchValue(value, EventLogConstants.LOG_COLUMN_NAME_replacedLE);
}

19 Source : HBaseUtilTest.java
with Apache License 2.0
from whirlys

@Test
public void getFileDetails() {
    Result result = HBaseUtil.getRow("FileTable", "rowkey1");
    if (result != null) {
        System.out.println("rowkey=" + Bytes.toString(result.getRow()));
        System.out.println("fileName=" + Bytes.toString(result.getValue(Bytes.toBytes("fileInfo"), Bytes.toBytes("name"))));
    }
}

19 Source : Hbase11xHelper.java
with Apache License 2.0
from wgzhao

public static void deleteTable(Configuration configuration) {
    String userTable = configuration.getString(Key.TABLE);
    LOG.info("HBasWriter begins to delete table {} .", userTable);
    Scan scan = new Scan();
    org.apache.hadoop.hbase.client.Table hTable = Hbase11xHelper.getTable(configuration);
    try (ResultScanner scanner = hTable.getScanner(scan)) {
        for (Result rr = scanner.next(); rr != null; rr = scanner.next()) {
            hTable.delete(new Delete(rr.getRow()));
        }
    } catch (Exception e) {
        throw DataXException.asDataXException(Hbase11xWriterErrorCode.DELETE_HBASE_ERROR, e);
    } finally {
        Hbase11xHelper.closeTable(hTable);
    }
}

19 Source : NormalTask.java
with Apache License 2.0
from wgzhao

@Override
public boolean fetchLine(Record record) throws Exception {
    Result result = super.getNextHbaseRow();
    if (null == result) {
        return false;
    }
    super.lastResult = result;
    try {
        byte[] hbaseColumnValue;
        String columnName;
        ColumnType columnType;
        byte[] columnFamily;
        byte[] qualifier;
        for (HbaseColumnCell cell : this.hbaseColumnCells) {
            columnType = cell.getColumnType();
            if (cell.isConstant()) {
                // 对常量字段的处理
                String constantValue = cell.getColumnValue();
                Column constantColumn = super.convertValueToreplacedignType(columnType, constantValue, cell.getDateformat());
                record.addColumn(constantColumn);
            } else {
                // 根据列名称获取值
                columnName = cell.getColumnName();
                if (Hbase20xHelper.isRowkeyColumn(columnName)) {
                    hbaseColumnValue = result.getRow();
                } else {
                    columnFamily = cell.getColumnFamily();
                    qualifier = cell.getQualifier();
                    hbaseColumnValue = result.getValue(columnFamily, qualifier);
                }
                Column hbaseColumn = super.convertBytesToreplacedignType(columnType, hbaseColumnValue, cell.getDateformat());
                record.addColumn(hbaseColumn);
            }
        }
    } catch (Exception e) {
        // 注意,这里catch的异常,期望是byte数组转换失败的情况。而实际上,string的byte数组,转成整数类型是不容易报错的。但是转成double类型容易报错。
        record.setColumn(0, new StringColumn(Bytes.toStringBinary(result.getRow())));
        throw e;
    }
    return true;
}

19 Source : MultiVersionTask.java
with Apache License 2.0
from wgzhao

@Override
public boolean fetchLine(Record record) throws Exception {
    Result result;
    if (this.cellArr == null || this.cellArr.length == this.currentReadPosition) {
        result = super.getNextHbaseRow();
        if (result == null) {
            return false;
        }
        super.lastResult = result;
        this.cellArr = result.rawCells();
        if (this.cellArr == null || this.cellArr.length == 0) {
            return false;
        }
        this.currentReadPosition = 0;
    }
    try {
        Cell cell = this.cellArr[this.currentReadPosition];
        convertCellToLine(cell, record);
    } finally {
        this.currentReadPosition++;
    }
    return true;
}

19 Source : HbaseAbstractTask.java
with Apache License 2.0
from wgzhao

protected Result getNextHbaseRow() throws IOException {
    Result result;
    try {
        result = resultScanner.next();
    } catch (IOException e) {
        if (lastResult != null) {
            this.scan.withStopRow(lastResult.getRow());
        }
        resultScanner = this.htable.getScanner(scan);
        result = resultScanner.next();
        if (lastResult != null && Bytes.equals(lastResult.getRow(), result.getRow())) {
            result = resultScanner.next();
        }
    }
    lastResult = result;
    // may be null
    return result;
}

19 Source : NormalTask.java
with Apache License 2.0
from wgzhao

@Override
public boolean fetchLine(Record record) throws Exception {
    Result result = super.getNextHbaseRow();
    if (null == result) {
        return false;
    }
    super.lastResult = result;
    try {
        byte[] hbaseColumnValue;
        String columnName;
        ColumnType columnType;
        byte[] columnFamily;
        byte[] qualifier;
        for (HbaseColumnCell cell : this.hbaseColumnCells) {
            columnType = cell.getColumnType();
            if (cell.isConstant()) {
                // 对常量字段的处理
                String constantValue = cell.getColumnValue();
                Column constantColumn = super.convertValueToreplacedignType(columnType, constantValue, cell.getDateformat());
                record.addColumn(constantColumn);
            } else {
                // 根据列名称获取值
                columnName = cell.getColumnName();
                if (Hbase11xHelper.isRowkeyColumn(columnName)) {
                    hbaseColumnValue = result.getRow();
                } else {
                    columnFamily = cell.getColumnFamily();
                    qualifier = cell.getQualifier();
                    hbaseColumnValue = result.getValue(columnFamily, qualifier);
                }
                Column hbaseColumn = super.convertBytesToreplacedignType(columnType, hbaseColumnValue, cell.getDateformat());
                record.addColumn(hbaseColumn);
            }
        }
    } catch (Exception e) {
        // 注意,这里catch的异常,期望是byte数组转换失败的情况。而实际上,string的byte数组,转成整数类型是不容易报错的。但是转成double类型容易报错。
        record.setColumn(0, new StringColumn(Bytes.toStringBinary(result.getRow())));
        throw e;
    }
    return true;
}

19 Source : Helper.java
with GNU Lesser General Public License v3.0
from waterguo

public static void getRowKey(BluntHeap heap, TableMeta table, Result r) {
    byte[] key = hbaseKeyToAnts(r.getRow());
    KeyBytes.allocSet(heap, key);
}

19 Source : Helper.java
with GNU Lesser General Public License v3.0
from waterguo

public static Map<String, byte[]> toMap(Result r) {
    Map<String, byte[]> row = new HashMap<>();
    byte[] key = r.getRow();
    row.put("", key);
    for (Map.Entry<byte[], NavigableMap<byte[], byte[]>> i : r.getNoVersionMap().entrySet()) {
        String cf = new String(i.getKey());
        for (Map.Entry<byte[], byte[]> j : i.getValue().entrySet()) {
            String q = new String(getKeyName(j.getKey()));
            String name = cf + ":" + q;
            row.put(name, j.getValue());
        }
    }
    return row;
}

19 Source : Helper.java
with GNU Lesser General Public License v3.0
from waterguo

public static Result get(Connection conn, TableName tableName, byte[] key) throws IOException {
    Table htable = conn.getTable(tableName);
    Get get = new Get(key);
    Result r = htable.get(get);
    return r;
}

19 Source : Helper.java
with GNU Lesser General Public License v3.0
from waterguo

public static Result exist(Connection conn, TableName tableName, byte[] key) throws IOException {
    Table htable = conn.getTable(tableName);
    Get get = new Get(key);
    get.addColumn(DATA_COLUMN_FAMILY_BYTES, SYS_COLUMN_VERSION_BYTES);
    Result r = htable.get(get);
    return r;
}

19 Source : Helper.java
with GNU Lesser General Public License v3.0
from waterguo

public static long getVersion(Result r) {
    NavigableMap<byte[], byte[]> sys = r.getFamilyMap(DATA_COLUMN_FAMILY_BYTES);
    byte[] versionBytes = sys.get(SYS_COLUMN_VERSION_BYTES);
    long version = Bytes.toLong(versionBytes);
    return version;
}

19 Source : Helper.java
with GNU Lesser General Public License v3.0
from waterguo

public static long toIndexLine(Heap heap, Result r) {
    if (r.isEmpty()) {
        return 0;
    }
    NavigableMap<byte[], byte[]> sys = r.getFamilyMap(DATA_COLUMN_FAMILY_BYTES);
    byte[] indexKey = r.getRow();
    byte[] rowKey = sys.get(SYS_COLUMN_INDEXKEY_BYTES);
    byte misc = sys.get(SYS_COLUMN_MISC_BYTES)[0];
    indexKey = hbaseKeyToAnts(indexKey);
    rowKey = hbaseKeyToAnts(rowKey);
    return IndexLine.alloc(heap, indexKey, rowKey, misc).getAddress();
}

19 Source : Helper.java
with GNU Lesser General Public License v3.0
from waterguo

public static long toRow(Heap heap, Result r, TableMeta table, int tableId) {
    if (r.isEmpty()) {
        return 0;
    }
    // some preparation
    NavigableMap<byte[], byte[]> dataFamilyMap = r.getFamilyMap(DATA_COLUMN_FAMILY_BYTES);
    byte[] colDataType = dataFamilyMap.get(SYS_COLUMN_DATATYPE_BYTES);
    byte[] sizeBytes = dataFamilyMap.get(SYS_COLUMN_SIZE_BYTES);
    int size = Bytes.toInt(sizeBytes);
    // populate the row. system table doesn't come with metadata
    VaporizingRow row = null;
    byte[] key = hbaseKeyToAnts(r.getRow());
    if (table != null) {
        row = populateUsingMetadata(heap, table, dataFamilyMap, colDataType, size, key);
    } else if (tableId < 0x100) {
        row = populateDirect(heap, dataFamilyMap, colDataType, size, key);
    } else {
        throw new OrcaHBaseException("metadata not found for table " + tableId);
    }
    row.setVersion(1);
    long pRow = Row.from(heap, row);
    return pRow;
}

19 Source : Helper.java
with GNU Lesser General Public License v3.0
from waterguo

public static int getSize(Result r) {
    NavigableMap<byte[], byte[]> f = r.getFamilyMap(DATA_COLUMN_FAMILY_BYTES);
    byte[] sizeBytes = f.get(SYS_COLUMN_SIZE_BYTES);
    if (sizeBytes != null) {
        int size = Bytes.toInt(sizeBytes);
        return size;
    } else {
        byte[] indexKey = r.getRow();
        byte[] rowKey = f.get(SYS_COLUMN_INDEXKEY_BYTES);
        return indexKey.length + KeyBytes.HEADER_SIZE + rowKey.length + KeyBytes.HEADER_SIZE + 1;
    }
}

See More Examples