wu-sheng commented on a change in pull request #4:
URL: 
https://github.com/apache/skywalking-banyandb-java-client/pull/4#discussion_r749047765



##########
File path: README.md
##########
@@ -19,10 +19,94 @@ Create a `BanyanDBClient` with host, port and a 
user-specified group and then es
 ```java
 // use `default` group
 client = new BanyanDBClient("127.0.0.1", 17912, "default");
-// establish a connection
+// to send any request, a connection to the server must be estabilished
 client.connect(channel);
 ```
 
+## Schema Management
+
+### Stream
+
+Then we may define a stream with customized configurations,
+
+```java
+StreamMetadataRegistry streamRegistry = client.streamRegistry();
+// build a stream "sw" with 2 shards and ttl equals to 30 days
+Stream s = new Stream("sw", 2, Duration.ofDays(30));
+s.addTagNameAsEntity("service_id").addTagNameAsEntity("service_instance_id").addTagNameAsEntity("state");
+// TagFamily - data
+TagFamilySpec dataFamily = new TagFamilySpec("data");
+dataFamily.addTagSpec(TagFamilySpec.TagSpec.newBinaryTag("data_binary"));
+s.addTagFamilySpec(dataFamily);
+// TagFamily - searchable
+TagFamilySpec searchableFamily = new TagFamilySpec("searchable");
+searchableFamily.addTagSpec(TagFamilySpec.TagSpec.newStringTag("trace_id"))
+        .addTagSpec(TagFamilySpec.TagSpec.newIntTag("state"))
+        .addTagSpec(TagFamilySpec.TagSpec.newStringTag("service_id"));
+s.addTagFamilySpec(searchableFamily);
+// create with the stream schema
+streamRegistry.create(s);
+```
+
+with `StreamMetadataRegistry`, CRUD operations are supported for `Stream`, 
`IndexRuleBinding` and `IndexRule`.
+
+### IndexRuleBinding/IndexRule
+
+For better search performance, index rules are necessary for `Stream` while 
`IndexRuleBinding` helps 
+bind the `IndexRule` to the `Stream`,
+
+```java
+IndexRuleMetadataRegistry indexRuleRegistry = client.indexRuleRegistry();
+// create IndexRule with inverted index type and save it to series store
+IndexRule indexRule = new IndexRule("db.instance", 
IndexRule.IndexType.INVERTED, IndexRule.IndexLocation.SERIES);
+// tag name specifies the indexed tag
+indexRule.addTag("db.instance");
+// create the index rule "db.instance"
+this.client.create(indexRule);
+```
+
+and then create an `IndexRuleBinding` to bind it/them to the Stream,
+
+```java
+IndexRuleBindingMetadataRegistry indexRuleBindingRegistry = 
client.indexRuleBindingRegistry();
+// define the rule binding "sw-index-rule-binding" and bind it with Stream "sw"
+IndexRuleBinding indexRuleBinding = new 
IndexRuleBinding("sw-index-rule-binding", 
IndexRuleBinding.Subject.referToStream("sw"));
+indexRuleBinding.setBeginAt(ZonedDateTime.now().minusDays(15));
+indexRuleBinding.setExpireAt(ZonedDateTime.now().plusYears(100));
+indexRuleBinding.addRule("db.instance");
+// create the index rule binding
+this.client.create(indexRuleBinding);
+```
+
+### Measure
+
+`Measure` can also be created with `MeasureMetadataRegistry`,
+
+```java
+// create a measure registry
+MeasureMetadataRegistry measureRegistry = client.measureRegistry();
+// create a new measure schema with 2 shards and ttl 30 days.
+Measure m = new Measure("measure-example", 2, Duration.ofDays(30));
+// set entity
+m.addTagNameAsEntity("service_id").addTagNameAsEntity("service_instance_id").addTagNameAsEntity("state");
+// add tag family: "searchable"
+TagFamilySpec searchableFamily = new TagFamilySpec("searchable");
+searchableFamily.addTagSpec(TagFamilySpec.TagSpec.newStringTag("trace_id"))
+    .addTagSpec(TagFamilySpec.TagSpec.newIntTag("state"))
+    .addTagSpec(TagFamilySpec.TagSpec.newStringTag("service_id"));
+m.addTagFamilySpec(searchableFamily);
+// set interval rules
+m.addIntervalRule(Measure.IntervalRule.matchStringLabel("interval", "day", 
"1d"));
+m.addIntervalRule(Measure.IntervalRule.matchNumericLabel("interval", 3600L, 
"1h"));
+// add field spec
+// compressMethod and encodingMethod can be specified
+m.addFieldSpec(Measure.FieldSpec.newIntField("tps").compressWithZSTD().encodeWithGorilla().build());
+// send create request
+measureRegistry.create(m);

Review comment:
       The APIs are not consistent. You don't have `indexRuleRegistry#create`, 
but `measureRegistry#create`.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to