SteveYurongSu commented on code in PR #13400:
URL: https://github.com/apache/iotdb/pull/13400#discussion_r1750010653
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/memory/LoadTsFileMemoryManager.java:
##########
@@ -100,6 +100,31 @@ public synchronized LoadTsFileAnalyzeSchemaMemoryBlock
allocateAnalyzeSchemaMemo
return new LoadTsFileAnalyzeSchemaMemoryBlock(sizeInBytes);
}
+ /**
+ * Resize the memory block to the new size.
+ *
+ * @throws LoadRuntimeOutOfMemoryException if failed to allocate enough
memory
+ */
+ synchronized void forceResize(LoadTsFileAnalyzeSchemaMemoryBlock
memoryBlock, long newSizeInBytes)
+ throws LoadRuntimeOutOfMemoryException {
+ if (memoryBlock.getTotalMemorySizeInBytes() >= newSizeInBytes) {
+ releaseToQuery(memoryBlock.getTotalMemorySizeInBytes() - newSizeInBytes);
+ memoryBlock.setTotalMemorySizeInBytes(newSizeInBytes);
+ return;
+ }
+
+ long bytesNeeded = newSizeInBytes -
memoryBlock.getTotalMemorySizeInBytes();
+ try {
+ forceAllocateFromQuery(bytesNeeded);
+ } catch (LoadRuntimeOutOfMemoryException e) {
+ if (dataCacheMemoryBlock != null &&
dataCacheMemoryBlock.doShrink(bytesNeeded)) {
+ memoryBlock.setTotalMemorySizeInBytes(newSizeInBytes);
+ }
Review Comment:
```suggestion
if (dataCacheMemoryBlock != null &&
dataCacheMemoryBlock.doShrink(bytesNeeded)) {
memoryBlock.setTotalMemorySizeInBytes(newSizeInBytes);
return;
}
```
--
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]