jt2594838 commented on code in PR #602: URL: https://github.com/apache/tsfile/pull/602#discussion_r2438010934
########## java/tsfile/src/main/java/org/apache/tsfile/file/metadata/IDeviceID.java: ########## @@ -47,6 +47,8 @@ public interface IDeviceID extends Comparable<IDeviceID>, Accountable, Serializa boolean isTableModel(); + String getDeviceID(); + Review Comment: Better to replace it with toString. ########## java/tsfile/src/main/java/org/apache/tsfile/write/schema/MeasurementSchemaBuilder.java: ########## @@ -0,0 +1,135 @@ +/* + * 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.tsfile.write.schema; + +import org.apache.tsfile.common.conf.TSFileDescriptor; +import org.apache.tsfile.enums.TSDataType; +import org.apache.tsfile.file.metadata.enums.CompressionType; +import org.apache.tsfile.file.metadata.enums.TSEncoding; + +import java.util.HashMap; +import java.util.Map; + +/** + * A builder class for constructing {@link MeasurementSchema} instances. + * + * <p>This builder provides a fluent API for setting various properties of a measurement schema, + * including required fields (name and data type) and optional fields (encoding and compression). + * + * <p>Example usage: + * + * <pre>{@code + * MeasurementSchema schema = new MeasurementSchemaBuilder("temperature", TSDataType.FLOAT) + * .withEncoding(TSEncoding.RLE) + * .withCompression(CompressionType.SNAPPY) + * .build(); + * }</pre> + */ +public class MeasurementSchemaBuilder { + private String measurementName; + private TSDataType dataType; + private TSEncoding encoding; + private CompressionType compressionType; + private Map<String, String> props; + + /** + * Creates a new builder with the required fields. + * + * @param measurementName the name of the measurement (cannot be null or empty) + * @param dataType the data type of the measurement (cannot be null) + * @throws IllegalArgumentException if required parameters are null or empty + */ + public MeasurementSchemaBuilder(String measurementName, TSDataType dataType) { + if (measurementName == null || measurementName.trim().isEmpty()) { + throw new IllegalArgumentException("Measurement name cannot be null or empty"); + } + if (dataType == null) { + throw new IllegalArgumentException("Data type cannot be null"); + } + + this.measurementName = measurementName; + this.dataType = dataType; + // Set default values from TSFile configuration + this.encoding = + TSEncoding.valueOf(TSFileDescriptor.getInstance().getConfig().getValueEncoder(dataType)); + this.compressionType = TSFileDescriptor.getInstance().getConfig().getCompressor(); Review Comment: determine compression by datatype -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
