ob_table_load_assigned_memory_manager.h 1.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
/**
 * Copyright (c) 2021 OceanBase
 * OceanBase CE is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */

#pragma once

#include "lib/hash/ob_hashmap.h"
#include "lib/lock/ob_mutex.h"
#include "observer/table_load/ob_table_load_struct.h"
#include "observer/table_load/ob_table_load_service.h"


namespace oceanbase
{
namespace observer
{

class ObTableLoadAssignedMemoryManager
{
public:
	// Minimum memory required in sort execution mode
	static const int64_t MIN_SORT_MEMORY_PER_TASK = 128LL * 1024LL * 1024LL;  // 128 MB
  ObTableLoadAssignedMemoryManager();
	~ObTableLoadAssignedMemoryManager();
	int init();
	int assign_memory(bool is_sort, int64_t assign_memory);
	int recycle_memory(bool is_sort, int64_t assign_memory);
	int64_t get_avail_memory();
	int refresh_avail_memory(int64_t avail_memory);
	int get_sort_memory(int64_t &sort_memory);
private:
	int64_t avail_sort_memory_;
	int64_t avail_memory_;
O
obdev 已提交
42
	int64_t chunk_count_;
43 44 45 46 47 48
  mutable lib::ObMutex mutex_;
  bool is_inited_;
};

} // namespace observer
} // namespace oceanbase