Original practice scenario inspired by CNOOC Limited's public business context; this is not a reported interview question or a description of its internal systems. A fictional offshore operations dataset records a measurement whenever its value changes, with periodic heartbeats. Explain why an ordinary average may mislead and how to estimate a time-weighted daily mean.
Read model answer +
Event-triggered samples overrepresent periods when values change frequently. A time-weighted mean asks how long each value represented the process, subject to a defensible interpolation and staleness rule.
Work through it
Sort and deduplicate sensor events, normalize timestamps, and define whether values remain constant until the next reading or require another interpolation method.
Intersect each valid interval with the reporting day, multiply value by covered duration, and divide by total valid covered time. Split intervals at day boundaries.
Publish coverage and exclude intervals beyond the allowed heartbeat gap. Test midnight crossings, duplicate timestamps, missing days, and a long stale period.
Tradeoffs to discuss
A step-function estimate is transparent but may be wrong for rapidly varying processes. More sophisticated interpolation needs domain evidence and still cannot recover unobserved events exactly.
Common pitfalls
A simple row average depends on sampling behavior.
Filling an entire outage with the last value can create a precise-looking daily mean from almost no valid coverage.
Original practice scenario inspired by CNOOC Limited's public business context; this is not a reported interview question or a description of its internal systems. A synthetic field device buffers observations on disk while connectivity is unavailable. It can lose power during a write or acknowledgement. Explain a durable queue and replay protocol that avoids silent gaps.
Read model answer +
Use a crash-consistent local log with stable record identities and explicit acknowledgement checkpoints. Connectivity retries should resend the same observation, allowing the receiver to deduplicate rather than relying on exactly-once transport.
Work through it
Frame records with lengths and checksums, and define when a write is durably committed. On recovery, detect and truncate or quarantine an incomplete trailing record.
Upload bounded batches with stable IDs. Advance the local acknowledgement checkpoint only after durable remote acceptance, then reclaim acknowledged storage safely.
Test power loss at each write and checkpoint boundary, repeated acknowledgements, disk exhaustion, and a prolonged outage. Expose dropped or rejected records through counters.
Tradeoffs to discuss
Stronger durability increases write latency and storage wear. Capacity limits need an explicit retention or backpressure policy rather than an unbounded promise.
Common pitfalls
Deleting a batch when sending starts loses data on timeout.
Reusing sequence IDs after a device reset can cause valid observations to be mistaken for duplicates.