library-udf dprofile UDFs share state across queries (MvAvg/MinMax/Segment/Percentile/Histogram); gap-fill drops the inclusive endTime point

Offen
#19,304 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
java
Bereich
database, testing

Rechercherichtung

The issue identifies six defects across library-udf UDFs and AbstractGapFillOperator, and says unit tests were added in the linked PR. Start by locating those classes and reviewing the tests that reproduce each reported case. Done means each reproduction passes, including overlapping query state, non-finite input, histogram boundaries, and the inclusive endTime gap point.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Verified against current master (536dd7f) by compiling library-udf and executing the real UDF classes through their validate → beforeStart → transform/merge → terminate lifecycle; every item below was reproduced before fixing.

1. UDTFMvAvg computes (new − evicted) / w instead of a sliding mean
windowSum is a local variable of transform(), so it is reset to 0 on every row and never accumulates. With window=3 and inputs 1..5 the UDTF outputs {3=1.0, 4=1.0, 5=1.0} where the sliding mean is {3=2.0, 4=3.0, 5=4.0}.

2. UDTFMinMax desynchronises its timestamps/values tables on non-finite input
In batch mode the timestamp is appended unconditionally while the value is appended only when finite, so a single NaN row shifts every subsequent timestamp/value pair: inputs (1,1.0) (2,NaN) (3,3.0) produce {1=0.0, 2=1.0} instead of {1=0.0, 3=1.0}.

3. UDTFSegment keeps per-query data in a static final List
Every UDTF call gets a fresh instance (UDFManagementService.reflect), but the collected points live in static fields, so two overlapping segment queries clear/corrupt each other: after query B calls beforeStart, query A's terminate emits 0 points instead of its collected 5.

4. UDAFPercentile keeps the exact-count maps in 4 static Maps
Same class of defect: the anonymous PercentileOperations singleton reassigns static state in initialize(), so overlapping percentile queries lose their value→timestamp mapping (exact-mode output timestamps become 0) and the state is not thread-safe.

5. UDTFHistogram bucket computation overflows when min/max are omitted
With default (auto) boundaries end - start can overflow to +Inf, making gap = +Inf and every value fall into bucket 0: inputs 1..10 with count=10 produce {0=10} instead of a 10-bucket histogram. A value equal to max also maps to NaN → bucket 0.

6. AbstractGapFillOperator drops the gap point at an inclusive endTime
The terminal fill guard at hasRemainingGapInPreviousGroup() uses currentTime < endTime, while group switching (<=) and fillGaps treat endTime as inclusive (the constructor documents "end time(inclusive)" and the existing tests expect the endpoint row). With start=0, end=10, step=2 and the last real row at t=8, the gap row at t=10 is never emitted. Fixing the comparison to <= restores it.

All six are fixed in the linked PR with unit tests (the MvAvg and gap-fill fixes were additionally verified by temporarily reverting the source change and observing the new tests fail, then re-applying).

Vorherrschende Sprache
Java
Sterne
6.4k
Forks
1.2k
Ø Merge
1 T. 12 Std.
Gemergte PRs (30 T.)
284

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus apache/iotdb

Alle Issues in apache/iotdb

Ähnliche Issues

Weitere Issues zu Java

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.