Skip to content

Commit

Permalink
fix cpp example
Browse files Browse the repository at this point in the history
  • Loading branch information
atimin committed Sep 11, 2024
1 parent dbd1f41 commit 8d44e62
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 73 deletions.
2 changes: 1 addition & 1 deletion docs/examples/cpp/src/data_management_delete_query.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ int main() {
assert(err == Error::kOk);

// Delete all records withing a time range
auto [removed_records, query_err] = bucket->RemoveQuery("cpp-example", ts, ts + 1s, {});
auto [removed_records, query_err] = bucket->RemoveQuery("cpp-example", ts, ts + 2s, {});
assert(query_err == Error::kOk);
assert(removed_records == 2);

Expand Down
12 changes: 9 additions & 3 deletions docs/examples/js/src/data_management_delete_query.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ record = await bucket.beginWrite("entry-1", timestamp + 1000_000n);
await record.write("Some more binary data");

// Delete all records withing a time range
const removedRecords = await bucket.removeQuery("entry-1", timestamp, timestamp + 2000_000n);
const removedRecords = await bucket.removeQuery(
"entry-1",
timestamp,
timestamp + 2000_000n,
);
assert(removedRecords === 2);

// You can also delete all records with a specific label
await bucket.removeQuery("entry-1", undefined, undefined, { include: { label1: "value1" } });
await bucket.removeQuery("entry-1", undefined, undefined, {
include: { label1: "value1" },
});

// Or each N-th record
await bucket.removeQuery("entry-1", undefined, undefined, { eachN: 2 });
await bucket.removeQuery("entry-1", undefined, undefined, { eachN: 2 });
138 changes: 69 additions & 69 deletions docs/guides/data-management.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";

<head>
<link
rel="canonical"
href="https://www.reduct.store/docs/guides/data-management"
/>
<link
rel="canonical"
href="https://www.reduct.store/docs/guides/data-management"
/>
</head>

# Data Management With ReductStore
Expand All @@ -34,21 +34,21 @@ import ChangeLabelsCpp from "!!raw-loader!../examples/cpp/src/data_management_up
import ChangeLabelsCurl from "!!raw-loader!../examples/curl/data_management_update_labels.sh";

<Tabs>
<TabItem value="Python">
<CodeBlock language="python">{ChangeLabelsPy}</CodeBlock>
</TabItem>
<TabItem value="JavaScript">
<CodeBlock language="javascript">{ChangeLabelsJs}</CodeBlock>
</TabItem>
<TabItem value="Rust">
<CodeBlock language="rust">{ChangeLabelsRs}</CodeBlock>
</TabItem>
<TabItem value="C++">
<CodeBlock language="cpp">{ChangeLabelsCpp}</CodeBlock>
</TabItem>
<TabItem value="cURL">
<CodeBlock language="bash">{ChangeLabelsCurl}</CodeBlock>
</TabItem>
<TabItem value="Python">
<CodeBlock language="python">{ChangeLabelsPy}</CodeBlock>
</TabItem>
<TabItem value="JavaScript">
<CodeBlock language="javascript">{ChangeLabelsJs}</CodeBlock>
</TabItem>
<TabItem value="Rust">
<CodeBlock language="rust">{ChangeLabelsRs}</CodeBlock>
</TabItem>
<TabItem value="C++">
<CodeBlock language="cpp">{ChangeLabelsCpp}</CodeBlock>
</TabItem>
<TabItem value="cURL">
<CodeBlock language="bash">{ChangeLabelsCurl}</CodeBlock>
</TabItem>
</Tabs>

## Deleting Data
Expand All @@ -68,24 +68,24 @@ import DeleteDataCli from "!!raw-loader!../examples/cli/data_management_delete_d
import DeleteDataCurl from "!!raw-loader!../examples/curl/data_management_delete_data.sh";

<Tabs>
<TabItem value="Python">
<CodeBlock language="python">{DeleteDataPy}</CodeBlock>
</TabItem>
<TabItem value="JavaScript">
<CodeBlock language="javascript">{DeleteDataJs}</CodeBlock>
</TabItem>
<TabItem value="Rust">
<CodeBlock language="rust">{DeleteDataRs}</CodeBlock>
</TabItem>
<TabItem value="C++">
<CodeBlock language="cpp">{DeleteDataCpp}</CodeBlock>
</TabItem>
<TabItem value="CLI">
<CodeBlock language="bash">{DeleteDataCli}</CodeBlock>
</TabItem>
<TabItem value="cURL">
<CodeBlock language="bash">{DeleteDataCurl}</CodeBlock>
</TabItem>
<TabItem value="Python">
<CodeBlock language="python">{DeleteDataPy}</CodeBlock>
</TabItem>
<TabItem value="JavaScript">
<CodeBlock language="javascript">{DeleteDataJs}</CodeBlock>
</TabItem>
<TabItem value="Rust">
<CodeBlock language="rust">{DeleteDataRs}</CodeBlock>
</TabItem>
<TabItem value="C++">
<CodeBlock language="cpp">{DeleteDataCpp}</CodeBlock>
</TabItem>
<TabItem value="CLI">
<CodeBlock language="bash">{DeleteDataCli}</CodeBlock>
</TabItem>
<TabItem value="cURL">
<CodeBlock language="bash">{DeleteDataCurl}</CodeBlock>
</TabItem>
</Tabs>

### Deleting Specific Records
Expand All @@ -99,29 +99,29 @@ import DeleteRecordsCpp from "!!raw-loader!../examples/cpp/src/data_management_d
import DeleteRecordsCurl from "!!raw-loader!../examples/curl/data_management_delete_records.sh";

<Tabs>
<TabItem value="Python">
<CodeBlock language="python">{DeleteRecordsPy}</CodeBlock>
</TabItem>
<TabItem value="JavaScript">
<CodeBlock language="javascript">{DeleteRecordsJs}</CodeBlock>
</TabItem>
<TabItem value="Rust">
<CodeBlock language="rust">{DeleteRecordsRs}</CodeBlock>
</TabItem>
<TabItem value="C++">
<CodeBlock language="cpp">{DeleteRecordsCpp}</CodeBlock>
</TabItem>
<TabItem value="cURL">
<CodeBlock language="bash">{DeleteRecordsCurl}</CodeBlock>
</TabItem>
<TabItem value="Python">
<CodeBlock language="python">{DeleteRecordsPy}</CodeBlock>
</TabItem>
<TabItem value="JavaScript">
<CodeBlock language="javascript">{DeleteRecordsJs}</CodeBlock>
</TabItem>
<TabItem value="Rust">
<CodeBlock language="rust">{DeleteRecordsRs}</CodeBlock>
</TabItem>
<TabItem value="C++">
<CodeBlock language="cpp">{DeleteRecordsCpp}</CodeBlock>
</TabItem>
<TabItem value="cURL">
<CodeBlock language="bash">{DeleteRecordsCurl}</CodeBlock>
</TabItem>
</Tabs>

### Deleting Records in a Time Range

You can delete records in a specific time range by specifying the start and end timestamps, and you can use query parameters to filter the records:

| Parameter | Description | Type | Default |
|-----------|-----------------------------------|-------------------------|------------------------------------------------|
| --------- | --------------------------------- | ----------------------- | ---------------------------------------------- |
| `start` | Remove records from | Timestamp | The timestamp of the first record in the entry |
| `end` | Remove records until | Timestamp | The timestamp of the last record in the entry |
| `include` | Remove only records with labels | List of key-value pairs | Disabled |
Expand All @@ -138,23 +138,23 @@ import DeleteRecordsRangeCpp from "!!raw-loader!../examples/cpp/src/data_managem
import DeleteRecordsRangeCurl from "!!raw-loader!../examples/curl/data_management_delete_query.sh";

<Tabs>
<TabItem value="Python">
<CodeBlock language="python">{DeleteRecordsRangePy}</CodeBlock>
</TabItem>
<TabItem value="JavaScript">
<CodeBlock language="javascript">{DeleteRecordsRangeJs}</CodeBlock>
</TabItem>
<TabItem value="Rust">
<CodeBlock language="rust">{DeleteRecordsRangeRs}</CodeBlock>
</TabItem>
<TabItem value="C++">
<CodeBlock language="cpp">{DeleteRecordsRangeCpp}</CodeBlock>
</TabItem>
<TabItem value="cURL">
<CodeBlock language="bash">{DeleteRecordsRangeCurl}</CodeBlock>
</TabItem>
<TabItem value="Python">
<CodeBlock language="python">{DeleteRecordsRangePy}</CodeBlock>
</TabItem>
<TabItem value="JavaScript">
<CodeBlock language="javascript">{DeleteRecordsRangeJs}</CodeBlock>
</TabItem>
<TabItem value="Rust">
<CodeBlock language="rust">{DeleteRecordsRangeRs}</CodeBlock>
</TabItem>
<TabItem value="C++">
<CodeBlock language="cpp">{DeleteRecordsRangeCpp}</CodeBlock>
</TabItem>
<TabItem value="cURL">
<CodeBlock language="bash">{DeleteRecordsRangeCurl}</CodeBlock>
</TabItem>
</Tabs>

:::info
Deleting records in a time range is a heavy operation and may take a long time to complete because it copies the retained records to new blocks and deletes the old ones.
:::
:::

0 comments on commit 8d44e62

Please sign in to comment.