Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
n1v0lg committed Dec 20, 2023
2 parents 22fbbcb + d5a2dc4 commit 975a842
Show file tree
Hide file tree
Showing 119 changed files with 2,020 additions and 1,451 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@
import org.elasticsearch.compute.data.BlockFactory;
import org.elasticsearch.compute.data.BooleanBlock;
import org.elasticsearch.compute.data.BytesRefBlock;
import org.elasticsearch.compute.data.DoubleArrayVector;
import org.elasticsearch.compute.data.DoubleBlock;
import org.elasticsearch.compute.data.ElementType;
import org.elasticsearch.compute.data.IntBlock;
import org.elasticsearch.compute.data.LongArrayVector;
import org.elasticsearch.compute.data.LongBlock;
import org.elasticsearch.compute.data.Page;
import org.elasticsearch.compute.operator.AggregationOperator;
Expand Down Expand Up @@ -116,8 +114,7 @@ public class AggregatorBenchmark {
@Param({ VECTOR_LONGS, HALF_NULL_LONGS, VECTOR_DOUBLES, HALF_NULL_DOUBLES })
public String blockType;

private static Operator operator(String grouping, String op, String dataType) {
DriverContext driverContext = driverContext();
private static Operator operator(DriverContext driverContext, String grouping, String op, String dataType) {
if (grouping.equals("none")) {
return new AggregationOperator(
List.of(supplier(op, dataType, 0).aggregatorFactory(AggregatorMode.SINGLE).apply(driverContext)),
Expand Down Expand Up @@ -432,19 +429,19 @@ private static void checkUngrouped(String prefix, String op, String dataType, Pa
}
}

private static Page page(String grouping, String blockType) {
Block dataBlock = dataBlock(blockType);
private static Page page(BlockFactory blockFactory, String grouping, String blockType) {
Block dataBlock = dataBlock(blockFactory, blockType);
if (grouping.equals("none")) {
return new Page(dataBlock);
}
List<Block> blocks = groupingBlocks(grouping, blockType);
return new Page(Stream.concat(blocks.stream(), Stream.of(dataBlock)).toArray(Block[]::new));
}

private static Block dataBlock(String blockType) {
private static Block dataBlock(BlockFactory blockFactory, String blockType) {
return switch (blockType) {
case VECTOR_LONGS -> new LongArrayVector(LongStream.range(0, BLOCK_LENGTH).toArray(), BLOCK_LENGTH).asBlock();
case VECTOR_DOUBLES -> new DoubleArrayVector(
case VECTOR_LONGS -> blockFactory.newLongArrayVector(LongStream.range(0, BLOCK_LENGTH).toArray(), BLOCK_LENGTH).asBlock();
case VECTOR_DOUBLES -> blockFactory.newDoubleArrayVector(
LongStream.range(0, BLOCK_LENGTH).mapToDouble(l -> Long.valueOf(l).doubleValue()).toArray(),
BLOCK_LENGTH
).asBlock();
Expand Down Expand Up @@ -574,8 +571,9 @@ private static void run(String grouping, String op, String blockType, int opCoun
default -> throw new IllegalArgumentException();
};

Operator operator = operator(grouping, op, dataType);
Page page = page(grouping, blockType);
DriverContext driverContext = driverContext();
Operator operator = operator(driverContext, grouping, op, dataType);
Page page = page(driverContext.blockFactory(), grouping, blockType);
for (int i = 0; i < opCount; i++) {
operator.addInput(page);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,20 @@
import org.elasticsearch.common.util.LongArray;
import org.elasticsearch.compute.data.Block;
import org.elasticsearch.compute.data.BlockFactory;
import org.elasticsearch.compute.data.BooleanArrayVector;
import org.elasticsearch.compute.data.BooleanBigArrayBlock;
import org.elasticsearch.compute.data.BooleanBigArrayVector;
import org.elasticsearch.compute.data.BooleanBlock;
import org.elasticsearch.compute.data.BooleanVector;
import org.elasticsearch.compute.data.BytesRefArrayVector;
import org.elasticsearch.compute.data.BytesRefBlock;
import org.elasticsearch.compute.data.BytesRefVector;
import org.elasticsearch.compute.data.ConstantBooleanVector;
import org.elasticsearch.compute.data.ConstantBytesRefVector;
import org.elasticsearch.compute.data.ConstantDoubleVector;
import org.elasticsearch.compute.data.ConstantIntVector;
import org.elasticsearch.compute.data.ConstantLongVector;
import org.elasticsearch.compute.data.DoubleArrayVector;
import org.elasticsearch.compute.data.DoubleBigArrayBlock;
import org.elasticsearch.compute.data.DoubleBigArrayVector;
import org.elasticsearch.compute.data.DoubleBlock;
import org.elasticsearch.compute.data.DoubleVector;
import org.elasticsearch.compute.data.IntArrayVector;
import org.elasticsearch.compute.data.IntBigArrayBlock;
import org.elasticsearch.compute.data.IntBigArrayVector;
import org.elasticsearch.compute.data.IntBlock;
import org.elasticsearch.compute.data.IntVector;
import org.elasticsearch.compute.data.LongArrayVector;
import org.elasticsearch.compute.data.LongBigArrayBlock;
import org.elasticsearch.compute.data.LongBigArrayVector;
import org.elasticsearch.compute.data.LongBlock;
Expand Down Expand Up @@ -149,7 +139,7 @@ private static BenchmarkBlocks buildBlocks(String dataType, String blockKind, in
case "boolean" -> {
for (int blockIndex = 0; blockIndex < NUM_BLOCKS_PER_ITERATION; blockIndex++) {
if (blockKind.equalsIgnoreCase("vector-const")) {
BooleanVector vector = new ConstantBooleanVector(random.nextBoolean(), totalPositions);
BooleanVector vector = blockFactory.newConstantBooleanVector(random.nextBoolean(), totalPositions);
blocks[blockIndex] = vector.asBlock();
continue;
}
Expand Down Expand Up @@ -203,7 +193,7 @@ private static BenchmarkBlocks buildBlocks(String dataType, String blockKind, in
);
}
case "vector" -> {
BooleanVector vector = new BooleanArrayVector(values, totalPositions);
BooleanVector vector = blockFactory.newBooleanArrayVector(values, totalPositions);
blocks[blockIndex] = vector.asBlock();
}
case "vector-big-array" -> {
Expand All @@ -213,7 +203,7 @@ private static BenchmarkBlocks buildBlocks(String dataType, String blockKind, in
valuesBigArray.set(i);
}
}
BooleanVector vector = new BooleanBigArrayVector(valuesBigArray, totalPositions);
BooleanVector vector = new BooleanBigArrayVector(valuesBigArray, totalPositions, blockFactory);
blocks[blockIndex] = vector.asBlock();
}
default -> {
Expand All @@ -233,7 +223,7 @@ private static BenchmarkBlocks buildBlocks(String dataType, String blockKind, in
byte[] bytes = new byte[random.nextInt(MAX_BYTES_REF_LENGTH)];
random.nextBytes(bytes);

BytesRefVector vector = new ConstantBytesRefVector(new BytesRef(bytes), totalPositions);
BytesRefVector vector = blockFactory.newConstantBytesRefVector(new BytesRef(bytes), totalPositions);
blocks[blockIndex] = vector.asBlock();
continue;
}
Expand Down Expand Up @@ -270,7 +260,7 @@ private static BenchmarkBlocks buildBlocks(String dataType, String blockKind, in
);
}
case "vector" -> {
BytesRefVector vector = new BytesRefArrayVector(values, totalPositions);
BytesRefVector vector = blockFactory.newBytesRefArrayVector(values, totalPositions);
blocks[blockIndex] = vector.asBlock();
}
default -> {
Expand All @@ -287,7 +277,7 @@ private static BenchmarkBlocks buildBlocks(String dataType, String blockKind, in
case "double" -> {
for (int blockIndex = 0; blockIndex < NUM_BLOCKS_PER_ITERATION; blockIndex++) {
if (blockKind.equalsIgnoreCase("vector-const")) {
DoubleVector vector = new ConstantDoubleVector(random.nextDouble() * 1000000.0, totalPositions);
DoubleVector vector = blockFactory.newConstantDoubleVector(random.nextDouble() * 1000000.0, totalPositions);
blocks[blockIndex] = vector.asBlock();
continue;
}
Expand Down Expand Up @@ -341,7 +331,7 @@ private static BenchmarkBlocks buildBlocks(String dataType, String blockKind, in
);
}
case "vector" -> {
DoubleVector vector = new DoubleArrayVector(values, totalPositions);
DoubleVector vector = blockFactory.newDoubleArrayVector(values, totalPositions);
blocks[blockIndex] = vector.asBlock();
}
case "vector-big-array" -> {
Expand All @@ -351,7 +341,7 @@ private static BenchmarkBlocks buildBlocks(String dataType, String blockKind, in
for (int i = 0; i < values.length; i++) {
valuesBigArray.set(i, values[i]);
}
DoubleVector vector = new DoubleBigArrayVector(valuesBigArray, totalPositions);
DoubleVector vector = new DoubleBigArrayVector(valuesBigArray, totalPositions, blockFactory);
blocks[blockIndex] = vector.asBlock();
}
default -> {
Expand All @@ -368,7 +358,7 @@ private static BenchmarkBlocks buildBlocks(String dataType, String blockKind, in
case "int" -> {
for (int blockIndex = 0; blockIndex < NUM_BLOCKS_PER_ITERATION; blockIndex++) {
if (blockKind.equalsIgnoreCase("vector-const")) {
IntVector vector = new ConstantIntVector(random.nextInt(), totalPositions);
IntVector vector = blockFactory.newConstantIntVector(random.nextInt(), totalPositions);
blocks[blockIndex] = vector.asBlock();
continue;
}
Expand Down Expand Up @@ -420,15 +410,15 @@ private static BenchmarkBlocks buildBlocks(String dataType, String blockKind, in
);
}
case "vector" -> {
IntVector vector = new IntArrayVector(values, totalPositions);
IntVector vector = blockFactory.newIntArrayVector(values, totalPositions);
blocks[blockIndex] = vector.asBlock();
}
case "vector-big-array" -> {
IntArray valuesBigArray = BlockFactory.getNonBreakingInstance().bigArrays().newIntArray(totalPositions, false);
for (int i = 0; i < values.length; i++) {
valuesBigArray.set(i, values[i]);
}
IntVector vector = new IntBigArrayVector(valuesBigArray, totalPositions);
IntVector vector = new IntBigArrayVector(valuesBigArray, totalPositions, blockFactory);
blocks[blockIndex] = vector.asBlock();
}
default -> {
Expand All @@ -445,7 +435,7 @@ private static BenchmarkBlocks buildBlocks(String dataType, String blockKind, in
case "long" -> {
for (int blockIndex = 0; blockIndex < NUM_BLOCKS_PER_ITERATION; blockIndex++) {
if (blockKind.equalsIgnoreCase("vector-const")) {
LongVector vector = new ConstantLongVector(random.nextLong(), totalPositions);
LongVector vector = blockFactory.newConstantLongVector(random.nextLong(), totalPositions);
blocks[blockIndex] = vector.asBlock();
continue;
}
Expand Down Expand Up @@ -499,7 +489,7 @@ private static BenchmarkBlocks buildBlocks(String dataType, String blockKind, in
);
}
case "vector" -> {
LongVector vector = new LongArrayVector(values, totalPositions);
LongVector vector = blockFactory.newLongArrayVector(values, totalPositions);
blocks[blockIndex] = vector.asBlock();
}
case "vector-big-array" -> {
Expand All @@ -509,7 +499,7 @@ private static BenchmarkBlocks buildBlocks(String dataType, String blockKind, in
for (int i = 0; i < values.length; i++) {
valuesBigArray.set(i, values[i]);
}
LongVector vector = new LongBigArrayVector(valuesBigArray, totalPositions);
LongVector vector = new LongBigArrayVector(valuesBigArray, totalPositions, blockFactory);
blocks[blockIndex] = vector.asBlock();
}
default -> {
Expand Down
2 changes: 2 additions & 0 deletions build-tools-internal/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ dependencies {
compileOnly buildLibs.checkstyle
compileOnly buildLibs.reflections

implementation 'com.github.javaparser:javaparser-core:3.18.0'

runtimeOnly "org.elasticsearch.gradle:reaper:$version"
testImplementation buildLibs.checkstyle
testImplementation buildLibs.wiremock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public void apply(Project project) {

final Version version = VersionProperties.getElasticsearchVersion();

project.getTasks()
.register("updateVersions", UpdateVersionsTask.class, t -> project.getTasks().named("spotlessApply").get().mustRunAfter(t));

final FileTree yamlFiles = projectDirectory.dir("docs/changelog")
.getAsFileTree()
.matching(new PatternSet().include("**/*.yml", "**/*.yaml"));
Expand Down
Loading

0 comments on commit 975a842

Please sign in to comment.