From 028052fc8b0e439f4499b432d0b5dcb9a614beee Mon Sep 17 00:00:00 2001 From: zengruios Date: Thu, 7 Nov 2019 17:21:53 +0800 Subject: [PATCH] fix bug in KYLIN-4243 --- .../columnar/compress/NoCompressedColumnReader.java | 8 ++++---- .../storage/columnar/compress/NoCompressColumnTest.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/stream-core/src/main/java/org/apache/kylin/stream/core/storage/columnar/compress/NoCompressedColumnReader.java b/stream-core/src/main/java/org/apache/kylin/stream/core/storage/columnar/compress/NoCompressedColumnReader.java index 29ec3cae7..f29efad8c 100644 --- a/stream-core/src/main/java/org/apache/kylin/stream/core/storage/columnar/compress/NoCompressedColumnReader.java +++ b/stream-core/src/main/java/org/apache/kylin/stream/core/storage/columnar/compress/NoCompressedColumnReader.java @@ -28,15 +28,15 @@ public class NoCompressedColumnReader implements ColumnDataReader { private ByteBuffer dataBuffer; private byte[] readBuffer; private int colDataStartOffset; - private int colValLength; private int rowCount; + private int valLen; public NoCompressedColumnReader(ByteBuffer dataBuffer, int colDataStartOffset, int colValLength, int rowCount) { this.dataBuffer = dataBuffer; this.colDataStartOffset = colDataStartOffset; - this.colValLength = colValLength; this.rowCount = rowCount; - this.readBuffer = new byte[colValLength]; + this.valLen = colValLength / rowCount; + this.readBuffer = new byte[valLen]; } public Iterator iterator() { @@ -44,7 +44,7 @@ public class NoCompressedColumnReader implements ColumnDataReader { } public byte[] read(int rowNum) { - dataBuffer.position(colDataStartOffset + rowNum * colValLength); + dataBuffer.position(colDataStartOffset + rowNum * valLen); dataBuffer.get(readBuffer); return readBuffer; } diff --git a/stream-core/src/test/java/org/apache/kylin/stream/core/storage/columnar/compress/NoCompressColumnTest.java b/stream-core/src/test/java/org/apache/kylin/stream/core/storage/columnar/compress/NoCompressColumnTest.java index cdd306921..f733a684d 100644 --- a/stream-core/src/test/java/org/apache/kylin/stream/core/storage/columnar/compress/NoCompressColumnTest.java +++ b/stream-core/src/test/java/org/apache/kylin/stream/core/storage/columnar/compress/NoCompressColumnTest.java @@ -52,7 +52,7 @@ public class NoCompressColumnTest { writeNoCompressedData(rowCnt); ByteBuffer byteBuffer = Files.map(tmpColFile, MapMode.READ_ONLY); - try (NoCompressedColumnReader reader = new NoCompressedColumnReader(byteBuffer, 0, 4, rowCnt)) { + try (NoCompressedColumnReader reader = new NoCompressedColumnReader(byteBuffer, 0, 40000, rowCnt)) { int k = 0; for (byte[] val : reader) { assertEquals(k, Bytes.toInt(val)); -- 2.20.1.windows.1