StephanEwen commented on a change in pull request #9516: [FLINK-13815][State 
Backends] Implement the SpaceAllocator
URL: https://github.com/apache/flink/pull/9516#discussion_r347246397
 
 

 ##########
 File path: 
flink-state-backends/flink-statebackend-heap-spillable/src/main/java/org/apache/flink/runtime/state/heap/space/BlockAllocator.java
 ##########
 @@ -0,0 +1,135 @@
+/*
+ * 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 org.apache.commons.collections.map.LinkedMap;
+import org.apache.flink.annotation.VisibleForTesting;
+
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+import static 
org.apache.flink.runtime.state.heap.space.SpaceConstants.NO_SPACE;
+
+/**
+ * Allocates blocks with fixed size from {@link Bucket}.
+ */
+final class BlockAllocator {
+
+       /**
+        * Index of this block allocator.
+        */
+       private final int blockAllocatorIndex;
+
+       /**
+        * Queue of free buckets. Allocator can apply a free bucket
+        * from the queue, and returns a free bucket to the queue.
+        */
+       private final ConcurrentLinkedQueue<Bucket> freeBucketsQueue;
+
+       /**
+        * Map of buckets applied by this allocator from queue.
+        */
+       private LinkedMap appliedBuckets;
+
+       /**
+        * Map of buckets that have free blocks to allocate.
+        */
+       private LinkedMap freeBuckets;
 
 Review comment:
   Coudl you double check whether we need the commons collection map here, or 
whether a JDK LinkedHashMap would work? Would be nice to try and avoid 
dependencies as much as possible.

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

Reply via email to