|
|
|
@ -230,92 +230,92 @@ public abstract class BaseTimeseriesServiceTest extends AbstractServiceTest { |
|
|
|
public void testFindByQuery_whenPeriodHaveTwoIntervalWithEqualsLength() throws Exception { |
|
|
|
DeviceId deviceId = new DeviceId(Uuids.timeBased()); |
|
|
|
saveEntries(deviceId, TS - 1L); |
|
|
|
for (long i = TS; i <= TS + 100L; i += 10L) { |
|
|
|
for (long i = TS; i <= TS + 100000L; i += 10000L) { |
|
|
|
saveEntries(deviceId, i); |
|
|
|
} |
|
|
|
saveEntries(deviceId, TS + 100L + 1L); |
|
|
|
saveEntries(deviceId, TS + 100000L + 1L); |
|
|
|
|
|
|
|
List<ReadTsKvQuery> queries = List.of(new BaseReadTsKvQuery(LONG_KEY, TS, TS + 99, 50, 1, Aggregation.COUNT, DESC_ORDER)); |
|
|
|
List<ReadTsKvQuery> queries = List.of(new BaseReadTsKvQuery(LONG_KEY, TS, TS + 99999, 50000, 1, Aggregation.COUNT, DESC_ORDER)); |
|
|
|
|
|
|
|
List<TsKvEntry> entries = tsService.findAll(tenantId, deviceId, queries).get(); |
|
|
|
Assert.assertEquals(2, entries.size()); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 25, new LongDataEntry(LONG_KEY, 5L)), entries.get(0)); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 75, new LongDataEntry(LONG_KEY, 5L)), entries.get(1)); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 25000, new LongDataEntry(LONG_KEY, 5L)), entries.get(0)); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 75000, new LongDataEntry(LONG_KEY, 5L)), entries.get(1)); |
|
|
|
|
|
|
|
EntityView entityView = saveAndCreateEntityView(deviceId, List.of(LONG_KEY)); |
|
|
|
|
|
|
|
entries = tsService.findAll(tenantId, entityView.getId(), queries).get(); |
|
|
|
Assert.assertEquals(2, entries.size()); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 25, new LongDataEntry(LONG_KEY, 5L)), entries.get(0)); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 75, new LongDataEntry(LONG_KEY, 5L)), entries.get(1)); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 25000, new LongDataEntry(LONG_KEY, 5L)), entries.get(0)); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 75000, new LongDataEntry(LONG_KEY, 5L)), entries.get(1)); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void testFindByQuery_whenPeriodHaveTwoInterval_whereSecondShorterThanFirst() throws Exception { |
|
|
|
DeviceId deviceId = new DeviceId(Uuids.timeBased()); |
|
|
|
saveEntries(deviceId, TS - 1L); |
|
|
|
for (long i = TS; i <= TS + 80L; i += 10L) { |
|
|
|
for (long i = TS; i <= TS + 80000L; i += 10000L) { |
|
|
|
saveEntries(deviceId, i); |
|
|
|
} |
|
|
|
saveEntries(deviceId, TS + 80L + 1L); |
|
|
|
saveEntries(deviceId, TS + 80000L + 1L); |
|
|
|
|
|
|
|
List<ReadTsKvQuery> queries = List.of(new BaseReadTsKvQuery(LONG_KEY, TS, TS + 80, 50, 1, Aggregation.COUNT, DESC_ORDER)); |
|
|
|
List<ReadTsKvQuery> queries = List.of(new BaseReadTsKvQuery(LONG_KEY, TS, TS + 80000, 50000, 1, Aggregation.COUNT, DESC_ORDER)); |
|
|
|
|
|
|
|
List<TsKvEntry> entries = tsService.findAll(tenantId, deviceId, queries).get(); |
|
|
|
Assert.assertEquals(2, entries.size()); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 25, new LongDataEntry(LONG_KEY, 5L)), entries.get(0)); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 65, new LongDataEntry(LONG_KEY, 4L)), entries.get(1)); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 25000, new LongDataEntry(LONG_KEY, 5L)), entries.get(0)); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 65000, new LongDataEntry(LONG_KEY, 4L)), entries.get(1)); |
|
|
|
|
|
|
|
EntityView entityView = saveAndCreateEntityView(deviceId, List.of(LONG_KEY)); |
|
|
|
|
|
|
|
entries = tsService.findAll(tenantId, entityView.getId(), queries).get(); |
|
|
|
Assert.assertEquals(2, entries.size()); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 25, new LongDataEntry(LONG_KEY, 5L)), entries.get(0)); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 65, new LongDataEntry(LONG_KEY, 4L)), entries.get(1)); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 25000, new LongDataEntry(LONG_KEY, 5L)), entries.get(0)); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 65000, new LongDataEntry(LONG_KEY, 4L)), entries.get(1)); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void testFindByQuery_whenPeriodHaveTwoIntervalWithEqualsLength_whereNotAllEntriesInRange() throws Exception { |
|
|
|
DeviceId deviceId = new DeviceId(Uuids.timeBased()); |
|
|
|
for (long i = TS - 1L; i <= TS + 100L + 1L; i += 10) { |
|
|
|
for (long i = TS - 1L; i <= TS + 100000L + 1L; i += 10000) { |
|
|
|
saveEntries(deviceId, i); |
|
|
|
} |
|
|
|
|
|
|
|
List<ReadTsKvQuery> queries = List.of(new BaseReadTsKvQuery(LONG_KEY, TS, TS + 99, 50, 1, Aggregation.COUNT, DESC_ORDER)); |
|
|
|
List<ReadTsKvQuery> queries = List.of(new BaseReadTsKvQuery(LONG_KEY, TS, TS + 99999, 50000, 1, Aggregation.COUNT, DESC_ORDER)); |
|
|
|
|
|
|
|
List<TsKvEntry> entries = tsService.findAll(tenantId, deviceId, queries).get(); |
|
|
|
Assert.assertEquals(2, entries.size()); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 25, new LongDataEntry(LONG_KEY, 5L)), entries.get(0)); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 75, new LongDataEntry(LONG_KEY, 5L)), entries.get(1)); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 25000, new LongDataEntry(LONG_KEY, 5L)), entries.get(0)); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 75000, new LongDataEntry(LONG_KEY, 5L)), entries.get(1)); |
|
|
|
|
|
|
|
EntityView entityView = saveAndCreateEntityView(deviceId, List.of(LONG_KEY)); |
|
|
|
|
|
|
|
entries = tsService.findAll(tenantId, entityView.getId(), queries).get(); |
|
|
|
Assert.assertEquals(2, entries.size()); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 25, new LongDataEntry(LONG_KEY, 5L)), entries.get(0)); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 75, new LongDataEntry(LONG_KEY, 5L)), entries.get(1)); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 25000, new LongDataEntry(LONG_KEY, 5L)), entries.get(0)); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 75000, new LongDataEntry(LONG_KEY, 5L)), entries.get(1)); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void testFindByQuery_whenPeriodHaveTwoInterval_whereSecondShorterThanFirst_andNotAllEntriesInRange() throws Exception { |
|
|
|
DeviceId deviceId = new DeviceId(Uuids.timeBased()); |
|
|
|
for (long i = TS - 1L; i <= TS + 100L + 1L; i += 10L) { |
|
|
|
for (long i = TS - 1L; i <= TS + 100000L + 1L; i += 10000L) { |
|
|
|
saveEntries(deviceId, i); |
|
|
|
} |
|
|
|
|
|
|
|
List<ReadTsKvQuery> queries = List.of(new BaseReadTsKvQuery(LONG_KEY, TS, TS + 80, 50, 1, Aggregation.COUNT, DESC_ORDER)); |
|
|
|
List<ReadTsKvQuery> queries = List.of(new BaseReadTsKvQuery(LONG_KEY, TS, TS + 80000, 50000, 1, Aggregation.COUNT, DESC_ORDER)); |
|
|
|
|
|
|
|
List<TsKvEntry> entries = tsService.findAll(tenantId, deviceId, queries).get(); |
|
|
|
Assert.assertEquals(2, entries.size()); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 25, new LongDataEntry(LONG_KEY, 5L)), entries.get(0)); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 65, new LongDataEntry(LONG_KEY, 3L)), entries.get(1)); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 25000, new LongDataEntry(LONG_KEY, 5L)), entries.get(0)); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 65000, new LongDataEntry(LONG_KEY, 3L)), entries.get(1)); |
|
|
|
|
|
|
|
EntityView entityView = saveAndCreateEntityView(deviceId, List.of(LONG_KEY)); |
|
|
|
|
|
|
|
entries = tsService.findAll(tenantId, entityView.getId(), queries).get(); |
|
|
|
Assert.assertEquals(2, entries.size()); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 25, new LongDataEntry(LONG_KEY, 5L)), entries.get(0)); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 65, new LongDataEntry(LONG_KEY, 3L)), entries.get(1)); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 25000, new LongDataEntry(LONG_KEY, 5L)), entries.get(0)); |
|
|
|
Assert.assertEquals(toTsEntry(TS + 65000, new LongDataEntry(LONG_KEY, 3L)), entries.get(1)); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
|