|
@@ -78,25 +78,14 @@ public class BlockFactory {
|
|
|
|
|
|
/**
|
|
|
* Adjust the circuit breaker with the given delta, if the delta is negative, the breaker will
|
|
|
- * be adjusted without tripping. If the data was already created before calling this method,
|
|
|
- * and the breaker trips, we add the delta without breaking to account for the created data.
|
|
|
- * If the data has not been created yet, we do not add the delta to the breaker if it trips.
|
|
|
+ * be adjusted without tripping.
|
|
|
+ * @throws CircuitBreakingException if the breaker was put above its limit
|
|
|
*/
|
|
|
- void adjustBreaker(final long delta, final boolean isDataAlreadyCreated) {
|
|
|
+ void adjustBreaker(final long delta) throws CircuitBreakingException {
|
|
|
// checking breaker means potentially tripping, but it doesn't
|
|
|
// have to if the delta is negative
|
|
|
if (delta > 0) {
|
|
|
- try {
|
|
|
- breaker.addEstimateBytesAndMaybeBreak(delta, "<esql_block_factory>");
|
|
|
- } catch (CircuitBreakingException e) {
|
|
|
- // if (isDataAlreadyCreated) { // TODO: remove isDataAlreadyCreated
|
|
|
- // since we've already created the data, we need to
|
|
|
- // add it so closing the stream re-adjusts properly
|
|
|
- // breaker.addWithoutBreaking(delta);
|
|
|
- // }
|
|
|
- // re-throw the original exception
|
|
|
- throw e;
|
|
|
- }
|
|
|
+ breaker.addEstimateBytesAndMaybeBreak(delta, "<esql_block_factory>");
|
|
|
} else {
|
|
|
breaker.addWithoutBreaking(delta);
|
|
|
}
|
|
@@ -105,25 +94,25 @@ public class BlockFactory {
|
|
|
/** Pre-adjusts the breaker for the given position count and element type. Returns the pre-adjusted amount. */
|
|
|
public long preAdjustBreakerForBoolean(int positionCount) {
|
|
|
long bytes = (long) positionCount * Byte.BYTES;
|
|
|
- adjustBreaker(bytes, false);
|
|
|
+ adjustBreaker(bytes);
|
|
|
return bytes;
|
|
|
}
|
|
|
|
|
|
public long preAdjustBreakerForInt(int positionCount) {
|
|
|
long bytes = (long) positionCount * Integer.BYTES;
|
|
|
- adjustBreaker(bytes, false);
|
|
|
+ adjustBreaker(bytes);
|
|
|
return bytes;
|
|
|
}
|
|
|
|
|
|
public long preAdjustBreakerForLong(int positionCount) {
|
|
|
long bytes = (long) positionCount * Long.BYTES;
|
|
|
- adjustBreaker(bytes, false);
|
|
|
+ adjustBreaker(bytes);
|
|
|
return bytes;
|
|
|
}
|
|
|
|
|
|
public long preAdjustBreakerForDouble(int positionCount) {
|
|
|
long bytes = (long) positionCount * Double.BYTES;
|
|
|
- adjustBreaker(bytes, false);
|
|
|
+ adjustBreaker(bytes);
|
|
|
return bytes;
|
|
|
}
|
|
|
|
|
@@ -144,7 +133,7 @@ public class BlockFactory {
|
|
|
|
|
|
public BooleanBlock newBooleanArrayBlock(boolean[] values, int pc, int[] fvi, BitSet nulls, MvOrdering mvOrder, long preAdjustedBytes) {
|
|
|
var b = new BooleanArrayBlock(values, pc, fvi, nulls, mvOrder, this);
|
|
|
- adjustBreaker(b.ramBytesUsed() - preAdjustedBytes, true);
|
|
|
+ adjustBreaker(b.ramBytesUsed() - preAdjustedBytes);
|
|
|
return b;
|
|
|
}
|
|
|
|
|
@@ -158,7 +147,7 @@ public class BlockFactory {
|
|
|
|
|
|
public BooleanVector newBooleanArrayVector(boolean[] values, int positionCount, long preAdjustedBytes) {
|
|
|
var b = new BooleanArrayVector(values, positionCount, this);
|
|
|
- adjustBreaker(b.ramBytesUsed() - preAdjustedBytes, true);
|
|
|
+ adjustBreaker(b.ramBytesUsed() - preAdjustedBytes);
|
|
|
return b;
|
|
|
}
|
|
|
|
|
@@ -168,12 +157,12 @@ public class BlockFactory {
|
|
|
|
|
|
public BooleanBlock newConstantBooleanBlockWith(boolean value, int positions, long preAdjustedBytes) {
|
|
|
var b = new ConstantBooleanVector(value, positions, this).asBlock();
|
|
|
- adjustBreaker(b.ramBytesUsed() - preAdjustedBytes, true);
|
|
|
+ adjustBreaker(b.ramBytesUsed() - preAdjustedBytes);
|
|
|
return b;
|
|
|
}
|
|
|
|
|
|
public BooleanVector newConstantBooleanVector(boolean value, int positions) {
|
|
|
- adjustBreaker(ConstantBooleanVector.RAM_BYTES_USED, false);
|
|
|
+ adjustBreaker(ConstantBooleanVector.RAM_BYTES_USED);
|
|
|
var v = new ConstantBooleanVector(value, positions, this);
|
|
|
assert v.ramBytesUsed() == ConstantBooleanVector.RAM_BYTES_USED;
|
|
|
return v;
|
|
@@ -189,7 +178,7 @@ public class BlockFactory {
|
|
|
|
|
|
public IntBlock newIntArrayBlock(int[] values, int pc, int[] fvi, BitSet nulls, MvOrdering mvOrdering, long preAdjustedBytes) {
|
|
|
var b = new IntArrayBlock(values, pc, fvi, nulls, mvOrdering, this);
|
|
|
- adjustBreaker(b.ramBytesUsed() - preAdjustedBytes, true);
|
|
|
+ adjustBreaker(b.ramBytesUsed() - preAdjustedBytes);
|
|
|
return b;
|
|
|
}
|
|
|
|
|
@@ -225,7 +214,7 @@ public class BlockFactory {
|
|
|
*/
|
|
|
public IntVector newIntArrayVector(int[] values, int positionCount, long preAdjustedBytes) {
|
|
|
var b = new IntArrayVector(values, positionCount, this);
|
|
|
- adjustBreaker(b.ramBytesUsed() - preAdjustedBytes, true);
|
|
|
+ adjustBreaker(b.ramBytesUsed() - preAdjustedBytes);
|
|
|
return b;
|
|
|
}
|
|
|
|
|
@@ -235,12 +224,12 @@ public class BlockFactory {
|
|
|
|
|
|
public IntBlock newConstantIntBlockWith(int value, int positions, long preAdjustedBytes) {
|
|
|
var b = new ConstantIntVector(value, positions, this).asBlock();
|
|
|
- adjustBreaker(b.ramBytesUsed() - preAdjustedBytes, true);
|
|
|
+ adjustBreaker(b.ramBytesUsed() - preAdjustedBytes);
|
|
|
return b;
|
|
|
}
|
|
|
|
|
|
public IntVector newConstantIntVector(int value, int positions) {
|
|
|
- adjustBreaker(ConstantIntVector.RAM_BYTES_USED, false);
|
|
|
+ adjustBreaker(ConstantIntVector.RAM_BYTES_USED);
|
|
|
var v = new ConstantIntVector(value, positions, this);
|
|
|
assert v.ramBytesUsed() == ConstantIntVector.RAM_BYTES_USED;
|
|
|
return v;
|
|
@@ -256,7 +245,7 @@ public class BlockFactory {
|
|
|
|
|
|
public LongBlock newLongArrayBlock(long[] values, int pc, int[] fvi, BitSet nulls, MvOrdering mvOrdering, long preAdjustedBytes) {
|
|
|
var b = new LongArrayBlock(values, pc, fvi, nulls, mvOrdering, this);
|
|
|
- adjustBreaker(b.ramBytesUsed() - preAdjustedBytes, true);
|
|
|
+ adjustBreaker(b.ramBytesUsed() - preAdjustedBytes);
|
|
|
return b;
|
|
|
}
|
|
|
|
|
@@ -277,7 +266,7 @@ public class BlockFactory {
|
|
|
|
|
|
public LongVector newLongArrayVector(long[] values, int positionCount, long preAdjustedBytes) {
|
|
|
var b = new LongArrayVector(values, positionCount, this);
|
|
|
- adjustBreaker(b.ramBytesUsed() - preAdjustedBytes, true);
|
|
|
+ adjustBreaker(b.ramBytesUsed() - preAdjustedBytes);
|
|
|
return b;
|
|
|
}
|
|
|
|
|
@@ -287,12 +276,12 @@ public class BlockFactory {
|
|
|
|
|
|
public LongBlock newConstantLongBlockWith(long value, int positions, long preAdjustedBytes) {
|
|
|
var b = new ConstantLongVector(value, positions, this).asBlock();
|
|
|
- adjustBreaker(b.ramBytesUsed() - preAdjustedBytes, true);
|
|
|
+ adjustBreaker(b.ramBytesUsed() - preAdjustedBytes);
|
|
|
return b;
|
|
|
}
|
|
|
|
|
|
public LongVector newConstantLongVector(long value, int positions) {
|
|
|
- adjustBreaker(ConstantLongVector.RAM_BYTES_USED, false);
|
|
|
+ adjustBreaker(ConstantLongVector.RAM_BYTES_USED);
|
|
|
var v = new ConstantLongVector(value, positions, this);
|
|
|
assert v.ramBytesUsed() == ConstantLongVector.RAM_BYTES_USED;
|
|
|
return v;
|
|
@@ -309,7 +298,7 @@ public class BlockFactory {
|
|
|
|
|
|
public DoubleBlock newDoubleArrayBlock(double[] values, int pc, int[] fvi, BitSet nulls, MvOrdering mvOrdering, long preAdjustedBytes) {
|
|
|
var b = new DoubleArrayBlock(values, pc, fvi, nulls, mvOrdering, this);
|
|
|
- adjustBreaker(b.ramBytesUsed() - preAdjustedBytes, true);
|
|
|
+ adjustBreaker(b.ramBytesUsed() - preAdjustedBytes);
|
|
|
return b;
|
|
|
}
|
|
|
|
|
@@ -330,7 +319,7 @@ public class BlockFactory {
|
|
|
|
|
|
public DoubleVector newDoubleArrayVector(double[] values, int positionCount, long preAdjustedBytes) {
|
|
|
var b = new DoubleArrayVector(values, positionCount, this);
|
|
|
- adjustBreaker(b.ramBytesUsed() - preAdjustedBytes, true);
|
|
|
+ adjustBreaker(b.ramBytesUsed() - preAdjustedBytes);
|
|
|
return b;
|
|
|
}
|
|
|
|
|
@@ -340,12 +329,12 @@ public class BlockFactory {
|
|
|
|
|
|
public DoubleBlock newConstantDoubleBlockWith(double value, int positions, long preAdjustedBytes) {
|
|
|
var b = new ConstantDoubleVector(value, positions, this).asBlock();
|
|
|
- adjustBreaker(b.ramBytesUsed() - preAdjustedBytes, true);
|
|
|
+ adjustBreaker(b.ramBytesUsed() - preAdjustedBytes);
|
|
|
return b;
|
|
|
}
|
|
|
|
|
|
public DoubleVector newConstantDoubleVector(double value, int positions) {
|
|
|
- adjustBreaker(ConstantDoubleVector.RAM_BYTES_USED, false);
|
|
|
+ adjustBreaker(ConstantDoubleVector.RAM_BYTES_USED);
|
|
|
var v = new ConstantDoubleVector(value, positions, this);
|
|
|
assert v.ramBytesUsed() == ConstantDoubleVector.RAM_BYTES_USED;
|
|
|
return v;
|
|
@@ -357,7 +346,7 @@ public class BlockFactory {
|
|
|
|
|
|
public BytesRefBlock newBytesRefArrayBlock(BytesRefArray values, int pc, int[] firstValueIndexes, BitSet nulls, MvOrdering mvOrdering) {
|
|
|
var b = new BytesRefArrayBlock(values, pc, firstValueIndexes, nulls, mvOrdering, this);
|
|
|
- adjustBreaker(b.ramBytesUsed() - values.bigArraysRamBytesUsed(), true);
|
|
|
+ adjustBreaker(b.ramBytesUsed() - values.bigArraysRamBytesUsed());
|
|
|
return b;
|
|
|
}
|
|
|
|
|
@@ -367,19 +356,19 @@ public class BlockFactory {
|
|
|
|
|
|
public BytesRefVector newBytesRefArrayVector(BytesRefArray values, int positionCount) {
|
|
|
var b = new BytesRefArrayVector(values, positionCount, this);
|
|
|
- adjustBreaker(b.ramBytesUsed() - values.bigArraysRamBytesUsed(), true);
|
|
|
+ adjustBreaker(b.ramBytesUsed() - values.bigArraysRamBytesUsed());
|
|
|
return b;
|
|
|
}
|
|
|
|
|
|
public BytesRefBlock newConstantBytesRefBlockWith(BytesRef value, int positions) {
|
|
|
var b = new ConstantBytesRefVector(value, positions, this).asBlock();
|
|
|
- adjustBreaker(b.ramBytesUsed(), true);
|
|
|
+ adjustBreaker(b.ramBytesUsed());
|
|
|
return b;
|
|
|
}
|
|
|
|
|
|
public BytesRefVector newConstantBytesRefVector(BytesRef value, int positions) {
|
|
|
long preadjusted = ConstantBytesRefVector.ramBytesUsed(value);
|
|
|
- adjustBreaker(preadjusted, false);
|
|
|
+ adjustBreaker(preadjusted);
|
|
|
var v = new ConstantBytesRefVector(value, positions, this);
|
|
|
assert v.ramBytesUsed() == preadjusted;
|
|
|
return v;
|
|
@@ -387,7 +376,7 @@ public class BlockFactory {
|
|
|
|
|
|
public Block newConstantNullBlock(int positions) {
|
|
|
var b = new ConstantNullBlock(positions, this);
|
|
|
- adjustBreaker(b.ramBytesUsed(), true);
|
|
|
+ adjustBreaker(b.ramBytesUsed());
|
|
|
return b;
|
|
|
}
|
|
|
|