private void writeHead(DataOutput out) throws IOException { ByteArrayOutputStream byteBuf = new ByteArrayOutputStream(); DataOutputStream headOut = new DataOutputStream(byteBuf); headOut.writeInt(baseId); headOut.writeUTF(bytesConvert == null ? "" : bytesConvert.getClass().getName()); //write accuOffset headOut.writeInt(accuOffset.size()); for (int i = 0; i < accuOffset.size(); i++) headOut.writeInt(accuOffset.get(i)); //write valueDivide headOut.writeInt(valueDivide.size()); for (int i = 0; i < valueDivide.size(); i++) { ByteArray ba = valueDivide.get(i); byte[] byteStr = ba.toBytes(); headOut.writeInt(byteStr.length); headOut.write(byteStr); } //write tree size headOut.writeInt(trees.size()); headOut.close(); //output byte[] head = byteBuf.toByteArray(); out.writeInt(head.length); out.write(head); }
public static void prepareTestData() throws Exception { try { util.getHBaseAdmin().disableTable(TABLE); util.getHBaseAdmin().deleteTable(TABLE); } catch (Exception e) { // ignore table not found } Table table = util.createTable(TABLE, FAM); HRegionInfo hRegionInfo = new HRegionInfo(table.getName()); region = util.createLocalHRegion(hRegionInfo, table.getTableDescriptor()); gtInfo = newInfo(); GridTable gridTable = newTable(gtInfo); IGTScanner scanner = gridTable.scan(new GTScanRequestBuilder().setInfo(gtInfo).setRanges(null) .setDimensions(null).setFilterPushDown(null).createGTScanRequest()); for (GTRecord record : scanner) { byte[] value = record.exportColumns(gtInfo.getPrimaryKey()).toBytes(); byte[] key = new byte[RowConstants.ROWKEY_SHARD_AND_CUBOID_LEN + value.length]; System.arraycopy(Bytes.toBytes(baseCuboid), 0, key, RowConstants.ROWKEY_SHARDID_LEN, RowConstants.ROWKEY_CUBOIDID_LEN); System.arraycopy(value, 0, key, RowConstants.ROWKEY_SHARD_AND_CUBOID_LEN, value.length); Put put = new Put(key); put.addColumn(FAM, COL_M, record.exportColumns(gtInfo.getColumnBlock(1)).toBytes()); region.put(put); } }
private void writeHead(DataOutput out) throws IOException { ByteArrayOutputStream byteBuf = new ByteArrayOutputStream(); DataOutputStream headOut = new DataOutputStream(byteBuf); headOut.writeInt(baseId); headOut.writeUTF(bytesConvert == null ? "" : bytesConvert.getClass().getName()); //write accuOffset headOut.writeInt(accuOffset.size()); for (int i = 0; i < accuOffset.size(); i++) headOut.writeInt(accuOffset.get(i)); //write valueDivide headOut.writeInt(valueDivide.size()); for (int i = 0; i < valueDivide.size(); i++) { ByteArray ba = valueDivide.get(i); byte[] byteStr = ba.toBytes(); headOut.writeInt(byteStr.length); headOut.write(byteStr); } //write tree size headOut.writeInt(trees.size()); headOut.close(); //output byte[] head = byteBuf.toByteArray(); out.writeInt(head.length); out.write(head); }