Skip to content

Commit

Permalink
spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
liyuheng55555 committed Jun 1, 2023
1 parent a75a92a commit 277abd8
Show file tree
Hide file tree
Showing 5 changed files with 223 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,58 @@

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 java.util.List;

public interface IBenchmarkSession {
void open() throws IoTDBConnectionException;
void open(boolean enableRPCCompression) throws IoTDBConnectionException;
void insertRecord(String deviceId, long time, List<String> measurements, List<TSDataType> types, List<Object> values) throws IoTDBConnectionException, StatementExecutionException;
void insertAlignedRecord(String multiSeriesId, long time, List<String> multiMeasurementComponents, List<TSDataType> types, List<Object> values) throws IoTDBConnectionException, StatementExecutionException;
void insertRecords(List<String> deviceIds, List<Long> times, List<List<String>> measurementsList, List<List<TSDataType>> typesList, List<List<Object>> valuesList) throws IoTDBConnectionException, StatementExecutionException;
void insertAlignedRecords(List<String> multiSeriesIds, List<Long> times, List<List<String>> multiMeasurementComponentsList, List<List<TSDataType>> typesList, List<List<Object>> valuesList) throws IoTDBConnectionException, StatementExecutionException;
void insertTablet(Tablet tablet) throws IoTDBConnectionException, StatementExecutionException;
void insertAlignedTablet(Tablet tablet) throws IoTDBConnectionException, StatementExecutionException;
ISessionDataSet executeQueryStatement(String sql) throws IoTDBConnectionException, StatementExecutionException;
void executeNonQueryStatement(String deleteSeriesSql) throws IoTDBConnectionException, StatementExecutionException;
void close() throws IoTDBConnectionException;
void open() throws IoTDBConnectionException;

void open(boolean enableRPCCompression) throws IoTDBConnectionException;

void insertRecord(
String deviceId,
long time,
List<String> measurements,
List<TSDataType> types,
List<Object> values)
throws IoTDBConnectionException, StatementExecutionException;

void insertAlignedRecord(
String multiSeriesId,
long time,
List<String> multiMeasurementComponents,
List<TSDataType> types,
List<Object> values)
throws IoTDBConnectionException, StatementExecutionException;

void insertRecords(
List<String> deviceIds,
List<Long> times,
List<List<String>> measurementsList,
List<List<TSDataType>> typesList,
List<List<Object>> valuesList)
throws IoTDBConnectionException, StatementExecutionException;

void insertAlignedRecords(
List<String> multiSeriesIds,
List<Long> times,
List<List<String>> multiMeasurementComponentsList,
List<List<TSDataType>> typesList,
List<List<Object>> valuesList)
throws IoTDBConnectionException, StatementExecutionException;

void insertTablet(Tablet tablet) throws IoTDBConnectionException, StatementExecutionException;

void insertAlignedTablet(Tablet tablet)
throws IoTDBConnectionException, StatementExecutionException;

ISessionDataSet executeQueryStatement(String sql)
throws IoTDBConnectionException, StatementExecutionException;

void executeNonQueryStatement(String deleteSeriesSql)
throws IoTDBConnectionException, StatementExecutionException;

void close() throws IoTDBConnectionException;
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package cn.edu.tsinghua.iot.benchmark.iotdb110;

import org.apache.iotdb.isession.SessionDataSet;
import org.apache.iotdb.isession.pool.SessionDataSetWrapper;
import org.apache.iotdb.rpc.IoTDBConnectionException;
import org.apache.iotdb.rpc.StatementExecutionException;
import org.apache.iotdb.tsfile.read.common.RowRecord;

public interface ISessionDataSet {
RowRecord next() throws IoTDBConnectionException, StatementExecutionException;
boolean hasNext() throws IoTDBConnectionException, StatementExecutionException;
void close() throws IoTDBConnectionException, StatementExecutionException;
}
RowRecord next() throws IoTDBConnectionException, StatementExecutionException;

boolean hasNext() throws IoTDBConnectionException, StatementExecutionException;

void close() throws IoTDBConnectionException, StatementExecutionException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@

package cn.edu.tsinghua.iot.benchmark.iotdb110;

import cn.edu.tsinghua.iot.benchmark.tsdb.DBConfig;
import cn.edu.tsinghua.iot.benchmark.tsdb.TsdbException;
import org.apache.iotdb.isession.pool.SessionDataSetWrapper;
import org.apache.iotdb.rpc.IoTDBConnectionException;
import org.apache.iotdb.rpc.StatementExecutionException;
import org.apache.iotdb.session.pool.SessionPool;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
import org.apache.iotdb.tsfile.read.common.RowRecord;
import org.apache.iotdb.tsfile.write.record.Tablet;

import cn.edu.tsinghua.iot.benchmark.tsdb.DBConfig;
import cn.edu.tsinghua.iot.benchmark.tsdb.TsdbException;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
Expand All @@ -37,59 +38,99 @@
public class IoTDBClusterSession extends IoTDBSessionBase {
private class BenchmarkSessionPool implements IBenchmarkSession {
private final SessionPool sessionPool;

public BenchmarkSessionPool(SessionPool sessionPool) {
this.sessionPool = sessionPool;
}

@Override
public void open() {

}
public void open() {}

@Override
public void open(boolean enableRPCCompression) {

}
public void open(boolean enableRPCCompression) {}

@Override
public void insertRecord(String deviceId, long time, List<String> measurements, List<TSDataType> types, List<Object> values) throws IoTDBConnectionException, StatementExecutionException {
public void insertRecord(
String deviceId,
long time,
List<String> measurements,
List<TSDataType> types,
List<Object> values)
throws IoTDBConnectionException, StatementExecutionException {
sessionPool.insertRecord(deviceId, time, measurements, types, values);
}

@Override
public void insertAlignedRecord(String multiSeriesId, long time, List<String> multiMeasurementComponents, List<TSDataType> types, List<Object> values) throws IoTDBConnectionException, StatementExecutionException {
sessionPool.insertAlignedRecord(multiSeriesId, time, multiMeasurementComponents, types, values);
public void insertAlignedRecord(
String multiSeriesId,
long time,
List<String> multiMeasurementComponents,
List<TSDataType> types,
List<Object> values)
throws IoTDBConnectionException, StatementExecutionException {
sessionPool.insertAlignedRecord(
multiSeriesId, time, multiMeasurementComponents, types, values);
}

@Override
public void insertRecords(List<String> deviceIds, List<Long> times, List<List<String>> measurementsList, List<List<TSDataType>> typesList, List<List<Object>> valuesList) throws IoTDBConnectionException, StatementExecutionException {
public void insertRecords(
List<String> deviceIds,
List<Long> times,
List<List<String>> measurementsList,
List<List<TSDataType>> typesList,
List<List<Object>> valuesList)
throws IoTDBConnectionException, StatementExecutionException {
sessionPool.insertRecords(deviceIds, times, measurementsList, typesList, valuesList);
}

@Override
public void insertAlignedRecords(List<String> multiSeriesIds, List<Long> times, List<List<String>> multiMeasurementComponentsList, List<List<TSDataType>> typesList, List<List<Object>> valuesList) throws IoTDBConnectionException, StatementExecutionException {
sessionPool.insertAlignedRecords(multiSeriesIds, times, multiMeasurementComponentsList, typesList, valuesList);
public void insertAlignedRecords(
List<String> multiSeriesIds,
List<Long> times,
List<List<String>> multiMeasurementComponentsList,
List<List<TSDataType>> typesList,
List<List<Object>> valuesList)
throws IoTDBConnectionException, StatementExecutionException {
sessionPool.insertAlignedRecords(
multiSeriesIds, times, multiMeasurementComponentsList, typesList, valuesList);
}

@Override
public void insertTablet(Tablet tablet) throws IoTDBConnectionException, StatementExecutionException {
public void insertTablet(Tablet tablet)
throws IoTDBConnectionException, StatementExecutionException {
sessionPool.insertTablet(tablet);
}

@Override
public void insertAlignedTablet(Tablet tablet) throws IoTDBConnectionException, StatementExecutionException {
public void insertAlignedTablet(Tablet tablet)
throws IoTDBConnectionException, StatementExecutionException {
sessionPool.insertAlignedTablet(tablet);
}

@Override
public ISessionDataSet executeQueryStatement(String sql) throws IoTDBConnectionException, StatementExecutionException {
public ISessionDataSet executeQueryStatement(String sql)
throws IoTDBConnectionException, StatementExecutionException {
return new SessionDataSet2(sessionPool.executeQueryStatement(sql));
}

@Override
public void close() {
sessionPool.close();
}

@Override
public void executeNonQueryStatement(String deleteSeriesSql) throws IoTDBConnectionException, StatementExecutionException {
public void executeNonQueryStatement(String deleteSeriesSql)
throws IoTDBConnectionException, StatementExecutionException {
sessionPool.executeNonQueryStatement(deleteSeriesSql);
}

private class SessionDataSet2 implements ISessionDataSet {
SessionDataSetWrapper sessionDataSet;

public SessionDataSet2(SessionDataSetWrapper sessionDataSetWrapper) {
this.sessionDataSet = sessionDataSetWrapper;
}

@Override
public RowRecord next() throws IoTDBConnectionException, StatementExecutionException {
return sessionDataSet.next();
Expand All @@ -106,6 +147,7 @@ public void close() throws IoTDBConnectionException, StatementExecutionException
}
}
}

private static final int MAX_SESSION_CONNECTION_PER_CLIENT = 3;

public IoTDBClusterSession(DBConfig dbConfig) {
Expand All @@ -115,15 +157,15 @@ public IoTDBClusterSession(DBConfig dbConfig) {
for (int i = 0; i < dbConfig.getHOST().size(); i++) {
hostUrls.add(dbConfig.getHOST().get(i) + ":" + dbConfig.getPORT().get(i));
}
sessionWrapper = new BenchmarkSessionPool(
new SessionPool(
hostUrls,
dbConfig.getUSERNAME(),
dbConfig.getPASSWORD(),
MAX_SESSION_CONNECTION_PER_CLIENT,
config.isENABLE_THRIFT_COMPRESSION(),
true)
);
sessionWrapper =
new BenchmarkSessionPool(
new SessionPool(
hostUrls,
dbConfig.getUSERNAME(),
dbConfig.getPASSWORD(),
MAX_SESSION_CONNECTION_PER_CLIENT,
config.isENABLE_THRIFT_COMPRESSION(),
true));
}

@Override
Expand Down
Loading

0 comments on commit 277abd8

Please sign in to comment.