carp84 commented on a change in pull request #9516: [FLINK-13815][State Backends] Implement the SpaceAllocator URL: https://github.com/apache/flink/pull/9516#discussion_r344699884
########## File path: flink-state-backends/flink-statebackend-heap-spillable/src/main/java/org/apache/flink/runtime/state/heap/space/ChunkAllocator.java ########## @@ -0,0 +1,64 @@ +/* + * 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.flink.runtime.state.heap.space; + +import java.io.Closeable; + +/** + * Allocator to create chunks. + */ +public interface ChunkAllocator extends Closeable { + + /** + * Creates a chunk with the id and strategy. + * + * @param chunkId id of the chunk. + * @param allocateStrategy strategy to allocate chunk. + * @return a chunk. + */ + Chunk createChunk(int chunkId, AllocateStrategy allocateStrategy); + + /** + * Type of space where to allocate chunks. + */ + enum SpaceType { Review comment: The major type of chunk/space allocator we plan to use in spill-able backend is the memory-mapped file, and we will introduce the `FILE` type when implementing `MmapManager`, so it actually differs with `MemoryType`. The existing `SpaceType` truly looks like `MemoryType`, but let me explain different meanings of the existing types: - `HEAP` is just for unit testing - `OFFHEAP` is reserved if user would like to use memory instead of disk for the spilled part (serialized data, less memory consumption, won't affect GC, and better control comparing to page cache for mmap) ---------------------------------------------------------------- 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] With regards, Apache Git Services
