Github user ajantha-bhat commented on a diff in the pull request: https://github.com/apache/carbondata/pull/2850#discussion_r229179713 --- Diff: store/sdk/src/main/java/org/apache/carbondata/sdk/file/CarbonReader.java --- @@ -114,6 +117,43 @@ public static CarbonReaderBuilder builder(String tablePath) { return builder(tablePath, tableName); } + /** + * Return a new list of {@link CarbonReader} objects + * + * @param maxSplits + */ + public List<CarbonReader> split(int maxSplits) throws IOException { + validateReader(); + if (maxSplits < 1) { + throw new RuntimeException( + this.getClass().getSimpleName() + ".split: maxSplits must be positive"); + } + + List<CarbonReader> carbonReaders = new ArrayList<>(); + + // If maxSplits < readers.size + // Split the reader into maxSplits splits with each + // element contains >= 1 CarbonRecordReader objects + if (maxSplits < this.readers.size()) { + for (int i = 0; i < maxSplits; ++i) { + carbonReaders.add(new CarbonReader<>(this.readers + .subList((int) Math.ceil((float) (i * this.readers.size()) / maxSplits), + (int) Math.ceil((float) ((i + 1) * this.readers.size()) / maxSplits)))); + } + } + // If maxSplits >= readers.size + // Split the reader into reader.size splits with each --- End diff -- keep comments inside else block for easy reading of the code
---