Skip to content

Commit d8e66d4

Browse files
committed
smaller builder
1 parent 93942ca commit d8e66d4

File tree

4 files changed

+2
-44
lines changed

4 files changed

+2
-44
lines changed

server/src/main/java/org/elasticsearch/index/mapper/BlockLoader.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,10 +567,6 @@ interface SingletonLongBuilder extends Builder {
567567
* Specialized builder for collecting dense arrays of double values.
568568
*/
569569
interface SingletonDoubleBuilder extends Builder {
570-
SingletonDoubleBuilder appendDouble(double value);
571-
572-
SingletonDoubleBuilder appendDoubles(double[] values, int from, int length);
573-
574570
SingletonDoubleBuilder appendLongs(BlockDocValuesReader.ToDouble toDouble, long[] values, int from, int length);
575571
}
576572

test/framework/src/main/java/org/elasticsearch/index/mapper/TestBlock.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -263,19 +263,6 @@ public BlockLoader.Block build() {
263263
return new TestBlock(Arrays.stream(values).boxed().collect(Collectors.toUnmodifiableList()));
264264
}
265265

266-
@Override
267-
public BlockLoader.SingletonDoubleBuilder appendDoubles(double[] newValues, int from, int length) {
268-
System.arraycopy(newValues, from, values, count, length);
269-
count += length;
270-
return this;
271-
}
272-
273-
@Override
274-
public BlockLoader.SingletonDoubleBuilder appendDouble(double value) {
275-
values[count++] = value;
276-
return this;
277-
}
278-
279266
@Override
280267
public BlockLoader.SingletonDoubleBuilder appendLongs(
281268
BlockDocValuesReader.ToDouble toDouble,

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/lucene/read/SingletonDoubleBuilder.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,6 @@ public Block build() {
7272
return blockFactory.newDoubleArrayVector(values, count).asBlock();
7373
}
7474

75-
@Override
76-
public BlockLoader.SingletonDoubleBuilder appendDouble(double value) {
77-
values[count++] = value;
78-
return this;
79-
}
80-
81-
@Override
82-
public BlockLoader.SingletonDoubleBuilder appendDoubles(double[] values, int from, int length) {
83-
System.arraycopy(values, from, this.values, count, length);
84-
count += length;
85-
return this;
86-
}
87-
8875
@Override
8976
public BlockLoader.SingletonDoubleBuilder appendLongs(BlockDocValuesReader.ToDouble toDouble, long[] longValues, int from, int length) {
9077
for (int i = 0; i < length; i++) {

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/lucene/read/SingletonDoubleBuilderTests.java

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,7 @@ private void testRead(BlockFactory factory) throws IOException {
6969
try (var builder = new SingletonDoubleBuilder(ctx.reader().numDocs(), factory)) {
7070
for (int i = 0; i < ctx.reader().maxDoc(); i++) {
7171
assertThat(docValues.advanceExact(i), equalTo(true));
72-
double value = Double.longBitsToDouble(docValues.longValue());
73-
if (randomBoolean()) {
74-
builder.appendDoubles(new double[] { value }, 0, 1);
75-
} else if (randomBoolean()) {
76-
builder.appendLongs(Double::longBitsToDouble, new long[] { docValues.longValue() }, 0, 1);
77-
} else {
78-
builder.appendDouble(value);
79-
}
72+
builder.appendLongs(Double::longBitsToDouble, new long[] { docValues.longValue() }, 0, 1);
8073
}
8174
try (var build = (DoubleVector) builder.build().asVector()) {
8275
for (int i = 0; i < build.getPositionCount(); i++) {
@@ -115,12 +108,7 @@ public void testMoreValues() throws IOException {
115108
try (var builder = new SingletonDoubleBuilder(count - offset, blockFactory())) {
116109
for (int i = offset; i < leafReader.maxDoc(); i++) {
117110
assertThat(docValues.advanceExact(i), equalTo(true));
118-
double value = Double.longBitsToDouble(docValues.longValue());
119-
if (randomBoolean()) {
120-
builder.appendDoubles(new double[] { value }, 0, 1);
121-
} else {
122-
builder.appendDouble(value);
123-
}
111+
builder.appendLongs(Double::longBitsToDouble, new long[] { docValues.longValue() }, 0, 1);
124112
}
125113
try (var build = (DoubleVector) builder.build().asVector()) {
126114
assertThat(build.getPositionCount(), equalTo(count - offset));

0 commit comments

Comments
 (0)