qiaojialin commented on a change in pull request #2317: URL: https://github.com/apache/iotdb/pull/2317#discussion_r549069072
########## File path: server/src/main/java/org/apache/iotdb/db/rescon/MemTableManager.java ########## @@ -0,0 +1,110 @@ +/* + * 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.db.rescon; + +import org.apache.iotdb.db.conf.IoTDBConfig; +import org.apache.iotdb.db.conf.IoTDBDescriptor; +import org.apache.iotdb.db.engine.memtable.IMemTable; +import org.apache.iotdb.db.engine.memtable.PrimitiveMemTable; +import org.apache.iotdb.db.engine.storagegroup.TsFileResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.TimeUnit; + +public class MemTableManager { + + private static final IoTDBConfig CONFIG = IoTDBDescriptor.getInstance().getConfig(); + + private static final Logger logger = LoggerFactory.getLogger(MemTableManager.class); + + private static final int WAIT_TIME = 100; + public static final int MEMTABLE_NUM_FOR_EACH_PARTITION = 4; + private int currentMemtableNumber = 0; + + private MemTableManager() { + } + + public static MemTableManager getInstance() { + return InstanceHolder.INSTANCE; + } + + /** + * Called when memory control is disabled + */ + public synchronized IMemTable getAvailableMemTable(TsFileResource tsFileResource) { + if (!reachMaxMemtableNumber()) { + currentMemtableNumber++; + return new PrimitiveMemTable(); + } else { + // wait until the size of flushingMemTables is less than 2 Review comment: ```suggestion // wait until the total memtable number is less than the capacity of the system ``` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected]
