Package org.lealone.hbase.util

Examples of org.lealone.hbase.util.HBaseRegionInfo


    private HBaseRow createRow(Value rowKey, String value) {
        rowKey = ValueString.get(rowKey.getString());
        byte[] rowKeyAsBytes = HBaseUtils.toBytes(rowKey);

        HBaseRegionInfo hri = HBaseUtils.getHBaseRegionInfo(getTableNameAsBytes(), rowKeyAsBytes);
        if (!HBaseUtils.isLocal(session, hri)) {
            Map<String, List<String>> regions = servers.get(hri.getRegionServerURL());
            if (regions == null) {
                regions = New.hashMap();
                servers.put(hri.getRegionServerURL(), regions);
            }

            List<String> values = regions.get(hri.getRegionName());
            if (values == null) {
                values = New.arrayList();
                regions.put(hri.getRegionName(), values);
            }
            values.add(value);

            return null;
        }

        HBaseRow row = (HBaseRow) table.getTemplateRow();
        row.setRowKey(rowKey);
        row.setRegionName(hri.getRegionNameAsBytes());
        row.setPut(session.getTransaction().createHBasePut(table.getDefaultColumnFamilyNameAsBytes(), rowKey));

        return row;
    }
View Full Code Here


            if (searchRow != null) {
                if (selectPrepared == null)
                    initSelectPrepared();

                byte[] rowKey = HBaseUtils.toBytes(searchRow.getRowKey());
                HBaseRegionInfo regionInfo = HBaseUtils.getHBaseRegionInfo(dataTableName, rowKey);
                selectParameter.setValue(ValueString.get(Bytes.toString(rowKey)));
                ResultInterface r = selectPrepared.query(1);
                if (r.next()) {
                    Value[] data = r.currentRow();
                    List<Column> cols = columns;
                    if (cols == null)
                        cols = Arrays.asList(secondaryIndex.getTable().getColumns());

                    List<KeyValue> kvs = New.arrayList(cols.size());
                    for (Column c : columns) {
                        kvs.add(new KeyValue(rowKey, c.getColumnFamilyNameAsBytes(), c.getNameAsBytes()));
                    }
                    row = new HBaseRow(regionInfo.getRegionNameAsBytes(), searchRow.getRowKey(), data, Row.MEMORY_CALCULATE,
                            new Result(kvs));
                } else {
                    throw new RuntimeException("row key " + searchRow.getRowKey() + " not found");
                }
            }
View Full Code Here

TOP

Related Classes of org.lealone.hbase.util.HBaseRegionInfo

Copyright © 2018 www.massapicom. 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.