@Test public void testIterateAndRead() throws Exception { FragmentMetaInfo fragmentMetaInfo = fragment.getMetaInfo(); FragmentData fragmentData = new FragmentData(fragmentMetaInfo, fragment.getDataFile()); CuboidInfo cuboidInfo = parsedStreamingCubeInfo.getCuboidInfo(parsedStreamingCubeInfo.basicCuboid.getId()); Map<TblColRef, Dictionary<String>> dictionaryMap = fragmentData .getDimensionDictionaries(parsedStreamingCubeInfo.dimensionsUseDictEncoding); TblColRef[] dimensions = cuboidInfo.getDimensions(); DimensionEncoding[] dimensionEncodings = ParsedStreamingCubeInfo.getDimensionEncodings( parsedStreamingCubeInfo.cubeDesc, dimensions, dictionaryMap); FragmentCuboidReader fragmentCuboidReader = new FragmentCuboidReader(parsedStreamingCubeInfo.cubeDesc, fragmentData, fragmentMetaInfo.getBasicCuboidMetaInfo(), cuboidInfo.getDimensions(), parsedStreamingCubeInfo.measureDescs, dimensionEncodings); int i = 0; for (RawRecord rawRecord : fragmentCuboidReader) { System.out.println(rawRecord); if (i > 10) { break; } i++; } RawRecord rawRecord = fragmentCuboidReader.read(9999); byte[] itmVal = rawRecord.getDimensions()[0]; assertEquals("ITM0000009999", dimensionEncodings[0].decode(itmVal, 0, itmVal.length)); cuboidInfo = parsedStreamingCubeInfo.getCuboidInfo(17); dictionaryMap = fragmentData.getDimensionDictionaries(parsedStreamingCubeInfo.dimensionsUseDictEncoding); dimensions = cuboidInfo.getDimensions(); dimensionEncodings = ParsedStreamingCubeInfo.getDimensionEncodings(parsedStreamingCubeInfo.cubeDesc, dimensions, dictionaryMap); fragmentCuboidReader = new FragmentCuboidReader(parsedStreamingCubeInfo.cubeDesc, fragmentData, fragmentMetaInfo.getBasicCuboidMetaInfo(), cuboidInfo.getDimensions(), parsedStreamingCubeInfo.measureDescs, dimensionEncodings); int j = 0; for (RawRecord newRawRecord : fragmentCuboidReader) { System.out.println(newRawRecord); if (j >= 10) { break; } j++; } }
public RawRecord read(int rowNum) { if (rowNum > rowCount - 1) { throw new IllegalStateException("cannot read row:" + rowNum + ", total row cnt is:" + rowCount); } RawRecord rawRecord = new RawRecord(dimCnt, metricCnt); for (int i = 0; i < dimCnt; i++) { rawRecord.setDimension(i, dimensionDataReaders[i].read(rowNum)); } for (int i = 0; i < metricCnt; i++) { rawRecord.setMetric(i, metricDataReaders[i].read(rowNum)); } readRowCount++; return rawRecord; }
FragmentCuboidReader implements Iterable<RawRecord> { public RawRecord read(int rowNum) { if (rowNum > rowCount - 1) { throw new IllegalStateException("cannot read row:" + rowNum + ", total row cnt is:" + rowCount); } RawRecord rawRecord = new RawRecord(dimCnt, metricCnt); for (int i = 0; i < dimCnt; i++) { rawRecord.setDimension(i, dimensionDataReaders[i].read(rowNum)); } for (int i = 0; i < metricCnt; i++) { rawRecord.setMetric(i, metricDataReaders[i].read(rowNum)); } readRowCount++; return rawRecord; } }
FragmentCuboidReader implements Iterable<RawRecord> { public RawRecord read(int rowNum) { if (rowNum > rowCount - 1) { throw new IllegalStateException("cannot read row:" + rowNum + ", total row cnt is:" + rowCount); } RawRecord rawRecord = new RawRecord(dimCnt, metricCnt); for (int i = 0; i < dimCnt; i++) { rawRecord.setDimension(i, dimensionDataReaders[i].read(rowNum)); } for (int i = 0; i < metricCnt; i++) { rawRecord.setMetric(i, metricDataReaders[i].read(rowNum)); } readRowCount++; return rawRecord; } FragmentCuboidReader(CubeDesc cubeDesc, FragmentData fragmentData, CuboidMetaInfo cuboidMetaInfo,
            TblColRef[] dimensions, MeasureDesc[] measures, DimensionEncoding[] dimEncodings); }
FragmentCuboidReader implements Iterable<RawRecord> { public RawRecord read(int rowNum) { if (rowNum > rowCount - 1) { throw new IllegalStateException("cannot read row:" + rowNum + ", total row cnt is:" + rowCount); } RawRecord rawRecord = new RawRecord(dimCnt, metricCnt); for (int i = 0; i < dimCnt; i++) { rawRecord.setDimension(i, dimensionDataReaders[i].read(rowNum)); } for (int i = 0; i < metricCnt; i++) { rawRecord.setMetric(i, metricDataReaders[i].read(rowNum)); } readRowCount++; return rawRecord; } FragmentCuboidReader(CubeDesc cubeDesc, FragmentData fragmentData, CuboidMetaInfo cuboidMetaInfo,
            TblColRef[] dimensions, MeasureDesc[] measures, DimensionEncoding[] dimEncodings); RawRecord read(int rowNum); @Override Iterator<RawRecord> iterator(); long getReadRowCount(); ColumnDataReader getDimensionDataReader(DimensionMetaInfo dimensionMetaInfo, int numberOfRows,
            TblColRef dimension, DimensionEncoding dimensionEncoding, ByteBuffer dataReadBuffer); ColumnDataReader getMetricsDataReader(MeasureDesc measure, MetricMetaInfo metricMetaInfo, int numberOfRows,
            ByteBuffer dataReadBuffer); }
FragmentCuboidReader implements Iterable<RawRecord> { public RawRecord read(int rowNum) { if (rowNum > rowCount - 1) { throw new IllegalStateException("cannot read row:" + rowNum + ", total row cnt is:" + rowCount); } RawRecord rawRecord = new RawRecord(dimCnt, metricCnt); for (int i = 0; i < dimCnt; i++) { rawRecord.setDimension(i, dimensionDataReaders[i].read(rowNum)); } for (int i = 0; i < metricCnt; i++) { rawRecord.setMetric(i, metricDataReaders[i].read(rowNum)); } readRowCount++; return rawRecord; } FragmentCuboidReader(CubeDesc cubeDesc, FragmentData fragmentData, CuboidMetaInfo cuboidMetaInfo,
            TblColRef[] dimensions, MeasureDesc[] measures, DimensionEncoding[] dimEncodings); RawRecord read(int rowNum); @Override Iterator<RawRecord> iterator(); long getReadRowCount(); ColumnDataReader getDimensionDataReader(DimensionMetaInfo dimensionMetaInfo, int numberOfRows,
            TblColRef dimension, DimensionEncoding dimensionEncoding, ByteBuffer dataReadBuffer); ColumnDataReader getMetricsDataReader(MeasureDesc measure, MetricMetaInfo metricMetaInfo, int numberOfRows,
            ByteBuffer dataReadBuffer);  }