Skip to content

Commit

Permalink
Merge branch 'main' into dev_support_arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
hanahmily authored Aug 19, 2024
2 parents 4b10a06 + b05e53c commit ed92e8e
Show file tree
Hide file tree
Showing 7 changed files with 232 additions and 54 deletions.
13 changes: 13 additions & 0 deletions api/proto/banyandb/database/v1/rpc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -483,3 +483,16 @@ service TopNAggregationRegistryService {
// Exist doesn't expose an HTTP endpoint. Please use HEAD method to touch Get instead
rpc Exist(TopNAggregationRegistryServiceExistRequest) returns (TopNAggregationRegistryServiceExistResponse);
}

message MeasureAggregateFunctionServiceSupportRequest {}

message MeasureAggregateFunctionServiceSupportResponse {
repeated banyandb.database.v1.MeasureAggregateFunction measure_aggregate_function = 1;
}

service MeasureAggregateFunctionService {
// Support doesn't need metadata, it's static and stateless.
rpc Support(MeasureAggregateFunctionServiceSupportRequest) returns (MeasureAggregateFunctionServiceSupportResponse) {
option (google.api.http) = {get: "/v1/measure-agg/schema/support"};
}
}
10 changes: 10 additions & 0 deletions api/proto/banyandb/database/v1/schema.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ syntax = "proto3";
package banyandb.database.v1;

import "banyandb/common/v1/common.proto";
import "banyandb/model/v1/common.proto";
import "banyandb/model/v1/query.proto";
import "google/protobuf/timestamp.proto";
import "validate/validate.proto";
Expand Down Expand Up @@ -95,6 +96,8 @@ message FieldSpec {
EncodingMethod encoding_method = 3 [(validate.rules).enum.defined_only = true];
// compression_method indicates how to compress data during writing
CompressionMethod compression_method = 4 [(validate.rules).enum.defined_only = true];
// aggregate_function indicates how to aggregate data
model.v1.AggregationFunction aggregate_function = 5;
}

// Measure intends to store data point
Expand All @@ -114,6 +117,13 @@ message Measure {
google.protobuf.Timestamp updated_at = 6;
}

message MeasureAggregateFunction {
// type indicates the type of function argument
FieldType type = 1 [(validate.rules).enum.defined_only = true];
// aggregate_function indicates specific function for measure data
model.v1.MeasureAggregate aggregate_function = 2;
}

