|
@@ -26,34 +26,24 @@ import org.apache.lucene.store.Directory;
|
|
|
import org.apache.lucene.tests.index.RandomIndexWriter;
|
|
|
import org.apache.lucene.util.BytesRef;
|
|
|
import org.elasticsearch.common.Randomness;
|
|
|
-import org.elasticsearch.compute.aggregation.AggregatorMode;
|
|
|
-import org.elasticsearch.compute.aggregation.RateLongAggregatorFunctionSupplier;
|
|
|
-import org.elasticsearch.compute.aggregation.blockhash.BlockHash;
|
|
|
-import org.elasticsearch.compute.data.BytesRefBlock;
|
|
|
import org.elasticsearch.compute.data.BytesRefVector;
|
|
|
import org.elasticsearch.compute.data.DocVector;
|
|
|
-import org.elasticsearch.compute.data.DoubleBlock;
|
|
|
import org.elasticsearch.compute.data.ElementType;
|
|
|
-import org.elasticsearch.compute.data.IntVector;
|
|
|
import org.elasticsearch.compute.data.LongVector;
|
|
|
import org.elasticsearch.compute.data.Page;
|
|
|
import org.elasticsearch.compute.operator.AnyOperatorTestCase;
|
|
|
import org.elasticsearch.compute.operator.Driver;
|
|
|
import org.elasticsearch.compute.operator.DriverContext;
|
|
|
-import org.elasticsearch.compute.operator.HashAggregationOperator;
|
|
|
import org.elasticsearch.compute.operator.Operator;
|
|
|
import org.elasticsearch.compute.operator.OperatorTestCase;
|
|
|
-import org.elasticsearch.compute.operator.OrdinalsGroupingOperator;
|
|
|
import org.elasticsearch.compute.operator.TestResultPageSinkOperator;
|
|
|
import org.elasticsearch.core.CheckedFunction;
|
|
|
import org.elasticsearch.core.IOUtils;
|
|
|
import org.elasticsearch.core.TimeValue;
|
|
|
-import org.elasticsearch.index.mapper.BlockDocValuesReader;
|
|
|
import org.elasticsearch.index.mapper.DataStreamTimestampFieldMapper;
|
|
|
import org.elasticsearch.index.mapper.DateFieldMapper;
|
|
|
import org.elasticsearch.index.mapper.KeywordFieldMapper;
|
|
|
import org.elasticsearch.index.mapper.NumberFieldMapper;
|
|
|
-import org.elasticsearch.index.mapper.SourceLoader;
|
|
|
import org.elasticsearch.index.mapper.TimeSeriesIdFieldMapper;
|
|
|
import org.junit.After;
|
|
|
|
|
@@ -65,9 +55,9 @@ import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Locale;
|
|
|
import java.util.Map;
|
|
|
+import java.util.function.Consumer;
|
|
|
import java.util.function.Function;
|
|
|
|
|
|
-import static org.elasticsearch.index.mapper.DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER;
|
|
|
import static org.hamcrest.Matchers.equalTo;
|
|
|
import static org.hamcrest.Matchers.hasSize;
|
|
|
import static org.hamcrest.Matchers.lessThanOrEqualTo;
|
|
@@ -91,12 +81,12 @@ public class TimeSeriesSortedSourceOperatorTests extends AnyOperatorTestCase {
|
|
|
// for now we emit at most one time series each page
|
|
|
int offset = 0;
|
|
|
for (Page page : results) {
|
|
|
- assertThat(page.getBlockCount(), equalTo(5));
|
|
|
+ assertThat(page.getBlockCount(), equalTo(6));
|
|
|
DocVector docVector = (DocVector) page.getBlock(0).asVector();
|
|
|
- IntVector tsidVector = (IntVector) page.getBlock(1).asVector();
|
|
|
+ BytesRefVector tsidVector = (BytesRefVector) page.getBlock(1).asVector();
|
|
|
LongVector timestampVector = (LongVector) page.getBlock(2).asVector();
|
|
|
- LongVector voltageVector = (LongVector) page.getBlock(3).asVector();
|
|
|
- BytesRefVector hostnameVector = (BytesRefVector) page.getBlock(4).asVector();
|
|
|
+ LongVector voltageVector = (LongVector) page.getBlock(4).asVector();
|
|
|
+ BytesRefVector hostnameVector = (BytesRefVector) page.getBlock(5).asVector();
|
|
|
for (int i = 0; i < page.getPositionCount(); i++) {
|
|
|
int expectedTsidOrd = offset / numSamplesPerTS;
|
|
|
String expectedHostname = String.format(Locale.ROOT, "host-%02d", expectedTsidOrd);
|
|
@@ -106,7 +96,7 @@ public class TimeSeriesSortedSourceOperatorTests extends AnyOperatorTestCase {
|
|
|
assertThat(docVector.shards().getInt(i), equalTo(0));
|
|
|
assertThat(voltageVector.getLong(i), equalTo(expectedVoltage));
|
|
|
assertThat(hostnameVector.getBytesRef(i, new BytesRef()).utf8ToString(), equalTo(expectedHostname));
|
|
|
- assertThat(tsidVector.getInt(i), equalTo(expectedTsidOrd));
|
|
|
+ assertThat(tsidVector.getBytesRef(i, new BytesRef()).utf8ToString(), equalTo("\u0001\bhostnames\u0007" + expectedHostname));
|
|
|
assertThat(timestampVector.getLong(i), equalTo(expectedTimestamp));
|
|
|
offset++;
|
|
|
}
|
|
@@ -121,27 +111,27 @@ public class TimeSeriesSortedSourceOperatorTests extends AnyOperatorTestCase {
|
|
|
List<Page> results = runDriver(limit, randomIntBetween(1, 1024), randomBoolean(), numTimeSeries, numSamplesPerTS, timestampStart);
|
|
|
assertThat(results, hasSize(1));
|
|
|
Page page = results.get(0);
|
|
|
- assertThat(page.getBlockCount(), equalTo(5));
|
|
|
+ assertThat(page.getBlockCount(), equalTo(6));
|
|
|
|
|
|
DocVector docVector = (DocVector) page.getBlock(0).asVector();
|
|
|
assertThat(docVector.getPositionCount(), equalTo(limit));
|
|
|
|
|
|
- IntVector tsidVector = (IntVector) page.getBlock(1).asVector();
|
|
|
+ BytesRefVector tsidVector = (BytesRefVector) page.getBlock(1).asVector();
|
|
|
assertThat(tsidVector.getPositionCount(), equalTo(limit));
|
|
|
|
|
|
LongVector timestampVector = (LongVector) page.getBlock(2).asVector();
|
|
|
assertThat(timestampVector.getPositionCount(), equalTo(limit));
|
|
|
|
|
|
- LongVector voltageVector = (LongVector) page.getBlock(3).asVector();
|
|
|
+ LongVector voltageVector = (LongVector) page.getBlock(4).asVector();
|
|
|
assertThat(voltageVector.getPositionCount(), equalTo(limit));
|
|
|
|
|
|
- BytesRefVector hostnameVector = (BytesRefVector) page.getBlock(4).asVector();
|
|
|
+ BytesRefVector hostnameVector = (BytesRefVector) page.getBlock(5).asVector();
|
|
|
assertThat(hostnameVector.getPositionCount(), equalTo(limit));
|
|
|
|
|
|
assertThat(docVector.shards().getInt(0), equalTo(0));
|
|
|
assertThat(voltageVector.getLong(0), equalTo(5L));
|
|
|
assertThat(hostnameVector.getBytesRef(0, new BytesRef()).utf8ToString(), equalTo("host-00"));
|
|
|
- assertThat(tsidVector.getInt(0), equalTo(0));
|
|
|
+ assertThat(tsidVector.getBytesRef(0, new BytesRef()).utf8ToString(), equalTo("\u0001\bhostnames\u0007host-00")); // legacy tsid
|
|
|
assertThat(timestampVector.getLong(0), equalTo(timestampStart + ((numSamplesPerTS - 1) * 10_000L)));
|
|
|
}
|
|
|
|
|
@@ -161,13 +151,21 @@ public class TimeSeriesSortedSourceOperatorTests extends AnyOperatorTestCase {
|
|
|
}
|
|
|
int maxPageSize = between(1, 1024);
|
|
|
int limit = randomBoolean() ? between(1, 100000) : Integer.MAX_VALUE;
|
|
|
- var timeSeriesFactory = createTimeSeriesSourceOperator(limit, maxPageSize, randomBoolean(), writer -> {
|
|
|
- Randomness.shuffle(docs);
|
|
|
- for (Doc doc : docs) {
|
|
|
- writeTS(writer, doc.timestamp, new Object[] { "hostname", "h" + doc.host }, new Object[] { "metric", doc.metric });
|
|
|
+ var timeSeriesFactory = createTimeSeriesSourceOperator(
|
|
|
+ directory,
|
|
|
+ r -> this.reader = r,
|
|
|
+ limit,
|
|
|
+ maxPageSize,
|
|
|
+ randomBoolean(),
|
|
|
+ TimeValue.ZERO,
|
|
|
+ writer -> {
|
|
|
+ Randomness.shuffle(docs);
|
|
|
+ for (Doc doc : docs) {
|
|
|
+ writeTS(writer, doc.timestamp, new Object[] { "hostname", "h" + doc.host }, new Object[] { "metric", doc.metric });
|
|
|
+ }
|
|
|
+ return docs.size();
|
|
|
}
|
|
|
- return docs.size();
|
|
|
- });
|
|
|
+ );
|
|
|
DriverContext driverContext = driverContext();
|
|
|
List<Page> results = new ArrayList<>();
|
|
|
var metricField = new NumberFieldMapper.NumberFieldType("metric", NumberFieldMapper.NumberType.LONG);
|
|
@@ -192,16 +190,16 @@ public class TimeSeriesSortedSourceOperatorTests extends AnyOperatorTestCase {
|
|
|
assertThat(page.getPositionCount(), lessThanOrEqualTo(limit));
|
|
|
assertThat(page.getPositionCount(), lessThanOrEqualTo(maxPageSize));
|
|
|
}
|
|
|
- assertThat(page.getBlockCount(), equalTo(4));
|
|
|
+ assertThat(page.getBlockCount(), equalTo(5));
|
|
|
DocVector docVector = (DocVector) page.getBlock(0).asVector();
|
|
|
- IntVector tsidVector = (IntVector) page.getBlock(1).asVector();
|
|
|
+ BytesRefVector tsidVector = (BytesRefVector) page.getBlock(1).asVector();
|
|
|
LongVector timestampVector = (LongVector) page.getBlock(2).asVector();
|
|
|
- LongVector metricVector = (LongVector) page.getBlock(3).asVector();
|
|
|
+ LongVector metricVector = (LongVector) page.getBlock(4).asVector();
|
|
|
for (int i = 0; i < page.getPositionCount(); i++) {
|
|
|
Doc doc = docs.get(offset);
|
|
|
offset++;
|
|
|
assertThat(docVector.shards().getInt(0), equalTo(0));
|
|
|
- assertThat(tsidVector.getInt(i), equalTo(hostToTsidOrd.get(doc.host)));
|
|
|
+ assertThat(tsidVector.getBytesRef(i, new BytesRef()).utf8ToString(), equalTo("\u0001\bhostnames\u0002h" + doc.host));
|
|
|
assertThat(timestampVector.getLong(i), equalTo(doc.timestamp));
|
|
|
assertThat(metricVector.getLong(i), equalTo(doc.metric));
|
|
|
}
|
|
@@ -209,169 +207,9 @@ public class TimeSeriesSortedSourceOperatorTests extends AnyOperatorTestCase {
|
|
|
assertThat(offset, equalTo(Math.min(limit, numDocs)));
|
|
|
}
|
|
|
|
|
|
- public void testBasicRate() {
|
|
|
- long[] v1 = { 1, 1, 3, 0, 2, 9, 21, 3, 7, 7, 9, 12 };
|
|
|
- long[] t1 = { 1, 5, 11, 20, 21, 59, 88, 91, 92, 97, 99, 112 };
|
|
|
-
|
|
|
- long[] v2 = { 7, 2, 0, 11, 24, 0, 4, 1, 10, 2 };
|
|
|
- long[] t2 = { 1, 2, 4, 5, 6, 8, 10, 11, 12, 14 };
|
|
|
-
|
|
|
- long[] v3 = { 0, 1, 0, 1, 1, 4, 2, 2, 2, 2, 3, 5, 5 };
|
|
|
- long[] t3 = { 2, 3, 5, 7, 8, 9, 10, 12, 14, 15, 18, 20, 22 };
|
|
|
- List<Pod> pods = List.of(new Pod("p1", t1, v1), new Pod("p2", t2, v2), new Pod("p3", t3, v3));
|
|
|
- long unit = between(1, 5);
|
|
|
- Map<String, Double> actualRates = runRateTest(pods, TimeValue.timeValueMillis(unit));
|
|
|
- assertThat(actualRates, equalTo(Map.of("p1", 35.0 * unit / 111.0, "p2", 42.0 * unit / 13.0, "p3", 10.0 * unit / 20.0)));
|
|
|
- }
|
|
|
-
|
|
|
- public void testRandomRate() {
|
|
|
- int numPods = between(1, 10);
|
|
|
- List<Pod> pods = new ArrayList<>();
|
|
|
- Map<String, Double> expectedRates = new HashMap<>();
|
|
|
- TimeValue unit = TimeValue.timeValueSeconds(1);
|
|
|
- for (int p = 0; p < numPods; p++) {
|
|
|
- int numValues = between(2, 100);
|
|
|
- long[] values = new long[numValues];
|
|
|
- long[] times = new long[numValues];
|
|
|
- long t = DEFAULT_DATE_TIME_FORMATTER.parseMillis("2024-01-01T00:00:00Z");
|
|
|
- for (int i = 0; i < numValues; i++) {
|
|
|
- values[i] = randomIntBetween(0, 100);
|
|
|
- t += TimeValue.timeValueSeconds(between(1, 10)).millis();
|
|
|
- times[i] = t;
|
|
|
- }
|
|
|
- Pod pod = new Pod("p" + p, times, values);
|
|
|
- pods.add(pod);
|
|
|
- if (numValues == 1) {
|
|
|
- expectedRates.put(pod.name, null);
|
|
|
- } else {
|
|
|
- expectedRates.put(pod.name, pod.expectedRate(unit));
|
|
|
- }
|
|
|
- }
|
|
|
- Map<String, Double> actualRates = runRateTest(pods, unit);
|
|
|
- assertThat(actualRates, equalTo(expectedRates));
|
|
|
- }
|
|
|
-
|
|
|
- record Pod(String name, long[] times, long[] values) {
|
|
|
- Pod {
|
|
|
- assert times.length == values.length : times.length + "!=" + values.length;
|
|
|
- }
|
|
|
-
|
|
|
- double expectedRate(TimeValue unit) {
|
|
|
- double dv = 0;
|
|
|
- for (int i = 0; i < values.length - 1; i++) {
|
|
|
- if (values[i + 1] < values[i]) {
|
|
|
- dv += values[i];
|
|
|
- }
|
|
|
- }
|
|
|
- dv += (values[values.length - 1] - values[0]);
|
|
|
- long dt = times[times.length - 1] - times[0];
|
|
|
- return (dv * unit.millis()) / dt;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- Map<String, Double> runRateTest(List<Pod> pods, TimeValue unit) {
|
|
|
- long unitInMillis = unit.millis();
|
|
|
- record Doc(String pod, long timestamp, long requests) {
|
|
|
-
|
|
|
- }
|
|
|
- var sourceOperatorFactory = createTimeSeriesSourceOperator(Integer.MAX_VALUE, between(1, 100), randomBoolean(), writer -> {
|
|
|
- List<Doc> docs = new ArrayList<>();
|
|
|
- for (Pod pod : pods) {
|
|
|
- for (int i = 0; i < pod.times.length; i++) {
|
|
|
- docs.add(new Doc(pod.name, pod.times[i], pod.values[i]));
|
|
|
- }
|
|
|
- }
|
|
|
- Randomness.shuffle(docs);
|
|
|
- for (Doc doc : docs) {
|
|
|
- writeTS(writer, doc.timestamp, new Object[] { "pod", doc.pod }, new Object[] { "requests", doc.requests });
|
|
|
- }
|
|
|
- return docs.size();
|
|
|
- });
|
|
|
- var ctx = driverContext();
|
|
|
- HashAggregationOperator finalHash = new HashAggregationOperator(
|
|
|
- List.of(new RateLongAggregatorFunctionSupplier(List.of(1, 2, 3), unitInMillis).groupingAggregatorFactory(AggregatorMode.FINAL)),
|
|
|
- () -> BlockHash.build(
|
|
|
- List.of(new HashAggregationOperator.GroupSpec(0, ElementType.BYTES_REF)),
|
|
|
- ctx.blockFactory(),
|
|
|
- randomIntBetween(1, 1000),
|
|
|
- randomBoolean()
|
|
|
- ),
|
|
|
- ctx
|
|
|
- );
|
|
|
- List<Page> results = new ArrayList<>();
|
|
|
- var requestsField = new NumberFieldMapper.NumberFieldType("requests", NumberFieldMapper.NumberType.LONG);
|
|
|
- var podField = new KeywordFieldMapper.KeywordFieldType("pod");
|
|
|
- if (randomBoolean()) {
|
|
|
- HashAggregationOperator initialHash = new HashAggregationOperator(
|
|
|
- List.of(
|
|
|
- new RateLongAggregatorFunctionSupplier(List.of(4, 2), unitInMillis).groupingAggregatorFactory(AggregatorMode.INITIAL)
|
|
|
- ),
|
|
|
- () -> BlockHash.build(
|
|
|
- List.of(new HashAggregationOperator.GroupSpec(3, ElementType.BYTES_REF)),
|
|
|
- ctx.blockFactory(),
|
|
|
- randomIntBetween(1, 1000),
|
|
|
- randomBoolean()
|
|
|
- ),
|
|
|
- ctx
|
|
|
- );
|
|
|
- OperatorTestCase.runDriver(
|
|
|
- new Driver(
|
|
|
- ctx,
|
|
|
- sourceOperatorFactory.get(ctx),
|
|
|
- List.of(
|
|
|
- ValuesSourceReaderOperatorTests.factory(reader, podField, ElementType.BYTES_REF).get(ctx),
|
|
|
- ValuesSourceReaderOperatorTests.factory(reader, requestsField, ElementType.LONG).get(ctx),
|
|
|
- initialHash,
|
|
|
- finalHash
|
|
|
- ),
|
|
|
- new TestResultPageSinkOperator(results::add),
|
|
|
- () -> {}
|
|
|
- )
|
|
|
- );
|
|
|
- } else {
|
|
|
- var blockLoader = new BlockDocValuesReader.BytesRefsFromOrdsBlockLoader("pod");
|
|
|
- var shardContext = new ValuesSourceReaderOperator.ShardContext(reader, () -> SourceLoader.FROM_STORED_SOURCE);
|
|
|
- var ordinalGrouping = new OrdinalsGroupingOperator(
|
|
|
- shardIdx -> blockLoader,
|
|
|
- List.of(shardContext),
|
|
|
- ElementType.BYTES_REF,
|
|
|
- 0,
|
|
|
- "pod",
|
|
|
- List.of(
|
|
|
- new RateLongAggregatorFunctionSupplier(List.of(3, 2), unitInMillis).groupingAggregatorFactory(AggregatorMode.INITIAL)
|
|
|
- ),
|
|
|
- randomIntBetween(1, 1000),
|
|
|
- ctx
|
|
|
- );
|
|
|
- OperatorTestCase.runDriver(
|
|
|
- new Driver(
|
|
|
- ctx,
|
|
|
- sourceOperatorFactory.get(ctx),
|
|
|
- List.of(
|
|
|
- ValuesSourceReaderOperatorTests.factory(reader, requestsField, ElementType.LONG).get(ctx),
|
|
|
- ordinalGrouping,
|
|
|
- finalHash
|
|
|
- ),
|
|
|
- new TestResultPageSinkOperator(results::add),
|
|
|
- () -> {}
|
|
|
- )
|
|
|
- );
|
|
|
- }
|
|
|
- Map<String, Double> rates = new HashMap<>();
|
|
|
- for (Page result : results) {
|
|
|
- BytesRefBlock keysBlock = result.getBlock(0);
|
|
|
- DoubleBlock ratesBlock = result.getBlock(1);
|
|
|
- for (int i = 0; i < result.getPositionCount(); i++) {
|
|
|
- rates.put(keysBlock.getBytesRef(i, new BytesRef()).utf8ToString(), ratesBlock.getDouble(i));
|
|
|
- }
|
|
|
- result.releaseBlocks();
|
|
|
- }
|
|
|
- return rates;
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
protected Operator.OperatorFactory simple() {
|
|
|
- return createTimeSeriesSourceOperator(1, 1, false, writer -> {
|
|
|
+ return createTimeSeriesSourceOperator(directory, r -> this.reader = r, 1, 1, false, TimeValue.ZERO, writer -> {
|
|
|
long timestamp = DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER.parseMillis("2024-01-01T00:00:00Z");
|
|
|
writeTS(writer, timestamp, new Object[] { "hostname", "host-01" }, new Object[] { "voltage", 2 });
|
|
|
return 1;
|
|
@@ -390,18 +228,26 @@ public class TimeSeriesSortedSourceOperatorTests extends AnyOperatorTestCase {
|
|
|
|
|
|
List<Page> runDriver(int limit, int maxPageSize, boolean forceMerge, int numTimeSeries, int numSamplesPerTS, long timestampStart) {
|
|
|
var ctx = driverContext();
|
|
|
- var timeSeriesFactory = createTimeSeriesSourceOperator(limit, maxPageSize, forceMerge, writer -> {
|
|
|
- long timestamp = timestampStart;
|
|
|
- for (int i = 0; i < numSamplesPerTS; i++) {
|
|
|
- for (int j = 0; j < numTimeSeries; j++) {
|
|
|
- String hostname = String.format(Locale.ROOT, "host-%02d", j);
|
|
|
- writeTS(writer, timestamp, new Object[] { "hostname", hostname }, new Object[] { "voltage", j + 5 });
|
|
|
+ var timeSeriesFactory = createTimeSeriesSourceOperator(
|
|
|
+ directory,
|
|
|
+ indexReader -> this.reader = indexReader,
|
|
|
+ limit,
|
|
|
+ maxPageSize,
|
|
|
+ forceMerge,
|
|
|
+ TimeValue.ZERO,
|
|
|
+ writer -> {
|
|
|
+ long timestamp = timestampStart;
|
|
|
+ for (int i = 0; i < numSamplesPerTS; i++) {
|
|
|
+ for (int j = 0; j < numTimeSeries; j++) {
|
|
|
+ String hostname = String.format(Locale.ROOT, "host-%02d", j);
|
|
|
+ writeTS(writer, timestamp, new Object[] { "hostname", hostname }, new Object[] { "voltage", j + 5 });
|
|
|
+ }
|
|
|
+ timestamp += 10_000;
|
|
|
+ writer.commit();
|
|
|
}
|
|
|
- timestamp += 10_000;
|
|
|
- writer.commit();
|
|
|
+ return numTimeSeries * numSamplesPerTS;
|
|
|
}
|
|
|
- return numTimeSeries * numSamplesPerTS;
|
|
|
- });
|
|
|
+ );
|
|
|
|
|
|
List<Page> results = new ArrayList<>();
|
|
|
var voltageField = new NumberFieldMapper.NumberFieldType("voltage", NumberFieldMapper.NumberType.LONG);
|
|
@@ -426,16 +272,20 @@ public class TimeSeriesSortedSourceOperatorTests extends AnyOperatorTestCase {
|
|
|
return results;
|
|
|
}
|
|
|
|
|
|
- TimeSeriesSortedSourceOperatorFactory createTimeSeriesSourceOperator(
|
|
|
+ public static TimeSeriesSortedSourceOperatorFactory createTimeSeriesSourceOperator(
|
|
|
+ Directory directory,
|
|
|
+ Consumer<IndexReader> readerConsumer,
|
|
|
int limit,
|
|
|
int maxPageSize,
|
|
|
boolean forceMerge,
|
|
|
+ TimeValue timeValue,
|
|
|
CheckedFunction<RandomIndexWriter, Integer, IOException> indexingLogic
|
|
|
) {
|
|
|
Sort sort = new Sort(
|
|
|
new SortField(TimeSeriesIdFieldMapper.NAME, SortField.Type.STRING, false),
|
|
|
new SortedNumericSortField(DataStreamTimestampFieldMapper.DEFAULT_PATH, SortField.Type.LONG, true)
|
|
|
);
|
|
|
+ IndexReader reader;
|
|
|
try (
|
|
|
RandomIndexWriter writer = new RandomIndexWriter(
|
|
|
random(),
|
|
@@ -449,16 +299,17 @@ public class TimeSeriesSortedSourceOperatorTests extends AnyOperatorTestCase {
|
|
|
writer.forceMerge(1);
|
|
|
}
|
|
|
reader = writer.getReader();
|
|
|
+ readerConsumer.accept(reader);
|
|
|
assertThat(reader.numDocs(), equalTo(numDocs));
|
|
|
} catch (IOException e) {
|
|
|
throw new UncheckedIOException(e);
|
|
|
}
|
|
|
var ctx = new LuceneSourceOperatorTests.MockShardContext(reader, 0);
|
|
|
Function<ShardContext, Query> queryFunction = c -> new MatchAllDocsQuery();
|
|
|
- return TimeSeriesSortedSourceOperatorFactory.create(limit, maxPageSize, 1, List.of(ctx), queryFunction);
|
|
|
+ return TimeSeriesSortedSourceOperatorFactory.create(limit, maxPageSize, 1, timeValue, List.of(ctx), queryFunction);
|
|
|
}
|
|
|
|
|
|
- static void writeTS(RandomIndexWriter iw, long timestamp, Object[] dimensions, Object[] metrics) throws IOException {
|
|
|
+ public static void writeTS(RandomIndexWriter iw, long timestamp, Object[] dimensions, Object[] metrics) throws IOException {
|
|
|
final List<IndexableField> fields = new ArrayList<>();
|
|
|
fields.add(new SortedNumericDocValuesField(DataStreamTimestampFieldMapper.DEFAULT_PATH, timestamp));
|
|
|
fields.add(new LongPoint(DataStreamTimestampFieldMapper.DEFAULT_PATH, timestamp));
|