From c5a963d68181d9bb9b9a583f361b0e3f3838c890 Mon Sep 17 00:00:00 2001 From: JeremyHi Date: Mon, 11 Mar 2024 20:52:01 +0800 Subject: [PATCH] chore: add some comment about naming convention (#37) --- .../main/java/io/greptime/models/Column.java | 7 ++++++ .../java/io/greptime/models/TableSchema.java | 22 ++++++++++++++++++- .../greptime/options/GreptimeOptionsTest.java | 4 ++++ .../main/java/io/greptime/rpc/RpcOptions.java | 1 - 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/ingester-protocol/src/main/java/io/greptime/models/Column.java b/ingester-protocol/src/main/java/io/greptime/models/Column.java index f711fa9..d2f74fb 100644 --- a/ingester-protocol/src/main/java/io/greptime/models/Column.java +++ b/ingester-protocol/src/main/java/io/greptime/models/Column.java @@ -29,6 +29,13 @@ @Target(ElementType.FIELD) public @interface Column { + /** + * The name of the column in the table. + *

+ * It is strongly recommended to use snake case naming convention and avoid + * using camel case. This is because GreptimeDB treats column names as + * case-insensitive, which can cause confusion when querying with camel case. + */ String name(); boolean tag() default false; diff --git a/ingester-protocol/src/main/java/io/greptime/models/TableSchema.java b/ingester-protocol/src/main/java/io/greptime/models/TableSchema.java index 012d145..aabdba9 100644 --- a/ingester-protocol/src/main/java/io/greptime/models/TableSchema.java +++ b/ingester-protocol/src/main/java/io/greptime/models/TableSchema.java @@ -77,6 +77,10 @@ public Builder(String tableName) { /** * Add tag schema. + *

+ * It is strongly recommended to use snake case naming convention and avoid + * using camel case. This is because GreptimeDB treats column names as + * case-insensitive, which can cause confusion when querying with camel case. * * @param name the name of this tag * @param dataType the data type of this tag @@ -88,6 +92,10 @@ public Builder addTag(String name, DataType dataType) { /** * Add timestamp schema. + *

+ * It is strongly recommended to use snake case naming convention and avoid + * using camel case. This is because GreptimeDB treats column names as + * case-insensitive, which can cause confusion when querying with camel case. * * @param name the name of this timestamp * @param dataType the data type of this timestamp @@ -101,6 +109,10 @@ public Builder addTimestamp(String name, DataType dataType) { /** * Add field schema. + *

+ * It is strongly recommended to use snake case naming convention and avoid + * using camel case. This is because GreptimeDB treats column names as + * case-insensitive, which can cause confusion when querying with camel case. * * @param name the name of this field * @param dataType the data type of this field @@ -112,6 +124,10 @@ public Builder addField(String name, DataType dataType) { /** * Add column schema. + *

+ * It is strongly recommended to use snake case naming convention and avoid + * using camel case. This is because GreptimeDB treats column names as + * case-insensitive, which can cause confusion when querying with camel case. * * @param name the name of this column * @param semanticType the semantic type of this column (`Tag`, `Field` or `Timestamp`) @@ -124,6 +140,10 @@ public Builder addColumn(String name, SemanticType semanticType, DataType dataTy /** * Add column schema. + *

+ * It is strongly recommended to use snake case naming convention and avoid + * using camel case. This is because GreptimeDB treats column names as + * case-insensitive, which can cause confusion when querying with camel case. * * @param name the name of this column * @param semanticType the semantic type of this column (`Tag`, `Field` or `Timestamp`) @@ -144,7 +164,7 @@ public Builder addColumn(String name, // "Invalid timestamp data type: %s, only support `DataType.TimestampXXX`", dataType); } - // trim leading and trailing spaces + // Trim leading and trailing spaces name = name.trim(); this.columnNames.add(name); diff --git a/ingester-protocol/src/test/java/io/greptime/options/GreptimeOptionsTest.java b/ingester-protocol/src/test/java/io/greptime/options/GreptimeOptionsTest.java index 6ecf8dc..d86d270 100644 --- a/ingester-protocol/src/test/java/io/greptime/options/GreptimeOptionsTest.java +++ b/ingester-protocol/src/test/java/io/greptime/options/GreptimeOptionsTest.java @@ -20,6 +20,7 @@ import io.greptime.limit.LimitedPolicy; import io.greptime.models.AuthInfo; import io.greptime.rpc.RpcOptions; +import io.greptime.rpc.TlsOptions; import org.junit.Assert; import org.junit.Test; import java.util.List; @@ -44,10 +45,12 @@ public void testAllOptions() { long routeTableRefreshPeriodSeconds = 99; AuthInfo authInfo = new AuthInfo("user", "password"); Router router = createTestRouter(); + TlsOptions tlsOptions = new TlsOptions(); GreptimeOptions opts = GreptimeOptions.newBuilder(endpoints, database) // .asyncPool(asyncPool) // .rpcOptions(rpcOptions) // + .tlsOptions(tlsOptions) // .writeMaxRetries(writeMaxRetries) // .maxInFlightWritePoints(maxInFlightWritePoints) // .writeLimitedPolicy(limitedPolicy) // @@ -60,6 +63,7 @@ public void testAllOptions() { Assert.assertEquals(database, opts.getDatabase()); Assert.assertArrayEquals(endpoints, opts.getEndpoints().stream().map(Endpoint::toString).toArray()); Assert.assertEquals(rpcOptions, opts.getRpcOptions()); + Assert.assertEquals(tlsOptions, opts.getRpcOptions().getTlsOptions()); RouterOptions routerOptions = opts.getRouterOptions(); Assert.assertNotNull(routerOptions); diff --git a/ingester-rpc/src/main/java/io/greptime/rpc/RpcOptions.java b/ingester-rpc/src/main/java/io/greptime/rpc/RpcOptions.java index 08d19d8..d1d92c1 100644 --- a/ingester-rpc/src/main/java/io/greptime/rpc/RpcOptions.java +++ b/ingester-rpc/src/main/java/io/greptime/rpc/RpcOptions.java @@ -16,7 +16,6 @@ package io.greptime.rpc; import io.greptime.common.Copiable; -import java.util.Optional; import java.util.concurrent.TimeUnit; /**