Skip to content

Commit

Permalink
ESQL: Deprecate builder methods on Blocks
Browse files Browse the repository at this point in the history
We have a factory, let's use it!
  • Loading branch information
nik9000 committed Oct 26, 2023
1 parent 328ebc4 commit 7efd206
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,22 +166,40 @@ static int hash(BooleanBlock block) {
return result;
}

/** Returns a builder using the {@link BlockFactory#getNonBreakingInstance block factory}. */
/**
* Returns a builder using the {@link BlockFactory#getNonBreakingInstance non-breaking block factory}.
* @deprecated use {@link BlockFactory#newBooleanBlockBuilder}
*/
// Eventually, we want to remove this entirely, always passing an explicit BlockFactory
@Deprecated
static Builder newBlockBuilder(int estimatedSize) {
return newBlockBuilder(estimatedSize, BlockFactory.getNonBreakingInstance());
}

/**
* Returns a builder.
* @deprecated use {@link BlockFactory#newBooleanBlockBuilder}
*/
@Deprecated
static Builder newBlockBuilder(int estimatedSize, BlockFactory blockFactory) {
return blockFactory.newBooleanBlockBuilder(estimatedSize);
}

/** Returns a block using the {@link BlockFactory#getNonBreakingInstance block factory}. */
/**
* Returns a constant block built by the {@link BlockFactory#getNonBreakingInstance non-breaking block factory}.
* @deprecated use {@link BlockFactory#newConstantBooleanBlockWith}
*/
// Eventually, we want to remove this entirely, always passing an explicit BlockFactory
@Deprecated
static BooleanBlock newConstantBlockWith(boolean value, int positions) {
return newConstantBlockWith(value, positions, BlockFactory.getNonBreakingInstance());
}

