public static AbstractRowKeyEncoder createInstance(CubeSegment cubeSeg, Cuboid cuboid) { return new RowKeyEncoder(cubeSeg, cuboid); }
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; } }
private void printKVInfo(PrintWriter writer) { Cuboid cuboid = Cuboid.getBaseCuboid(seg.getCubeDesc()); RowKeyEncoder encoder = new RowKeyEncoder(seg, cuboid); for (TblColRef col : cuboid.getColumns()) { writer.println("Length of dimension " + col + " is " + encoder.getColumnLength(col)); } }
@Test public void testEncodeWithoutSlr() throws Exception { CubeInstance cube = CubeManager.getInstance(getTestConfig()).getCube("TEST_KYLIN_CUBE_WITHOUT_SLR_READY"); // CubeSegment seg = cube.getTheOnlySegment(); CubeDesc cubeDesc = cube.getDescriptor(); // String data = // "2013-08-18Abbigliamento e accessoriDonna: AccessoriSciarpFoulard e ScialliAuctionItalyRegular"; String[] data = new String[8]; data[0] = "2012-12-15"; data[1] = "11848"; data[2] = "Health & Beauty"; data[3] = "Fragrances"; data[4] = "Women"; data[5] = "FP-GTC"; data[6] = "0"; data[7] = "15"; long baseCuboidId = Cuboid.getBaseCuboidId(cubeDesc); Cuboid baseCuboid = Cuboid.findForMandatory(cubeDesc, baseCuboidId); RowKeyEncoder rowKeyEncoder = new RowKeyEncoder(cube.getFirstSegment(), baseCuboid); byte[] encodedKey = rowKeyEncoder.encode(data); assertEquals(22 + rowKeyEncoder.getHeaderLength(), encodedKey.length); byte[] cuboidId = Arrays.copyOfRange(encodedKey, RowConstants.ROWKEY_SHARDID_LEN, rowKeyEncoder.getHeaderLength()); byte[] rest = Arrays.copyOfRange(encodedKey, rowKeyEncoder.getHeaderLength(), encodedKey.length); assertEquals(255, 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); }
RowKeyEncoder rowKeyEncoder = new RowKeyEncoder(cube.getFirstSegment(), baseCuboid);
RowKeyEncoder rowKeyEncoder = new RowKeyEncoder(cube.getFirstSegment(), baseCuboid);
@Test public void testEncodeAndDecodeWithUtf8() throws IOException { CubeInstance cube = CubeManager.getInstance(getTestConfig()).getCube("TEST_KYLIN_CUBE_WITHOUT_SLR_READY"); CubeDesc cubeDesc = cube.getDescriptor(); String[] data = new String[8]; data[0] = "2012-12-15"; data[1] = "11848"; data[2] = "Health & Beauty"; data[3] = "Fragrances"; data[4] = "Women"; data[5] = "刊登格式测试";// UTF-8 data[6] = "0"; data[7] = "15"; long baseCuboidId = Cuboid.getBaseCuboidId(cubeDesc); Cuboid baseCuboid = Cuboid.findForMandatory(cubeDesc, baseCuboidId); RowKeyEncoder rowKeyEncoder = new RowKeyEncoder(cube.getFirstSegment(), baseCuboid); byte[] encodedKey = rowKeyEncoder.encode(data); assertEquals(22 + rowKeyEncoder.getHeaderLength(), encodedKey.length); RowKeyDecoder rowKeyDecoder = new RowKeyDecoder(cube.getFirstSegment()); rowKeyDecoder.decode(encodedKey); List<String> values = rowKeyDecoder.getValues(); assertEquals("[" + millis("2012-12-15") + ", 11848, Health & Beauty, Fragrances, Women, 刊登格式, 0, 15]", values.toString()); }
public static AbstractRowKeyEncoder createInstance(CubeSegment cubeSeg, Cuboid cuboid) { // The storage location identifier is unique for every segment Map<Long, AbstractRowKeyEncoder> cubeCache = ENCODER_CACHE.get(cubeSeg.getStorageLocationIdentifier()); if (cubeCache == null) { cubeCache = new HashMap<Long, AbstractRowKeyEncoder>(); ENCODER_CACHE.put(cuboid.getCube().getName(), cubeCache); } AbstractRowKeyEncoder encoder = cubeCache.get(cuboid.getId()); if (encoder == null) { encoder = new RowKeyEncoder(cubeSeg, cuboid); cubeCache.put(cuboid.getId(), encoder); } return encoder; }
public static AbstractRowKeyEncoder createInstance(CubeSegment cubeSeg, Cuboid cuboid) { return new RowKeyEncoder(cubeSeg, cuboid); }
public static AbstractRowKeyEncoder createInstance(CubeSegment cubeSeg, Cuboid cuboid) { return new RowKeyEncoder(cubeSeg, cuboid); }
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; } }
private void printKVInfo(PrintWriter writer) { Cuboid cuboid = Cuboid.getBaseCuboid(seg.getCubeDesc()); RowKeyEncoder encoder = new RowKeyEncoder(seg, cuboid); for (TblColRef col : cuboid.getColumns()) { writer.println("Length of dimension " + col + " is " + encoder.getColumnLength(col)); } }