-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[HUDI-5047] Add partition value in HoodieLogRecordReader when hoodie.datasource.write.drop.partition.columns=true #6986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8b09437
6c3f427
970ad79
df2c48f
088cfee
22f7b31
ab5cfec
29919d7
74787e6
240b1a4
1d34a26
350592c
599f8a2
cd21d98
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.hudi.common.model; | ||
|
|
||
| public class HoodieLogFileWithPartition extends HoodieLogFile { | ||
|
|
||
| private Object[] partitionFieldAndValues; | ||
|
|
||
| public HoodieLogFileWithPartition(HoodieLogFile logFile, Object[] partitionFieldAndValues) { | ||
| super(logFile); | ||
| this.partitionFieldAndValues = partitionFieldAndValues; | ||
| } | ||
|
|
||
| public Object[] getPartitionFieldAndValues() { | ||
| return this.partitionFieldAndValues; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -107,6 +107,33 @@ protected HoodieMergedLogRecordScanner(FileSystem fs, String basePath, List<Stri | |
| } | ||
| } | ||
|
|
||
| @SuppressWarnings("unchecked") | ||
| protected HoodieMergedLogRecordScanner(FileSystem fs, String basePath, List<String> logFilePaths, Schema readerSchema, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's avoid copying the whole ctor. Instead, generalize existing one and redirect this one to it. |
||
| String latestInstantTime, Long maxMemorySizeInBytes, boolean readBlocksLazily, | ||
| boolean reverseReader, int bufferSize, String spillableMapBasePath, | ||
| Option<InstantRange> instantRange, | ||
| ExternalSpillableMap.DiskMapType diskMapType, | ||
| boolean isBitCaskDiskMapCompressionEnabled, | ||
| boolean withOperationField, boolean forceFullScan, | ||
| Option<String> partitionName, InternalSchema internalSchema, | ||
| boolean useScanV2, Option<Object[]> partitionValues) { | ||
| super(fs, basePath, logFilePaths, readerSchema, latestInstantTime, readBlocksLazily, reverseReader, bufferSize, | ||
| instantRange, withOperationField, | ||
| forceFullScan, partitionName, internalSchema, useScanV2, partitionValues); | ||
| try { | ||
| // Store merged records for all versions for this log file, set the in-memory footprint to maxInMemoryMapSize | ||
| this.records = new ExternalSpillableMap<>(maxMemorySizeInBytes, spillableMapBasePath, new DefaultSizeEstimator(), | ||
| new HoodieRecordSizeEstimator(readerSchema), diskMapType, isBitCaskDiskMapCompressionEnabled); | ||
| this.maxMemorySizeInBytes = maxMemorySizeInBytes; | ||
| } catch (IOException e) { | ||
| throw new HoodieIOException("IOException when creating ExternalSpillableMap at " + spillableMapBasePath, e); | ||
| } | ||
|
|
||
| if (forceFullScan) { | ||
| performScan(); | ||
| } | ||
| } | ||
|
|
||
| protected void performScan() { | ||
| // Do the scan and merge | ||
| timer.startTimer(); | ||
|
|
@@ -233,6 +260,8 @@ public static class Builder extends AbstractHoodieLogRecordReader.Builder { | |
| // Use scanV2 method. | ||
| private boolean useScanV2 = false; | ||
|
|
||
| private Object[] partitionValues; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's create an object akin to |
||
|
|
||
| @Override | ||
| public Builder withFileSystem(FileSystem fs) { | ||
| this.fs = fs; | ||
|
|
@@ -331,6 +360,11 @@ public Builder withUseScanV2(boolean useScanV2) { | |
| return this; | ||
| } | ||
|
|
||
| public Builder withPartitionValues(Object[] partitionValues) { | ||
| this.partitionValues = partitionValues; | ||
| return this; | ||
| } | ||
|
|
||
| @Override | ||
| public HoodieMergedLogRecordScanner build() { | ||
| if (this.partitionName == null && CollectionUtils.nonEmpty(this.logFilePaths)) { | ||
|
|
@@ -340,7 +374,7 @@ public HoodieMergedLogRecordScanner build() { | |
| latestInstantTime, maxMemorySizeInBytes, readBlocksLazily, reverseReader, | ||
| bufferSize, spillableMapBasePath, instantRange, | ||
| diskMapType, isBitCaskDiskMapCompressionEnabled, withOperationField, true, | ||
| Option.ofNullable(partitionName), internalSchema, useScanV2); | ||
| Option.ofNullable(partitionName), internalSchema, useScanV2, Option.ofNullable(partitionValues)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check my comment below regarding this class