|
82 | 82 | import org.apache.iotdb.rpc.TSStatusCode; |
83 | 83 | import org.apache.iotdb.trigger.api.enums.TriggerEvent; |
84 | 84 |
|
| 85 | +import org.apache.tsfile.enums.TSDataType; |
85 | 86 | import org.apache.tsfile.utils.Pair; |
86 | 87 | import org.slf4j.Logger; |
87 | 88 | import org.slf4j.LoggerFactory; |
@@ -420,7 +421,12 @@ private RegionExecutionResult executeCreateTimeSeries( |
420 | 421 | final ISchemaRegion schemaRegion = |
421 | 422 | schemaEngine.getSchemaRegion((SchemaRegionId) context.getRegionId()); |
422 | 423 | final RegionExecutionResult result = |
423 | | - checkQuotaBeforeCreatingTimeSeries(schemaRegion, node.getPath().getDevicePath(), 1); |
| 424 | + checkQuotaAndTypeBeforeCreatingTimeSeries( |
| 425 | + schemaRegion, |
| 426 | + node.getPath().getDevicePath(), |
| 427 | + 1, |
| 428 | + Collections.singletonList(node.getPath().getMeasurement()), |
| 429 | + Collections.singletonList(node.getDataType())); |
424 | 430 | if (result != null) { |
425 | 431 | return result; |
426 | 432 | } |
@@ -475,8 +481,12 @@ private RegionExecutionResult executeCreateAlignedTimeSeries( |
475 | 481 | final ISchemaRegion schemaRegion = |
476 | 482 | schemaEngine.getSchemaRegion((SchemaRegionId) context.getRegionId()); |
477 | 483 | final RegionExecutionResult result = |
478 | | - checkQuotaBeforeCreatingTimeSeries( |
479 | | - schemaRegion, node.getDevicePath(), node.getMeasurements().size()); |
| 484 | + checkQuotaAndTypeBeforeCreatingTimeSeries( |
| 485 | + schemaRegion, |
| 486 | + node.getDevicePath(), |
| 487 | + node.getMeasurements().size(), |
| 488 | + node.getMeasurements(), |
| 489 | + node.getDataTypes()); |
480 | 490 | if (result != null) { |
481 | 491 | return result; |
482 | 492 | } |
@@ -533,8 +543,12 @@ private RegionExecutionResult executeCreateMultiTimeSeries( |
533 | 543 | for (final Map.Entry<PartialPath, MeasurementGroup> entry : |
534 | 544 | node.getMeasurementGroupMap().entrySet()) { |
535 | 545 | result = |
536 | | - checkQuotaBeforeCreatingTimeSeries( |
537 | | - schemaRegion, entry.getKey(), entry.getValue().getMeasurements().size()); |
| 546 | + checkQuotaAndTypeBeforeCreatingTimeSeries( |
| 547 | + schemaRegion, |
| 548 | + entry.getKey(), |
| 549 | + entry.getValue().getMeasurements().size(), |
| 550 | + entry.getValue().getMeasurements(), |
| 551 | + entry.getValue().getDataTypes()); |
538 | 552 | if (result != null) { |
539 | 553 | return result; |
540 | 554 | } |
@@ -649,8 +663,12 @@ private RegionExecutionResult executeInternalCreateTimeSeries( |
649 | 663 | final ISchemaRegion schemaRegion = |
650 | 664 | schemaEngine.getSchemaRegion((SchemaRegionId) context.getRegionId()); |
651 | 665 | final RegionExecutionResult result = |
652 | | - checkQuotaBeforeCreatingTimeSeries( |
653 | | - schemaRegion, node.getDevicePath(), node.getMeasurementGroup().size()); |
| 666 | + checkQuotaAndTypeBeforeCreatingTimeSeries( |
| 667 | + schemaRegion, |
| 668 | + node.getDevicePath(), |
| 669 | + node.getMeasurementGroup().size(), |
| 670 | + node.getMeasurementGroup().getMeasurements(), |
| 671 | + node.getMeasurementGroup().getDataTypes()); |
654 | 672 | if (result != null) { |
655 | 673 | return result; |
656 | 674 | } |
@@ -736,8 +754,12 @@ private RegionExecutionResult executeInternalCreateMultiTimeSeries( |
736 | 754 | for (final Map.Entry<PartialPath, Pair<Boolean, MeasurementGroup>> deviceEntry : |
737 | 755 | node.getDeviceMap().entrySet()) { |
738 | 756 | result = |
739 | | - checkQuotaBeforeCreatingTimeSeries( |
740 | | - schemaRegion, deviceEntry.getKey(), deviceEntry.getValue().getRight().size()); |
| 757 | + checkQuotaAndTypeBeforeCreatingTimeSeries( |
| 758 | + schemaRegion, |
| 759 | + deviceEntry.getKey(), |
| 760 | + deviceEntry.getValue().getRight().size(), |
| 761 | + deviceEntry.getValue().getRight().getMeasurements(), |
| 762 | + deviceEntry.getValue().getRight().getDataTypes()); |
741 | 763 | if (result != null) { |
742 | 764 | return result; |
743 | 765 | } |
@@ -823,8 +845,22 @@ private RegionExecutionResult executeInternalCreateMultiTimeSeries( |
823 | 845 | * |
824 | 846 | * @return null if the quota is not exceeded, otherwise return the execution result. |
825 | 847 | */ |
826 | | - private RegionExecutionResult checkQuotaBeforeCreatingTimeSeries( |
827 | | - final ISchemaRegion schemaRegion, final PartialPath path, final int size) { |
| 848 | + private RegionExecutionResult checkQuotaAndTypeBeforeCreatingTimeSeries( |
| 849 | + final ISchemaRegion schemaRegion, |
| 850 | + final PartialPath path, |
| 851 | + final int size, |
| 852 | + final List<String> measurements, |
| 853 | + final List<TSDataType> dataTypes) { |
| 854 | + for (int i = 0; i < measurements.size(); ++i) { |
| 855 | + if (dataTypes.get(i) == TSDataType.OBJECT) { |
| 856 | + final String errorStr = |
| 857 | + "The object type series " |
| 858 | + + path.concatAsMeasurementPath(measurements.get(i)) |
| 859 | + + " is not supported."; |
| 860 | + return RegionExecutionResult.create( |
| 861 | + false, errorStr, RpcUtils.getStatus(TSStatusCode.METADATA_ERROR, errorStr)); |
| 862 | + } |
| 863 | + } |
828 | 864 | try { |
829 | 865 | schemaRegion.checkSchemaQuota(path, size); |
830 | 866 | } catch (final SchemaQuotaExceededException e) { |
@@ -949,8 +985,12 @@ private RegionExecutionResult executeActivateTemplate( |
949 | 985 | ISchemaRegion schemaRegion = |
950 | 986 | schemaEngine.getSchemaRegion((SchemaRegionId) context.getRegionId()); |
951 | 987 | RegionExecutionResult result = |
952 | | - checkQuotaBeforeCreatingTimeSeries( |
953 | | - schemaRegion, node.getActivatePath(), templateSetInfo.left.getMeasurementNumber()); |
| 988 | + checkQuotaAndTypeBeforeCreatingTimeSeries( |
| 989 | + schemaRegion, |
| 990 | + node.getActivatePath(), |
| 991 | + templateSetInfo.left.getMeasurementNumber(), |
| 992 | + Collections.emptyList(), |
| 993 | + Collections.emptyList()); |
954 | 994 | if (result == null) { |
955 | 995 | return receivedFromPipe |
956 | 996 | ? super.visitPipeEnrichedWritePlanNode(new PipeEnrichedWritePlanNode(node), context) |
@@ -992,8 +1032,12 @@ private RegionExecutionResult executeBatchActivateTemplate( |
992 | 1032 | false, message, RpcUtils.getStatus(TSStatusCode.METADATA_ERROR, message)); |
993 | 1033 | } |
994 | 1034 | RegionExecutionResult result = |
995 | | - checkQuotaBeforeCreatingTimeSeries( |
996 | | - schemaRegion, devicePath, templateSetInfo.left.getMeasurementNumber()); |
| 1035 | + checkQuotaAndTypeBeforeCreatingTimeSeries( |
| 1036 | + schemaRegion, |
| 1037 | + devicePath, |
| 1038 | + templateSetInfo.left.getMeasurementNumber(), |
| 1039 | + Collections.emptyList(), |
| 1040 | + Collections.emptyList()); |
997 | 1041 | if (result != null) { |
998 | 1042 | return result; |
999 | 1043 | } |
@@ -1039,8 +1083,12 @@ private RegionExecutionResult executeInternalBatchActivateTemplate( |
1039 | 1083 | false, message, RpcUtils.getStatus(TSStatusCode.METADATA_ERROR, message)); |
1040 | 1084 | } |
1041 | 1085 | RegionExecutionResult result = |
1042 | | - checkQuotaBeforeCreatingTimeSeries( |
1043 | | - schemaRegion, entry.getKey(), templateSetInfo.left.getMeasurementNumber()); |
| 1086 | + checkQuotaAndTypeBeforeCreatingTimeSeries( |
| 1087 | + schemaRegion, |
| 1088 | + entry.getKey(), |
| 1089 | + templateSetInfo.left.getMeasurementNumber(), |
| 1090 | + Collections.emptyList(), |
| 1091 | + Collections.emptyList()); |
1044 | 1092 | if (result != null) { |
1045 | 1093 | return result; |
1046 | 1094 | } |
|
0 commit comments