/**
* Returns a constant block.
* @deprecated use {@link BlockFactory#newConstantBooleanBlockWith}
*/
@Deprecated
static BooleanBlock newConstantBlockWith(boolean value, int positions, BlockFactory blockFactory) {
return blockFactory.newConstantBooleanBlockWith(value, positions);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,22 +171,40 @@ static int hash(BytesRefBlock block) {
return result;
}

/** Returns a builder using the {@link BlockFactory#getNonBreakingInstance block factory}. */
/**
* Returns a builder using the {@link BlockFactory#getNonBreakingInstance non-breaking block factory}.
* @deprecated use {@link BlockFactory#newBytesRefBlockBuilder}
*/
// Eventually, we want to remove this entirely, always passing an explicit BlockFactory
@Deprecated
static Builder newBlockBuilder(int estimatedSize) {
return newBlockBuilder(estimatedSize, BlockFactory.getNonBreakingInstance());
}

/**
* Returns a builder.
* @deprecated use {@link BlockFactory#newBytesRefBlockBuilder}
*/
@Deprecated
static Builder newBlockBuilder(int estimatedSize, BlockFactory blockFactory) {
return blockFactory.newBytesRefBlockBuilder(estimatedSize);
}

/** Returns a block using the {@link BlockFactory#getNonBreakingInstance block factory}. */
/**
* Returns a constant block built by the {@link BlockFactory#getNonBreakingInstance non-breaking block factory}.
* @deprecated use {@link BlockFactory#newConstantBytesRefBlockWith}
*/
// Eventually, we want to remove this entirely, always passing an explicit BlockFactory
@Deprecated
static BytesRefBlock newConstantBlockWith(BytesRef value, int positions) {
return newConstantBlockWith(value, positions, BlockFactory.getNonBreakingInstance());
}

/**
* Returns a constant block.
* @deprecated use {@link BlockFactory#newConstantBytesRefBlockWith}
*/
@Deprecated
static BytesRefBlock newConstantBlockWith(BytesRef value, int positions, BlockFactory blockFactory) {
return blockFactory.newConstantBytesRefBlockWith(value, positions);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,22 +167,40 @@ static int hash(DoubleBlock block) {
return result;
}

/** Returns a builder using the {@link BlockFactory#getNonBreakingInstance block factory}. */
/**
* Returns a builder using the {@link BlockFactory#getNonBreakingInstance non-breaking block factory}.
* @deprecated use {@link BlockFactory#newDoubleBlockBuilder}
*/
// Eventually, we want to remove this entirely, always passing an explicit BlockFactory
@Deprecated
static Builder newBlockBuilder(int estimatedSize) {
return newBlockBuilder(estimatedSize, BlockFactory.getNonBreakingInstance());
}

/**
* Returns a builder.
* @deprecated use {@link BlockFactory#newDoubleBlockBuilder}
*/
@Deprecated
static Builder newBlockBuilder(int estimatedSize, BlockFactory blockFactory) {
return blockFactory.newDoubleBlockBuilder(estimatedSize);
}

/** Returns a block using the {@link BlockFactory#getNonBreakingInstance block factory}. */
/**
* Returns a constant block built by the {@link BlockFactory#getNonBreakingInstance non-breaking block factory}.
* @deprecated use {@link BlockFactory#newConstantDoubleBlockWith}
*/
// Eventually, we want to remove this entirely, always passing an explicit BlockFactory
@Deprecated
static DoubleBlock newConstantBlockWith(double value, int positions) {
return newConstantBlockWith(value, positions, BlockFactory.getNonBreakingInstance());
}

/**
* Returns a constant block.
* @deprecated use {@link BlockFactory#newConstantDoubleBlockWith}
*/
@Deprecated
static DoubleBlock newConstantBlockWith(double value, int positions, BlockFactory blockFactory) {
return blockFactory.newConstantDoubleBlockWith(value, positions);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,22 +166,40 @@ static int hash(IntBlock block) {
return result;
}

/** Returns a builder using the {@link BlockFactory#getNonBreakingInstance block factory}. */
/**
* Returns a builder using the {@link BlockFactory#getNonBreakingInstance non-breaking block factory}.
* @deprecated use {@link BlockFactory#newIntBlockBuilder}
*/
// Eventually, we want to remove this entirely, always passing an explicit BlockFactory
@Deprecated
static Builder newBlockBuilder(int estimatedSize) {
return newBlockBuilder(estimatedSize, BlockFactory.getNonBreakingInstance());
}

/**
* Returns a builder.
* @deprecated use {@link BlockFactory#newIntBlockBuilder}
*/
@Deprecated
static Builder newBlockBuilder(int estimatedSize, BlockFactory blockFactory) {
return blockFactory.newIntBlockBuilder(estimatedSize);
}

/** Returns a block using the {@link BlockFactory#getNonBreakingInstance block factory}. */
/**
* Returns a constant block built by the {@link BlockFactory#getNonBreakingInstance non-breaking block factory}.
* @deprecated use {@link BlockFactory#newConstantIntBlockWith}
*/
// Eventually, we want to remove this entirely, always passing an explicit BlockFactory
@Deprecated
static IntBlock newConstantBlockWith(int value, int positions) {
return newConstantBlockWith(value, positions, BlockFactory.getNonBreakingInstance());
}

/**
* Returns a constant block.
* @deprecated use {@link BlockFactory#newConstantIntBlockWith}
*/
@Deprecated
static IntBlock newConstantBlockWith(int value, int positions, BlockFactory blockFactory) {
return blockFactory.newConstantIntBlockWith(value, positions);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,22 +167,40 @@ static int hash(LongBlock block) {
return result;
}

/** Returns a builder using the {@link BlockFactory#getNonBreakingInstance block factory}. */
/**
* Returns a builder using the {@link BlockFactory#getNonBreakingInstance non-breaking block factory}.
* @deprecated use {@link BlockFactory#newLongBlockBuilder}
*/
// Eventually, we want to remove this entirely, always passing an explicit BlockFactory
@Deprecated
static Builder newBlockBuilder(int estimatedSize) {
return newBlockBuilder(estimatedSize, BlockFactory.getNonBreakingInstance());
}

/**
* Returns a builder.
* @deprecated use {@link BlockFactory#newLongBlockBuilder}
*/
@Deprecated
static Builder newBlockBuilder(int estimatedSize, BlockFactory blockFactory) {
return blockFactory.newLongBlockBuilder(estimatedSize);
}

/** Returns a block using the {@link BlockFactory#getNonBreakingInstance block factory}. */
/**
* Returns a constant block built by the {@link BlockFactory#getNonBreakingInstance non-breaking block factory}.
* @deprecated use {@link BlockFactory#newConstantLongBlockWith}
*/
// Eventually, we want to remove this entirely, always passing an explicit BlockFactory
@Deprecated
static LongBlock newConstantBlockWith(long value, int positions) {
return newConstantBlockWith(value, positions, BlockFactory.getNonBreakingInstance());
}

/**
* Returns a constant block.
* @deprecated use {@link BlockFactory#newConstantLongBlockWith}
*/
@Deprecated
static LongBlock newConstantBlockWith(long value, int positions, BlockFactory blockFactory) {
return blockFactory.newConstantLongBlockWith(value, positions);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,19 @@ default boolean mvSortedAscending() {

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

/**
* {@return a constant null block with the given number of positions}.
* @deprecated use {@link BlockFactory#newConstantNullBlock}
*/
@Deprecated
static Block constantNullBlock(int positions, BlockFactory blockFactory) {
return blockFactory.newConstantNullBlock(positions);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,22 +203,40 @@ $endif$
return result;
}

/** Returns a builder using the {@link BlockFactory#getNonBreakingInstance block factory}. */
/**
* Returns a builder using the {@link BlockFactory#getNonBreakingInstance non-breaking block factory}.
* @deprecated use {@link BlockFactory#new$Type$BlockBuilder}
*/
// Eventually, we want to remove this entirely, always passing an explicit BlockFactory
@Deprecated
static Builder newBlockBuilder(int estimatedSize) {
return newBlockBuilder(estimatedSize, BlockFactory.getNonBreakingInstance());
}

/**
* Returns a builder.
* @deprecated use {@link BlockFactory#new$Type$BlockBuilder}
*/
@Deprecated
static Builder newBlockBuilder(int estimatedSize, BlockFactory blockFactory) {
return blockFactory.new$Type$BlockBuilder(estimatedSize);
}

/** Returns a block using the {@link BlockFactory#getNonBreakingInstance block factory}. */
/**
* Returns a constant block built by the {@link BlockFactory#getNonBreakingInstance non-breaking block factory}.
* @deprecated use {@link BlockFactory#newConstant$Type$BlockWith}
*/
// Eventually, we want to remove this entirely, always passing an explicit BlockFactory
@Deprecated
static $Type$Block newConstantBlockWith($type$ value, int positions) {
return newConstantBlockWith(value, positions, BlockFactory.getNonBreakingInstance());
}

/**
* Returns a constant block.
* @deprecated use {@link BlockFactory#newConstant$Type$BlockWith}
*/
@Deprecated
static $Type$Block newConstantBlockWith($type$ value, int positions, BlockFactory blockFactory) {
return blockFactory.newConstant$Type$BlockWith(value, positions);
}
Expand Down

0 comments on commit 7efd206

Please sign in to comment.