[GitHub] carbondata pull request #2601: [CARBONDATA-2804][DataMap] fix the bug when b...
Github user asfgit closed the pull request at: https://github.com/apache/carbondata/pull/2601 ---
[GitHub] carbondata pull request #2601: [CARBONDATA-2804][DataMap] fix the bug when b...
Github user ndwangsen commented on a diff in the pull request: https://github.com/apache/carbondata/pull/2601#discussion_r207430989 --- Diff: core/src/main/java/org/apache/carbondata/core/util/CarbonUtil.java --- @@ -3212,28 +3213,27 @@ public static ColumnarFormatVersion getFormatVersion(CarbonTable carbonTable) } storePath = carbonTable.getSegmentPath(validSegments.get(0).getSegmentNo()); } - -CarbonFile[] carbonFiles = FileFactory -.getCarbonFile(storePath) -.listFiles(new CarbonFileFilter() { - @Override - public boolean accept(CarbonFile file) { -if (file == null) { - return false; -} -return file.getName().endsWith("carbondata"); - } -}); -if (carbonFiles == null || carbonFiles.length < 1) { - return CarbonProperties.getInstance().getFormatVersion(); +// get the carbon index file header +FileFactory.FileType fileType = FileFactory.getFileType(storePath); +ColumnarFormatVersion version = null; +if (FileFactory.isFileExist(storePath, fileType)) { + SegmentIndexFileStore fileStore = new SegmentIndexFileStore(); + fileStore.readAllIIndexOfSegment(storePath); + Map carbonIndexMap = fileStore.getCarbonIndexMap(); + if (carbonIndexMap.size() == 0) { +version = CarbonProperties.getInstance().getFormatVersion(); + } + CarbonIndexFileReader indexReader = new CarbonIndexFileReader(); + for (byte[] fileData : carbonIndexMap.values()) { +indexReader.openThriftReader(fileData); +IndexHeader indexHeader = indexReader.readIndexHeader(); +version = ColumnarFormatVersion.valueOf((short)indexHeader.getVersion()); +break; --- End diff -- modified according to review comments ---
[GitHub] carbondata pull request #2601: [CARBONDATA-2804][DataMap] fix the bug when b...
Github user ndwangsen commented on a diff in the pull request: https://github.com/apache/carbondata/pull/2601#discussion_r207430964 --- Diff: core/src/main/java/org/apache/carbondata/core/util/CarbonUtil.java --- @@ -3212,28 +3213,27 @@ public static ColumnarFormatVersion getFormatVersion(CarbonTable carbonTable) } storePath = carbonTable.getSegmentPath(validSegments.get(0).getSegmentNo()); } - -CarbonFile[] carbonFiles = FileFactory -.getCarbonFile(storePath) -.listFiles(new CarbonFileFilter() { - @Override - public boolean accept(CarbonFile file) { -if (file == null) { - return false; -} -return file.getName().endsWith("carbondata"); - } -}); -if (carbonFiles == null || carbonFiles.length < 1) { - return CarbonProperties.getInstance().getFormatVersion(); +// get the carbon index file header +FileFactory.FileType fileType = FileFactory.getFileType(storePath); +ColumnarFormatVersion version = null; +if (FileFactory.isFileExist(storePath, fileType)) { --- End diff -- modified according to review comments ---
[GitHub] carbondata pull request #2601: [CARBONDATA-2804][DataMap] fix the bug when b...
Github user ndwangsen commented on a diff in the pull request: https://github.com/apache/carbondata/pull/2601#discussion_r207430996 --- Diff: core/src/main/java/org/apache/carbondata/core/util/CarbonUtil.java --- @@ -3212,28 +3213,27 @@ public static ColumnarFormatVersion getFormatVersion(CarbonTable carbonTable) } storePath = carbonTable.getSegmentPath(validSegments.get(0).getSegmentNo()); } - -CarbonFile[] carbonFiles = FileFactory -.getCarbonFile(storePath) -.listFiles(new CarbonFileFilter() { - @Override - public boolean accept(CarbonFile file) { -if (file == null) { - return false; -} -return file.getName().endsWith("carbondata"); - } -}); -if (carbonFiles == null || carbonFiles.length < 1) { - return CarbonProperties.getInstance().getFormatVersion(); +// get the carbon index file header +FileFactory.FileType fileType = FileFactory.getFileType(storePath); +ColumnarFormatVersion version = null; +if (FileFactory.isFileExist(storePath, fileType)) { + SegmentIndexFileStore fileStore = new SegmentIndexFileStore(); + fileStore.readAllIIndexOfSegment(storePath); + Map carbonIndexMap = fileStore.getCarbonIndexMap(); + if (carbonIndexMap.size() == 0) { +version = CarbonProperties.getInstance().getFormatVersion(); + } + CarbonIndexFileReader indexReader = new CarbonIndexFileReader(); + for (byte[] fileData : carbonIndexMap.values()) { +indexReader.openThriftReader(fileData); +IndexHeader indexHeader = indexReader.readIndexHeader(); +version = ColumnarFormatVersion.valueOf((short)indexHeader.getVersion()); +break; + } +} else { + version = CarbonProperties.getInstance().getFormatVersion(); --- End diff -- modified according to review comments ---
[GitHub] carbondata pull request #2601: [CARBONDATA-2804][DataMap] fix the bug when b...
Github user manishgupta88 commented on a diff in the pull request: https://github.com/apache/carbondata/pull/2601#discussion_r207224591 --- Diff: core/src/main/java/org/apache/carbondata/core/util/CarbonUtil.java --- @@ -3212,28 +3213,27 @@ public static ColumnarFormatVersion getFormatVersion(CarbonTable carbonTable) } storePath = carbonTable.getSegmentPath(validSegments.get(0).getSegmentNo()); } - -CarbonFile[] carbonFiles = FileFactory -.getCarbonFile(storePath) -.listFiles(new CarbonFileFilter() { - @Override - public boolean accept(CarbonFile file) { -if (file == null) { - return false; -} -return file.getName().endsWith("carbondata"); - } -}); -if (carbonFiles == null || carbonFiles.length < 1) { - return CarbonProperties.getInstance().getFormatVersion(); +// get the carbon index file header +FileFactory.FileType fileType = FileFactory.getFileType(storePath); +ColumnarFormatVersion version = null; +if (FileFactory.isFileExist(storePath, fileType)) { + SegmentIndexFileStore fileStore = new SegmentIndexFileStore(); + fileStore.readAllIIndexOfSegment(storePath); + Map carbonIndexMap = fileStore.getCarbonIndexMap(); + if (carbonIndexMap.size() == 0) { +version = CarbonProperties.getInstance().getFormatVersion(); + } + CarbonIndexFileReader indexReader = new CarbonIndexFileReader(); + for (byte[] fileData : carbonIndexMap.values()) { +indexReader.openThriftReader(fileData); +IndexHeader indexHeader = indexReader.readIndexHeader(); +version = ColumnarFormatVersion.valueOf((short)indexHeader.getVersion()); +break; --- End diff -- once reading is complete close indexReader using try and finally block indexReader.closeThriftReader() ---
[GitHub] carbondata pull request #2601: [CARBONDATA-2804][DataMap] fix the bug when b...
Github user manishgupta88 commented on a diff in the pull request: https://github.com/apache/carbondata/pull/2601#discussion_r207223659 --- Diff: core/src/main/java/org/apache/carbondata/core/util/CarbonUtil.java --- @@ -3212,28 +3213,27 @@ public static ColumnarFormatVersion getFormatVersion(CarbonTable carbonTable) } storePath = carbonTable.getSegmentPath(validSegments.get(0).getSegmentNo()); } - -CarbonFile[] carbonFiles = FileFactory -.getCarbonFile(storePath) -.listFiles(new CarbonFileFilter() { - @Override - public boolean accept(CarbonFile file) { -if (file == null) { - return false; -} -return file.getName().endsWith("carbondata"); - } -}); -if (carbonFiles == null || carbonFiles.length < 1) { - return CarbonProperties.getInstance().getFormatVersion(); +// get the carbon index file header +FileFactory.FileType fileType = FileFactory.getFileType(storePath); +ColumnarFormatVersion version = null; +if (FileFactory.isFileExist(storePath, fileType)) { --- End diff -- Rename storePath to segmentPath ---
[GitHub] carbondata pull request #2601: [CARBONDATA-2804][DataMap] fix the bug when b...
Github user manishgupta88 commented on a diff in the pull request: https://github.com/apache/carbondata/pull/2601#discussion_r207225748 --- Diff: core/src/main/java/org/apache/carbondata/core/util/CarbonUtil.java --- @@ -3212,28 +3213,27 @@ public static ColumnarFormatVersion getFormatVersion(CarbonTable carbonTable) } storePath = carbonTable.getSegmentPath(validSegments.get(0).getSegmentNo()); } - -CarbonFile[] carbonFiles = FileFactory -.getCarbonFile(storePath) -.listFiles(new CarbonFileFilter() { - @Override - public boolean accept(CarbonFile file) { -if (file == null) { - return false; -} -return file.getName().endsWith("carbondata"); - } -}); -if (carbonFiles == null || carbonFiles.length < 1) { - return CarbonProperties.getInstance().getFormatVersion(); +// get the carbon index file header +FileFactory.FileType fileType = FileFactory.getFileType(storePath); +ColumnarFormatVersion version = null; +if (FileFactory.isFileExist(storePath, fileType)) { + SegmentIndexFileStore fileStore = new SegmentIndexFileStore(); + fileStore.readAllIIndexOfSegment(storePath); + Map carbonIndexMap = fileStore.getCarbonIndexMap(); + if (carbonIndexMap.size() == 0) { +version = CarbonProperties.getInstance().getFormatVersion(); + } + CarbonIndexFileReader indexReader = new CarbonIndexFileReader(); + for (byte[] fileData : carbonIndexMap.values()) { +indexReader.openThriftReader(fileData); +IndexHeader indexHeader = indexReader.readIndexHeader(); +version = ColumnarFormatVersion.valueOf((short)indexHeader.getVersion()); +break; + } +} else { + version = CarbonProperties.getInstance().getFormatVersion(); --- End diff -- 1. This else condition is not required as for a valid segment its path will exist in the file system. 2. If at all the path does not exist then read the version info from the next valid segment and log a warning that valid segment path does not exist in the system ---
[GitHub] carbondata pull request #2601: [CARBONDATA-2804][DataMap] fix the bug when b...
GitHub user ndwangsen opened a pull request: https://github.com/apache/carbondata/pull/2601 [CARBONDATA-2804][DataMap] fix the bug when bloom filter or preaggregate datamap tried to be created on older V1-V2 version stores [CARBONDATA-2804] fix the bug when bloom filter or preaggregate datamap tried to be created on older V1-V2 version store fix the bug for read the carbondata format version form carbondata file header of the older V1-V2 version stores, the version filed is moved to FileHeader Be sure to do all of the following checklist to help us incorporate your contribution quickly and easily: - [ ] Any interfaces changed? NA - [ ] Any backward compatibility impacted? NA - [ ] Document update required? NA - [ ] Testing done Please provide details on - Whether new unit test cases have been added or why no new tests are required? - How it is tested? Please attach test report. - Is it a performance related change? Please attach the performance test report. - Any additional information to help reviewers in testing this change. test pass in test environment - [ ] For large changes, please consider breaking it into sub-tasks under an umbrella JIRA. NA You can merge this pull request into a Git repository by running: $ git pull https://github.com/ndwangsen/incubator-carbondata fix_block_dm_v1_v2 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/carbondata/pull/2601.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #2601 commit 921c436b5d19421d68dc7085c9155608dfdb81e3 Author: ndwangsen Date: 2018-08-02T08:21:22Z [CARBONDATA-2804] fix the bug when bloom filter or preaggregate datamap tried to be created on older V1-V2 version stores ---