[GitHub] [incubator-hudi] bschell commented on a change in pull request #1091: [HUDI-389] Fixing Index look up to return right partitions for a given key along with fileId with Global Bloom
bschell commented on a change in pull request #1091: [HUDI-389] Fixing Index look up to return right partitions for a given key along with fileId with Global Bloom URL: https://github.com/apache/incubator-hudi/pull/1091#discussion_r357361788 ## File path: hudi-client/src/main/java/org/apache/hudi/index/bloom/HoodieGlobalBloomIndex.java ## @@ -85,6 +86,7 @@ public HoodieGlobalBloomIndex(HoodieWriteConfig config) { JavaRDD> explodeRecordRDDWithFileComparisons( final Map> partitionToFileIndexInfo, JavaPairRDD partitionRecordKeyPairRDD) { + Map indexToPartitionMap = new HashMap<>(); for (Entry> entry : partitionToFileIndexInfo.entrySet()) { entry.getValue().forEach(indexFile -> indexToPartitionMap.put(indexFile.getFileId(), entry.getKey())); Review comment: This whole "indexToPartitionMap" can be deleted now right? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-hudi] bschell commented on a change in pull request #1091: [HUDI-389] Fixing Index look up to return right partitions for a given key along with fileId with Global Bloom
bschell commented on a change in pull request #1091: [HUDI-389] Fixing Index look up to return right partitions for a given key along with fileId with Global Bloom URL: https://github.com/apache/incubator-hudi/pull/1091#discussion_r357366421 ## File path: hudi-client/src/test/java/org/apache/hudi/TestHoodieClientOnCopyOnWriteStorage.java ## @@ -336,7 +335,54 @@ public void testDeletes() throws Exception { } /** - * Test scenario of new file-group getting added during upsert(). + * Test update of a record to different partition with Global Index + */ + @Test + public void testUpsertToDiffPartitionGlobaIndex() throws Exception { Review comment: [nit] testUpsertToDiffPartitionGlobaIndex -> testUpsertToDiffPartitionGlobalIndex This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-hudi] bschell commented on a change in pull request #1091: [HUDI-389] Fixing Index look up to return right partitions for a given key along with fileId with Global Bloom
bschell commented on a change in pull request #1091: [HUDI-389] Fixing Index look up to return right partitions for a given key along with fileId with Global Bloom URL: https://github.com/apache/incubator-hudi/pull/1091#discussion_r357365653 ## File path: hudi-client/src/main/java/org/apache/hudi/index/bloom/ListBasedGlobalIndexFileFilter.java ## @@ -35,17 +36,14 @@ } @Override - public Set getMatchingFiles(String partitionPath, String recordKey) { -Set toReturn = new HashSet<>(); -partitionToFileIndexInfo.values().forEach(indexInfos -> { - if (indexInfos != null) { // could be null, if there are no files in a given partition yet. -// for each candidate file in partition, that needs to be compared. -for (BloomIndexFileInfo indexInfo : indexInfos) { - if (shouldCompareWithFile(indexInfo, recordKey)) { -toReturn.add(indexInfo.getFileId()); - } + public Set> getMatchingFilesAndPartition(String partitionPath, String recordKey) { +Set> toReturn = new HashSet<>(); +partitionToFileIndexInfo.forEach((parition, bloomIndexFileInfoList) -> { Review comment: [nit] parition -> partition This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-hudi] bschell commented on a change in pull request #1091: [HUDI-389] Fixing Index look up to return right partitions for a given key along with fileId with Global Bloom
bschell commented on a change in pull request #1091: [HUDI-389] Fixing Index look up to return right partitions for a given key along with fileId with Global Bloom URL: https://github.com/apache/incubator-hudi/pull/1091#discussion_r357363234 ## File path: hudi-client/src/main/java/org/apache/hudi/index/bloom/HoodieGlobalBloomIndex.java ## @@ -98,26 +100,34 @@ public HoodieGlobalBloomIndex(HoodieWriteConfig config) { String recordKey = partitionRecordKeyPair._2(); String partitionPath = partitionRecordKeyPair._1(); - return indexFileFilter.getMatchingFiles(partitionPath, recordKey).stream() - .map(file -> new Tuple2<>(file, new HoodieKey(recordKey, indexToPartitionMap.get(file + return indexFileFilter.getMatchingFilesAndPartition(partitionPath, recordKey).stream() + .map(partitionFileIdPair -> new Tuple2<>(partitionFileIdPair.getRight(), + new HoodieKey(recordKey, partitionFileIdPair.getLeft( .collect(Collectors.toList()); }).flatMap(List::iterator); } - /** * Tagging for global index should only consider the record key. */ @Override protected JavaRDD> tagLocationBacktoRecords( JavaPairRDD keyFilenamePairRDD, JavaRDD> recordRDD) { -JavaPairRDD> rowKeyRecordPairRDD = -recordRDD.mapToPair(record -> new Tuple2<>(record.getRecordKey(), record)); -// Here as the recordRDD might have more data than rowKeyRDD (some rowKeys' fileId is null), -// so we do left outer join. -return rowKeyRecordPairRDD.leftOuterJoin(keyFilenamePairRDD.mapToPair(p -> new Tuple2<>(p._1.getRecordKey(), p._2))) -.values().map(value -> getTaggedRecord(value._1, Option.ofNullable(value._2.orNull(; +Map> keyMap = keyFilenamePairRDD +.mapToPair(e -> new Tuple2<>(e._1.getRecordKey(), Pair.of(e._1, e._2))).collectAsMap(); + +JavaRDD> toReturn = recordRDD.map(rec -> { + if (keyMap.containsKey(rec.getRecordKey())) { +Pair value = keyMap.get(rec.getRecordKey()); +return getTaggedRecord(new HoodieRecord(value.getLeft(), rec.getData()), Option.of(value Review comment: That is what is happening here right? This logic only occurs when the record_key is already matching so we are essentially replacing just the partitionPath when we replace the HoodieKey. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-hudi] bschell commented on a change in pull request #1091: [HUDI-389] Fixing Index look up to return right partitions for a given key along with fileId with Global Bloom
bschell commented on a change in pull request #1091: [HUDI-389] Fixing Index look up to return right partitions for a given key along with fileId with Global Bloom URL: https://github.com/apache/incubator-hudi/pull/1091#discussion_r357343158 ## File path: hudi-client/src/main/java/org/apache/hudi/index/bloom/HoodieGlobalBloomIndex.java ## @@ -98,26 +100,34 @@ public HoodieGlobalBloomIndex(HoodieWriteConfig config) { String recordKey = partitionRecordKeyPair._2(); String partitionPath = partitionRecordKeyPair._1(); - return indexFileFilter.getMatchingFiles(partitionPath, recordKey).stream() - .map(file -> new Tuple2<>(file, new HoodieKey(recordKey, indexToPartitionMap.get(file + return indexFileFilter.getMatchingFilesAndPartition(partitionPath, recordKey).stream() + .map(partitionFileIdPair -> new Tuple2<>(partitionFileIdPair.getRight(), + new HoodieKey(recordKey, partitionFileIdPair.getLeft( .collect(Collectors.toList()); }).flatMap(List::iterator); } - /** * Tagging for global index should only consider the record key. */ @Override protected JavaRDD> tagLocationBacktoRecords( JavaPairRDD keyFilenamePairRDD, JavaRDD> recordRDD) { -JavaPairRDD> rowKeyRecordPairRDD = -recordRDD.mapToPair(record -> new Tuple2<>(record.getRecordKey(), record)); -// Here as the recordRDD might have more data than rowKeyRDD (some rowKeys' fileId is null), -// so we do left outer join. -return rowKeyRecordPairRDD.leftOuterJoin(keyFilenamePairRDD.mapToPair(p -> new Tuple2<>(p._1.getRecordKey(), p._2))) -.values().map(value -> getTaggedRecord(value._1, Option.ofNullable(value._2.orNull(; +Map> keyMap = keyFilenamePairRDD Review comment: What about something like this instead? This will avoid collecting and maintains the same operations to what already exists. [taglocation.txt](https://github.com/apache/incubator-hudi/files/3957588/taglocation.txt) This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services