Skip to content

Commit

Permalink
add anotations
Browse files Browse the repository at this point in the history
  • Loading branch information
shuwenwei committed Dec 9, 2024
1 parent a6680a4 commit e646b96
Show file tree
Hide file tree
Showing 21 changed files with 122 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.annotations;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* This annotation indicates that the related filed, method, or constructor is only used for
* TableModel.
*/
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR})
@Retention(RetentionPolicy.SOURCE)
public @interface TableModel {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.annotations;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* This annotation indicates that the related filed, method, or constructor is only used for
* TreeModel.
*/
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR})
@Retention(RetentionPolicy.SOURCE)
public @interface TreeModel {}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

package org.apache.tsfile.common;
package org.apache.tsfile.annotations;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.apache.tsfile.file.metadata;

import org.apache.tsfile.common.TsFileApi;
import org.apache.tsfile.annotations.TsFileApi;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.write.record.Tablet.ColumnCategory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.apache.tsfile.file.metadata;

import org.apache.tsfile.common.TsFileApi;
import org.apache.tsfile.annotations.TsFileApi;
import org.apache.tsfile.compatibility.DeserializeConfig;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.utils.ReadWriteForEncodingUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.apache.tsfile.read;

import org.apache.tsfile.common.TsFileApi;
import org.apache.tsfile.annotations.TsFileApi;
import org.apache.tsfile.read.controller.CachedChunkLoaderImpl;
import org.apache.tsfile.read.controller.IChunkLoader;
import org.apache.tsfile.read.controller.IMetadataQuerier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.apache.tsfile.read.query.dataset;

import org.apache.tsfile.common.TsFileApi;
import org.apache.tsfile.annotations.TsFileApi;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.exception.NullFieldException;
import org.apache.tsfile.read.common.Field;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.apache.tsfile.read.query.dataset;

import org.apache.tsfile.common.TsFileApi;
import org.apache.tsfile.annotations.TsFileApi;

import java.io.IOException;
import java.time.LocalDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.apache.tsfile.read.query.dataset;

import org.apache.tsfile.common.TsFileApi;
import org.apache.tsfile.annotations.TsFileApi;
import org.apache.tsfile.enums.TSDataType;

