From ded62c68b06378072ab8320dd3b4b1bd782e4557 Mon Sep 17 00:00:00 2001 From: ChrisHegarty Date: Wed, 13 Sep 2023 17:52:46 +0100 Subject: [PATCH] use closeExpectNoException --- .../compute/data/BooleanVectorBlock.java | 3 ++- .../compute/data/BytesRefArrayVector.java | 2 +- .../elasticsearch/compute/data/BytesRefVector.java | 11 ++++++++--- .../compute/data/BytesRefVectorBlock.java | 3 ++- .../elasticsearch/compute/data/DoubleVectorBlock.java | 3 ++- .../compute/data/FilterBooleanBlock.java | 3 ++- .../compute/data/FilterBooleanVector.java | 3 ++- .../compute/data/FilterBytesRefBlock.java | 3 ++- .../compute/data/FilterBytesRefVector.java | 3 ++- .../elasticsearch/compute/data/FilterDoubleBlock.java | 3 ++- .../compute/data/FilterDoubleVector.java | 3 ++- .../elasticsearch/compute/data/FilterIntBlock.java | 3 ++- .../elasticsearch/compute/data/FilterIntVector.java | 3 ++- .../elasticsearch/compute/data/FilterLongBlock.java | 3 ++- .../elasticsearch/compute/data/FilterLongVector.java | 3 ++- .../elasticsearch/compute/data/IntVectorBlock.java | 3 ++- .../elasticsearch/compute/data/LongVectorBlock.java | 3 ++- .../java/org/elasticsearch/compute/data/DocBlock.java | 2 +- .../org/elasticsearch/compute/data/DocVector.java | 2 +- .../elasticsearch/compute/data/X-ArrayVector.java.st | 2 +- .../elasticsearch/compute/data/X-FilterBlock.java.st | 3 ++- .../elasticsearch/compute/data/X-FilterVector.java.st | 3 ++- .../elasticsearch/compute/data/X-VectorBlock.java.st | 3 ++- 23 files changed, 48 insertions(+), 25 deletions(-) diff --git a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BooleanVectorBlock.java b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BooleanVectorBlock.java index 900090843d822..6c138b8f56d11 100644 --- a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BooleanVectorBlock.java +++ b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BooleanVectorBlock.java @@ -8,6 +8,7 @@ package org.elasticsearch.compute.data; import org.apache.lucene.util.RamUsageEstimator; +import org.elasticsearch.core.Releasables; /** * Block view of a BooleanVector. @@ -74,6 +75,6 @@ public String toString() { @Override public void close() { - vector.close(); + Releasables.closeExpectNoException(vector); } } diff --git a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BytesRefArrayVector.java b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BytesRefArrayVector.java index 13f10ddad98ab..21422598a0bde 100644 --- a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BytesRefArrayVector.java +++ b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BytesRefArrayVector.java @@ -81,6 +81,6 @@ public String toString() { @Override public void close() { - Releasables.close(values); + Releasables.closeExpectNoException(values); } } diff --git a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BytesRefVector.java b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BytesRefVector.java index 6201ab4a3728a..919651d894a11 100644 --- a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BytesRefVector.java +++ b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BytesRefVector.java @@ -10,6 +10,7 @@ import org.apache.lucene.util.BytesRef; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.util.BigArrays; import java.io.IOException; @@ -78,7 +79,7 @@ static BytesRefVector of(StreamInput in) throws IOException { if (constant && positions > 0) { return new ConstantBytesRefVector(in.readBytesRef(), positions); } else { - var builder = BytesRefVector.newVectorBuilder(positions); + var builder = BytesRefVector.newVectorBuilder(positions, BigArrays.NON_RECYCLING_INSTANCE); for (int i = 0; i < positions; i++) { builder.appendBytesRef(in.readBytesRef()); } @@ -100,8 +101,12 @@ default void writeTo(StreamOutput out) throws IOException { } } - static Builder newVectorBuilder(int estimatedSize) { - return new BytesRefVectorBuilder(estimatedSize); + static Builder newVectorBuilder(int estimatedSize) { // For now + return new BytesRefVectorBuilder(estimatedSize, BigArrays.NON_RECYCLING_INSTANCE); + } + + static Builder newVectorBuilder(int estimatedSize, BigArrays bigArrays) { + return new BytesRefVectorBuilder(estimatedSize, bigArrays); } sealed interface Builder extends Vector.Builder permits BytesRefVectorBuilder { diff --git a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BytesRefVectorBlock.java b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BytesRefVectorBlock.java index d05c29c9aa791..791ea6809de63 100644 --- a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BytesRefVectorBlock.java +++ b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BytesRefVectorBlock.java @@ -9,6 +9,7 @@ import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.RamUsageEstimator; +import org.elasticsearch.core.Releasables; /** * Block view of a BytesRefVector. @@ -75,6 +76,6 @@ public String toString() { @Override public void close() { - vector.close(); + Releasables.closeExpectNoException(vector); } } diff --git a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/DoubleVectorBlock.java b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/DoubleVectorBlock.java index f735504e49ba0..92243b6a53b70 100644 --- a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/DoubleVectorBlock.java +++ b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/DoubleVectorBlock.java @@ -8,6 +8,7 @@ package org.elasticsearch.compute.data; import org.apache.lucene.util.RamUsageEstimator; +import org.elasticsearch.core.Releasables; /** * Block view of a DoubleVector. @@ -74,6 +75,6 @@ public String toString() { @Override public void close() { - vector.close(); + Releasables.closeExpectNoException(vector); } } diff --git a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterBooleanBlock.java b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterBooleanBlock.java index 0846787a54cd0..8b410fffc032b 100644 --- a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterBooleanBlock.java +++ b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterBooleanBlock.java @@ -8,6 +8,7 @@ package org.elasticsearch.compute.data; import org.apache.lucene.util.RamUsageEstimator; +import org.elasticsearch.core.Releasables; /** * Filter block for BooleanBlocks. @@ -125,6 +126,6 @@ private void appendValues(StringBuilder sb) { @Override public void close() { - block.close(); + Releasables.closeExpectNoException(block); } } diff --git a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterBooleanVector.java b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterBooleanVector.java index 63e3ba8a26d9a..2ff1dcd58dea5 100644 --- a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterBooleanVector.java +++ b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterBooleanVector.java @@ -8,6 +8,7 @@ package org.elasticsearch.compute.data; import org.apache.lucene.util.RamUsageEstimator; +import org.elasticsearch.core.Releasables; /** * Filter vector for BooleanVectors. @@ -91,6 +92,6 @@ private void appendValues(StringBuilder sb) { @Override public void close() { - vector.close(); + Releasables.closeExpectNoException(vector); } } diff --git a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterBytesRefBlock.java b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterBytesRefBlock.java index b10976ebbf197..cdc925c01f53e 100644 --- a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterBytesRefBlock.java +++ b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterBytesRefBlock.java @@ -9,6 +9,7 @@ import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.RamUsageEstimator; +import org.elasticsearch.core.Releasables; /** * Filter block for BytesRefBlocks. @@ -128,6 +129,6 @@ private void appendValues(StringBuilder sb) { @Override public void close() { - block.close(); + Releasables.closeExpectNoException(block); } } diff --git a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterBytesRefVector.java b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterBytesRefVector.java index 78f3ba31f1fed..0d51121d3c0ec 100644 --- a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterBytesRefVector.java +++ b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterBytesRefVector.java @@ -9,6 +9,7 @@ import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.RamUsageEstimator; +import org.elasticsearch.core.Releasables; /** * Filter vector for BytesRefVectors. @@ -92,6 +93,6 @@ private void appendValues(StringBuilder sb) { @Override public void close() { - vector.close(); + Releasables.closeExpectNoException(vector); } } diff --git a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterDoubleBlock.java b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterDoubleBlock.java index 9ef820a22fa0c..2d02a8665b87f 100644 --- a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterDoubleBlock.java +++ b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterDoubleBlock.java @@ -8,6 +8,7 @@ package org.elasticsearch.compute.data; import org.apache.lucene.util.RamUsageEstimator; +import org.elasticsearch.core.Releasables; /** * Filter block for DoubleBlocks. @@ -125,6 +126,6 @@ private void appendValues(StringBuilder sb) { @Override public void close() { - block.close(); + Releasables.closeExpectNoException(block); } } diff --git a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterDoubleVector.java b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterDoubleVector.java index 02ba6d7c421ab..1c1c6d1c3db02 100644 --- a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterDoubleVector.java +++ b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterDoubleVector.java @@ -8,6 +8,7 @@ package org.elasticsearch.compute.data; import org.apache.lucene.util.RamUsageEstimator; +import org.elasticsearch.core.Releasables; /** * Filter vector for DoubleVectors. @@ -91,6 +92,6 @@ private void appendValues(StringBuilder sb) { @Override public void close() { - vector.close(); + Releasables.closeExpectNoException(vector); } } diff --git a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterIntBlock.java b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterIntBlock.java index 5918c39fb86ce..ffd72ec10d234 100644 --- a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterIntBlock.java +++ b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterIntBlock.java @@ -8,6 +8,7 @@ package org.elasticsearch.compute.data; import org.apache.lucene.util.RamUsageEstimator; +import org.elasticsearch.core.Releasables; /** * Filter block for IntBlocks. @@ -125,6 +126,6 @@ private void appendValues(StringBuilder sb) { @Override public void close() { - block.close(); + Releasables.closeExpectNoException(block); } } diff --git a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterIntVector.java b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterIntVector.java index 44622fd3338b7..f0833c1878b61 100644 --- a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterIntVector.java +++ b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterIntVector.java @@ -8,6 +8,7 @@ package org.elasticsearch.compute.data; import org.apache.lucene.util.RamUsageEstimator; +import org.elasticsearch.core.Releasables; /** * Filter vector for IntVectors. @@ -91,6 +92,6 @@ private void appendValues(StringBuilder sb) { @Override public void close() { - vector.close(); + Releasables.closeExpectNoException(vector); } } diff --git a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterLongBlock.java b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterLongBlock.java index 6d1e9afa9b1ab..85f72b1b0b44e 100644 --- a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterLongBlock.java +++ b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterLongBlock.java @@ -8,6 +8,7 @@ package org.elasticsearch.compute.data; import org.apache.lucene.util.RamUsageEstimator; +import org.elasticsearch.core.Releasables; /** * Filter block for LongBlocks. @@ -125,6 +126,6 @@ private void appendValues(StringBuilder sb) { @Override public void close() { - block.close(); + Releasables.closeExpectNoException(block); } } diff --git a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterLongVector.java b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterLongVector.java index 38ca09d4c0742..5eb987863aa80 100644 --- a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterLongVector.java +++ b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FilterLongVector.java @@ -8,6 +8,7 @@ package org.elasticsearch.compute.data; import org.apache.lucene.util.RamUsageEstimator; +import org.elasticsearch.core.Releasables; /** * Filter vector for LongVectors. @@ -91,6 +92,6 @@ private void appendValues(StringBuilder sb) { @Override public void close() { - vector.close(); + Releasables.closeExpectNoException(vector); } } diff --git a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/IntVectorBlock.java b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/IntVectorBlock.java index 96ad91d173f68..20499fe900558 100644 --- a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/IntVectorBlock.java +++ b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/IntVectorBlock.java @@ -8,6 +8,7 @@ package org.elasticsearch.compute.data; import org.apache.lucene.util.RamUsageEstimator; +import org.elasticsearch.core.Releasables; /** * Block view of a IntVector. @@ -74,6 +75,6 @@ public String toString() { @Override public void close() { - vector.close(); + Releasables.closeExpectNoException(vector); } } diff --git a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/LongVectorBlock.java b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/LongVectorBlock.java index 55922d822be55..cf8fc931f1351 100644 --- a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/LongVectorBlock.java +++ b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/LongVectorBlock.java @@ -8,6 +8,7 @@ package org.elasticsearch.compute.data; import org.apache.lucene.util.RamUsageEstimator; +import org.elasticsearch.core.Releasables; /** * Block view of a LongVector. @@ -74,6 +75,6 @@ public String toString() { @Override public void close() { - vector.close(); + Releasables.closeExpectNoException(vector); } } diff --git a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/DocBlock.java b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/DocBlock.java index 51ef19ea73f73..8f2c2474d7f63 100644 --- a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/DocBlock.java +++ b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/DocBlock.java @@ -59,7 +59,7 @@ public long ramBytesUsed() { @Override public void close() { - Releasables.close(vector); + Releasables.closeExpectNoException(vector); } /** diff --git a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/DocVector.java b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/DocVector.java index 7e5a4f218606a..cecae256e8974 100644 --- a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/DocVector.java +++ b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/DocVector.java @@ -202,6 +202,6 @@ public long ramBytesUsed() { @Override public void close() { - Releasables.close(shards, segments, docs); + Releasables.closeExpectNoException(shards, segments, docs); } } diff --git a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-ArrayVector.java.st b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-ArrayVector.java.st index 1554392d7ac19..103e8bc22d9ed 100644 --- a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-ArrayVector.java.st +++ b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-ArrayVector.java.st @@ -110,7 +110,7 @@ $endif$ @Override public void close() { $if(BytesRef)$ - Releasables.close(values); + Releasables.closeExpectNoException(values); $else$ // no-op $endif$ diff --git a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-FilterBlock.java.st b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-FilterBlock.java.st index a8eb68200cabf..a4c524422533d 100644 --- a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-FilterBlock.java.st +++ b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-FilterBlock.java.st @@ -11,6 +11,7 @@ $if(BytesRef)$ import org.apache.lucene.util.BytesRef; $endif$ import org.apache.lucene.util.RamUsageEstimator; +import org.elasticsearch.core.Releasables; /** * Filter block for $Type$Blocks. @@ -149,6 +150,6 @@ $endif$ @Override public void close() { - block.close(); + Releasables.closeExpectNoException(block); } } diff --git a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-FilterVector.java.st b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-FilterVector.java.st index fd22a21fdd15d..e68fc6838d3f4 100644 --- a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-FilterVector.java.st +++ b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-FilterVector.java.st @@ -11,6 +11,7 @@ $if(BytesRef)$ import org.apache.lucene.util.BytesRef; $endif$ import org.apache.lucene.util.RamUsageEstimator; +import org.elasticsearch.core.Releasables; /** * Filter vector for $Type$Vectors. @@ -103,6 +104,6 @@ $endif$ @Override public void close() { - vector.close(); + Releasables.closeExpectNoException(vector); } } diff --git a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-VectorBlock.java.st b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-VectorBlock.java.st index 18d6874545c0e..3abc702839118 100644 --- a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-VectorBlock.java.st +++ b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-VectorBlock.java.st @@ -11,6 +11,7 @@ $if(BytesRef)$ import org.apache.lucene.util.BytesRef; $endif$ import org.apache.lucene.util.RamUsageEstimator; +import org.elasticsearch.core.Releasables; /** * Block view of a $Type$Vector. @@ -82,6 +83,6 @@ $endif$ @Override public void close() { - vector.close(); + Releasables.closeExpectNoException(vector); } }