Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.iotdb.db.queryengine.plan.analyze.QueryType;
import org.apache.iotdb.db.queryengine.plan.execution.ExecutionResult;
import org.apache.iotdb.db.queryengine.plan.execution.IQueryExecution;
import org.apache.iotdb.db.queryengine.plan.execution.PendingResultFragment;
import org.apache.iotdb.rest.protocol.model.ExecutionStatus;
import org.apache.iotdb.rest.protocol.v1.model.QueryDataSet;
import org.apache.iotdb.rpc.TSStatusCode;
Expand Down Expand Up @@ -88,6 +89,7 @@ private static final class TestQueryExecution implements IQueryExecution {

private final Queue<Optional<TsBlock>> batches = new ArrayDeque<>();
private final DatasetHeader datasetHeader;
private final PendingResultFragment pendingResultFragment = new PendingResultFragment(() -> {});

private TestQueryExecution(TsBlock... tsBlocks) {
for (TsBlock tsBlock : tsBlocks) {
Expand Down Expand Up @@ -124,10 +126,15 @@ public Optional<TsBlock> getBatchResult() throws IoTDBException {
}

@Override
public Optional<ByteBuffer> getByteBufferBatchResult() {
public Optional<ByteBuffer> getByteBufferBatchResult(boolean retainMemory) {
return Optional.empty();
}

@Override
public PendingResultFragment getPendingResultFragment() {
return pendingResultFragment;
}

@Override
public boolean hasNextResult() {
return !batches.isEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ public SessionDataSet(
ZoneId zoneId,
int timeFactor,
boolean tableModel,
List<Integer> columnIndex2TsBlockColumnIndexList) {
List<Integer> columnIndex2TsBlockColumnIndexList,
boolean offsetSet,
int offset,
int totalLength) {
this.ioTDBRpcDataSet =
new IoTDBRpcDataSet(
sql,
Expand All @@ -81,7 +84,48 @@ public SessionDataSet(
RpcUtils.DEFAULT_TIME_FORMAT,
timeFactor,
tableModel,
columnIndex2TsBlockColumnIndexList);
columnIndex2TsBlockColumnIndexList,
offsetSet,
offset,
totalLength);
}

@SuppressWarnings("squid:S107") // ignore Methods should not have too many parameters
public SessionDataSet(
String sql,
List<String> columnNameList,
List<String> columnTypeList,
Map<String, Integer> columnNameIndex,
long queryId,
long statementId,
IClientRPCService.Iface client,
long sessionId,
List<ByteBuffer> queryResult,
boolean ignoreTimeStamp,
boolean moreData,
ZoneId zoneId,
int timeFactor,
boolean tableModel,
List<Integer> columnIndex2TsBlockColumnIndexList) {
this(
sql,
columnNameList,
columnTypeList,
columnNameIndex,
queryId,
statementId,
client,
sessionId,
queryResult,
ignoreTimeStamp,
moreData,
zoneId,
timeFactor,
tableModel,
columnIndex2TsBlockColumnIndexList,
false,
0,
0);
}

@SuppressWarnings("squid:S107") // ignore Methods should not have too many parameters
Expand All @@ -102,7 +146,10 @@ public SessionDataSet(
ZoneId zoneId,
int timeFactor,
boolean tableModel,
List<Integer> columnIndex2TsBlockColumnIndexList) {
List<Integer> columnIndex2TsBlockColumnIndexList,
boolean offsetSet,
int offset,
int totalLength) {
this.ioTDBRpcDataSet =
new IoTDBRpcDataSet(
sql,
Expand All @@ -122,7 +169,52 @@ public SessionDataSet(
RpcUtils.DEFAULT_TIME_FORMAT,
timeFactor,
tableModel,
columnIndex2TsBlockColumnIndexList);
columnIndex2TsBlockColumnIndexList,
offsetSet,
offset,
totalLength);
}

@SuppressWarnings("squid:S107") // ignore Methods should not have too many parameters
public SessionDataSet(
String sql,
List<String> columnNameList,
List<String> columnTypeList,
Map<String, Integer> columnNameIndex,
long queryId,
long statementId,
IClientRPCService.Iface client,
long sessionId,
List<ByteBuffer> queryResult,
boolean ignoreTimeStamp,
long timeout,
boolean moreData,
int fetchSize,
ZoneId zoneId,
int timeFactor,
boolean tableModel,
List<Integer> columnIndex2TsBlockColumnIndexList) {
this(
sql,
columnNameList,
columnTypeList,
columnNameIndex,
queryId,
statementId,
client,
sessionId,
queryResult,
ignoreTimeStamp,
timeout,
moreData,
fetchSize,
zoneId,
timeFactor,
tableModel,
columnIndex2TsBlockColumnIndexList,
false,
0,
0);
}

public int getFetchSize() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,6 @@ private Config() {
public static final String SQL_DIALECT = "sql_dialect";

public static final String DATABASE = "db";

public static final String ENABLE_RESULT_CHUNKING = "enable_result_chunking";
}
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,8 @@ private void openSession() throws SQLException {
openReq.setZoneId(getTimeZone());
openReq.putToConfiguration(Config.VERSION, params.getVersion().toString());
openReq.putToConfiguration(Config.SQL_DIALECT, params.getSqlDialect());
// this client can assemble fragmented query results, see TSFetchResultsReq#offset
openReq.putToConfiguration(Config.ENABLE_RESULT_CHUNKING, Boolean.TRUE.toString());
params.getDb().ifPresent(db -> openReq.putToConfiguration(Config.DATABASE, db));

TSOpenSessionResp openResp = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ public IoTDBJDBCResultSet(
ZoneId zoneId,
Charset charset,
boolean tableModel,
List<Integer> columnIndex2TsBlockColumnIndexList)
List<Integer> columnIndex2TsBlockColumnIndexList,
boolean offsetSet,
int offset,
int totalLength)
throws SQLException {
this.ioTDBRpcDataSet =
new IoTDBRpcDataSet(
Expand All @@ -125,7 +128,10 @@ public IoTDBJDBCResultSet(
timeFormat,
statement.getTimeFactor(),
tableModel,
columnIndex2TsBlockColumnIndexList);
columnIndex2TsBlockColumnIndexList,
offsetSet,
offset,
totalLength);
this.statement = statement;
this.columnTypeList = columnTypeList;
if (tracingInfo != null) {
Expand All @@ -135,6 +141,49 @@ public IoTDBJDBCResultSet(
this.charset = charset;
}

@SuppressWarnings("squid:S107") // ignore Methods should not have too many parameters
public IoTDBJDBCResultSet(
IoTDBStatement statement,
List<String> columnNameList,
List<String> columnTypeList,
Map<String, Integer> columnNameIndex,
boolean ignoreTimeStamp,
IClientRPCService.Iface client,
String sql,
long queryId,
long sessionId,
List<ByteBuffer> dataSet,
TSTracingInfo tracingInfo,
long timeout,
boolean moreData,
ZoneId zoneId,
Charset charset,
boolean tableModel,
List<Integer> columnIndex2TsBlockColumnIndexList)
throws SQLException {
this(
statement,
columnNameList,
columnTypeList,
columnNameIndex,
ignoreTimeStamp,
client,
sql,
queryId,
sessionId,
dataSet,
tracingInfo,
timeout,
moreData,
zoneId,
charset,
tableModel,
columnIndex2TsBlockColumnIndexList,
false,
0,
0);
}

@SuppressWarnings("squid:S107") // ignore Methods should not have too many parameters
public IoTDBJDBCResultSet(
Statement statement,
Expand All @@ -150,7 +199,10 @@ public IoTDBJDBCResultSet(
TSTracingInfo tracingInfo,
long timeout,
boolean moreData,
ZoneId zoneId)
ZoneId zoneId,
boolean offsetSet,
int offset,
int totalLength)
throws SQLException {
this.ioTDBRpcDataSet =
new IoTDBRpcDataSet(
Expand All @@ -171,7 +223,10 @@ public IoTDBJDBCResultSet(
timeFormat,
((IoTDBStatement) statement).getTimeFactor(),
false,
IntStream.range(0, columnNameList.size()).boxed().collect(Collectors.toList()));
IntStream.range(0, columnNameList.size()).boxed().collect(Collectors.toList()),
offsetSet,
offset,
totalLength);
this.statement = (IoTDBStatement) statement;
this.columnTypeList = columnTypeList;
if (tracingInfo != null) {
Expand All @@ -180,6 +235,43 @@ public IoTDBJDBCResultSet(
}
}

@SuppressWarnings("squid:S107") // ignore Methods should not have too many parameters
public IoTDBJDBCResultSet(
Statement statement,
List<String> columnNameList,
List<String> columnTypeList,
Map<String, Integer> columnNameIndex,
boolean ignoreTimeStamp,
IClientRPCService.Iface client,
String sql,
long queryId,
long sessionId,
List<ByteBuffer> dataSet,
TSTracingInfo tracingInfo,
long timeout,
boolean moreData,
ZoneId zoneId)
throws SQLException {
this(
statement,
columnNameList,
columnTypeList,
columnNameIndex,
ignoreTimeStamp,
client,
sql,
queryId,
sessionId,
dataSet,
tracingInfo,
timeout,
moreData,
zoneId,
false,
0,
0);
}

@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,10 @@ private boolean executeSQL(String sql) throws TException, SQLException {
zoneId,
charset,
execResp.isSetTableModel() && execResp.isTableModel(),
execResp.getColumnIndex2TsBlockColumnIndexList());
execResp.getColumnIndex2TsBlockColumnIndexList(),
execResp.isSetOffset(),
execResp.offset,
execResp.totalLength);
}
return true;
}
Expand Down Expand Up @@ -549,7 +552,10 @@ private ResultSet executeQuerySQL(String sql, long timeoutInMS) throws TExceptio
zoneId,
charset,
execResp.isSetTableModel() && execResp.isTableModel(),
execResp.getColumnIndex2TsBlockColumnIndexList());
execResp.getColumnIndex2TsBlockColumnIndexList(),
execResp.isSetOffset(),
execResp.offset,
execResp.totalLength);
}
return resultSet;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,10 @@ private ResultSet processQueryResult(TSExecuteStatementResp resp) throws SQLExce
resp.isSetTableModel() && resp.isTableModel(),
resp.getColumnIndex2TsBlockColumnIndexList() == null
? null
: new ArrayList<>(resp.getColumnIndex2TsBlockColumnIndexList()));
: new ArrayList<>(resp.getColumnIndex2TsBlockColumnIndexList()),
resp.isSetOffset(),
resp.offset,
resp.totalLength);
return resultSet;
}
return null;
Expand Down
5 changes: 5 additions & 0 deletions iotdb-client/service-rpc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,15 @@ private RpcMessages() {}

