Skip to content

Commit 5978614

Browse files
committed
Fix issue and adjust some bugs on the IT, remove some debug code.
1 parent 54e54ac commit 5978614

File tree

10 files changed

+181
-196
lines changed

10 files changed

+181
-196
lines changed

integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBAlterTimeSeriesTypeIT.java

Lines changed: 138 additions & 119 deletions
Large diffs are not rendered by default.

integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSchemaTemplateIT.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,6 @@ public void testHybridAutoExtendSchemaTemplate()
490490
Arrays.asList(1d, 2d, 3));
491491
Assert.fail();
492492
} catch (StatementExecutionException e) {
493-
System.out.println("hi: " + e.getMessage());
494493
Assert.assertTrue(
495494
e.getMessage()
496495
.contains(

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ProcedureManager.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,6 @@ public TSStatus alterTimeSeriesDataType(final TAlterTimeSeriesReq req) {
480480
req.getQueryId(),
481481
(MeasurementPath)
482482
PathDeserializeUtil.deserialize(ByteBuffer.wrap(req.getMeasurementPath())),
483-
//
484-
// MeasurementPath.deserialize(ByteBuffer.wrap(req.getMeasurementPath())),
485483
req.getOperationType(),
486484
TSDataType.deserialize(req.updateInfo.get()),
487485
false);

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterTimeSeriesDataTypeProcedure.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,30 +102,22 @@ protected StateMachineProcedure.Flow executeFromState(
102102
case ALTER_TIME_SERIES_DATA_TYPE:
103103
LOGGER.info("altering time series {} data type", measurementPath.getFullPath());
104104
if (!alterTimeSeriesDataType(env)) {
105-
LOGGER.info("altering time series {} data type failed", measurementPath.getFullPath());
105+
LOGGER.error("alter time series {} data type failed", measurementPath.getFullPath());
106106
return Flow.NO_MORE_STATE;
107107
}
108-
LOGGER.info(
109-
"altering time series {} data type successful", measurementPath.getFullPath());
110108
break;
111109
case CLEAR_CACHE:
112110
LOGGER.info(
113111
"clearing cache after alter time series {} data type", measurementPath.getFullPath());
114112
PathPatternTree patternTree = new PathPatternTree();
115113
patternTree.appendPathPattern(measurementPath);
116114
patternTree.constructTree();
117-
LOGGER.info(
118-
"Invalidate cache of timeSeries {} in AlterTimeSeriesDataTypeProcedure",
119-
measurementPath.getFullPath());
120115
invalidateCache(
121116
env,
122117
preparePatternTreeBytesData(patternTree),
123118
measurementPath.getFullPath(),
124119
this::setFailure,
125120
true);
126-
LOGGER.info(
127-
"clear cache successful after alter time series {} data type",
128-
measurementPath.getFullPath());
129121
break;
130122
default:
131123
setFailure(
@@ -247,9 +239,7 @@ protected void onAllReplicasetFailure(
247239
}
248240
};
249241
alterTimerSeriesTask.execute();
250-
LOGGER.error("start clear cache in AlterTimeSeriesDataTypeProcedure");
251242
setNextState(AlterTimeSeriesDataTypeState.CLEAR_CACHE);
252-
LOGGER.error("end clear cache in AlterTimeSeriesDataTypeProcedure");
253243
return true;
254244
}
255245

@@ -352,6 +342,8 @@ public void serialize(final DataOutputStream stream) throws IOException {
352342
super.serialize(stream);
353343
ReadWriteIOUtils.write(queryId, stream);
354344
measurementPath.serialize(stream);
345+
ReadWriteIOUtils.write(operationType, stream);
346+
ReadWriteIOUtils.write(dataType, stream);
355347
}
356348

357349
@Override
@@ -362,6 +354,12 @@ public void deserialize(final ByteBuffer byteBuffer) {
362354
if (getCurrentState() == AlterTimeSeriesDataTypeState.CLEAR_CACHE) {
363355
LOGGER.info("Successfully restored, will set mods to the data regions anyway");
364356
}
357+
if (byteBuffer.hasRemaining()) {
358+
operationType = ReadWriteIOUtils.readByte(byteBuffer);
359+
}
360+
if (byteBuffer.hasRemaining()) {
361+
dataType = ReadWriteIOUtils.readDataType(byteBuffer);
362+
}
365363
}
366364

367365
@Override
@@ -377,7 +375,9 @@ public boolean equals(final Object o) {
377375
&& this.getCurrentState().equals(that.getCurrentState())
378376
&& this.getCycles() == getCycles()
379377
&& this.isGeneratedByPipe == that.isGeneratedByPipe
380-
&& this.measurementPath.equals(that.measurementPath);
378+
&& this.measurementPath.equals(that.measurementPath)
379+
&& this.operationType == that.operationType
380+
&& this.dataType.equals(that.dataType);
381381
}
382382

383383
@Override

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/store/ProcedureFactory.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ public Procedure create(ByteBuffer buffer) throws IOException {
323323
case PIPE_ENRICHED_ALTER_COLUMN_DATATYPE_PROCEDURE:
324324
procedure = new AlterTableColumnDataTypeProcedure(true);
325325
break;
326+
case PIPE_ENRICHED_ALTER_TIMESERIES_DATATYPE_PROCEDURE:
327+
procedure = new AlterTimeSeriesDataTypeProcedure(true);
328+
break;
326329
case PIPE_ENRICHED_DELETE_DEVICES_PROCEDURE:
327330
procedure = new DeleteDevicesProcedure(true);
328331
break;

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/exception/metadata/DataTypeMismatchException.java

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,11 @@
2222
import org.apache.iotdb.commons.exception.MetadataException;
2323

2424
import org.apache.tsfile.enums.TSDataType;
25-
import org.slf4j.Logger;
26-
import org.slf4j.LoggerFactory;
2725

2826
public class DataTypeMismatchException extends MetadataException {
2927

3028
// NOTICE: DO NOT CHANGE THIS STRING, IT IS USED IN THE ERROR HANDLING OF PIPE
3129
public static final String REGISTERED_TYPE_STRING = "registered type";
32-
private static final Logger log = LoggerFactory.getLogger(DataTypeMismatchException.class);
3330

3431
public DataTypeMismatchException(
3532
String deviceName,
@@ -49,21 +46,6 @@ public DataTypeMismatchException(
4946
insertType,
5047
time,
5148
value == null ? "null" : processValue(value.toString())));
52-
53-
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
54-
55-
// 通常,我们需要忽略前两层堆栈信息,因为它们分别对应于printCallerInfo()方法和当前正在执行的方法(例如methodB())
56-
if (stackTraceElements.length > 2) {
57-
// 获取调用者的信息
58-
StackTraceElement caller =
59-
stackTraceElements[2]; // 获取调用者信息,索引从0开始,所以要取第3个元素(因为第0和第1个是当前方法的堆栈)
60-
log.error("调用者类名: {}", caller.getClassName());
61-
log.error("调用者方法名: {}", caller.getMethodName());
62-
log.error("调用者文件名: {}", caller.getFileName());
63-
log.error("调用者行号: {}", caller.getLineNumber());
64-
} else {
65-
log.error("堆栈跟踪信息不足,无法确定调用者信息。");
66-
}
6749
}
6850

6951
public DataTypeMismatchException(
@@ -77,20 +59,6 @@ public DataTypeMismatchException(
7759
insertType,
7860
time,
7961
value == null ? "null" : processValue(value.toString())));
80-
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
81-
82-
// 通常,我们需要忽略前两层堆栈信息,因为它们分别对应于printCallerInfo()方法和当前正在执行的方法(例如methodB())
83-
if (stackTraceElements.length > 2) {
84-
// 获取调用者的信息
85-
StackTraceElement caller =
86-
stackTraceElements[2]; // 获取调用者信息,索引从0开始,所以要取第3个元素(因为第0和第1个是当前方法的堆栈)
87-
log.error("调用者类名: {}", caller.getClassName());
88-
log.error("调用者方法名: {}", caller.getMethodName());
89-
log.error("调用者文件名: {}", caller.getFileName());
90-
log.error("调用者行号: {}", caller.getLineNumber());
91-
} else {
92-
log.error("堆栈跟踪信息不足,无法确定调用者信息。");
93-
}
9462
}
9563

9664
private static String processValue(String value) {

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/aggregation/FirstValueAccumulator.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,13 @@ public void addStatistics(Statistics statistics) {
150150
StandardCharsets.UTF_8),
151151
statistics.getStartTime());
152152
} else {
153-
updateBinaryFirstValue((Binary) statistics.getFirstValue(), statistics.getStartTime());
153+
if (statistics.getFirstValue() instanceof Binary) {
154+
updateBinaryFirstValue((Binary) statistics.getFirstValue(), statistics.getStartTime());
155+
} else {
156+
updateBinaryFirstValue(
157+
new Binary(String.valueOf(statistics.getFirstValue()), StandardCharsets.UTF_8),
158+
statistics.getStartTime());
159+
}
154160
}
155161
break;
156162
case BOOLEAN:

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/aggregation/LastValueAccumulator.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,13 @@ public void addStatistics(Statistics statistics) {
150150
StandardCharsets.UTF_8),
151151
statistics.getEndTime());
152152
} else {
153-
updateBinaryLastValue((Binary) statistics.getLastValue(), statistics.getEndTime());
153+
if (statistics.getLastValue() instanceof Binary) {
154+
updateBinaryLastValue((Binary) statistics.getLastValue(), statistics.getEndTime());
155+
} else {
156+
updateBinaryLastValue(
157+
new Binary(String.valueOf(statistics.getLastValue()), StandardCharsets.UTF_8),
158+
statistics.getEndTime());
159+
}
154160
}
155161
break;
156162
case BOOLEAN:

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/AlterColumnDataType.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,17 @@
1919