// TopNAggregation generates offline TopN statistics for a measure's TopN approximation
message TopNAggregation {
// metadata is the identity of an aggregation
Expand Down
26 changes: 26 additions & 0 deletions api/proto/banyandb/model/v1/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,29 @@ enum AggregationFunction {
AGGREGATION_FUNCTION_COUNT = 4;
AGGREGATION_FUNCTION_SUM = 5;
}

enum MeasureAggregate {
MEASURE_AGGREGATE_UNSPECIFIED = 0;
// Calculate the minimum value of delta measures.
MEASURE_AGGREGATE_MIN = 1;
// Calculate the maximum value of delta measures.
MEASURE_AGGREGATE_MAX = 2;
// Count the number of delta measures.
MEASURE_AGGREGATE_COUNT = 3;
// Calculate the sum value of delta measures.
MEASURE_AGGREGATE_SUM = 4;
// Calculate the average value of delta measures.
MEASURE_AGGREGATE_AVG = 5;
// Calculate the percentage of delta measures, where the input matches with the condition.
MEASURE_AGGREGATE_PERCENT = 6;
// Calculate the ratio for measures, where the input matches with the condition.
MEASURE_AGGREGATE_RATE = 7;
// Calculate the histogram for delta measures.
MEASURE_AGGREGATE_HISTOGRAM = 8;
// Calculate the {p99, p95, p90, p75, p50} for delta measures.
MEASURE_AGGREGATE_PERCENTILE2 = 9;
// Calculate the apdex for delta measures.
MEASURE_AGGREGATE_APDEX = 10;
// Same like PERCENTILE2, little different on algorithm.
MEASURE_AGGREGATE_PERCENTILE = 11;
}
79 changes: 79 additions & 0 deletions docs/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
- [TagValue](#banyandb-model-v1-TagValue)

- [AggregationFunction](#banyandb-model-v1-AggregationFunction)
- [MeasureAggregate](#banyandb-model-v1-MeasureAggregate)

- [banyandb/model/v1/query.proto](#banyandb_model_v1_query-proto)
- [Condition](#banyandb-model-v1-Condition)
Expand All @@ -62,6 +63,7 @@
- [IndexRule](#banyandb-database-v1-IndexRule)
- [IndexRuleBinding](#banyandb-database-v1-IndexRuleBinding)
- [Measure](#banyandb-database-v1-Measure)
- [MeasureAggregateFunction](#banyandb-database-v1-MeasureAggregateFunction)
- [Stream](#banyandb-database-v1-Stream)
- [Subject](#banyandb-database-v1-Subject)
- [TagFamilySpec](#banyandb-database-v1-TagFamilySpec)
Expand Down Expand Up @@ -112,6 +114,8 @@
- [IndexRuleRegistryServiceListResponse](#banyandb-database-v1-IndexRuleRegistryServiceListResponse)
- [IndexRuleRegistryServiceUpdateRequest](#banyandb-database-v1-IndexRuleRegistryServiceUpdateRequest)
- [IndexRuleRegistryServiceUpdateResponse](#banyandb-database-v1-IndexRuleRegistryServiceUpdateResponse)
- [MeasureAggregateFunctionServiceSupportRequest](#banyandb-database-v1-MeasureAggregateFunctionServiceSupportRequest)
- [MeasureAggregateFunctionServiceSupportResponse](#banyandb-database-v1-MeasureAggregateFunctionServiceSupportResponse)
- [MeasureRegistryServiceCreateRequest](#banyandb-database-v1-MeasureRegistryServiceCreateRequest)
- [MeasureRegistryServiceCreateResponse](#banyandb-database-v1-MeasureRegistryServiceCreateResponse)
- [MeasureRegistryServiceDeleteRequest](#banyandb-database-v1-MeasureRegistryServiceDeleteRequest)
Expand Down Expand Up @@ -152,6 +156,7 @@
- [GroupRegistryService](#banyandb-database-v1-GroupRegistryService)
- [IndexRuleBindingRegistryService](#banyandb-database-v1-IndexRuleBindingRegistryService)
- [IndexRuleRegistryService](#banyandb-database-v1-IndexRuleRegistryService)
- [MeasureAggregateFunctionService](#banyandb-database-v1-MeasureAggregateFunctionService)
- [MeasureRegistryService](#banyandb-database-v1-MeasureRegistryService)
- [StreamRegistryService](#banyandb-database-v1-StreamRegistryService)
- [TopNAggregationRegistryService](#banyandb-database-v1-TopNAggregationRegistryService)
Expand Down Expand Up @@ -690,6 +695,28 @@ Trace is the top level message of a trace.
| AGGREGATION_FUNCTION_SUM | 5 | |



<a name="banyandb-model-v1-MeasureAggregate"></a>

### MeasureAggregate


| Name | Number | Description |
| ---- | ------ | ----------- |
| MEASURE_AGGREGATE_UNSPECIFIED | 0 | |
| MEASURE_AGGREGATE_MIN | 1 | Calculate the minimum value of delta measures. |
| MEASURE_AGGREGATE_MAX | 2 | Calculate the maximum value of delta measures. |
| MEASURE_AGGREGATE_COUNT | 3 | Count the number of delta measures. |
| MEASURE_AGGREGATE_SUM | 4 | Calculate the sum value of delta measures. |
| MEASURE_AGGREGATE_AVG | 5 | Calculate the average value of delta measures. |
| MEASURE_AGGREGATE_PERCENT | 6 | Calculate the percentage of delta measures, where the input matches with the condition. |
| MEASURE_AGGREGATE_RATE | 7 | Calculate the ratio for measures, where the input matches with the condition. |
| MEASURE_AGGREGATE_HISTOGRAM | 8 | Calculate the histogram for delta measures. |
| MEASURE_AGGREGATE_PERCENTILE2 | 9 | Calculate the {p99, p95, p90, p75, p50} for delta measures. |
| MEASURE_AGGREGATE_APDEX | 10 | Calculate the apdex for delta measures. |
| MEASURE_AGGREGATE_PERCENTILE | 11 | Same like PERCENTILE2, little different on algorithm. |





Expand Down Expand Up @@ -954,6 +981,7 @@ FieldSpec is the specification of field
| field_type | [FieldType](#banyandb-database-v1-FieldType) | | field_type denotes the type of field value |
| encoding_method | [EncodingMethod](#banyandb-database-v1-EncodingMethod) | | encoding_method indicates how to encode data during writing |
| compression_method | [CompressionMethod](#banyandb-database-v1-CompressionMethod) | | compression_method indicates how to compress data during writing |
| aggregate_function | [banyandb.model.v1.AggregationFunction](#banyandb-model-v1-AggregationFunction) | | aggregate_function indicates how to aggregate data |



Expand Down Expand Up @@ -1023,6 +1051,22 @@ Measure intends to store data point



<a name="banyandb-database-v1-MeasureAggregateFunction"></a>

### MeasureAggregateFunction



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| type | [FieldType](#banyandb-database-v1-FieldType) | | type indicates the type of function argument |
| aggregate_function | [banyandb.model.v1.MeasureAggregate](#banyandb-model-v1-MeasureAggregate) | | aggregate_function indicates specific function for measure data |






<a name="banyandb-database-v1-Stream"></a>

### Stream
Expand Down Expand Up @@ -1717,6 +1761,31 @@ Type determine the index structure under the hood



<a name="banyandb-database-v1-MeasureAggregateFunctionServiceSupportRequest"></a>

### MeasureAggregateFunctionServiceSupportRequest







<a name="banyandb-database-v1-MeasureAggregateFunctionServiceSupportResponse"></a>

### MeasureAggregateFunctionServiceSupportResponse



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| measure_aggregate_function | [MeasureAggregateFunction](#banyandb-database-v1-MeasureAggregateFunction) | repeated | |






<a name="banyandb-database-v1-MeasureRegistryServiceCreateRequest"></a>

### MeasureRegistryServiceCreateRequest
Expand Down Expand Up @@ -2301,6 +2370,16 @@ Type determine the index structure under the hood
| Exist | [IndexRuleRegistryServiceExistRequest](#banyandb-database-v1-IndexRuleRegistryServiceExistRequest) | [IndexRuleRegistryServiceExistResponse](#banyandb-database-v1-IndexRuleRegistryServiceExistResponse) | Exist doesn&#39;t expose an HTTP endpoint. Please use HEAD method to touch Get instead |


<a name="banyandb-database-v1-MeasureAggregateFunctionService"></a>

### MeasureAggregateFunctionService


| Method Name | Request Type | Response Type | Description |
| ----------- | ------------ | ------------- | ------------|
| Support | [MeasureAggregateFunctionServiceSupportRequest](#banyandb-database-v1-MeasureAggregateFunctionServiceSupportRequest) | [MeasureAggregateFunctionServiceSupportResponse](#banyandb-database-v1-MeasureAggregateFunctionServiceSupportResponse) | Support doesn&#39;t need metadata, it&#39;s static and stateless. |


<a name="banyandb-database-v1-MeasureRegistryService"></a>

### MeasureRegistryService
Expand Down
102 changes: 102 additions & 0 deletions docs/interacting/data-lifecycle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Data Lifecycle

## [Measures](../concept/data-model.md#measures) and [Streams](../concept/data-model.md#streams)

Due to the design of BanyanDB, the data in the `Measures and Streams` can not be deleted directly.
The data will be deleted automatically based on the [Groups](../concept/data-model.md#groups) `TTL` setting.

The TTL means the `time to live` of the data in the group.
Each group has an internal trigger which is triggered by writing events. If there is no further data, the expired data can’t get removed.

For example, the following command will create a group with a TTL of 7 days:
```shell
bydbctl group create -f - <<EOF
metadata:
name: sw_metric
catalog: CATALOG_MEASURE
resource_opts:
shard_num: 2
segment_interval:
unit: UNIT_DAY
num: 1
ttl:
unit: UNIT_DAY
num: 7
EOF
```
The data in this group will keep 7 days.

If you want to change the `TTL` of the data in this group to be 1 day, use the command:

```shell
bydbctl group update -f - <<EOF
metadata:
name: sw_metric
catalog: CATALOG_MEASURE
resource_opts:
shard_num: 2
segment_interval:
unit: UNIT_DAY
num: 1
ttl:
unit: UNIT_DAY
num: 1
EOF
```

More ttl units can be found in the [IntervalRule.Unit](../api-reference.md#intervalruleunit).

You can also manage the Group by other clients such as [Web-UI](./web-ui/schema/group.md) or [Java-Client](java-client.md).

## [Property](../concept/data-model.md#properties)

`Property` data provides both [CRUD](./bydbctl/property.md) operations and TTL mechanism.

The TTL field in a property is used to set the time to live of the property. The property will be deleted automatically after the TTL.
It's a string in the format of "1h", "2m", "3s", "1500ms". It defaults to 0s, which means the property never expires.

For example, the following command will create a property with a TTL of 1 hour:

```shell
bydbctl property apply -f - <<EOF
metadata:
container:
group: sw
name: temp_data
id: General-Service
tags:
- key: state
value:
str:
value: "failed"
ttl: "1h"
EOF
```

"General-Service" will be dropped after 1 hour. If you want to extend the TTL, you could use the "keepalive" operation. The "lease_id" is returned in the apply response.
You can use get operation to get the property with the lease_id as well.

```shell
bydbctl property get -g sw -n temp_data --id General-Service
```

```yaml
...
lease_id: 7587880824757265022
```
The lease_id is used to keep the property alive. You can use keepalive operation to keep the property alive.
When the keepalive operation is called, the property's TTL will be reset to the original value.
```shell
bydbctl property keepalive --lease_id 7587880824757265022
```

"General-Service" lives another 1 hour.

You can also manage the Property by other clients such as [Web-UI](./web-ui/property.md) or [Java-Client](java-client.md).

## The API reference
- [Group Registration Operations](../api-reference.md#groupregistryservice)
- [ResourceOpts Definition](../api-reference.md#resourceopts)
- [PropertyService v1](../api-reference.md#propertyservice)
52 changes: 0 additions & 52 deletions docs/interacting/deleting-data.md

This file was deleted.

4 changes: 2 additions & 2 deletions docs/menu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ catalog:
path: "/interacting/web-ui/property"
- name: "Java Client"
path: "/interacting/java-client"
- name: "Deleting Data"
path: "/interacting/deleting-data"
- name: "Data Lifecycle"
path: "/interacting/data-lifecycle"
- name: "Operation and Maintenance"
catalog:
- name: "Configure BanyanDB"
Expand Down

0 comments on commit ed92e8e

Please sign in to comment.