Skip to content

Commit

Permalink
use closeExpectNoException
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisHegarty committed Sep 13, 2023
1 parent 06064d3 commit ded62c6
Show file tree
Hide file tree
Showing 23 changed files with 48 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -74,6 +75,6 @@ public String toString() {

@Override
public void close() {
vector.close();
Releasables.closeExpectNoException(vector);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ public String toString() {

@Override
public void close() {
Releasables.close(values);
Releasables.closeExpectNoException(values);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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());
}
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -75,6 +76,6 @@ public String toString() {

@Override
public void close() {
vector.close();
Releasables.closeExpectNoException(vector);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -74,6 +75,6 @@ public String toString() {

@Override
public void close() {
vector.close();
Releasables.closeExpectNoException(vector);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package org.elasticsearch.compute.data;

import org.apache.lucene.util.RamUsageEstimator;
import org.elasticsearch.core.Releasables;

/**
* Filter block for BooleanBlocks.
Expand Down Expand Up @@ -125,6 +126,6 @@ private void appendValues(StringBuilder sb) {

@Override
public void close() {
block.close();
Releasables.closeExpectNoException(block);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package org.elasticsearch.compute.data;

import org.apache.lucene.util.RamUsageEstimator;
import org.elasticsearch.core.Releasables;

/**
* Filter vector for BooleanVectors.
Expand Down Expand Up @@ -91,6 +92,6 @@ private void appendValues(StringBuilder sb) {

@Override
public void close() {
vector.close();
Releasables.closeExpectNoException(vector);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -128,6 +129,6 @@ private void appendValues(StringBuilder sb) {

@Override
public void close() {
block.close();
Releasables.closeExpectNoException(block);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -92,6 +93,6 @@ private void appendValues(StringBuilder sb) {

@Override
public void close() {
vector.close();
Releasables.closeExpectNoException(vector);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package org.elasticsearch.compute.data;

import org.apache.lucene.util.RamUsageEstimator;
import org.elasticsearch.core.Releasables;

/**
* Filter block for DoubleBlocks.
Expand Down Expand Up @@ -125,6 +126,6 @@ private void appendValues(StringBuilder sb) {

@Override
public void close() {
block.close();
Releasables.closeExpectNoException(block);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package org.elasticsearch.compute.data;

import org.apache.lucene.util.RamUsageEstimator;
import org.elasticsearch.core.Releasables;

/**
* Filter vector for DoubleVectors.
Expand Down Expand Up @@ -91,6 +92,6 @@ private void appendValues(StringBuilder sb) {

@Override
public void close() {
vector.close();
Releasables.closeExpectNoException(vector);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package org.elasticsearch.compute.data;

import org.apache.lucene.util.RamUsageEstimator;
import org.elasticsearch.core.Releasables;

/**
* Filter block for IntBlocks.
Expand Down Expand Up @@ -125,6 +126,6 @@ private void appendValues(StringBuilder sb) {

@Override
public void close() {
block.close();
Releasables.closeExpectNoException(block);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package org.elasticsearch.compute.data;

import org.apache.lucene.util.RamUsageEstimator;
import org.elasticsearch.core.Releasables;

/**
* Filter vector for IntVectors.
Expand Down Expand Up @@ -91,6 +92,6 @@ private void appendValues(StringBuilder sb) {

@Override
public void close() {
vector.close();
Releasables.closeExpectNoException(vector);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package org.elasticsearch.compute.data;

import org.apache.lucene.util.RamUsageEstimator;
import org.elasticsearch.core.Releasables;

/**
* Filter block for LongBlocks.
Expand Down Expand Up @@ -125,6 +126,6 @@ private void appendValues(StringBuilder sb) {

@Override
public void close() {
block.close();
Releasables.closeExpectNoException(block);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package org.elasticsearch.compute.data;

import org.apache.lucene.util.RamUsageEstimator;
import org.elasticsearch.core.Releasables;

/**
* Filter vector for LongVectors.
Expand Down Expand Up @@ -91,6 +92,6 @@ private void appendValues(StringBuilder sb) {

@Override
public void close() {
vector.close();
Releasables.closeExpectNoException(vector);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -74,6 +75,6 @@ public String toString() {

@Override
public void close() {
vector.close();
Releasables.closeExpectNoException(vector);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -74,6 +75,6 @@ public String toString() {

@Override
public void close() {
vector.close();
Releasables.closeExpectNoException(vector);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public long ramBytesUsed() {

@Override
public void close() {
Releasables.close(vector);
Releasables.closeExpectNoException(vector);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,6 @@ public long ramBytesUsed() {

@Override
public void close() {
Releasables.close(shards, segments, docs);
Releasables.closeExpectNoException(shards, segments, docs);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ $endif$
@Override
public void close() {
$if(BytesRef)$
Releasables.close(values);
Releasables.closeExpectNoException(values);
$else$
// no-op
$endif$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -149,6 +150,6 @@ $endif$

@Override
public void close() {
block.close();
Releasables.closeExpectNoException(block);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -103,6 +104,6 @@ $endif$

@Override
public void close() {
vector.close();
Releasables.closeExpectNoException(vector);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -82,6 +83,6 @@ $endif$

@Override
public void close() {
vector.close();
Releasables.closeExpectNoException(vector);
}
}

0 comments on commit ded62c6

Please sign in to comment.