DeleteHistoryRange
Delete historical data by time range.
Regulatory Requirements
Data deletion is a highly sensitive operation. Regulated industries (such as pharmaceuticals and food) require that data be "never deleted" or that "deletions must be auditable." Server-side implementations may include additional safeguards.
Signature
Status DeleteHistoryRange(
std::string const& node_id,
int64_t start_ft,
int64_t end_ft,
bool delete_modified_too = false);
| Parameters | Note |
|---|---|
| node_id | Objective NodeId |
| start_ft | Range starts at (FileTime) |
| end_ft | Range Stop (FileTime) |
| delete_modified_too | true = Delete the history of modifications; false = Delete the original history |
Usage
constexpr int64_t WIN_EPOCH_OFFSET = 116444736000000000LL;
auto now_ns = std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::system_clock::now().time_since_epoch()).count();
int64_t now_ft = WIN_EPOCH_OFFSET + now_ns / 100;
// Delete data from [30 days ago, 7 days ago]
int64_t end_ft = now_ft - 7LL * 24 * 3600 * 10000000;
int64_t start_ft = now_ft - 30LL * 24 * 3600 * 10000000;
auto st = s.DeleteHistoryRange("ns=2;s=Temperature", start_ft, end_ft);
if (st != Status::Good) {
std::cerr << "Delete failed: 0x" << std::hex << static_cast<uint32_t>(st) << "\n";
}
Other Deletion Semantics
To delete a single entry from a list at a specified point in time, use UpdateHistory(..., HistoryUpdateType::Remove, ...) Use SourceTimestamp to select the point you want to delete; deleting by event is not currently supported.
Regulatory Constraints
- Never Delete (Only Allow Marking as Obsolete)
- 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 Status::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 extended use
std::thread, we recommend running the app in the background to prevent it from freezing UI.