Skip to content

Commit

Permalink
use a non-breaking block factory by default
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisHegarty committed Sep 19, 2023
1 parent fbb02ff commit b938dd6
Show file tree
Hide file tree
Showing 50 changed files with 110 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public final class BooleanArrayBlock extends AbstractArrayBlock implements Boole
private final boolean[] values;

public BooleanArrayBlock(boolean[] values, int positionCount, int[] firstValueIndexes, BitSet nulls, MvOrdering mvOrdering) {
this(values, positionCount, firstValueIndexes, nulls, mvOrdering, BlockFactory.getGlobalInstance());
this(values, positionCount, firstValueIndexes, nulls, mvOrdering, BlockFactory.getNonBreakingInstance());
}

public BooleanArrayBlock(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public final class BooleanArrayVector extends AbstractVector implements BooleanV
private final boolean[] values;

public BooleanArrayVector(boolean[] values, int positionCount) {
this(values, positionCount, BlockFactory.getGlobalInstance());
this(values, positionCount, BlockFactory.getNonBreakingInstance());
}

public BooleanArrayVector(boolean[] values, int positionCount, BlockFactory blockFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public final class BooleanBigArrayVector extends AbstractVector implements Boole
private final BitArray values;

public BooleanBigArrayVector(BitArray values, int positionCount) {
this(values, positionCount, BlockFactory.getGlobalInstance());
this(values, positionCount, BlockFactory.getNonBreakingInstance());
}

public BooleanBigArrayVector(BitArray values, int positionCount, BlockFactory blockFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,20 @@ static int hash(BooleanBlock block) {
return result;
}

/** Returns a builder using the {@link BlockFactory#getGlobalInstance block factory}. */
/** Returns a builder using the {@link BlockFactory#getNonBreakingInstance block factory}. */
// Eventually, this should use the GLOBAL breaking instance
static Builder newBlockBuilder(int estimatedSize) {
return newBlockBuilder(estimatedSize, BlockFactory.getGlobalInstance());
return newBlockBuilder(estimatedSize, BlockFactory.getNonBreakingInstance());
}

static Builder newBlockBuilder(int estimatedSize, BlockFactory blockFactory) {
return blockFactory.newBooleanBlockBuilder(estimatedSize);
}

/** Returns a block using the {@link BlockFactory#getGlobalInstance block factory}. */
/** Returns a block using the {@link BlockFactory#getNonBreakingInstance block factory}. */
// Eventually, this should use the GLOBAL breaking instance
static BooleanBlock newConstantBlockWith(boolean value, int positions) {
return newConstantBlockWith(value, positions, BlockFactory.getGlobalInstance());
return newConstantBlockWith(value, positions, BlockFactory.getNonBreakingInstance());
}

static BooleanBlock newConstantBlockWith(boolean value, int positions, BlockFactory blockFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ default void writeTo(StreamOutput out) throws IOException {
}
}

/** Returns a builder using the {@link BlockFactory#getGlobalInstance block factory}. */
/** Returns a builder using the {@link BlockFactory#getNonBreakingInstance block factory}. */
// Eventually, this should use the GLOBAL breaking instance
static Builder newVectorBuilder(int estimatedSize) {
return newVectorBuilder(estimatedSize, BlockFactory.getGlobalInstance());
return newVectorBuilder(estimatedSize, BlockFactory.getNonBreakingInstance());
}

static Builder newVectorBuilder(int estimatedSize, BlockFactory blockFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public final class BytesRefArrayBlock extends AbstractArrayBlock implements Byte
private final BytesRefArray values;

public BytesRefArrayBlock(BytesRefArray values, int positionCount, int[] firstValueIndexes, BitSet nulls, MvOrdering mvOrdering) {
this(values, positionCount, firstValueIndexes, nulls, mvOrdering, BlockFactory.getGlobalInstance());
this(values, positionCount, firstValueIndexes, nulls, mvOrdering, BlockFactory.getNonBreakingInstance());
}

public BytesRefArrayBlock(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public final class BytesRefArrayVector extends AbstractVector implements BytesRe
private final BytesRefArray values;

public BytesRefArrayVector(BytesRefArray values, int positionCount) {
this(values, positionCount, BlockFactory.getGlobalInstance());
this(values, positionCount, BlockFactory.getNonBreakingInstance());
}

public BytesRefArrayVector(BytesRefArray values, int positionCount, BlockFactory blockFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,20 @@ static int hash(BytesRefBlock block) {
return result;
}

/** Returns a builder using the {@link BlockFactory#getGlobalInstance block factory}. */
/** Returns a builder using the {@link BlockFactory#getNonBreakingInstance block factory}. */
// Eventually, this should use the GLOBAL breaking instance
static Builder newBlockBuilder(int estimatedSize) {
return newBlockBuilder(estimatedSize, BlockFactory.getGlobalInstance());
return newBlockBuilder(estimatedSize, BlockFactory.getNonBreakingInstance());
}

static Builder newBlockBuilder(int estimatedSize, BlockFactory blockFactory) {
return blockFactory.newBytesRefBlockBuilder(estimatedSize);
}

/** Returns a block using the {@link BlockFactory#getGlobalInstance block factory}. */
/** Returns a block using the {@link BlockFactory#getNonBreakingInstance block factory}. */
// Eventually, this should use the GLOBAL breaking instance
static BytesRefBlock newConstantBlockWith(BytesRef value, int positions) {
return newConstantBlockWith(value, positions, BlockFactory.getGlobalInstance());
return newConstantBlockWith(value, positions, BlockFactory.getNonBreakingInstance());
}

static BytesRefBlock newConstantBlockWith(BytesRef value, int positions, BlockFactory blockFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ default void writeTo(StreamOutput out) throws IOException {
}
}

/** Returns a builder using the {@link BlockFactory#getGlobalInstance block factory}. */
/** Returns a builder using the {@link BlockFactory#getNonBreakingInstance block factory}. */
// Eventually, this should use the GLOBAL breaking instance
static Builder newVectorBuilder(int estimatedSize) {
return newVectorBuilder(estimatedSize, BlockFactory.getGlobalInstance());
return newVectorBuilder(estimatedSize, BlockFactory.getNonBreakingInstance());
}

static Builder newVectorBuilder(int estimatedSize, BlockFactory blockFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public final class ConstantBooleanVector extends AbstractVector implements Boole
private final boolean value;

public ConstantBooleanVector(boolean value, int positionCount) {
this(value, positionCount, BlockFactory.getGlobalInstance());
this(value, positionCount, BlockFactory.getNonBreakingInstance());
}

public ConstantBooleanVector(boolean value, int positionCount, BlockFactory blockFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public final class ConstantBytesRefVector extends AbstractVector implements Byte
private final BytesRef value;

public ConstantBytesRefVector(BytesRef value, int positionCount) {
this(value, positionCount, BlockFactory.getGlobalInstance());
this(value, positionCount, BlockFactory.getNonBreakingInstance());
}

public ConstantBytesRefVector(BytesRef value, int positionCount, BlockFactory blockFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public final class ConstantDoubleVector extends AbstractVector implements Double
private final double value;

public ConstantDoubleVector(double value, int positionCount) {
this(value, positionCount, BlockFactory.getGlobalInstance());
this(value, positionCount, BlockFactory.getNonBreakingInstance());
}

public ConstantDoubleVector(double value, int positionCount, BlockFactory blockFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public final class ConstantIntVector extends AbstractVector implements IntVector
private final int value;

public ConstantIntVector(int value, int positionCount) {
this(value, positionCount, BlockFactory.getGlobalInstance());
this(value, positionCount, BlockFactory.getNonBreakingInstance());
}

public ConstantIntVector(int value, int positionCount, BlockFactory blockFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public final class ConstantLongVector extends AbstractVector implements LongVect
private final long value;

public ConstantLongVector(long value, int positionCount) {
this(value, positionCount, BlockFactory.getGlobalInstance());
this(value, positionCount, BlockFactory.getNonBreakingInstance());
}

public ConstantLongVector(long value, int positionCount, BlockFactory blockFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public final class DoubleArrayBlock extends AbstractArrayBlock implements Double
private final double[] values;

public DoubleArrayBlock(double[] values, int positionCount, int[] firstValueIndexes, BitSet nulls, MvOrdering mvOrdering) {
this(values, positionCount, firstValueIndexes, nulls, mvOrdering, BlockFactory.getGlobalInstance());
this(values, positionCount, firstValueIndexes, nulls, mvOrdering, BlockFactory.getNonBreakingInstance());
}

public DoubleArrayBlock(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public final class DoubleArrayVector extends AbstractVector implements DoubleVec
private final double[] values;

public DoubleArrayVector(double[] values, int positionCount) {
this(values, positionCount, BlockFactory.getGlobalInstance());
this(values, positionCount, BlockFactory.getNonBreakingInstance());
}

public DoubleArrayVector(double[] values, int positionCount, BlockFactory blockFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public final class DoubleBigArrayVector extends AbstractVector implements Double
private final DoubleArray values;

public DoubleBigArrayVector(DoubleArray values, int positionCount) {
this(values, positionCount, BlockFactory.getGlobalInstance());
this(values, positionCount, BlockFactory.getNonBreakingInstance());
}

public DoubleBigArrayVector(DoubleArray values, int positionCount, BlockFactory blockFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,20 @@ static int hash(DoubleBlock block) {
return result;
}

/** Returns a builder using the {@link BlockFactory#getGlobalInstance block factory}. */
/** Returns a builder using the {@link BlockFactory#getNonBreakingInstance block factory}. */
// Eventually, this should use the GLOBAL breaking instance
static Builder newBlockBuilder(int estimatedSize) {
return newBlockBuilder(estimatedSize, BlockFactory.getGlobalInstance());
return newBlockBuilder(estimatedSize, BlockFactory.getNonBreakingInstance());
}

static Builder newBlockBuilder(int estimatedSize, BlockFactory blockFactory) {
return blockFactory.newDoubleBlockBuilder(estimatedSize);
}

/** Returns a block using the {@link BlockFactory#getGlobalInstance block factory}. */
/** Returns a block using the {@link BlockFactory#getNonBreakingInstance block factory}. */
// Eventually, this should use the GLOBAL breaking instance
static DoubleBlock newConstantBlockWith(double value, int positions) {
return newConstantBlockWith(value, positions, BlockFactory.getGlobalInstance());
return newConstantBlockWith(value, positions, BlockFactory.getNonBreakingInstance());
}

static DoubleBlock newConstantBlockWith(double value, int positions, BlockFactory blockFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@ default void writeTo(StreamOutput out) throws IOException {
}
}

/** Returns a builder using the {@link BlockFactory#getGlobalInstance block factory}. */
/** Returns a builder using the {@link BlockFactory#getNonBreakingInstance block factory}. */
// Eventually, this should use the GLOBAL breaking instance
static Builder newVectorBuilder(int estimatedSize) {
return newVectorBuilder(estimatedSize, BlockFactory.getGlobalInstance());
return newVectorBuilder(estimatedSize, BlockFactory.getNonBreakingInstance());
}

static Builder newVectorBuilder(int estimatedSize, BlockFactory blockFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public final class IntArrayBlock extends AbstractArrayBlock implements IntBlock
private final int[] values;

public IntArrayBlock(int[] values, int positionCount, int[] firstValueIndexes, BitSet nulls, MvOrdering mvOrdering) {
this(values, positionCount, firstValueIndexes, nulls, mvOrdering, BlockFactory.getGlobalInstance());
this(values, positionCount, firstValueIndexes, nulls, mvOrdering, BlockFactory.getNonBreakingInstance());
}

public IntArrayBlock(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public final class IntArrayVector extends AbstractVector implements IntVector {
private final int[] values;

public IntArrayVector(int[] values, int positionCount) {
this(values, positionCount, BlockFactory.getGlobalInstance());
this(values, positionCount, BlockFactory.getNonBreakingInstance());
}

public IntArrayVector(int[] values, int positionCount, BlockFactory blockFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public final class IntBigArrayVector extends AbstractVector implements IntVector
private final IntArray values;

public IntBigArrayVector(IntArray values, int positionCount) {
this(values, positionCount, BlockFactory.getGlobalInstance());
this(values, positionCount, BlockFactory.getNonBreakingInstance());
}

public IntBigArrayVector(IntArray values, int positionCount, BlockFactory blockFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,20 @@ static int hash(IntBlock block) {
return result;
}

/** Returns a builder using the {@link BlockFactory#getGlobalInstance block factory}. */
/** Returns a builder using the {@link BlockFactory#getNonBreakingInstance block factory}. */
// Eventually, this should use the GLOBAL breaking instance
static Builder newBlockBuilder(int estimatedSize) {
return newBlockBuilder(estimatedSize, BlockFactory.getGlobalInstance());
return newBlockBuilder(estimatedSize, BlockFactory.getNonBreakingInstance());
}

static Builder newBlockBuilder(int estimatedSize, BlockFactory blockFactory) {
return blockFactory.newIntBlockBuilder(estimatedSize);
}

/** Returns a block using the {@link BlockFactory#getGlobalInstance block factory}. */
/** Returns a block using the {@link BlockFactory#getNonBreakingInstance block factory}. */
// Eventually, this should use the GLOBAL breaking instance
static IntBlock newConstantBlockWith(int value, int positions) {
return newConstantBlockWith(value, positions, BlockFactory.getGlobalInstance());
return newConstantBlockWith(value, positions, BlockFactory.getNonBreakingInstance());
}

static IntBlock newConstantBlockWith(int value, int positions, BlockFactory blockFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ default void writeTo(StreamOutput out) throws IOException {
}
}

/** Returns a builder using the {@link BlockFactory#getGlobalInstance block factory}. */
/** Returns a builder using the {@link BlockFactory#getNonBreakingInstance block factory}. */
// Eventually, this should use the GLOBAL breaking instance
static Builder newVectorBuilder(int estimatedSize) {
return newVectorBuilder(estimatedSize, BlockFactory.getGlobalInstance());
return newVectorBuilder(estimatedSize, BlockFactory.getNonBreakingInstance());
}

static Builder newVectorBuilder(int estimatedSize, BlockFactory blockFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public final class LongArrayBlock extends AbstractArrayBlock implements LongBloc
private final long[] values;

public LongArrayBlock(long[] values, int positionCount, int[] firstValueIndexes, BitSet nulls, MvOrdering mvOrdering) {
this(values, positionCount, firstValueIndexes, nulls, mvOrdering, BlockFactory.getGlobalInstance());
this(values, positionCount, firstValueIndexes, nulls, mvOrdering, BlockFactory.getNonBreakingInstance());
}

public LongArrayBlock(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public final class LongArrayVector extends AbstractVector implements LongVector
private final long[] values;

public LongArrayVector(long[] values, int positionCount) {
this(values, positionCount, BlockFactory.getGlobalInstance());
this(values, positionCount, BlockFactory.getNonBreakingInstance());
}

public LongArrayVector(long[] values, int positionCount, BlockFactory blockFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public final class LongBigArrayVector extends AbstractVector implements LongVect
private final LongArray values;

public LongBigArrayVector(LongArray values, int positionCount) {
this(values, positionCount, BlockFactory.getGlobalInstance());
this(values, positionCount, BlockFactory.getNonBreakingInstance());
}

public LongBigArrayVector(LongArray values, int positionCount, BlockFactory blockFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,20 @@ static int hash(LongBlock block) {
return result;
}

/** Returns a builder using the {@link BlockFactory#getGlobalInstance block factory}. */
/** Returns a builder using the {@link BlockFactory#getNonBreakingInstance block factory}. */
// Eventually, this should use the GLOBAL breaking instance
static Builder newBlockBuilder(int estimatedSize) {
return newBlockBuilder(estimatedSize, BlockFactory.getGlobalInstance());
return newBlockBuilder(estimatedSize, BlockFactory.getNonBreakingInstance());
}

static Builder newBlockBuilder(int estimatedSize, BlockFactory blockFactory) {
return blockFactory.newLongBlockBuilder(estimatedSize);
}

/** Returns a block using the {@link BlockFactory#getGlobalInstance block factory}. */
/** Returns a block using the {@link BlockFactory#getNonBreakingInstance block factory}. */
// Eventually, this should use the GLOBAL breaking instance
static LongBlock newConstantBlockWith(long value, int positions) {
return newConstantBlockWith(value, positions, BlockFactory.getGlobalInstance());
return newConstantBlockWith(value, positions, BlockFactory.getNonBreakingInstance());
}

static LongBlock newConstantBlockWith(long value, int positions, BlockFactory blockFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@ default void writeTo(StreamOutput out) throws IOException {
}
}

/** Returns a builder using the {@link BlockFactory#getGlobalInstance block factory}. */
/** Returns a builder using the {@link BlockFactory#getNonBreakingInstance block factory}. */
// Eventually, this should use the GLOBAL breaking instance
static Builder newVectorBuilder(int estimatedSize) {
return newVectorBuilder(estimatedSize, BlockFactory.getGlobalInstance());
return newVectorBuilder(estimatedSize, BlockFactory.getNonBreakingInstance());
}

static Builder newVectorBuilder(int estimatedSize, BlockFactory blockFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private IntVector add(LongVector vector) {
for (int i = 0; i < vector.getPositionCount(); i++) {
groups[i] = Math.toIntExact(hashOrdToGroupNullReserved(longHash.add(vector.getLong(i))));
}
return BlockFactory.getGlobalInstance().newIntArrayVector(groups, groups.length);
return vector.blockFactory().newIntArrayVector(groups, groups.length);
}

private IntBlock add(LongBlock block) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,11 @@ enum MvOrdering {
Block expand();

/**
* {@return a constant null block with the given number of positions, using the global block factory}.
* {@return a constant null block with the given number of positions, using the non-breaking block factory}.
*/
// Eventually, this should use the GLOBAL breaking instance
static Block constantNullBlock(int positions) {
return new ConstantNullBlock(positions, BlockFactory.getGlobalInstance());
return new ConstantNullBlock(positions, BlockFactory.getNonBreakingInstance());
}

static Block constantNullBlock(int positions, BlockFactory blockFactory) {
Expand Down
Loading

0 comments on commit b938dd6

Please sign in to comment.