@Override public byte[] createBuf() { return new byte[this.getBytesLength()]; }
public NDCuboidBuilder(CubeSegment cubeSegment) { this(cubeSegment, new RowKeyEncoderProvider(cubeSegment)); }
public CubeDimEncMap getDimensionEncodingMap() { return new CubeDimEncMap(this); }
@Override public byte[] encode(String[] values) { byte[] bytes = new byte[this.getBytesLength()]; int offset = getHeaderLength(); for (int i = 0; i < cuboid.getColumns().size(); i++) { TblColRef column = cuboid.getColumns().get(i); int colLength = colIO.getColumnLength(column); fillColumnValue(column, colLength, values[i], bytes, offset); offset += colLength; } //fill shard and cuboid fillHeader(bytes); return bytes; }
@Override public void encode(GTRecord record, ImmutableBitSet keyColumns, byte[] buf) { ByteArray byteArray = new ByteArray(buf, getHeaderLength(), 0); encodeDims(record, keyColumns, byteArray, defaultValue()); //fill shard and cuboid fillHeader(buf); }
protected void fillColumnValue(TblColRef column, int columnLen, String valueStr, byte[] outputValue, int outputValueOffset) { // special null value case if (valueStr == null) { Arrays.fill(outputValue, outputValueOffset, outputValueOffset + columnLen, defaultValue()); return; } colIO.writeColumn(column, valueStr, 0, this.blankByte, outputValue, outputValueOffset); }
public static AbstractRowKeyEncoder createInstance(CubeSegment cubeSeg, Cuboid cuboid) { return new RowKeyEncoder(cubeSeg, cuboid); }
public int getColumnLength(TblColRef col) { return colIO.getColumnLength(col); }
public FilterDecorator(IDimensionEncodingMap dimEncMap, FilterConstantsTreatment filterConstantsTreatment) { this.dimEncMap = dimEncMap; this.columnIO = new RowKeyColumnIO(dimEncMap); this.inevaluableColumns = Sets.newHashSet(); this.filterConstantsTreatment = filterConstantsTreatment; }
public CubeHBaseRPC(ISegment segment, Cuboid cuboid, GTInfo fullGTInfo, StorageContext context) { Preconditions.checkArgument(segment instanceof CubeSegment, "segment must be CubeSegment"); this.cubeSeg = (CubeSegment) segment; this.cuboid = cuboid; this.fullGTInfo = fullGTInfo; this.queryContext = QueryContextFacade.current(); this.storageContext = context; this.fuzzyKeyEncoder = new FuzzyKeyEncoder(cubeSeg, cuboid); this.fuzzyMaskEncoder = new FuzzyMaskEncoder(cubeSeg, cuboid); }
public byte[] buildKey(String[] flatRow) { String[] colKeys = kvBuilder.buildKey(flatRow); return rowKeyEncoder.encode(colKeys); }
/** * Build the new key, return a new ByteArray object each time. Suitable for spark * @param parentCuboid * @param childCuboid * @param splitBuffers * @return */ public ByteArray buildKey2(Cuboid parentCuboid, Cuboid childCuboid, ByteArray[] splitBuffers) { RowKeyEncoder rowkeyEncoder = rowKeyEncoderProvider.getRowkeyEncoder(childCuboid); int fullKeySize = rowkeyEncoder.getBytesLength(); ByteArray newKey = new ByteArray(fullKeySize); buildKeyInternal(parentCuboid, childCuboid, splitBuffers, newKey); return newKey; }
public int getBytesLength() { return getHeaderLength() + bodyLength; }
private void collectValue(TblColRef col, byte[] valueBytes, int offset, int length) throws IOException { String strValue = colIO.readColumnString(col, valueBytes, offset, length); values.add(strValue); }
@After public void after() throws Exception { this.cleanupTestMetadata(); }
@After public void after() throws Exception { this.cleanupTestMetadata(); }
@Before public void setUp() throws Exception { this.createTestMetadata(); }
@Before public void setUp() throws Exception { this.createTestMetadata(); }
@Override public void fillHeader(byte[] bytes) { int offset = 0; if (enableSharding) { Arrays.fill(bytes, 0, RowConstants.ROWKEY_SHARDID_LEN, RowConstants.BYTE_ONE); offset += RowConstants.ROWKEY_SHARDID_LEN; } // always fuzzy match cuboid ID to lock on the selected cuboid int headerLength = this.getHeaderLength(); Arrays.fill(bytes, offset, headerLength, RowConstants.BYTE_ZERO); }
public RowKeyEncoder getRowkeyEncoder(Cuboid cuboid) { RowKeyEncoder rowKeyEncoder = rowKeyEncoders.get(cuboid.getId()); if (rowKeyEncoder == null) { rowKeyEncoder = new RowKeyEncoder(cubeSegment, cuboid); rowKeyEncoders.put(cuboid.getId(), rowKeyEncoder); } return rowKeyEncoder; } }