@Test public void testEncodeWithSlr() throws Exception { CubeInstance cube = CubeManager.getInstance(getTestConfig()).getCube("TEST_KYLIN_CUBE_WITH_SLR_READY"); CubeDesc cubeDesc = cube.getDescriptor(); byte[][] data = new byte[9][]; data[0] = Bytes.toBytes("123456789"); data[1] = Bytes.toBytes("2012-12-15"); data[2] = Bytes.toBytes("11848"); data[3] = Bytes.toBytes("Health & Beauty"); data[4] = Bytes.toBytes("Fragrances"); data[5] = Bytes.toBytes("Women"); data[6] = Bytes.toBytes("FP-GTC"); data[7] = Bytes.toBytes("0"); data[8] = Bytes.toBytes("15"); long baseCuboidId = Cuboid.getBaseCuboidId(cubeDesc); Cuboid baseCuboid = Cuboid.findById(cubeDesc, baseCuboidId); AbstractRowKeyEncoder rowKeyEncoder = AbstractRowKeyEncoder.createInstance(cube.getFirstSegment(), baseCuboid); byte[] encodedKey = rowKeyEncoder.encode(data); assertEquals(48, encodedKey.length); byte[] sellerId = Arrays.copyOfRange(encodedKey, 8, 26); byte[] cuboidId = Arrays.copyOfRange(encodedKey, 0, 8); byte[] rest = Arrays.copyOfRange(encodedKey, 26, encodedKey.length); assertTrue(Bytes.toString(sellerId).startsWith("123456789")); assertEquals(511, Bytes.toLong(cuboidId)); assertArrayEquals(new byte[] { 11, 55, -13, 13, 22, 34, 121, 70, 80, 45, 71, 84, 67, 9, 9, 9, 9, 9, 9, 0, 10, 5 }, rest); }
@Override public byte[] encode(Map<TblColRef, String> valueMap) { List<byte[]> valueList = new ArrayList<byte[]>(); for (TblColRef bdCol : cuboid.getColumns()) { String value = valueMap.get(bdCol); valueList.add(valueStringToBytes(value)); } byte[][] values = valueList.toArray(RowConstants.BYTE_ARR_MARKER); return encode(values); }
RowKeyEncoder extends AbstractRowKeyEncoder { @Override public byte[] encode(Map<TblColRef, String> valueMap) { List<byte[]> valueList = new ArrayList<byte[]>(); for (TblColRef bdCol : cuboid.getColumns()) { String value = valueMap.get(bdCol); valueList.add(valueStringToBytes(value)); } byte[][] values = valueList.toArray(RowConstants.BYTE_ARR_MARKER); return encode(values); } }
RowKeyEncoder extends AbstractRowKeyEncoder { @Override public byte[] encode(Map<TblColRef, String> valueMap) { List<byte[]> valueList = new ArrayList<byte[]>(); for (TblColRef bdCol : cuboid.getColumns()) { String value = valueMap.get(bdCol); valueList.add(valueStringToBytes(value)); } byte[][] values = valueList.toArray(RowConstants.BYTE_ARR_MARKER); return encode(values); } protected  RowKeyEncoder(CubeSegment cubeSeg, Cuboid cuboid); }
RowKeyEncoder extends AbstractRowKeyEncoder { @Override public byte[] encode(Map<TblColRef, String> valueMap) { List<byte[]> valueList = new ArrayList<byte[]>(); for (TblColRef bdCol : cuboid.getColumns()) { String value = valueMap.get(bdCol); valueList.add(valueStringToBytes(value)); } byte[][] values = valueList.toArray(RowConstants.BYTE_ARR_MARKER); return encode(values); } protected  RowKeyEncoder(CubeSegment cubeSeg, Cuboid cuboid); RowKeyColumnIO getColumnIO(); int getColumnOffset(TblColRef col); int getColumnLength(TblColRef col); int getRowKeyLength(); int getHeaderLength(); @Override byte[] encode(Map<TblColRef, String> valueMap); byte[] valueStringToBytes(String value); @Override byte[] encode(byte[][] values); }
RowKeyEncoder extends AbstractRowKeyEncoder { @Override public byte[] encode(Map<TblColRef, String> valueMap) { List<byte[]> valueList = new ArrayList<byte[]>(); for (TblColRef bdCol : cuboid.getColumns()) { String value = valueMap.get(bdCol); valueList.add(valueStringToBytes(value)); } byte[][] values = valueList.toArray(RowConstants.BYTE_ARR_MARKER); return encode(values); } protected  RowKeyEncoder(CubeSegment cubeSeg, Cuboid cuboid); RowKeyColumnIO getColumnIO(); int getColumnOffset(TblColRef col); int getColumnLength(TblColRef col); int getRowKeyLength(); int getHeaderLength(); @Override byte[] encode(Map<TblColRef, String> valueMap); byte[] valueStringToBytes(String value); @Override byte[] encode(byte[][] values);  }