qiuchenjian commented on a change in pull request #3126: [WIP][CARBONDATA-3293] Prune datamaps improvement
URL: https://github.com/apache/carbondata/pull/3126#discussion_r257684422 ########## File path: core/src/main/java/org/apache/carbondata/core/indexstore/UnsafeMemoryDMStore.java ########## @@ -94,87 +101,110 @@ public void addIndexRow(CarbonRowSchema[] schema, DataMapRow indexRow) throws Me // Check whether allocated memory is sufficient or not. ensureSize(rowSize); int pointer = runningLength; - + List<Object> dataPos = new ArrayList<>(); for (int i = 0; i < schema.length; i++) { - addToUnsafe(schema[i], indexRow, i); + addToUnsafe(schema[i], indexRow, i, dataPos); } + dataPosition.put(rowCount, dataPos); pointers[rowCount++] = pointer; } - private void addToUnsafe(CarbonRowSchema schema, DataMapRow row, int index) { + private void addToUnsafe(CarbonRowSchema schema, DataMapRow row, int index, + List<Object> dataPos) { switch (schema.getSchemaType()) { case FIXED: DataType dataType = schema.getDataType(); if (dataType == DataTypes.BYTE) { getUnsafe() .putByte(memoryBlock.getBaseObject(), memoryBlock.getBaseOffset() + runningLength, row.getByte(index)); - runningLength += row.getSizeInBytes(index); + int sizeInBytes = row.getSizeInBytes(index); + dataPos.add(sizeInBytes); + runningLength += sizeInBytes; } else if (dataType == DataTypes.BOOLEAN) { getUnsafe() .putBoolean(memoryBlock.getBaseObject(), memoryBlock.getBaseOffset() + runningLength, row.getBoolean(index)); - runningLength += row.getSizeInBytes(index); + int sizeInBytes = row.getSizeInBytes(index); + dataPos.add(sizeInBytes); + runningLength += sizeInBytes; } else if (dataType == DataTypes.SHORT) { getUnsafe() .putShort(memoryBlock.getBaseObject(), memoryBlock.getBaseOffset() + runningLength, row.getShort(index)); - runningLength += row.getSizeInBytes(index); + int sizeInBytes = row.getSizeInBytes(index); + dataPos.add(sizeInBytes); + runningLength += sizeInBytes; } else if (dataType == DataTypes.INT) { getUnsafe() .putInt(memoryBlock.getBaseObject(), memoryBlock.getBaseOffset() + runningLength, row.getInt(index)); - runningLength += row.getSizeInBytes(index); + int sizeInBytes = row.getSizeInBytes(index); Review comment: duplicate code, better to use a method ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] With regards, Apache Git Services |
Free forum by Nabble | Edit this page |