Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* 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.iotdb.session.util;
import org.apache.iotdb.common.rpc.thrift.TEndPoint;
import org.apache.iotdb.rpc.IoTDBConnectionException;
import org.apache.iotdb.rpc.UrlUtils;
import org.apache.tsfile.common.conf.TSFileConfig;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.utils.Binary;
import org.apache.tsfile.utils.BitMap;
import org.apache.tsfile.utils.BytesUtils;
import org.apache.tsfile.utils.DateUtils;
import org.apache.tsfile.utils.ReadWriteIOUtils;
import org.apache.tsfile.write.UnSupportedDataTypeException;
import org.apache.tsfile.write.record.Tablet;
import org.apache.tsfile.write.schema.MeasurementSchema;
import java.nio.ByteBuffer;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import static org.apache.iotdb.session.Session.MSG_UNSUPPORTED_DATA_TYPE;
public class SessionUtils {
private static final byte TYPE_NULL = -2;
public static ByteBuffer getTimeBuffer(Tablet tablet) {
ByteBuffer timeBuffer = ByteBuffer.allocate(tablet.getTimeBytesSize());
for (int i = 0; i < tablet.rowSize; i++) {
timeBuffer.putLong(tablet.timestamps[i]);
}
timeBuffer.flip();
return timeBuffer;
}
@SuppressWarnings("squid:S3776") // Suppress high Cognitive Complexity warning
public static ByteBuffer getValueBuffer(Tablet tablet) {
ByteBuffer valueBuffer = ByteBuffer.allocate(tablet.getTotalValueOccupation());
for (int i = 0; i < tablet.getSchemas().size(); i++) {
MeasurementSchema schema = tablet.getSchemas().get(i);
getValueBufferOfDataType(schema.getType(), tablet, i, valueBuffer);
}
if (tablet.bitMaps != null) {
for (BitMap bitMap : tablet.bitMaps) {
boolean columnHasNull = bitMap != null && !bitMap.isAllUnmarked();
valueBuffer.put(BytesUtils.boolToByte(columnHasNull));
if (columnHasNull) {
byte[] bytes = bitMap.getByteArray();
for (int j = 0; j < tablet.rowSize / Byte.SIZE + 1; j++) {
valueBuffer.put(bytes[j]);
}
}
}
}
valueBuffer.flip();
return valueBuffer;
}
public static ByteBuffer getValueBuffer(List types, List