/*
package com.muyu.carData.controller;

import com.muyu.carData.config.lotdbconfig.IotDBSessionConfig;
import lombok.extern.log4j.Log4j2;
import org.apache.iotdb.rpc.IoTDBConnectionException;
import org.apache.iotdb.rpc.StatementExecutionException;
import org.apache.iotdb.session.Session;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
import org.apache.iotdb.tsfile.write.record.Tablet;
import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

*/
/**
 * @Author：张腾
 * @Package：com.muyu.carData.testcontroller
 * @Project：cloud-server-8
 * @name：IotDBController
 * @Date：2024/9/28 23:58
 *//*

@RequestMapping("/iotdb")
@RestController
@Log4j2
public class IotDBController {


    @Autowired
    private IotDBSessionConfig iotDBSessionConfig;

    */
/**
     * 批量插入数据
     * @param insertSize 每次插入的条数
     * @param count 插入的总条数
     * @return
     * @throws IoTDBConnectionException
     * @throws StatementExecutionException
     *//*

    @GetMapping("/insertData/{insertSize}/{count}")
    public String insert(@PathVariable(name = "insertSize") int insertSize,@PathVariable(name = "count") int count) throws IoTDBConnectionException, StatementExecutionException {
        Session session = iotDBSessionConfig.iotSession();
        //schemaList 属性及类型
        List<MeasurementSchema> schemaList = new ArrayList<>();
        schemaList.add(new MeasurementSchema("id", TSDataType.INT32));
        schemaList.add(new MeasurementSchema("name", TSDataType.TEXT));
        schemaList.add(new MeasurementSchema("sex", TSDataType.TEXT));

        //tablet 封装数据
        Tablet tablet = new Tablet("root.yang.baling", schemaList);

        //以当前时间戳作为插入的起始时间戳
        long timestamp = System.currentTimeMillis();
        long beginTime = System.currentTimeMillis();
        for (long row = 0;row < count; row++){
            int rowIndex = tablet.rowSize++;
            tablet.addTimestamp(rowIndex,timestamp); //批量插入的时间戳是数组形式，所以需要使用rowIndex来指定插入的位置
            tablet.addValue("id", rowIndex, ((row & 1) == 0 ? 1 : 0));
            tablet.addValue("name", rowIndex, "name<=>" + row);
            tablet.addValue("sex", rowIndex, "男");
            if (tablet.rowSize == insertSize){
                long bg = System.currentTimeMillis();
                session.insertTablet(tablet);
                tablet.reset();
                log.info("已经插入了"+(row + 1)+",插入耗时：" + (System.currentTimeMillis() - bg));
            }
            timestamp++;
        }

        if (tablet.rowSize != 0){
            session.insertTablet(tablet);
            log.info("插入完成，耗时：" + (System.currentTimeMillis() - beginTime));
            tablet.reset();
        }
        long endTime = System.currentTimeMillis();
        log.info("插入了"+insertSize+"条数据,每次插入"+count+"条数据,总耗时:"+(endTime - beginTime));
        return "时序性数据库测试success";
    }


    @GetMapping("/batchInsertRecords/{num}")
    public String batchInsertRecords(@PathVariable Integer num){
        String deviceId = "root.yang";

        //属性（字段）
        List<String> schemaList = new ArrayList<>();
        schemaList.add("id");
        schemaList.add("name");
        schemaList.add("age");

        ArrayList<TSDataType> tsDataTypes = new ArrayList<>();
        tsDataTypes.add(TSDataType.INT32);
        tsDataTypes.add(TSDataType.TEXT);
        tsDataTypes.add(TSDataType.INT32);

        List<Object> value = new ArrayList<>();
        value.add(1);
        value.add("张腾");
        value.add(18);

        ArrayList<String> deviceIds = new ArrayList<>();
        ArrayList<Long> times = new ArrayList<>();
        ArrayList<List<TSDataType>> typeList = new ArrayList<>();
        ArrayList<List<Object>> valueList = new ArrayList<>();
        for (int i = 0; i < num; i++) {
            deviceIds.add()
        }
    }
}
*/
