You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by vl...@apache.org on 2019/01/08 21:23:43 UTC
[calcite] branch master updated: [CALCITE-2778] Remove
ClosableAllocation, ClosableAllocationOwner,
CompoundClosableAllocation (BELUGA BEHR)
This is an automated email from the ASF dual-hosted git repository.
vladimirsitnikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/master by this push:
new d15d6e0 [CALCITE-2778] Remove ClosableAllocation, ClosableAllocationOwner, CompoundClosableAllocation (BELUGA BEHR)
d15d6e0 is described below
commit d15d6e036b11e4e3588985f315bc4d1e2d2d2471
Author: Beluga Behr <da...@gmail.com>
AuthorDate: Tue Jan 8 15:35:40 2019 -0500
[CALCITE-2778] Remove ClosableAllocation, ClosableAllocationOwner, CompoundClosableAllocation (BELUGA BEHR)
fixes #994
---
.../apache/calcite/util/ClosableAllocation.java | 32 ---------
.../calcite/util/ClosableAllocationOwner.java | 35 ---------
.../calcite/util/CompoundClosableAllocation.java | 84 ----------------------
3 files changed, 151 deletions(-)
diff --git a/core/src/main/java/org/apache/calcite/util/ClosableAllocation.java b/core/src/main/java/org/apache/calcite/util/ClosableAllocation.java
deleted file mode 100644
index 9568772..0000000
--- a/core/src/main/java/org/apache/calcite/util/ClosableAllocation.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.calcite.util;
-
-/**
- * ClosableAllocation represents an object which requires a call in order to
- * release resources early rather than waiting for finalization.
- */
-public interface ClosableAllocation {
- //~ Methods ----------------------------------------------------------------
-
- /**
- * Closes this object.
- */
- void closeAllocation();
-}
-
-// End ClosableAllocation.java
diff --git a/core/src/main/java/org/apache/calcite/util/ClosableAllocationOwner.java b/core/src/main/java/org/apache/calcite/util/ClosableAllocationOwner.java
deleted file mode 100644
index 3915657..0000000
--- a/core/src/main/java/org/apache/calcite/util/ClosableAllocationOwner.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.calcite.util;
-
-/**
- * ClosableAllocationOwner represents an object which can take ownership of
- * ClosableAllocations and guarantee that they will be cleaned up correctly when
- * its own closeAllocation() is called.
- */
-public interface ClosableAllocationOwner extends ClosableAllocation {
- //~ Methods ----------------------------------------------------------------
-
- /**
- * Assigns ownership of a ClosableAllocation to this owner.
- *
- * @param allocation the ClosableAllocation to take over
- */
- void addAllocation(ClosableAllocation allocation);
-}
-
-// End ClosableAllocationOwner.java
diff --git a/core/src/main/java/org/apache/calcite/util/CompoundClosableAllocation.java b/core/src/main/java/org/apache/calcite/util/CompoundClosableAllocation.java
deleted file mode 100644
index a4aef8a..0000000
--- a/core/src/main/java/org/apache/calcite/util/CompoundClosableAllocation.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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.calcite.util;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-
-/**
- * CompoundClosableAllocation represents a collection of ClosableAllocations
- * which share a common lifecycle. It guarantees that allocations are closed in
- * the reverse order in which they were added.
- */
-public class CompoundClosableAllocation implements ClosableAllocationOwner {
- //~ Instance fields --------------------------------------------------------
-
- /**
- * List of owned ClosableAllocation objects.
- */
- protected List<ClosableAllocation> allocations;
-
- //~ Constructors -----------------------------------------------------------
-
- public CompoundClosableAllocation() {
- allocations = new LinkedList<>();
- }
-
- //~ Methods ----------------------------------------------------------------
-
- // implement ClosableAllocationOwner
- public void addAllocation(ClosableAllocation allocation) {
- allocations.add(allocation);
- }
-
- // implement ClosableAllocation
- public void closeAllocation() {
- // traverse in reverse order
- ListIterator<ClosableAllocation> iter =
- allocations.listIterator(allocations.size());
- while (iter.hasPrevious()) {
- ClosableAllocation allocation = iter.previous();
-
- // NOTE: nullify the entry just retrieved so that if allocation
- // calls back to forgetAllocation, it won't find itself
- // (this prevents a ConcurrentModificationException)
- iter.set(null);
- allocation.closeAllocation();
- }
- allocations.clear();
- }
-
- /**
- * Forgets an allocation without closing it.
- *
- * @param allocation the allocation to forget
- * @return whether the allocation was known
- */
- public boolean forgetAllocation(ClosableAllocation allocation) {
- return allocations.remove(allocation);
- }
-
- /**
- * @return whether any allocations remain unclosed
- */
- public boolean hasAllocations() {
- return !allocations.isEmpty();
- }
-}
-
-// End CompoundClosableAllocation.java