Gabriel39 commented on code in PR #66612:
URL: https://github.com/apache/doris/pull/66612#discussion_r3861516931


##########
fe/be-java-extensions/paimon-connector/src/main/java/org/apache/doris/paimon/DorisIOManager.java:
##########
@@ -0,0 +1,289 @@
+// 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.doris.paimon;
+
+import org.apache.paimon.disk.BufferFileReader;
+import org.apache.paimon.disk.BufferFileWriter;
+import org.apache.paimon.disk.FileIOChannel;
+import org.apache.paimon.disk.IOManager;
+import org.apache.paimon.memory.Buffer;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.channels.FileChannel;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/** Paimon IOManager adapter which charges temporary channel I/O to Doris 
spill management. */
+final class DorisIOManager implements IOManager {
+    interface SpillAccountant {
+        void reserve(long bytes) throws IOException;
+
+        void rollback(long bytes);
+
+        void commitWrite(long bytes);
+
+        void recordRead(long bytes);
+
+        void release(long bytes);
+    }
+
+    private final IOManager delegate;
+    private final SpillAccountant accountant;
+    private final Map<String, Long> channelBytes = new ConcurrentHashMap<>();
+
+    static DorisIOManager create(String[] tempDirs, long nativeSpillDirectory) 
{
+        return new DorisIOManager(
+                IOManager.create(tempDirs), new 
NativeSpillAccountant(nativeSpillDirectory));
+    }
+
+    DorisIOManager(IOManager delegate, SpillAccountant accountant) {
+        this.delegate = delegate;
+        this.accountant = accountant;
+    }
+
+    @Override
+    public FileIOChannel.ID createChannel() {
+        return delegate.createChannel();
+    }
+
+    @Override
+    public FileIOChannel.ID createChannel(String prefix) {

Review Comment:
   Still unresolved on the latest head (`d65a91089c`). `createChannel(prefix)`, 
`tempDirs()`, and `pickTempDir()` still expose plain Paimon paths, while the 
directory-reconciliation callbacks have now been removed. The 
`BufferFileWriter` wrapper accounts only buffer channels; lookup, clustering, 
and RocksDB SST files written directly through these paths never call `reserve` 
or `updatePaimonSpillAccounting`, so they can bypass the spill limit and 
usage/I/O metrics entirely. Please either provide an accounting-aware 
integration for these raw-file paths or reject the affected modes, and cover 
real lookup/clustering SST creation in tests.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to