Skip to content

Commit

Permalink
[HOTFIX] Changes in selecting the carbonindex files
Browse files Browse the repository at this point in the history
Currently, in the query flow while getting the index files we are checking for either mergeFileName or the list of files. After this change, we will
be checking for both files and mergeFileName

This closes #2333
  • Loading branch information
dhatchayani authored and manishgupta88 committed May 29, 2018
1 parent d777318 commit 22d5035
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ public static String writeSegmentFile(String tablePath, String segmentId, String
CarbonFile segmentFolder = FileFactory.getCarbonFile(segmentPath);
CarbonFile[] indexFiles = segmentFolder.listFiles(new CarbonFileFilter() {
@Override public boolean accept(CarbonFile file) {
return file.getName().endsWith(CarbonTablePath.INDEX_FILE_EXT);
return (file.getName().endsWith(CarbonTablePath.INDEX_FILE_EXT) || file.getName()
.endsWith(CarbonTablePath.MERGE_INDEX_FILE_EXT));
}
});
if (indexFiles != null && indexFiles.length > 0) {
Expand All @@ -160,7 +161,11 @@ public static String writeSegmentFile(String tablePath, String segmentId, String
folderDetails.setRelative(true);
folderDetails.setStatus(SegmentStatus.SUCCESS.getMessage());
for (CarbonFile file : indexFiles) {
folderDetails.getFiles().add(file.getName());
if (file.getName().endsWith(CarbonTablePath.MERGE_INDEX_FILE_EXT)) {
folderDetails.setMergeFileName(file.getName());
} else {
folderDetails.getFiles().add(file.getName());
}
}
String segmentRelativePath = segmentPath.substring(tablePath.length(), segmentPath.length());
segmentFile.addPath(segmentRelativePath, folderDetails);
Expand Down Expand Up @@ -508,10 +513,11 @@ public Map<String, String> getIndexOrMergeFiles() {
if (null != mergeFileName) {
indexFiles.put(location + CarbonCommonConstants.FILE_SEPARATOR + mergeFileName,
entry.getValue().mergeFileName);
} else {
for (String indexFile : entry.getValue().getFiles()) {
indexFiles.put(location + CarbonCommonConstants.FILE_SEPARATOR + indexFile,
entry.getValue().mergeFileName);
}
Set<String> files = entry.getValue().getFiles();
if (null != files && !files.isEmpty()) {
for (String indexFile : files) {
indexFiles.put(location + CarbonCommonConstants.FILE_SEPARATOR + indexFile, null);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -140,6 +141,7 @@ private String writeMergeIndexFileBasedOnSegmentFile(
}
if (new Path(entry.getKey()).equals(new Path(location))) {
segentry.getValue().setMergeFileName(mergeIndexFile);
segentry.getValue().setFiles(new HashSet<String>());
break;
}
}
Expand Down

0 comments on commit 22d5035

Please sign in to comment.