From 84e9390904b7bc00125aa97a1642e6d00fd8666a Mon Sep 17 00:00:00 2001 From: JeremyHi Date: Fri, 12 Jan 2024 11:43:03 +0800 Subject: [PATCH] docs: add java doc (#21) --- .../java/io/greptime/models/TableSchema.java | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) 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 3e35ffa..301e51b 100644 --- a/ingester-protocol/src/main/java/io/greptime/models/TableSchema.java +++ b/ingester-protocol/src/main/java/io/greptime/models/TableSchema.java @@ -21,8 +21,13 @@ import java.util.List; /** - * Table schema for write. - * + * Table schema for write data to the database. + *

+ * If the same `TableSchema` will be used multiple times, it is advisable to cache it + * to prevent redundant creation. The responsibility of caching lies with the user, + * as the `Ingester` client should strive to avoid managing the cache and excessive + * memory consumption. + * * @author jiachun.fjc */ public class TableSchema { @@ -70,10 +75,27 @@ public Builder(String tableName) { this.tableName = tableName; } + /** + * Add column schema. + * + * @param name the name of this column + * @param semanticType the semantic type of this column (`Tag`, `Field` or `Timestamp`) + * @param dataType the data type of this column + * @return this builder + */ public Builder addColumn(String name, SemanticType semanticType, DataType dataType) { return addColumn(name, semanticType, dataType, null); } + /** + * Add column schema. + * + * @param name the name of this column + * @param semanticType the semantic type of this column (`Tag`, `Field` or `Timestamp`) + * @param dataType the data type of this column + * @param decimalTypeExtension the decimal type extension of this column(only for `DataType.Decimal128`) + * @return this builder + */ public Builder addColumn(String name, SemanticType semanticType, DataType dataType, DataType.DecimalTypeExtension decimalTypeExtension) { Ensures.ensureNonNull(name, "Null column name"); @@ -95,6 +117,11 @@ public Builder addColumn(String name, SemanticType semanticType, DataType dataTy return this; } + /** + * Build the table schema. + * + * @return the table schema + */ public TableSchema build() { Ensures.ensureNonNull(this.tableName, "Null table name"); Ensures.ensureNonNull(this.columnNames, "Null column names");