public interface ResultSetMetadata {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.apache.tsfile.read.query.dataset;

import org.apache.tsfile.common.TsFileApi;
import org.apache.tsfile.annotations.TsFileApi;
import org.apache.tsfile.read.common.Path;

import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.apache.tsfile.read.v4;

import org.apache.tsfile.common.TsFileApi;
import org.apache.tsfile.annotations.TsFileApi;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.exception.read.ReadProcessException;
import org.apache.tsfile.exception.write.NoMeasurementException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.apache.tsfile.read.v4;

import org.apache.tsfile.common.TsFileApi;
import org.apache.tsfile.annotations.TsFileApi;
import org.apache.tsfile.exception.read.ReadProcessException;
import org.apache.tsfile.exception.write.NoMeasurementException;
import org.apache.tsfile.exception.write.NoTableException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.apache.tsfile.read.v4;

import org.apache.tsfile.common.TsFileApi;
import org.apache.tsfile.annotations.TsFileApi;

import java.io.File;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.apache.tsfile.write;

import org.apache.tsfile.common.TsFileApi;
import org.apache.tsfile.annotations.TsFileApi;
import org.apache.tsfile.common.conf.TSFileConfig;
import org.apache.tsfile.common.conf.TSFileDescriptor;
import org.apache.tsfile.encrypt.EncryptParameter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.apache.tsfile.write.record;

import org.apache.tsfile.common.TsFileApi;
import org.apache.tsfile.annotations.TsFileApi;
import org.apache.tsfile.common.conf.TSFileConfig;
import org.apache.tsfile.file.metadata.IDeviceID;
import org.apache.tsfile.file.metadata.IDeviceID.Factory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@

package org.apache.tsfile.write.record;

import org.apache.tsfile.common.TsFileApi;
import org.apache.tsfile.annotations.TableModel;
import org.apache.tsfile.annotations.TreeModel;
import org.apache.tsfile.annotations.TsFileApi;
import org.apache.tsfile.common.conf.TSFileConfig;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.file.metadata.IDeviceID;
Expand Down Expand Up @@ -105,10 +107,12 @@ public class Tablet {
* @param schemas the list of {@link MeasurementSchema}s for creating the tablet, only
* measurementId and type take effects
*/
@TreeModel
public Tablet(String deviceId, List<IMeasurementSchema> schemas) {
this(deviceId, schemas, DEFAULT_SIZE);
}

@TreeModel
public Tablet(String deviceId, List<IMeasurementSchema> schemas, int maxRowNumber) {
this.insertTargetName = deviceId;
this.schemas = new ArrayList<>(schemas);
Expand All @@ -122,10 +126,12 @@ public Tablet(String deviceId, List<IMeasurementSchema> schemas, int maxRowNumbe
reset();
}

@TreeModel
public Tablet(IDeviceID deviceID, List<String> measurementList, List<TSDataType> dataTypeList) {
this(deviceID, measurementList, dataTypeList, DEFAULT_SIZE);
}

@TreeModel
public Tablet(
IDeviceID deviceID,
List<String> measurementList,
Expand All @@ -136,10 +142,12 @@ public Tablet(
measurementList,
dataTypeList,
ColumnCategory.nCopy(ColumnCategory.MEASUREMENT, measurementList.size()),
maxRowNumber);
maxRowNumber,
true);
}

@TsFileApi
@TableModel
public Tablet(List<String> columnNameList, List<TSDataType> dataTypeList) {
this(columnNameList, dataTypeList, DEFAULT_SIZE);
}
Expand All @@ -153,25 +161,28 @@ public Tablet(List<String> columnNameList, List<TSDataType> dataTypeList) {
* @param maxRowNum the maximum number of rows for this tablet
*/
@TsFileApi
@TableModel
public Tablet(List<String> columnNameList, List<TSDataType> dataTypeList, int maxRowNum) {
this(null, columnNameList, dataTypeList, null, maxRowNum, false);
}

@TableModel
public Tablet(
String tableName,
List<String> measurementList,
List<String> columnNameList,
List<TSDataType> dataTypeList,
List<ColumnCategory> columnCategoryList) {
this(tableName, measurementList, dataTypeList, columnCategoryList, DEFAULT_SIZE);
this(tableName, columnNameList, dataTypeList, columnCategoryList, DEFAULT_SIZE);
}

@TableModel
public Tablet(
String insertTargetName,
List<String> measurementList,
String tableName,
List<String> columnNameList,
List<TSDataType> dataTypeList,
List<ColumnCategory> columnCategoryList,
int maxRowNum) {
this(insertTargetName, measurementList, dataTypeList, columnCategoryList, maxRowNum, true);
this(tableName, columnNameList, dataTypeList, columnCategoryList, maxRowNum, true);
}

protected Tablet(
Expand Down Expand Up @@ -210,32 +221,37 @@ protected Tablet(
* @param bitMaps given {@link BitMap}s
* @param maxRowNumber the maximum number of rows for this {@link Tablet}
*/
@TreeModel
public Tablet(
String deviceId,
List<IMeasurementSchema> schemas,
long[] timestamps,
Object[] values,
BitMap[] bitMaps,
int maxRowNumber) {
this(
deviceId,
schemas,
ColumnCategory.nCopy(ColumnCategory.MEASUREMENT, schemas.size()),
timestamps,
values,
bitMaps,
maxRowNumber);
this.insertTargetName = deviceId;
this.schemas = schemas;
setColumnCategories(ColumnCategory.nCopy(ColumnCategory.MEASUREMENT, schemas.size()));
this.timestamps = timestamps;
this.values = values;
this.bitMaps = bitMaps;
this.maxRowNumber = maxRowNumber;
// rowSize == maxRowNumber in this case
this.rowSize = maxRowNumber;
measurementIndex = new HashMap<>();
constructMeasurementIndexMap();
}

@TableModel
public Tablet(
String insertTargetName,
String tableName,
List<IMeasurementSchema> schemas,
List<ColumnCategory> columnCategories,
long[] timestamps,
Object[] values,
BitMap[] bitMaps,
int maxRowNumber) {
this.insertTargetName = insertTargetName;
this.insertTargetName = tableName;
this.schemas = schemas;
setColumnCategories(columnCategories);
this.timestamps = timestamps;
Expand Down Expand Up @@ -1144,6 +1160,7 @@ public Object getValue(int i, int j) {
* @param i a row number.
* @return the IDeviceID of the i-th row.
*/
@TableModel
public IDeviceID getDeviceID(int i) {
String[] idArray = new String[idColumnIndexes.size() + 1];
idArray[0] = getTableName();
Expand Down Expand Up @@ -1193,6 +1210,7 @@ public static List<ColumnCategory> nCopy(ColumnCategory type, int n) {
*
* @return the insertTargetName as the deviceId
*/
@TreeModel
public String getDeviceId() {
return insertTargetName;
}
Expand All @@ -1202,10 +1220,12 @@ public String getDeviceId() {
*
* @param deviceId set the deviceId as the insertTargetName
*/
@TreeModel
public void setDeviceId(String deviceId) {
this.insertTargetName = deviceId;
}

@TableModel
public String getTableName() {
return insertTargetName == null ? null : insertTargetName.toLowerCase();
}
Expand All @@ -1215,6 +1235,7 @@ public String getTableName() {
*
* @param tableName set the tableName as the insertTargetName
*/
@TableModel
public void setTableName(String tableName) {
this.insertTargetName = tableName.toLowerCase();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.apache.tsfile.write.schema;

import org.apache.tsfile.common.TsFileApi;
import org.apache.tsfile.annotations.TsFileApi;
import org.apache.tsfile.common.conf.TSFileDescriptor;
import org.apache.tsfile.encoding.encoder.Encoder;
import org.apache.tsfile.encoding.encoder.TSEncodingBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.apache.tsfile.write.v4;

import org.apache.tsfile.common.TsFileApi;
import org.apache.tsfile.annotations.TsFileApi;
import org.apache.tsfile.common.conf.TSFileConfig;
import org.apache.tsfile.common.conf.TSFileDescriptor;
import org.apache.tsfile.encrypt.EncryptParameter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.apache.tsfile.write.v4;

import org.apache.tsfile.common.TsFileApi;
import org.apache.tsfile.annotations.TsFileApi;
import org.apache.tsfile.exception.write.ConflictDataTypeException;
import org.apache.tsfile.exception.write.NoMeasurementException;
import org.apache.tsfile.exception.write.NoTableException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.apache.tsfile.write.v4;

import org.apache.tsfile.common.TsFileApi;
import org.apache.tsfile.annotations.TsFileApi;
import org.apache.tsfile.exception.write.WriteProcessException;
import org.apache.tsfile.write.record.Tablet;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.apache.tsfile.write.v4;

import org.apache.tsfile.common.TsFileApi;
import org.apache.tsfile.annotations.TsFileApi;
import org.apache.tsfile.file.metadata.TableSchema;

import java.io.File;
Expand Down

0 comments on commit e646b96

Please sign in to comment.