You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2021/08/13 02:27:23 UTC

[skywalking] branch banyandb-client-api updated: Begin to build the bulk process.

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch banyandb-client-api
in repository https://gitbox.apache.org/repos/asf/skywalking.git


The following commit(s) were added to refs/heads/banyandb-client-api by this push:
     new d02d34e  Begin to build the bulk process.
d02d34e is described below

commit d02d34edc4762efc3d4673c353a67d10cb15021c
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Fri Aug 13 10:26:59 2021 +0800

    Begin to build the bulk process.
---
 oap-server/banyandb-java-client/pom.xml            |   4 +
 .../banyandb/v1/client/BanyanDBClient.java         |  71 +++++++--
 .../banyandb/v1/client/BulkWriteProcessor.java     |  78 ++++++++++
 .../skywalking/banyandb/v1/client/Options.java     |  35 +++++
 .../skywalking/banyandb/v1/client/TraceWrite.java  |  53 +++++++
 .../skywalking/banyandb/v1/client/WriteField.java  |  62 ++++++++
 .../v1/{banyandb.proto => banyandb-trace.proto}    | 173 +++++----------------
 .../src/main/proto/banyandb/v1/banyandb.proto      |  82 +---------
 8 files changed, 322 insertions(+), 236 deletions(-)

diff --git a/oap-server/banyandb-java-client/pom.xml b/oap-server/banyandb-java-client/pom.xml
index 2213c3b..3898053 100644
--- a/oap-server/banyandb-java-client/pom.xml
+++ b/oap-server/banyandb-java-client/pom.xml
@@ -44,6 +44,10 @@
             <version>${org.apache.tomcat.annotations-api.version}</version>
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.skywalking</groupId>
+            <artifactId>apm-datacarrier</artifactId>
+        </dependency>
     </dependencies>
 
     <build>
diff --git a/oap-server/banyandb-java-client/src/main/java/org/apache/skywalking/banyandb/v1/client/BanyanDBClient.java b/oap-server/banyandb-java-client/src/main/java/org/apache/skywalking/banyandb/v1/client/BanyanDBClient.java
index a9e5610..dcf3a80 100644
--- a/oap-server/banyandb-java-client/src/main/java/org/apache/skywalking/banyandb/v1/client/BanyanDBClient.java
+++ b/oap-server/banyandb-java-client/src/main/java/org/apache/skywalking/banyandb/v1/client/BanyanDBClient.java
@@ -23,16 +23,15 @@ import io.grpc.ManagedChannelBuilder;
 import io.grpc.NameResolverRegistry;
 import io.grpc.internal.DnsNameResolverProvider;
 import io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
+import java.util.concurrent.locks.ReentrantLock;
 import lombok.Setter;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.banyandb.v1.trace.TraceServiceGrpc;
 
 /**
  * BanyanDBClient represents a client instance interacting with BanyanDB server. This is built on the top of BanyanDB v1
  * gRPC APIs.
  */