2020
package org.apache.iotdb.db.queryengine.plan.relational.sql.ast;
2121

22+
import org.apache.tsfile.utils.RamUsageEstimator;
23+
2224
import javax.annotation.Nullable;
2325

2426
import java.util.Collections;
2527
import java.util.List;
2628
import java.util.Objects;
2729

2830
public class AlterColumnDataType extends Statement {
31+
private static final long INSTANCE_SIZE =
32+
RamUsageEstimator.shallowSizeOfInstance(AlterColumnDataType.class);
2933
private final QualifiedName tableName;
3034
private final Identifier columnName;
3135
private final DataType dataType;
@@ -116,4 +120,14 @@ public boolean isIfColumnExists() {
116120
public boolean isView() {
117121
return view;
118122
}
123+
124+
@Override
125+
public long ramBytesUsed() {
126+
long size = INSTANCE_SIZE;
127+
size += AstMemoryEstimationHelper.getEstimatedSizeOfNodeLocation(getLocationInternal());
128+
size += tableName == null ? 0L : tableName.ramBytesUsed();
129+
size += AstMemoryEstimationHelper.getEstimatedSizeOfAccountableObject(columnName);
130+
size += AstMemoryEstimationHelper.getEstimatedSizeOfAccountableObject(dataType);
131+
return size;
132+
}
119133
}

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/memtable/AbstractMemTable.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -362,28 +362,15 @@ public void writeAlignedRow(
362362

363363
public void writeTabletNode(InsertTabletNode insertTabletNode, int start, int end) {
364364
List<IMeasurementSchema> schemaList = new ArrayList<>();
365-
int j = 0;
366-
for (TSDataType tsDataType : insertTabletNode.getDataTypes()) {
367-
logger.error("getDataTypes[{}] is {}", j, tsDataType);
368-
j++;
369-
}
370365
for (int i = 0; i < insertTabletNode.getMeasurementSchemas().length; i++) {
371366
if (insertTabletNode.getColumns()[i] == null) {
372367
schemaList.add(null);
373368
} else {
374369
schemaList.add(insertTabletNode.getMeasurementSchemas()[i]);
375370
}
376371
}
377-
int i = 0;
378-
for (IMeasurementSchema schema : schemaList) {
379-
logger.error("schemaList[{}] is {}", i, schema);
380-
i++;
381-
}
382-
logger.error("be ready to createMemChunkGroupIfNotExistAndGet");
383372
IWritableMemChunkGroup memChunkGroup =
384373
createMemChunkGroupIfNotExistAndGet(insertTabletNode.getDeviceID(), schemaList);
385-
logger.error("after createMemChunkGroupIfNotExistAndGet");
386-
logger.error("be ready to [writeTabletNode]writeTablet");
387374
memChunkGroup.writeTablet(
388375
insertTabletNode.getTimes(),
389376
insertTabletNode.getColumns(),
@@ -392,16 +379,10 @@ public void writeTabletNode(InsertTabletNode insertTabletNode, int start, int en
392379
start,
393380
end,
394381
null);
395-
logger.error("after [writeTabletNode]writeTablet");
396382
}
397383

398384
public void writeAlignedTablet(
399385
InsertTabletNode insertTabletNode, int start, int end, TSStatus[] results) {
400-
int j = 0;
401-
for (TSDataType tsDataType : insertTabletNode.getDataTypes()) {
402-
logger.error("getDataTypes[{}] is {}", j, tsDataType);
403-
j++;
404-
}
405386
List<IMeasurementSchema> schemaList = new ArrayList<>();
406387
for (int i = 0; i < insertTabletNode.getMeasurementSchemas().length; i++) {
407388
if (insertTabletNode.getColumns()[i] == null
@@ -415,22 +396,14 @@ public void writeAlignedTablet(
415396
if (schemaList.isEmpty()) {
416397
return;
417398
}
418-
int i = 0;
419-
for (IMeasurementSchema schema : schemaList) {
420-
logger.error("schemaList[{}] is {}", i, schema);
421-
i++;
422-
}
423399
final List<Pair<IDeviceID, Integer>> deviceEndOffsetPair =
424400
insertTabletNode.splitByDevice(start, end);
425401
int splitStart = start;
426402
for (Pair<IDeviceID, Integer> pair : deviceEndOffsetPair) {
427403
final IDeviceID deviceID = pair.left;
428404
int splitEnd = pair.right;
429-
logger.error("be ready to createAlignedMemChunkGroupIfNotExistAndGet");
430405
IWritableMemChunkGroup memChunkGroup =
431406
createAlignedMemChunkGroupIfNotExistAndGet(deviceID, schemaList);
432-
logger.error("after createAlignedMemChunkGroupIfNotExistAndGet");
433-
logger.error("be ready to [writeAlignedTablet]writeTablet");
434407
memChunkGroup.writeTablet(
435408
insertTabletNode.getTimes(),
436409
insertTabletNode.getColumns(),
@@ -439,7 +412,6 @@ public void writeAlignedTablet(
439412
splitStart,
440413
splitEnd,
441414
results);
442-
logger.error("after [writeAlignedTablet]writeTablet");
443415
splitStart = splitEnd;
444416
}
445417
}

0 commit comments

Comments
 (0)