From f9e4e7b851cf388557ed8c9897c5a3ffcdfe20b5 Mon Sep 17 00:00:00 2001 From: zombee0 Date: Tue, 7 Mar 2023 23:21:04 +0800 Subject: [PATCH] change file length() and add some info Signed-off-by: zombee0 --- .../iceberg/io/IcebergCachingFileIO.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/io/IcebergCachingFileIO.java b/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/io/IcebergCachingFileIO.java index a5ed7de9ddcc36..a68072cca6e5d7 100644 --- a/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/io/IcebergCachingFileIO.java +++ b/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/io/IcebergCachingFileIO.java @@ -478,16 +478,23 @@ public int read(ByteBuffer buf) throws IOException { private static class CachingInputFile implements InputFile { private final ContentCache contentCache; private final InputFile wrappedInputFile; + private int getFrom; + private long length; + private long cachedEntryLength; + private int cachedEntrySize; private CachingInputFile(ContentCache cache, InputFile inFile) { this.contentCache = cache; this.wrappedInputFile = inFile; + getFrom = 0; + length = 0; } @Override public long getLength() { - return contentCache.getLength(location()) == -1 ? - wrappedInputFile.getLength() : contentCache.getLength(location()); + long len = contentCache.getLength(location()); + length = len == -1 ? wrappedInputFile.getLength() : len; + return length; } @Override @@ -526,11 +533,14 @@ private CacheEntry newCacheEntry() { if (contentCache.isExistOnDiskCache(location())) { LOG.debug(location() + " hit on disk cache"); stream = contentCache.getDiskSeekableStream(location()); + getFrom = 1; if (stream == null) { + getFrom = 2; LOG.debug(location() + " load from remote"); stream = wrappedInputFile.newStream(); } } else { + getFrom = 2; LOG.debug(location() + " load from remote"); stream = wrappedInputFile.newStream(); } @@ -563,6 +573,8 @@ private CacheEntry newCacheEntry() { private SeekableInputStream cachedStream() throws IOException { try { CacheEntry entry = contentCache.get(location(), k -> newCacheEntry()); + cachedEntryLength = entry.length; + cachedEntrySize = entry.buffers.size(); Preconditions.checkNotNull(entry, "CacheEntry should not be null when there is no RuntimeException occurs"); return ByteBufferInputStream.wrap(entry.buffers); } catch (UncheckedIOException ex) { @@ -574,7 +586,8 @@ private SeekableInputStream cachedStream() throws IOException { @Override public String toString() { - return location(); + return location() + ", get From: " + getFrom + ", length: " + length + ", CacheEntryLength: " + cachedEntryLength + + ", CacheEntrySize: " + cachedEntrySize; } } } \ No newline at end of file