-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[Core]Support async lookup in hash store #4423
base: master
Are you sure you want to change the base?
Changes from 5 commits
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 |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
import org.apache.paimon.table.source.StreamTableScan; | ||
import org.apache.paimon.utils.Filter; | ||
import org.apache.paimon.utils.ProjectedRow; | ||
import org.apache.paimon.utils.Triple; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
|
@@ -108,25 +109,31 @@ public void open() throws Exception { | |
|
||
@Override | ||
public List<InternalRow> get(InternalRow key) throws IOException { | ||
Triple<BinaryRow, Integer, InternalRow> partitionAndBucket = extractPartitionAndBucket(key); | ||
InternalRow kv = | ||
queryExecutor.lookup( | ||
partitionAndBucket.f0, partitionAndBucket.f1, partitionAndBucket.f2); | ||
if (kv == null) { | ||
return Collections.emptyList(); | ||
} else { | ||
return Collections.singletonList(kv); | ||
} | ||
} | ||
|
||
private synchronized Triple<BinaryRow, Integer, InternalRow> extractPartitionAndBucket( | ||
InternalRow key) { | ||
InternalRow adjustedKey = key; | ||
if (keyRearrange != null) { | ||
adjustedKey = keyRearrange.replaceRow(adjustedKey); | ||
} | ||
extractor.setRecord(adjustedKey); | ||
int bucket = extractor.bucket(); | ||
BinaryRow partition = extractor.partition(); | ||
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. It is reused 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. the same as above |
||
|
||
InternalRow trimmedKey = key; | ||
if (trimmedKeyRearrange != null) { | ||
trimmedKey = trimmedKeyRearrange.replaceRow(trimmedKey); | ||
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. It is reused 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. the same as above |
||
} | ||
|
||
InternalRow kv = queryExecutor.lookup(partition, bucket, trimmedKey); | ||
if (kv == null) { | ||
return Collections.emptyList(); | ||
} else { | ||
return Collections.singletonList(kv); | ||
} | ||
return Triple.of(partition, bucket, trimmedKey); | ||
} | ||
|
||
@Override | ||
|
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.
It is reused
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.
I have encapsulated these as a separate function called extractPartartitionAndBucket. And it has been declared as synchronized, so there will be no thread safety issues.