Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -82,6 +82,7 @@
import org.apache.iotdb.rpc.TSStatusCode;
import org.apache.iotdb.trigger.api.enums.TriggerEvent;

import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.utils.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -420,7 +421,12 @@ private RegionExecutionResult executeCreateTimeSeries(
final ISchemaRegion schemaRegion =
schemaEngine.getSchemaRegion((SchemaRegionId) context.getRegionId());
final RegionExecutionResult result =
checkQuotaBeforeCreatingTimeSeries(schemaRegion, node.getPath().getDevicePath(), 1);
checkQuotaAndTypeBeforeCreatingTimeSeries(
schemaRegion,
node.getPath().getDevicePath(),
1,
Collections.singletonList(node.getPath().getMeasurement()),
Collections.singletonList(node.getDataType()));
if (result != null) {
return result;
}
Expand Down Expand Up @@ -475,8 +481,12 @@ private RegionExecutionResult executeCreateAlignedTimeSeries(
final ISchemaRegion schemaRegion =
schemaEngine.getSchemaRegion((SchemaRegionId) context.getRegionId());
final RegionExecutionResult result =
checkQuotaBeforeCreatingTimeSeries(
schemaRegion, node.getDevicePath(), node.getMeasurements().size());
checkQuotaAndTypeBeforeCreatingTimeSeries(
schemaRegion,
node.getDevicePath(),
node.getMeasurements().size(),
node.getMeasurements(),
node.getDataTypes());
if (result != null) {
return result;
}
Expand Down Expand Up @@ -533,8 +543,12 @@ private RegionExecutionResult executeCreateMultiTimeSeries(
for (final Map.Entry<PartialPath, MeasurementGroup> entry :
node.getMeasurementGroupMap().entrySet()) {
result =
checkQuotaBeforeCreatingTimeSeries(
schemaRegion, entry.getKey(), entry.getValue().getMeasurements().size());
checkQuotaAndTypeBeforeCreatingTimeSeries(
schemaRegion,
entry.getKey(),
entry.getValue().getMeasurements().size(),
entry.getValue().getMeasurements(),
entry.getValue().getDataTypes());
if (result != null) {
return result;
}
Expand Down Expand Up @@ -649,8 +663,12 @@ private RegionExecutionResult executeInternalCreateTimeSeries(
final ISchemaRegion schemaRegion =
schemaEngine.getSchemaRegion((SchemaRegionId) context.getRegionId());
final RegionExecutionResult result =
checkQuotaBeforeCreatingTimeSeries(
schemaRegion, node.getDevicePath(), node.getMeasurementGroup().size());
checkQuotaAndTypeBeforeCreatingTimeSeries(
schemaRegion,
node.getDevicePath(),
node.getMeasurementGroup().size(),
node.getMeasurementGroup().getMeasurements(),
node.getMeasurementGroup().getDataTypes());
if (result != null) {
return result;
}
Expand Down Expand Up @@ -736,8 +754,12 @@ private RegionExecutionResult executeInternalCreateMultiTimeSeries(
for (final Map.Entry<PartialPath, Pair<Boolean, MeasurementGroup>> deviceEntry :
node.getDeviceMap().entrySet()) {
result =
checkQuotaBeforeCreatingTimeSeries(
schemaRegion, deviceEntry.getKey(), deviceEntry.getValue().getRight().size());
checkQuotaAndTypeBeforeCreatingTimeSeries(
schemaRegion,
deviceEntry.getKey(),
deviceEntry.getValue().getRight().size(),
deviceEntry.getValue().getRight().getMeasurements(),
deviceEntry.getValue().getRight().getDataTypes());
if (result != null) {
return result;
}
Expand Down Expand Up @@ -823,8 +845,22 @@ private RegionExecutionResult executeInternalCreateMultiTimeSeries(
*
* @return null if the quota is not exceeded, otherwise return the execution result.
*/
private RegionExecutionResult checkQuotaBeforeCreatingTimeSeries(
final ISchemaRegion schemaRegion, final PartialPath path, final int size) {
private RegionExecutionResult checkQuotaAndTypeBeforeCreatingTimeSeries(
final ISchemaRegion schemaRegion,
final PartialPath path,
final int size,
final List<String> measurements,
final List<TSDataType> dataTypes) {
for (int i = 0; i < measurements.size(); ++i) {
if (dataTypes.get(i) == TSDataType.OBJECT) {
final String errorStr =
"The object type series "
+ path.concatAsMeasurementPath(measurements.get(i))
+ " is not supported.";
return RegionExecutionResult.create(
false, errorStr, RpcUtils.getStatus(TSStatusCode.METADATA_ERROR, errorStr));
}
}
try {
schemaRegion.checkSchemaQuota(path, size);
} catch (final SchemaQuotaExceededException e) {
Expand Down Expand Up @@ -949,8 +985,12 @@ private RegionExecutionResult executeActivateTemplate(
ISchemaRegion schemaRegion =
schemaEngine.getSchemaRegion((SchemaRegionId) context.getRegionId());
RegionExecutionResult result =
checkQuotaBeforeCreatingTimeSeries(
schemaRegion, node.getActivatePath(), templateSetInfo.left.getMeasurementNumber());
checkQuotaAndTypeBeforeCreatingTimeSeries(
schemaRegion,
node.getActivatePath(),
templateSetInfo.left.getMeasurementNumber(),
Collections.emptyList(),
Collections.emptyList());
if (result == null) {
return receivedFromPipe
? super.visitPipeEnrichedWritePlanNode(new PipeEnrichedWritePlanNode(node), context)
Expand Down Expand Up @@ -992,8 +1032,12 @@ private RegionExecutionResult executeBatchActivateTemplate(
false, message, RpcUtils.getStatus(TSStatusCode.METADATA_ERROR, message));
}
RegionExecutionResult result =
checkQuotaBeforeCreatingTimeSeries(
schemaRegion, devicePath, templateSetInfo.left.getMeasurementNumber());
checkQuotaAndTypeBeforeCreatingTimeSeries(
schemaRegion,
devicePath,
templateSetInfo.left.getMeasurementNumber(),
Collections.emptyList(),
Collections.emptyList());
if (result != null) {
return result;
}
Expand Down Expand Up @@ -1039,8 +1083,12 @@ private RegionExecutionResult executeInternalBatchActivateTemplate(
false, message, RpcUtils.getStatus(TSStatusCode.METADATA_ERROR, message));
}
RegionExecutionResult result =
checkQuotaBeforeCreatingTimeSeries(
schemaRegion, entry.getKey(), templateSetInfo.left.getMeasurementNumber());
checkQuotaAndTypeBeforeCreatingTimeSeries(
schemaRegion,
entry.getKey(),
templateSetInfo.left.getMeasurementNumber(),
Collections.emptyList(),
Collections.emptyList());
if (result != null) {
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4092,7 +4092,9 @@
String dataTypeString = ctx.dataType.getText().toUpperCase();
try {
dataType = TSDataType.valueOf(dataTypeString);
if (TSDataType.UNKNOWN.equals(dataType) || TSDataType.VECTOR.equals(dataType)) {
if (TSDataType.UNKNOWN.equals(dataType)
|| TSDataType.VECTOR.equals(dataType)
|| TSDataType.OBJECT.equals(dataType)) {
throw new SemanticException(String.format(UNSUPPORTED_DATATYPE_MSG, dataTypeString));
}
} catch (Exception e) {
Expand Down Expand Up @@ -4677,7 +4679,7 @@
}

@Override
public Statement visitSetThrottleQuota(IoTDBSqlParser.SetThrottleQuotaContext ctx) {

Check warning on line 4682 in iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

A "Brain Method" was detected. Refactor it to reduce at least one of the following metrics: LOC from 95 to 64, Complexity from 20 to 14, Nesting Level from 3 to 2, Number of Variables from 14 to 6.

See more on https://sonarcloud.io/project/issues?id=apache_iotdb&issues=AZ0uCUcfxPDqg0gLJJPE&open=AZ0uCUcfxPDqg0gLJJPE&pullRequest=17373
if (!IoTDBDescriptor.getInstance().getConfig().isQuotaEnable()) {
throw new SemanticException(LIMIT_CONFIGURATION_ENABLED_ERROR_MSG);
}
Expand Down
Loading