public static final String EXCEPTION_DATA_TYPE_ARG_IS_NOT_SUPPORTED_31213160 =
"Data type %s is not supported.";

public static final String EXCEPTION_CHUNKED_RESULT_EMPTY_FRAGMENT_03A0EF39 =
"Empty fragment received when assembling a chunked query result";
public static final String
EXCEPTION_CHUNKED_RESULT_FRAGMENT_OFFSET_ARG_NOT_GREATER_THAN_ACCUMULATED_LENGTH_ARG_A0F032E3 =
"Fragment offset %d is not greater than the accumulated length %d";
public static final String EXCEPTION_CHUNKED_RESULT_MISSING_TOTAL_LENGTH_FOR_FIRST_FRAGMENT_1D11374F =
"Missing totalLength for the first fragment of a chunked TsBlock";
public static final String
EXCEPTION_CHUNKED_RESULT_ASSEMBLED_LENGTH_ARG_DOES_NOT_MATCH_TOTAL_LENGTH_ARG_925DCB15 =
"Assembled fragment length %d does not match the total length %d";
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,15 @@ private RpcMessages() {}
"通过列名 %s 获取的值为 NULL。";

public static final String EXCEPTION_DATA_TYPE_ARG_IS_NOT_SUPPORTED_31213160 = "不支持数据类型 %s。";

public static final String EXCEPTION_CHUNKED_RESULT_EMPTY_FRAGMENT_03A0EF39 =
"拼装分片查询结果时收到空分片";
public static final String
EXCEPTION_CHUNKED_RESULT_FRAGMENT_OFFSET_ARG_NOT_GREATER_THAN_ACCUMULATED_LENGTH_ARG_A0F032E3 =
"分片 offset %d 不大于已累计的长度 %d";
public static final String EXCEPTION_CHUNKED_RESULT_MISSING_TOTAL_LENGTH_FOR_FIRST_FRAGMENT_1D11374F =
"分片 TsBlock 的首个分片缺少 totalLength";
public static final String
EXCEPTION_CHUNKED_RESULT_ASSEMBLED_LENGTH_ARG_DOES_NOT_MATCH_TOTAL_LENGTH_ARG_925DCB15 =
"拼装后的分片长度 %d 与 totalLength %d 不一致";
}
Loading
Loading