public int getColumnLength(TblColRef col) { return colIO.getColumnLength(col); }
public static CoprocessorRowType fromCuboid(CubeSegment seg, Cuboid cuboid) { List<TblColRef> colList = cuboid.getColumns(); TblColRef[] cols = colList.toArray(new TblColRef[colList.size()]); RowKeyColumnIO colIO = new RowKeyColumnIO(seg.getDimensionEncodingMap()); int[] colSizes = new int[cols.length]; for (int i = 0; i < cols.length; i++) { colSizes[i] = colIO.getColumnLength(cols[i]); } return new CoprocessorRowType(cols, colSizes, seg.getRowKeyPreambleSize()); }
public RowKeyEncoder(CubeSegment cubeSeg, Cuboid cuboid) { super(cubeSeg, cuboid); enableSharding = cubeSeg.isEnableSharding(); headerLength = cubeSeg.getRowKeyPreambleSize(); Set<TblColRef> shardByColumns = cubeSeg.getCubeDesc().getShardByColumns(); if (shardByColumns.size() > 1) { throw new IllegalStateException("Does not support multiple UHC now"); } colIO = new RowKeyColumnIO(cubeSeg.getDimensionEncodingMap()); for (TblColRef column : cuboid.getColumns()) { if (shardByColumns.contains(column)) { uhcOffset = bodyLength; uhcLength = colIO.getColumnLength(column); } bodyLength += colIO.getColumnLength(column); } }
@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; }
splitOffsets[i] = offset; TblColRef col = cuboid.getColumns().get(i); int colLength = colIO.getColumnLength(col); ByteArray split = new ByteArray(bytes, offset, colLength); this.splitBuffers[this.bufferSize++] = split;
public int getColumnLength(TblColRef col) { return colIO.getColumnLength(col); }
private String nullString(TblColRef column) { byte[] id = new byte[columnIO.getColumnLength(column)]; for (int i = 0; i < id.length; i++) { id[i] = Dictionary.NULL; } return Dictionary.dictIdToString(id, 0, id.length); }
private String translate(TblColRef column, String v, int roundingFlag) { byte[] value = Bytes.toBytes(v); byte[] id = new byte[columnIO.getColumnLength(column)]; columnIO.writeColumn(column, value, value.length, roundingFlag, Dictionary.NULL, id, 0); return Dictionary.dictIdToString(id, 0, id.length); } }
public int getColumnOffset(TblColRef col) { int offset = RowConstants.ROWKEY_CUBOIDID_LEN; for (TblColRef dimCol : cuboid.getColumns()) { if (col.equals(dimCol)) return offset; offset += colIO.getColumnLength(dimCol); } throw new IllegalArgumentException("Column " + col + " not found on cuboid " + cuboid); }
public static CoprocessorRowType fromCuboid(CubeSegment seg, Cuboid cuboid) { List<TblColRef> colList = cuboid.getColumns(); TblColRef[] cols = colList.toArray(new TblColRef[colList.size()]); RowKeyColumnIO colIO = new RowKeyColumnIO(seg); int[] colSizes = new int[cols.length]; for (int i = 0; i < cols.length; i++) { colSizes[i] = colIO.getColumnLength(cols[i]); } return new CoprocessorRowType(cols, colSizes); }
protected RowKeyEncoder(CubeSegment cubeSeg, Cuboid cuboid) { super(cuboid); colIO = new RowKeyColumnIO(cubeSeg); bytesLength = headerLength = RowConstants.ROWKEY_CUBOIDID_LEN; // header for (TblColRef column : cuboid.getColumns()) { bytesLength += colIO.getColumnLength(column); } }
public void writeColumn(TblColRef column, byte[] value, int valueLen, int roundingFlag, byte dft, byte[] output, int outputOffset) { Dictionary<String> dict = getDictionary(column); int columnLen = getColumnLength(column); // non-dict value if (dict == null) { byte[] valueBytes = padFixLen(columnLen, value); System.arraycopy(valueBytes, 0, output, outputOffset, columnLen); return; } // dict value try { int id = dict.getIdFromValueBytes(value, 0, valueLen, roundingFlag); BytesUtil.writeUnsigned(id, output, outputOffset, dict.getSizeOfId()); } catch (IllegalArgumentException ex) { for (int i = outputOffset; i < outputOffset + columnLen; i++) output[i] = dft; logger.error("Can't translate value " + Bytes.toString(value, 0, valueLen) + " to dictionary ID, roundingFlag " + roundingFlag + ". Using default value " + String.format("\\x%02X", dft)); } }
int colLength = colIO.getColumnLength(col); SplittedBytes split = this.splitBuffers[this.bufferSize++]; split.length = colLength;
@Override public byte[] encode(byte[][] values) { byte[] bytes = new byte[this.bytesLength]; int offset = fillHeader(bytes, values); for (int i = 0; i < cuboid.getColumns().size(); i++) { TblColRef column = cuboid.getColumns().get(i); int colLength = colIO.getColumnLength(column); byte[] value = values[i]; if (value == null) { fillColumnValue(column, colLength, null, 0, bytes, offset); } else { fillColumnValue(column, colLength, value, value.length, bytes, offset); } offset += colLength; } return bytes; }
public int getColumnLength(TblColRef col) { return colIO.getColumnLength(col); }
public int getColumnLength(TblColRef col) { return colIO.getColumnLength(col); }
public int getColumnOffset(TblColRef col) { int offset = RowConstants.ROWKEY_CUBOIDID_LEN; for (TblColRef dimCol : cuboid.getColumns()) { if (col.equals(dimCol)) return offset; offset += colIO.getColumnLength(dimCol); } throw new IllegalArgumentException("Column " + col + " not found on cuboid " + cuboid); }
protected RowKeyEncoder(CubeSegment cubeSeg, Cuboid cuboid) { super(cuboid); colIO = new RowKeyColumnIO(cubeSeg); bytesLength = headerLength = RowConstants.ROWKEY_CUBOIDID_LEN; // header for (TblColRef column : cuboid.getColumns()) { bytesLength += colIO.getColumnLength(column); } }
public static CoprocessorRowType fromCuboid(CubeSegment seg, Cuboid cuboid) { List<TblColRef> colList = cuboid.getColumns(); TblColRef[] cols = colList.toArray(new TblColRef[colList.size()]); RowKeyColumnIO colIO = new RowKeyColumnIO(seg.getDimensionEncodingMap()); int[] colSizes = new int[cols.length]; for (int i = 0; i < cols.length; i++) { colSizes[i] = colIO.getColumnLength(cols[i]); } return new CoprocessorRowType(cols, colSizes, seg.getRowKeyPreambleSize()); }
@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; }