-@RequiredArgsConstructor
 @Slf4j
 public class BanyanDBClient {
     /**
@@ -57,35 +56,73 @@ public class BanyanDBClient {
      */
     private volatile ManagedChannel managedChannel;
     /**
+     * gRPC client stub
+     */
+    private volatile TraceServiceGrpc.TraceServiceStub traceServiceStub;
+    /**
      * The connection status.
      */
     private volatile boolean isConnected = false;
+    /**
+     * A lock to control the race condition in establishing and disconnecting network connection.
+     */
+    private volatile ReentrantLock connectionEstablishLock;
 
     /**
-     * Connect to the server.
+     * Create a BanyanDB client instance
      *
-     * @throws RuntimeException if server is not reachable.
+     * @param host  IP or domain name
+     * @param port  Server port
+     * @param group Database instance name
      */
-    public void connect() {
-        NameResolverRegistry.getDefaultRegistry().register(new DnsNameResolverProvider());
+    public BanyanDBClient(final String host, final int port, final String group) {
+        this(host, port, group, new Options());
+    }
 
-        final ManagedChannelBuilder nettyChannelBuilder = NettyChannelBuilder.forAddress(host, port);
-        nettyChannelBuilder.maxInboundMessageSize(options.getMaxInboundMessageSize());
+    /**
+     * Create a BanyanDB client instance with custom options
+     *
+     * @param host    IP or domain name
+     * @param port    Server port
+     * @param group   Database instance name
+     * @param options for database connection
+     */
+    public BanyanDBClient(final String host,
+                          final int port,
+                          final String group,
+                          final Options options) {
+        this.host = host;
+        this.port = port;
+        this.group = group;
+        this.options = options;
+        this.connectionEstablishLock = new ReentrantLock();
 
-        managedChannel = nettyChannelBuilder.build();
-        isConnected = true;
+        NameResolverRegistry.getDefaultRegistry().register(new DnsNameResolverProvider());
     }
 
     /**
-     * Client connection options.
+     * Connect to the server.
+     *
+     * @throws RuntimeException if server is not reachable.
      */
-    @Setter
-    @Getter
-    public class Options {
-        private int maxInboundMessageSize = 1024 * 1024 * 50;
+    public void connect() {
+        connectionEstablishLock.lock();
+        try {
+            if (!isConnected) {
+                final ManagedChannelBuilder nettyChannelBuilder = NettyChannelBuilder.forAddress(host, port);
+                nettyChannelBuilder.maxInboundMessageSize(options.getMaxInboundMessageSize());
 
-        private Options() {
+                managedChannel = nettyChannelBuilder.build();
+                traceServiceStub = TraceServiceGrpc.newStub(managedChannel);
+                isConnected = true;
+            }
+        } finally {
+            connectionEstablishLock.unlock();
         }
+    }
+
+    public void writeTrace(TraceWrite write) {
 
     }
+
 }
diff --git a/oap-server/banyandb-java-client/src/main/java/org/apache/skywalking/banyandb/v1/client/BulkWriteProcessor.java b/oap-server/banyandb-java-client/src/main/java/org/apache/skywalking/banyandb/v1/client/BulkWriteProcessor.java
new file mode 100644
index 0000000..f689e28
--- /dev/null
+++ b/oap-server/banyandb-java-client/src/main/java/org/apache/skywalking/banyandb/v1/client/BulkWriteProcessor.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.banyandb.v1.client;
+
+import java.util.List;
+import org.apache.skywalking.apm.commons.datacarrier.DataCarrier;
+import org.apache.skywalking.apm.commons.datacarrier.consumer.IConsumer;
+
+/**
+ * BulkWriteProcessor is a timeline and size dual driven processor.
+ *
+ * It includes an internal queue and timer, and accept the data sequentially. With the given thresholds of time and
+ * size, it could activate {@link #flush()} to continue the process to the next step.
+ */
+public abstract class BulkWriteProcessor<T> {
+    private DataCarrier queue;
+
+    /**
+     * Create the processor.
+     *
+     * @param maxBulkSize   the max bulk size for the flush operation
+     * @param flushInterval if given maxBulkSize is not reached in this period, the flush would be trigger
+     *                      automatically
+     * @param concurrency   the number of concurrency would run for the flush max.
+     */
+    protected BulkWriteProcessor(String processorName, int maxBulkSize, int flushInterval, int concurrency) {
+        this.queue = new DataCarrier(processorName, maxBulkSize * 2, 2);
+        queue.consume(QueueWatcher.class, concurrency);
+    }
+
+    /**
+     * The internal queue consumer for buld process.
+     */
+    private static class QueueWatcher implements IConsumer {
+        @Override
+        public void init() {
+
+        }
+
+        @Override
+        public void consume(final List data) {
+
+        }
+
+        @Override
+        public void onError(final List data, final Throwable t) {
+
+        }
+
+        @Override
+        public void onExit() {
+
+        }
+
+        @Override
+        public void nothingToConsume() {
+
+        }
+    }
+
+    protected abstract void flush();
+}
diff --git a/oap-server/banyandb-java-client/src/main/java/org/apache/skywalking/banyandb/v1/client/Options.java b/oap-server/banyandb-java-client/src/main/java/org/apache/skywalking/banyandb/v1/client/Options.java
new file mode 100644
index 0000000..5e9f48c
--- /dev/null
+++ b/oap-server/banyandb-java-client/src/main/java/org/apache/skywalking/banyandb/v1/client/Options.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.banyandb.v1.client;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * Client connection options.
+ */
+@Setter
+@Getter
+public class Options {
+    private int maxInboundMessageSize = 1024 * 1024 * 50;
+
+    Options() {
+    }
+
+}
\ No newline at end of file
diff --git a/oap-server/banyandb-java-client/src/main/java/org/apache/skywalking/banyandb/v1/client/TraceWrite.java b/oap-server/banyandb-java-client/src/main/java/org/apache/skywalking/banyandb/v1/client/TraceWrite.java
new file mode 100644
index 0000000..c4d72bf
--- /dev/null
+++ b/oap-server/banyandb-java-client/src/main/java/org/apache/skywalking/banyandb/v1/client/TraceWrite.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.banyandb.v1.client;
+
+import java.util.List;
+import lombok.AccessLevel;
+import lombok.Builder;
+import lombok.Getter;
+
+/**
+ * TraceWrite represents a write operation, including necessary fields, for {@link
+ * BanyanDBClient#writeTrace(TraceWrite)}.
+ */
+@Builder
+@Getter(AccessLevel.PROTECTED)
+public class TraceWrite {
+    /**
+     * Ower name current entity
+     */
+    private final String name;
+    /**
+     * ID of current entity
+     */
+    private final String entityId;
+    /**
+     * Timestamp represents the time of current trace or trace segment.
+     */
+    private final long timestamp;
+    /**
+     * The binary raw data represents the whole object of current trace or trace segment. It could be organized by
+     * different serialization formats. Natively, SkyWalking uses protobuf, but it is not required. The BanyanDB server
+     * wouldn't deserialize this. So, no format requirement.
+     */
+    private final byte[] binary;
+    private final List<WriteField> fields;
+
+}
diff --git a/oap-server/banyandb-java-client/src/main/java/org/apache/skywalking/banyandb/v1/client/WriteField.java b/oap-server/banyandb-java-client/src/main/java/org/apache/skywalking/banyandb/v1/client/WriteField.java
new file mode 100644
index 0000000..f4bf858
--- /dev/null
+++ b/oap-server/banyandb-java-client/src/main/java/org/apache/skywalking/banyandb/v1/client/WriteField.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.banyandb.v1.client;
+
+import lombok.RequiredArgsConstructor;
+
+/**
+ * WriteField represents a value of column/field for a write-op value.
+ */
+public interface WriteField {
+    class NullField {
+
+    }
+
+    /**
+     * The value of a String type field.
+     */
+    @RequiredArgsConstructor
+    class StringField {
+        private final String value;
+    }
+
+    /**
+     * The value of a String array type field.
+     */
+    @RequiredArgsConstructor
+    class StringArrayField {
+        private final String[] value;
+    }
+
+    /**
+     * The value of an int64(Long) type field.
+     */
+    @RequiredArgsConstructor
+    class LongField {
+        private final long value;
+    }
+
+    /**
+     * The value of an int64(Long) array type field.
+     */
+    @RequiredArgsConstructor
+    class LongArrayField {
+        private final long[] value;
+    }
+}
diff --git a/oap-server/banyandb-java-client/src/main/proto/banyandb/v1/banyandb.proto b/oap-server/banyandb-java-client/src/main/proto/banyandb/v1/banyandb-trace.proto
similarity index 56%
copy from oap-server/banyandb-java-client/src/main/proto/banyandb/v1/banyandb.proto
copy to oap-server/banyandb-java-client/src/main/proto/banyandb/v1/banyandb-trace.proto
index a468d3b..d59798e 100644
--- a/oap-server/banyandb-java-client/src/main/proto/banyandb/v1/banyandb.proto
+++ b/oap-server/banyandb-java-client/src/main/proto/banyandb/v1/banyandb-trace.proto
@@ -17,122 +17,17 @@
 
 syntax = "proto3";
 
-option java_package = "org.apache.skywalking.banyandb.v1";
+option java_package = "org.apache.skywalking.banyandb.v1.trace";
 
-package banyandb.v1;
+package banyandb.v1.trace;
 
 import "google/protobuf/timestamp.proto";
 import "google/protobuf/struct.proto";
+import "banyandb/v1/banyandb.proto";
 
 service TraceService {
-  rpc Query(banyandb.v1.QueryRequest) returns (banyandb.v1.QueryResponse);
-  rpc Write(stream banyandb.v1.WriteRequest) returns (stream banyandb.v1.WriteResponse);
-}
-
-// Metadata is for multi-tenant, multi-model use
-message Metadata {
-  // group contains a set of options, like retention policy, max
-  string group = 1;
-  // name of the entity
-  string name = 2;
-}
-
-// IntPair in a typed pair with an array of int64 as values
-message IntPair {
-  string key = 1;
-  repeated int64 values = 2;
-}
-
-// StrPair in a typed pair with an array of string as values
-message StrPair {
-  string key = 1;
-  repeated string values = 2;
-}
-
-// Pair is the building block of a record which is equivalent to a key-value pair.
-// In the context of Trace, it could be metadata of a trace such as service_name, service_instance, etc.
-// Besides, other fields/tags are organized in key-value pair in the underlying storage layer.
-// One should notice that the values can be a multi-value.
-message TypedPair {
-  oneof typed {
-    IntPair int_pair = 1;
-    StrPair str_pair = 2;
-  }
-}
-
-// PairQuery consists of the query condition with a single binary operator to be imposed
-// For 1:1 BinaryOp, values in condition must be an array with length = 1,
-// while for 1:N BinaryOp, values can be an array with length >= 1.
-message PairQuery {
-  // BinaryOp specifies the operation imposed to the given query condition
-  // For EQ, NE, LT, GT, LE and GE, only one operand should be given, i.e. one-to-one relationship.
-  // HAVING and NOT_HAVING allow multi-value to be the operand such as array/vector, i.e. one-to-many relationship.
-  // For example, "keyA" contains "valueA" **and** "valueB"
-  enum BinaryOp {
-    BINARY_OP_UNSPECIFIED = 0;
-    BINARY_OP_EQ = 1;
-    BINARY_OP_NE = 2;
-    BINARY_OP_LT = 3;
-    BINARY_OP_GT = 4;
-    BINARY_OP_LE = 5;
-    BINARY_OP_GE = 6;
-    BINARY_OP_HAVING = 7;
-    BINARY_OP_NOT_HAVING = 8;
-  }
-  BinaryOp op = 1;
-  TypedPair condition = 2;
-}
-
-// QueryOrder means a Sort operation to be done for a given field.
-// The key_name refers to the key of a Pair.
-message QueryOrder {
-  string key_name = 1;
-  enum Sort {
-    SORT_UNSPECIFIED = 0;
-    SORT_DESC = 1;
-    SORT_ASC = 2;
-  }
-  Sort sort = 2;
-}
-
-// Entity represents
-// (Trace context) a Span defined in Google Dapper paper or equivalently a Segment in Skywalking.
-// (Log context) a log
-message Entity {
-  // entity_id could be span_id of a Span or segment_id of a Segment in the context of Trace
-  string entity_id = 1;
-  // timestamp represents
-  // 1) either the start time of a Span/Segment,
-  // 2) or the timestamp of a log
-  google.protobuf.Timestamp timestamp = 2;
-  // data_binary contains all un-indexed Tags and other key-value pairs
-  bytes data_binary = 3;
-  // fields contains all indexed Field. Some typical names,
-  // - trace_id
-  // - duration
-  // - service_name
-  // - service_instance_id
-  // - end_time_nanoseconds
-  repeated TypedPair fields = 4;
-}
-
-// QueryResponse is the response for a query to the Query module.
-message QueryResponse {
-  // entities are the actual data returned
-  repeated Entity entities = 1;
-}
-
-// Projection is used to select the names of keys to be returned.
-message Projection {
-  // The key_name refers to the key(s) of Pair(s).
-  repeated string key_names = 1;
-}
-
-// TimeRange is a range query for uint64,
-// the range here follows left-inclusive and right-exclusive rule, i.e. [begin, end) if both edges exist
-message TimeRange {
-  google.protobuf.Timestamp begin = 1;
-  google.protobuf.Timestamp end = 2;
+  rpc Query(banyandb.v1.trace.QueryRequest) returns (banyandb.v1.trace.QueryResponse);
+  rpc Write(stream banyandb.v1.trace.WriteRequest) returns (stream banyandb.v1.trace.WriteResponse);
 }
 
 // QueryRequest is the request contract for query.
@@ -158,31 +53,42 @@ message QueryRequest {
   Projection projection = 7;
 }
 
-message Str {
-  string value = 1;
+// QueryResponse is the response for a query to the Query module.
+message QueryResponse {
+  // entities are the actual data returned
+  repeated Entity entities = 1;
 }
 
-message Int {
-  int64 value = 1;
+// Entity represents
+// (Trace context) a Span defined in Google Dapper paper or equivalently a Segment in Skywalking.
+// (Log context) a log
+message Entity {
+  // entity_id could be span_id of a Span or segment_id of a Segment in the context of Trace
+  string entity_id = 1;
+  // timestamp represents
+  // 1) either the start time of a Span/Segment,
+  // 2) or the timestamp of a log
+  google.protobuf.Timestamp timestamp = 2;
+  // data_binary contains all un-indexed Tags and other key-value pairs
+  bytes data_binary = 3;
+  // fields contains all indexed Field. Some typical names,
+  // - trace_id
+  // - duration
+  // - service_name
+  // - service_instance_id
+  // - end_time_nanoseconds
+  repeated TypedPair fields = 4;
 }
 
-message StrArray {
-  repeated string value = 1;
-}
 
-message IntArray {
-  repeated int64 value = 1;
+message WriteRequest {
+  // the metadata is only required in the first write.
+  Metadata metadata = 1;
+  // the entity is required.
+  EntityValue entity = 2;
 }
 
-message Field {
-  oneof value_type {
-    google.protobuf.NullValue null = 1;
-    Str str = 2;
-    StrArray str_array = 3;
-    Int int = 4;
-    IntArray int_array = 5;
-  }
-}
+message WriteResponse {}
 
 message EntityValue {
   // entity_id could be span_id of a Span or segment_id of a Segment in the context of Trace
@@ -198,13 +104,4 @@ message EntityValue {
   // by the index rules and index rule bindings of Metadata group.
   // indexed fields of multiple entities are compression in the fields.
   repeated Field fields = 4;
-}
-
-message WriteRequest {
-  // the metadata is only required in the first write.
-  Metadata metadata = 1;
-  // the entity is required.
-  EntityValue entity = 2;
-}
-
-message WriteResponse {}
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/oap-server/banyandb-java-client/src/main/proto/banyandb/v1/banyandb.proto b/oap-server/banyandb-java-client/src/main/proto/banyandb/v1/banyandb.proto
index a468d3b..bcf30fa 100644
--- a/oap-server/banyandb-java-client/src/main/proto/banyandb/v1/banyandb.proto
+++ b/oap-server/banyandb-java-client/src/main/proto/banyandb/v1/banyandb.proto
@@ -24,11 +24,6 @@ package banyandb.v1;
 import "google/protobuf/timestamp.proto";
 import "google/protobuf/struct.proto";
 
-service TraceService {
-  rpc Query(banyandb.v1.QueryRequest) returns (banyandb.v1.QueryResponse);
-  rpc Write(stream banyandb.v1.WriteRequest) returns (stream banyandb.v1.WriteResponse);
-}
-
 // Metadata is for multi-tenant, multi-model use
 message Metadata {
   // group contains a set of options, like retention policy, max
@@ -95,33 +90,6 @@ message QueryOrder {
   Sort sort = 2;
 }
 
-// Entity represents
-// (Trace context) a Span defined in Google Dapper paper or equivalently a Segment in Skywalking.
-// (Log context) a log
-message Entity {
-  // entity_id could be span_id of a Span or segment_id of a Segment in the context of Trace
-  string entity_id = 1;
-  // timestamp represents
-  // 1) either the start time of a Span/Segment,
-  // 2) or the timestamp of a log
-  google.protobuf.Timestamp timestamp = 2;
-  // data_binary contains all un-indexed Tags and other key-value pairs
-  bytes data_binary = 3;
-  // fields contains all indexed Field. Some typical names,
-  // - trace_id
-  // - duration
-  // - service_name
-  // - service_instance_id
-  // - end_time_nanoseconds
-  repeated TypedPair fields = 4;
-}
-
-// QueryResponse is the response for a query to the Query module.
-message QueryResponse {
-  // entities are the actual data returned
-  repeated Entity entities = 1;
-}
-
 // Projection is used to select the names of keys to be returned.
 message Projection {
   // The key_name refers to the key(s) of Pair(s).
@@ -135,29 +103,6 @@ message TimeRange {
   google.protobuf.Timestamp end = 2;
 }
 
-// QueryRequest is the request contract for query.
-message QueryRequest {
-  // metadata is required
-  Metadata metadata = 1;
-  // time_range is a range query with begin/end time of entities in the timeunit of nanoseconds.
-  // In the context of Trace, it represents the range of the `startTime` for spans/segments,
-  // while in the context of Log, it means the range of the timestamp(s) for logs.
-  // it is always recommended to specify time range for performance reason
-  TimeRange time_range = 2;
-  // offset is used to support pagination, together with the following limit
-  uint32 offset = 3;
-  // limit is used to impose a boundary on the number of records being returned
-  uint32 limit = 4;
-  // order_by is given to specify the sort for a field. So far, only fields in the type of Integer are supported
-  QueryOrder order_by = 5;
-  // fields are indexed. Some typical fields are listed below,
-  // - trace_id: if given, it takes precedence over other fields and will be used to retrieve entities before other conditions are imposed
-  // - duration: typical for trace context
-  repeated PairQuery fields = 6;
-  // projection can be used to select the key names of the entities in the response
-  Projection projection = 7;
-}
-
 message Str {
   string value = 1;
 }
@@ -182,29 +127,4 @@ message Field {
     Int int = 4;
     IntArray int_array = 5;
   }
-}
-
-message EntityValue {
-  // entity_id could be span_id of a Span or segment_id of a Segment in the context of Trace
-  string entity_id = 1;
-  // timestamp_nanoseconds is in the timeunit of nanoseconds. It represents
-  // 1) either the start time of a Span/Segment,
-  // 2) or the timestamp of a log
-  google.protobuf.Timestamp timestamp = 2;
-  // binary representation of segments, including tags, spans...
-  bytes data_binary = 3;
-  // support all of indexed fields in the fields.
-  // Pair only has value, as the value of PairValue match with the key
-  // by the index rules and index rule bindings of Metadata group.
-  // indexed fields of multiple entities are compression in the fields.
-  repeated Field fields = 4;
-}
-
-message WriteRequest {
-  // the metadata is only required in the first write.
-  Metadata metadata = 1;
-  // the entity is required.
-  EntityValue entity = 2;
-}
-
-message WriteResponse {}
\ No newline at end of file
+}
\ No newline at end of file