Delete Historical Data
Data deletion is a highly sensitive operation; regulated industries (pharmaceuticals, food, etc.) require that data be "never deleted" or that "deletions must be auditable." Server-side implementations may include additional safeguards.
deleteHistoryRange
Delete all data points within the specified time range.
public Enums.StatusCode deleteHistoryRange(
String nodeId,
Instant start,
Instant end,
boolean deleteModifiedToo);
| Parameters | Note |
|---|---|
| nodeId | Objective NodeId |
| start / end | Interval (UTC Instant, inclusive) |
| deleteModifiedToo | Mutually Exclusive Choice: true = Delete modified history; false = Delete raw history |
Returns Enums.StatusCode (Good = Deleted successfully).
import java.time.Instant;
import java.time.Duration;
Enums.StatusCode st = ua.deleteHistoryRange(
"ns=2;s=Temperature",
Instant.now().minus(Duration.ofDays(30)),
Instant.now().minus(Duration.ofDays(7)),
false);
if (st != Enums.StatusCode.Good) {
System.err.println("Delete failed: " + st);
}
Delete a Single Time Point (Go updateHistory)
Deleting single-point data values based on timestamps is done using the expression updateHistory(..., HistoryUpdateType.REMOVE, ...) (the values array uses only the SourceTimestamp field; the value field is ignored); a separate deleteAtTime method is no longer provided. For details, see HistoryUpdate.
There is no way to delete historical events by event ID: HistoryUpdateType Only the four data operations—INSERT, REPLACE, UPDATE, and REMOVE—are available, none of which involve deleting events.
Regulatory Constraints
- Never Delete (Only "obsolete" tags allowed)
- Deletions must be logged for auditing purposes (who deleted it, when, and why).
The server-side implementation may include additional safeguards. The client may receive BadUserAccessDenied.
Performance
- The server may be blocked for an extended period during a large-range DELETE operation. The duration varies depending on the server and the range size; the timeout/wait time should be set based on actual server performance tests.
- For operations that take a long time, we recommend using asynchronous processing to avoid UI freezes.
// Asynchronous Examples
import java.util.concurrent.CompletableFuture;
CompletableFuture<Enums.StatusCode> f = CompletableFuture.supplyAsync(() ->
ua.deleteHistoryRange("ns=2;s=Temperature",
Instant.now().minus(Duration.ofDays(30)),
Instant.now().minus(Duration.ofDays(7)),
false));
f.thenAccept(st -> System.out.println("Delete done: " + st));