>From Ali Alsuliman :
Ali Alsuliman has uploaded this change for review. (
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/21677?usp=email )
Change subject: [ASTERIXDB-3817][CLOUD] De-duplicate the local-only write path
..
[ASTERIXDB-3817][CLOUD] De-duplicate the local-only write path
AbstractCloudIOManager carried three methods with the same body,
localIoManager.syncWrite(...): localWriter(ByteBuffer) and both
overloads of localWriteOnly. "Write the local copy and do not upload"
now has one implementation per buffer shape and the localWriteOnly
overrides are one-line delegations to it.
The reason the duplication appeared is an asymmetry on ICloudIOManager:
cloudWrite is declared for both a single ByteBuffer and a ByteBuffer[],
but localWriter only for the single buffer. The gathering shape is the
one the uncompressed buffer-cache path actually takes, since a page is
written together with its header, so a caller needing "local only" for
that shape had nothing to call. Declare localWriter(ByteBuffer[]) beside
its cloudWrite counterpart and the seam is complete.
IOManager.localWriteOnly stays, and its javadoc now says why rather than
leaving it to be asked again. The behaviour is reachable through
ICloudIOManager, but the dispatch is not: the caller is
LocalOnlyWriteContext, which must live in hyracks-storage-common because
hyracks-storage-am-vtree selects it, and hyracks-cloud depends on
hyracks-storage-common rather than the reverse -- so unlike
DefaultCloudOnlyWriteContext it cannot name ICloudIOManager. A virtual
method on IOManager is therefore the only available seam. The exit is
recorded too: if the vector index ever gains a cloud-aware layer that
can inject a write context the way IColumnIndexDiskCacheManager does for
column indexes, that method and both of its overrides can go.
No behaviour change. The 31 LSM VTree tests cover the local path; the S3
and Azure cloud suites pass 4/4 each. LSMGCSTest fails in setup on a
ConnectException against the mock GCS server it expects on 127.0.0.1,
which is absent on this host and unrelated to this change.
Ext-ref: MB-73194
Co-Authored-By: Claude Opus 5
Change-Id: I723eaa5b947ab9be7630c046e775b2c0606ec14d
---
M
asterixdb/asterix-cloud/src/main/java/org/apache/asterix/cloud/AbstractCloudIOManager.java
M
hyracks-fullstack/hyracks/hyracks-cloud/src/main/java/org/apache/hyracks/cloud/io/ICloudIOManager.java
M
hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/io/IOManager.java
M
hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/context/write/LocalOnlyWriteContext.java
4 files changed, 63 insertions(+), 9 deletions(-)
git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb
refs/changes/77/21677/1
diff --git
a/asterixdb/asterix-cloud/src/main/java/org/apache/asterix/cloud/AbstractCloudIOManager.java
b/asterixdb/asterix-cloud/src/main/java/org/apache/asterix/cloud/AbstractCloudIOManager.java
index 2e22005..6829e39 100644
---
a/asterixdb/asterix-cloud/src/main/java/org/apache/asterix/cloud/AbstractCloudIOManager.java
+++
b/asterixdb/asterix-cloud/src/main/java/org/apache/asterix/cloud/AbstractCloudIOManager.java
@@ -66,6 +66,7 @@
import org.apache.hyracks.cloud.io.stream.CloudInputStream;
import org.apache.hyracks.cloud.util.CloudRetryableRequestUtil;
import org.apache.hyracks.control.nc.io.IOManager;
+import org.apache.hyracks.util.annotations.AiProvenance;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -248,16 +249,29 @@
return localIoManager.syncWrite(fHandle, offset, data);
}
+@AiProvenance(agent = AiProvenance.Agent.CLAUDE_OPUS_5, tool =
AiProvenance.Tool.CLAUDE_CODE_UI)
@Override
-public final int localWriteOnly(IFileHandle fHandle, long offset,
ByteBuffer data) throws HyracksDataException {
-// Local copy only; the long-term (cloud) upload is intentionally
deferred to a later pass.
+public final long localWriter(IFileHandle fHandle, long offset,
ByteBuffer[] data) throws HyracksDataException {
+// Using syncWrite here to avoid closing the file channel when the
thread is interrupted
return localIoManager.syncWrite(fHandle, offset, data);
}
+/**
+ * Deliberately identical to {@link #localWriter(IFileHandle, long,
ByteBuffer)}: writing the local copy
+ * and not uploading is one behaviour, and this is the {@code IOManager}
override through which callers
+ * that cannot see {@link ICloudIOManager} reach it. See {@code
IOManager#localWriteOnly} for why that
+ * indirection exists.
+ */
+@AiProvenance(agent = AiProvenance.Agent.CLAUDE_OPUS_5, tool =
AiProvenance.Tool.CLAUDE_CODE_UI, contributionKind =
AiProvenance.ContributionKind.REFACTORED, notes = "Delegate to localWriter")
+@Override
+public final int