jt2594838 commented on code in PR #14710:
URL: https://github.com/apache/iotdb/pull/14710#discussion_r1978569112


##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/IMemoryBlock.java:
##########
@@ -0,0 +1,137 @@
+/*
+ * 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.iotdb.commons.memory;
+
+import org.apache.iotdb.commons.utils.TestOnly;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class IMemoryBlock implements AutoCloseable {
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(IMemoryBlock.class);
+
+  /** The memory manager that manages this memory block */
+  protected MemoryManager memoryManager;
+
+  /** The name of this memory block */
+  protected String name;
+
+  /** The type of this memory block */
+  protected MemoryBlockType memoryBlockType;
+
+  /** The flag that indicates whether this memory block is released */
+  protected volatile boolean isReleased = false;
+
+  /** The total memory size in byte of this memory block */
+  protected long totalMemorySizeInBytes;
+
+  /**
+   * Force allocate memory without the limit of totalMemorySizeInBytes
+   *
+   * @param sizeInByte the size of memory to be allocated, should positive
+   * @return
+   */
+  public abstract long forceAllocate(final long sizeInByte);
+
+  /**
+   * Allocate memory managed by this memory block
+   *
+   * @param sizeInByte the size of memory to be allocated, should positive
+   */
+  public abstract boolean allocate(final long sizeInByte);
+
+  /**
+   * Allocate memory managed by this memory block
+   *
+   * @param sizeInByte the size of memory to be allocated, should positive
+   * @param maxRatio the maximum ratio of memory can be allocated
+   */
+  public abstract boolean allocateIfSufficient(final long sizeInByte, final 
double maxRatio);

Review Comment:
   Like, "if the currently used ratio (or the ratio after allocation?) is 
already above `maxRatio`, the allocation will fail".



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

Reply via email to