This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 35ea5006a2d Optimized DeleteTimeSeriesProcedure not to set mods when
the deleted time series are all views
35ea5006a2d is described below
commit 35ea5006a2d8020027d03f671343f7245ac72d29
Author: Caideyipi <[email protected]>
AuthorDate: Tue Jul 16 08:49:31 2024 +0800
Optimized DeleteTimeSeriesProcedure not to set mods when the deleted time
series are all views
---
.../java/org/apache/iotdb/rpc/TSStatusCode.java | 1 +
.../impl/schema/DeleteTimeSeriesProcedure.java | 152 ++++++++++++---------
.../schemaregion/SchemaExecutionVisitor.java | 13 +-
.../impl/DataNodeInternalRPCServiceImpl.java | 50 +++++--
.../schemaengine/schemaregion/ISchemaRegion.java | 16 ++-
.../schemaregion/impl/SchemaRegionMemoryImpl.java | 21 +--
.../schemaregion/impl/SchemaRegionPBTreeImpl.java | 25 ++--
.../mtree/impl/mem/MTreeBelowSGMemoryImpl.java | 13 +-
.../mtree/impl/pbtree/MTreeBelowSGCachedImpl.java | 13 +-
.../schemaRegion/SchemaRegionAliasAndTagTest.java | 8 +-
.../schemaRegion/SchemaRegionBasicTest.java | 5 +-
.../schemaRegion/SchemaRegionTemplateTest.java | 13 +-
.../schemaRegion/SchemaRegionTestUtil.java | 11 +-
.../schemaRegion/SchemaStatisticsTest.java | 118 ++++++++--------
.../schema/node/role/IMeasurementMNode.java | 2 +-
15 files changed, 269 insertions(+), 192 deletions(-)
diff --git
a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/TSStatusCode.java
b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/TSStatusCode.java
index 0d281a0bf3a..4b8a5fee813 100644
---
a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/TSStatusCode.java
+++
b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/TSStatusCode.java
@@ -80,6 +80,7 @@ public enum TSStatusCode {
DATABASE_CONFIG_ERROR(525),
SCHEMA_QUOTA_EXCEEDED(526),
MEASUREMENT_ALREADY_EXISTS_IN_TEMPLATE(527),
+ ONLY_LOGICAL_VIEW(528),
// Storage Engine
SYSTEM_READ_ONLY(600),
diff --git
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java
index 740e42f1967..cd9133c0cf5 100644
---
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java
+++
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java
@@ -76,24 +76,29 @@ public class DeleteTimeSeriesProcedure
private transient String requestMessage;
+ // Do not serialize it for compatibility concerns.
+ // If the procedure is restored, add mods to the data regions anyway.
+ private transient boolean isAllLogicalView;
+
private static final String CONSENSUS_WRITE_ERROR =
"Failed in the write API executing the consensus layer due to: ";
- public DeleteTimeSeriesProcedure(boolean isGeneratedByPipe) {
+ public DeleteTimeSeriesProcedure(final boolean isGeneratedByPipe) {
super(isGeneratedByPipe);
}
public DeleteTimeSeriesProcedure(
- String queryId, PathPatternTree patternTree, boolean isGeneratedByPipe) {
+ final String queryId, final PathPatternTree patternTree, final boolean
isGeneratedByPipe) {
super(isGeneratedByPipe);
this.queryId = queryId;
setPatternTree(patternTree);
}
@Override
- protected Flow executeFromState(ConfigNodeProcedureEnv env,
DeleteTimeSeriesState state)
+ protected Flow executeFromState(
+ final ConfigNodeProcedureEnv env, final DeleteTimeSeriesState state)
throws ProcedureSuspendedException, ProcedureYieldException,
InterruptedException {
- long startTime = System.currentTimeMillis();
+ final long startTime = System.currentTimeMillis();
try {
switch (state) {
case CONSTRUCT_BLACK_LIST:
@@ -135,15 +140,16 @@ public class DeleteTimeSeriesProcedure
}
}
- // return the total num of timeSeries in schemaEngine black list
- private long constructBlackList(ConfigNodeProcedureEnv env) {
- Map<TConsensusGroupId, TRegionReplicaSet> targetSchemaRegionGroup =
+ // Return the total num of timeSeries in schemaEngine black list
+ private long constructBlackList(final ConfigNodeProcedureEnv env) {
+ final Map<TConsensusGroupId, TRegionReplicaSet> targetSchemaRegionGroup =
env.getConfigManager().getRelatedSchemaRegionGroup(patternTree);
if (targetSchemaRegionGroup.isEmpty()) {
return 0;
}
- List<TSStatus> successResult = new ArrayList<>();
- DeleteTimeSeriesRegionTaskExecutor<TConstructSchemaBlackListReq>
constructBlackListTask =
+ isAllLogicalView = true;
+ final List<TSStatus> successResult = new ArrayList<>();
+ final DeleteTimeSeriesRegionTaskExecutor<TConstructSchemaBlackListReq>
constructBlackListTask =
new DeleteTimeSeriesRegionTaskExecutor<TConstructSchemaBlackListReq>(
"construct schema engine black list",
env,
@@ -153,14 +159,17 @@ public class DeleteTimeSeriesProcedure
new TConstructSchemaBlackListReq(consensusGroupIdList,
patternTreeBytes))) {
@Override
protected List<TConsensusGroupId> processResponseOfOneDataNode(
- TDataNodeLocation dataNodeLocation,
- List<TConsensusGroupId> consensusGroupIdList,
- TSStatus response) {
- List<TConsensusGroupId> failedRegionList = new ArrayList<>();
+ final TDataNodeLocation dataNodeLocation,
+ final List<TConsensusGroupId> consensusGroupIdList,
+ final TSStatus response) {
+ final List<TConsensusGroupId> failedRegionList = new ArrayList<>();
if (response.getCode() ==
TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+ isAllLogicalView = false;
+ successResult.add(response);
+ } else if (response.getCode() ==
TSStatusCode.ONLY_LOGICAL_VIEW.getStatusCode()) {
successResult.add(response);
} else if (response.getCode() ==
TSStatusCode.MULTIPLE_ERROR.getStatusCode()) {
- List<TSStatus> subStatusList = response.getSubStatus();
+ final List<TSStatus> subStatusList = response.getSubStatus();
for (int i = 0; i < subStatusList.size(); i++) {
if (subStatusList.get(i).getCode() ==
TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
successResult.add(subStatusList.get(i));
@@ -180,25 +189,24 @@ public class DeleteTimeSeriesProcedure
return 0;
}
- long preDeletedNum = 0;
- for (TSStatus resp : successResult) {
- preDeletedNum += Long.parseLong(resp.getMessage());
- }
- return preDeletedNum;
+ return successResult.stream()
+ .mapToLong(resp -> Long.parseLong(resp.getMessage()))
+ .reduce(Long::sum)
+ .orElse(0L);
}
- private void invalidateCache(ConfigNodeProcedureEnv env) {
- Map<Integer, TDataNodeLocation> dataNodeLocationMap =
+ private void invalidateCache(final ConfigNodeProcedureEnv env) {
+ final Map<Integer, TDataNodeLocation> dataNodeLocationMap =
env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations();
- DataNodeAsyncRequestContext<TInvalidateMatchedSchemaCacheReq, TSStatus>
clientHandler =
+ final DataNodeAsyncRequestContext<TInvalidateMatchedSchemaCacheReq,
TSStatus> clientHandler =
new DataNodeAsyncRequestContext<>(
CnToDnRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE,
new TInvalidateMatchedSchemaCacheReq(patternTreeBytes),
dataNodeLocationMap);
CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler);
- Map<Integer, TSStatus> statusMap = clientHandler.getResponseMap();
- for (TSStatus status : statusMap.values()) {
- // all dataNodes must clear the related schemaEngine cache
+ final Map<Integer, TSStatus> statusMap = clientHandler.getResponseMap();
+ for (final TSStatus status : statusMap.values()) {
+ // All dataNodes must clear the related schemaEngine cache
if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
LOGGER.error("Failed to invalidate schemaEngine cache of timeSeries
{}", requestMessage);
setFailure(
@@ -210,11 +218,11 @@ public class DeleteTimeSeriesProcedure
setNextState(DeleteTimeSeriesState.DELETE_DATA);
}
- private void deleteData(ConfigNodeProcedureEnv env) {
+ private void deleteData(final ConfigNodeProcedureEnv env) {
deleteDataWithRawPathPattern(env);
}
- private void deleteDataWithRawPathPattern(ConfigNodeProcedureEnv env) {
+ private void deleteDataWithRawPathPattern(final ConfigNodeProcedureEnv env) {
executeDeleteData(env, patternTree);
if (isFailed()) {
return;
@@ -222,16 +230,21 @@ public class DeleteTimeSeriesProcedure
setNextState(DeleteTimeSeriesState.DELETE_TIMESERIES_SCHEMA);
}
- private void executeDeleteData(ConfigNodeProcedureEnv env, PathPatternTree
patternTree) {
- Map<TConsensusGroupId, TRegionReplicaSet> relatedDataRegionGroup =
+ private void executeDeleteData(
+ final ConfigNodeProcedureEnv env, final PathPatternTree patternTree) {
+ if (isAllLogicalView) {
+ return;
+ }
+
+ final Map<TConsensusGroupId, TRegionReplicaSet> relatedDataRegionGroup =
env.getConfigManager().getRelatedDataRegionGroup(patternTree);
- // target timeSeries has no data
+ // Target timeSeries has no data
if (relatedDataRegionGroup.isEmpty()) {
return;
}
- DeleteTimeSeriesRegionTaskExecutor<TDeleteDataForDeleteSchemaReq>
deleteDataTask =
+ final DeleteTimeSeriesRegionTaskExecutor<TDeleteDataForDeleteSchemaReq>
deleteDataTask =
new DeleteTimeSeriesRegionTaskExecutor<>(
"delete data",
env,
@@ -246,8 +259,8 @@ public class DeleteTimeSeriesProcedure
deleteDataTask.execute();
}
- private void deleteTimeSeriesSchema(ConfigNodeProcedureEnv env) {
- DeleteTimeSeriesRegionTaskExecutor<TDeleteTimeSeriesReq>
deleteTimeSeriesTask =
+ private void deleteTimeSeriesSchema(final ConfigNodeProcedureEnv env) {
+ final DeleteTimeSeriesRegionTaskExecutor<TDeleteTimeSeriesReq>
deleteTimeSeriesTask =
new DeleteTimeSeriesRegionTaskExecutor<>(
"delete time series in schema engine",
env,
@@ -259,7 +272,7 @@ public class DeleteTimeSeriesProcedure
deleteTimeSeriesTask.execute();
}
- private void collectPayload4Pipe(ConfigNodeProcedureEnv env) {
+ private void collectPayload4Pipe(final ConfigNodeProcedureEnv env) {
TSStatus result;
try {
result =
@@ -269,7 +282,7 @@ public class DeleteTimeSeriesProcedure
isGeneratedByPipe
? new PipeEnrichedPlan(new
PipeDeleteTimeSeriesPlan(patternTreeBytes))
: new PipeDeleteTimeSeriesPlan(patternTreeBytes));
- } catch (ConsensusException e) {
+ } catch (final ConsensusException e) {
LOGGER.warn(CONSENSUS_WRITE_ERROR, e);
result = new
TSStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode());
result.setMessage(e.getMessage());
@@ -281,10 +294,10 @@ public class DeleteTimeSeriesProcedure
@Override
protected void rollbackState(
- ConfigNodeProcedureEnv env, DeleteTimeSeriesState deleteTimeSeriesState)
+ final ConfigNodeProcedureEnv env, final DeleteTimeSeriesState
deleteTimeSeriesState)
throws IOException, InterruptedException, ProcedureException {
if (deleteTimeSeriesState == DeleteTimeSeriesState.CONSTRUCT_BLACK_LIST) {
- DeleteTimeSeriesRegionTaskExecutor<TRollbackSchemaBlackListReq>
rollbackStateTask =
+ final DeleteTimeSeriesRegionTaskExecutor<TRollbackSchemaBlackListReq>
rollbackStateTask =
new DeleteTimeSeriesRegionTaskExecutor<>(
"roll back schema engine black list",
env,
@@ -297,17 +310,17 @@ public class DeleteTimeSeriesProcedure
}
@Override
- protected boolean isRollbackSupported(DeleteTimeSeriesState
deleteTimeSeriesState) {
+ protected boolean isRollbackSupported(final DeleteTimeSeriesState
deleteTimeSeriesState) {
return true;
}
@Override
- protected DeleteTimeSeriesState getState(int stateId) {
+ protected DeleteTimeSeriesState getState(final int stateId) {
return DeleteTimeSeriesState.values()[stateId];
}
@Override
- protected int getStateId(DeleteTimeSeriesState deleteTimeSeriesState) {
+ protected int getStateId(final DeleteTimeSeriesState deleteTimeSeriesState) {
return deleteTimeSeriesState.ordinal();
}
@@ -324,25 +337,25 @@ public class DeleteTimeSeriesProcedure
return patternTree;
}
- public void setPatternTree(PathPatternTree patternTree) {
+ public void setPatternTree(final PathPatternTree patternTree) {
this.patternTree = patternTree;
requestMessage = patternTree.getAllPathPatterns().toString();
patternTreeBytes = preparePatternTreeBytesData(patternTree);
}
- private ByteBuffer preparePatternTreeBytesData(PathPatternTree patternTree) {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- DataOutputStream dataOutputStream = new
DataOutputStream(byteArrayOutputStream);
+ private ByteBuffer preparePatternTreeBytesData(final PathPatternTree
patternTree) {
+ final ByteArrayOutputStream byteArrayOutputStream = new
ByteArrayOutputStream();
+ final DataOutputStream dataOutputStream = new
DataOutputStream(byteArrayOutputStream);
try {
patternTree.serialize(dataOutputStream);
- } catch (IOException ignored) {
-
+ } catch (final IOException ignored) {
+ // ByteArrayOutputStream won't throw IOException
}
return ByteBuffer.wrap(byteArrayOutputStream.toByteArray());
}
@Override
- public void serialize(DataOutputStream stream) throws IOException {
+ public void serialize(final DataOutputStream stream) throws IOException {
stream.writeShort(
isGeneratedByPipe
?
ProcedureType.PIPE_ENRICHED_DELETE_TIMESERIES_PROCEDURE.getTypeCode()
@@ -353,17 +366,21 @@ public class DeleteTimeSeriesProcedure
}
@Override
- public void deserialize(ByteBuffer byteBuffer) {
+ public void deserialize(final ByteBuffer byteBuffer) {
super.deserialize(byteBuffer);
queryId = ReadWriteIOUtils.readString(byteBuffer);
setPatternTree(PathPatternTree.deserialize(byteBuffer));
+ if (getCurrentState() == DeleteTimeSeriesState.CLEAN_DATANODE_SCHEMA_CACHE
+ || getCurrentState() == DeleteTimeSeriesState.DELETE_DATA) {
+ LOGGER.info("Successfully restored, will set mods to the data regions
anyway");
+ }
}
@Override
- public boolean equals(Object o) {
+ public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
- DeleteTimeSeriesProcedure that = (DeleteTimeSeriesProcedure) o;
+ final DeleteTimeSeriesProcedure that = (DeleteTimeSeriesProcedure) o;
return this.getProcId() == that.getProcId()
&& this.getCurrentState().equals(that.getCurrentState())
&& this.getCycles() == getCycles()
@@ -383,22 +400,22 @@ public class DeleteTimeSeriesProcedure
private final String taskName;
DeleteTimeSeriesRegionTaskExecutor(
- String taskName,
- ConfigNodeProcedureEnv env,
- Map<TConsensusGroupId, TRegionReplicaSet> targetSchemaRegionGroup,
- CnToDnRequestType dataNodeRequestType,
- BiFunction<TDataNodeLocation, List<TConsensusGroupId>, Q>
dataNodeRequestGenerator) {
+ final String taskName,
+ final ConfigNodeProcedureEnv env,
+ final Map<TConsensusGroupId, TRegionReplicaSet>
targetSchemaRegionGroup,
+ final CnToDnRequestType dataNodeRequestType,
+ final BiFunction<TDataNodeLocation, List<TConsensusGroupId>, Q>
dataNodeRequestGenerator) {
super(env, targetSchemaRegionGroup, false, dataNodeRequestType,
dataNodeRequestGenerator);
this.taskName = taskName;
}
DeleteTimeSeriesRegionTaskExecutor(
- String taskName,
- ConfigNodeProcedureEnv env,
- Map<TConsensusGroupId, TRegionReplicaSet> targetDataRegionGroup,
- boolean executeOnAllReplicaset,
- CnToDnRequestType dataNodeRequestType,
- BiFunction<TDataNodeLocation, List<TConsensusGroupId>, Q>
dataNodeRequestGenerator) {
+ final String taskName,
+ final ConfigNodeProcedureEnv env,
+ final Map<TConsensusGroupId, TRegionReplicaSet> targetDataRegionGroup,
+ final boolean executeOnAllReplicaset,
+ final CnToDnRequestType dataNodeRequestType,
+ final BiFunction<TDataNodeLocation, List<TConsensusGroupId>, Q>
dataNodeRequestGenerator) {
super(
env,
targetDataRegionGroup,
@@ -410,16 +427,16 @@ public class DeleteTimeSeriesProcedure
@Override
protected List<TConsensusGroupId> processResponseOfOneDataNode(
- TDataNodeLocation dataNodeLocation,
- List<TConsensusGroupId> consensusGroupIdList,
- TSStatus response) {
- List<TConsensusGroupId> failedRegionList = new ArrayList<>();
+ final TDataNodeLocation dataNodeLocation,
+ final List<TConsensusGroupId> consensusGroupIdList,
+ final TSStatus response) {
+ final List<TConsensusGroupId> failedRegionList = new ArrayList<>();
if (response.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
return failedRegionList;
}
if (response.getCode() == TSStatusCode.MULTIPLE_ERROR.getStatusCode()) {
- List<TSStatus> subStatus = response.getSubStatus();
+ final List<TSStatus> subStatus = response.getSubStatus();
for (int i = 0; i < subStatus.size(); i++) {
if (subStatus.get(i).getCode() !=
TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
failedRegionList.add(consensusGroupIdList.get(i));
@@ -433,7 +450,8 @@ public class DeleteTimeSeriesProcedure
@Override
protected void onAllReplicasetFailure(
- TConsensusGroupId consensusGroupId, Set<TDataNodeLocation>
dataNodeLocationSet) {
+ final TConsensusGroupId consensusGroupId,
+ final Set<TDataNodeLocation> dataNodeLocationSet) {
setFailure(
new ProcedureException(
new MetadataException(
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/consensus/statemachine/schemaregion/SchemaExecutionVisitor.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/consensus/statemachine/schemaregion/SchemaExecutionVisitor.java
index 0dbdeac8ce7..94d8dda19ac 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/consensus/statemachine/schemaregion/SchemaExecutionVisitor.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/consensus/statemachine/schemaregion/SchemaExecutionVisitor.java
@@ -383,11 +383,16 @@ public class SchemaExecutionVisitor extends
PlanVisitor<TSStatus, ISchemaRegion>
@Override
public TSStatus visitConstructSchemaBlackList(
- ConstructSchemaBlackListNode node, ISchemaRegion schemaRegion) {
+ final ConstructSchemaBlackListNode node, final ISchemaRegion
schemaRegion) {
try {
- long preDeletedNum =
schemaRegion.constructSchemaBlackList(node.getPatternTree());
- return RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS,
String.valueOf(preDeletedNum));
- } catch (MetadataException e) {
+ final Pair<Long, Boolean> preDeletedNumAndIsAllLogicalView =
+ schemaRegion.constructSchemaBlackList(node.getPatternTree());
+ return RpcUtils.getStatus(
+ Boolean.TRUE.equals(preDeletedNumAndIsAllLogicalView.getRight())
+ ? TSStatusCode.ONLY_LOGICAL_VIEW
+ : TSStatusCode.SUCCESS_STATUS,
+ String.valueOf(preDeletedNumAndIsAllLogicalView.getLeft()));
+ } catch (final MetadataException e) {
logger.error(e.getMessage(), e);
return RpcUtils.getStatus(e.getErrorCode(), e.getMessage());
}
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java
index 2effa00ce89..d5c894c13ad 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java
@@ -514,32 +514,34 @@ public class DataNodeInternalRPCServiceImpl implements
IDataNodeRPCService.Iface
}
@Override
- public TSStatus constructSchemaBlackList(TConstructSchemaBlackListReq req)
throws TException {
- PathPatternTree patternTree =
+ public TSStatus constructSchemaBlackList(final TConstructSchemaBlackListReq
req)
+ throws TException {
+ final PathPatternTree patternTree =
PathPatternTree.deserialize(ByteBuffer.wrap(req.getPathPatternTree()));
- AtomicInteger preDeletedNum = new AtomicInteger(0);
- TSStatus executionResult =
- executeInternalSchemaTask(
+ final AtomicLong preDeletedNum = new AtomicLong(0);
+ final TSStatus executionResult =
+ executeSchemaBlackListTask(
req.getSchemaRegionIdList(),
consensusGroupId -> {
- String storageGroup =
+ final String storageGroup =
schemaEngine
.getSchemaRegion(new
SchemaRegionId(consensusGroupId.getId()))
.getDatabaseFullPath();
- PathPatternTree filteredPatternTree =
+ final PathPatternTree filteredPatternTree =
filterPathPatternTree(patternTree, storageGroup);
if (filteredPatternTree.isEmpty()) {
- return RpcUtils.SUCCESS_STATUS;
+ return new
TSStatus(TSStatusCode.ONLY_LOGICAL_VIEW.getStatusCode());
}
- RegionWriteExecutor executor = new RegionWriteExecutor();
- TSStatus status =
+ final RegionWriteExecutor executor = new RegionWriteExecutor();
+ final TSStatus status =
executor
.execute(
new SchemaRegionId(consensusGroupId.getId()),
new ConstructSchemaBlackListNode(new PlanNodeId(""),
filteredPatternTree))
.getStatus();
- if (status.code == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
- preDeletedNum.getAndAdd(Integer.parseInt(status.getMessage()));
+ if (status.code == TSStatusCode.SUCCESS_STATUS.getStatusCode()
+ || status.code ==
TSStatusCode.ONLY_LOGICAL_VIEW.getStatusCode()) {
+ preDeletedNum.getAndAdd(Long.parseLong(status.getMessage()));
}
return status;
});
@@ -1295,6 +1297,30 @@ public class DataNodeInternalRPCServiceImpl implements
IDataNodeRPCService.Iface
return resp;
}
+ private TSStatus executeSchemaBlackListTask(
+ final List<TConsensusGroupId> consensusGroupIdList,
+ final Function<TConsensusGroupId, TSStatus> executeOnOneRegion) {
+ final List<TSStatus> statusList = new ArrayList<>();
+ TSStatus status;
+ boolean hasFailure = false;
+ for (final TConsensusGroupId consensusGroupId : consensusGroupIdList) {
+ status = executeOnOneRegion.apply(consensusGroupId);
+ if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()
+ && status.getCode() !=
TSStatusCode.ONLY_LOGICAL_VIEW.getStatusCode()) {
+ hasFailure = true;
+ }
+ statusList.add(status);
+ }
+ if (hasFailure) {
+ return RpcUtils.getStatus(statusList);
+ } else {
+ return statusList.stream()
+ .filter(tsStatus -> tsStatus.getCode() ==
TSStatusCode.SUCCESS_STATUS.getStatusCode())
+ .findFirst()
+ .orElse(new
TSStatus(TSStatusCode.ONLY_LOGICAL_VIEW.getStatusCode()));
+ }
+ }
+
private TSStatus executeInternalSchemaTask(
List<TConsensusGroupId> consensusGroupIdList,
Function<TConsensusGroupId, TSStatus> executeOnOneRegion) {
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/ISchemaRegion.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/ISchemaRegion.java
index 61ef64c1d26..da9c3f0a7b3 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/ISchemaRegion.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/ISchemaRegion.java
@@ -46,6 +46,8 @@ import
org.apache.iotdb.db.schemaengine.schemaregion.write.req.view.IAlterLogica
import
org.apache.iotdb.db.schemaengine.schemaregion.write.req.view.ICreateLogicalViewPlan;
import org.apache.iotdb.db.schemaengine.template.Template;
+import org.apache.tsfile.utils.Pair;
+
import java.io.File;
import java.io.IOException;
import java.util.List;
@@ -144,14 +146,16 @@ public interface ISchemaRegion {
throws SchemaQuotaExceededException;
/**
- * Construct schema black list via setting matched timeseries to pre deleted.
+ * Construct schema black list via setting matched time series to preDeleted.
*
- * @param patternTree
- * @throws MetadataException
- * @return preDeletedNum. If there are intersections of patterns in the
patternTree, there may be
- * more than are actually pre-deleted.
+ * @param patternTree the patterns to construct black list
+ * @throws MetadataException If write to mLog failed
+ * @return {@link Pair}{@literal <}preDeletedNum, isAllLogicalView{@literal
>}. If there are
+ * intersections of patterns in the patternTree, there may be more than
are actually
+ * pre-deleted.
*/
- long constructSchemaBlackList(PathPatternTree patternTree) throws
MetadataException;
+ Pair<Long, Boolean> constructSchemaBlackList(final PathPatternTree
patternTree)
+ throws MetadataException;
/**
* Rollback schema black list via setting matched timeseries to not pre
deleted.
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionMemoryImpl.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionMemoryImpl.java
index e9173cc5888..7647702e839 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionMemoryImpl.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionMemoryImpl.java
@@ -102,6 +102,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
import static org.apache.tsfile.common.constant.TsFileConstant.PATH_SEPARATOR;
@@ -717,23 +718,25 @@ public class SchemaRegionMemoryImpl implements
ISchemaRegion {
}
@Override
- public long constructSchemaBlackList(PathPatternTree patternTree) throws
MetadataException {
+ public Pair<Long, Boolean> constructSchemaBlackList(final PathPatternTree
patternTree)
+ throws MetadataException {
long preDeletedNum = 0;
- for (PartialPath pathPattern : patternTree.getAllPathPatterns()) {
- // Given pathPatterns may match one timeseries multi times, which may
results in the
- // preDeletedNum larger than the actual num of timeseries. It doesn't
matter since the main
- // purpose is to check whether there's timeseries to be deleted.
- List<PartialPath> paths = mtree.constructSchemaBlackList(pathPattern);
+ final AtomicBoolean isAllLogicalView = new AtomicBoolean(true);
+ for (final PartialPath pathPattern : patternTree.getAllPathPatterns()) {
+ // Given pathPatterns may match one time series multi times, which may
results in the
+ // preDeletedNum larger than the actual num of time series. It doesn't
matter since the main
+ // purpose is to check whether there's time series to be deleted.
+ final List<PartialPath> paths =
mtree.constructSchemaBlackList(pathPattern, isAllLogicalView);
preDeletedNum += paths.size();
- for (PartialPath path : paths) {
+ for (final PartialPath path : paths) {
try {
writeToMLog(SchemaRegionWritePlanFactory.getPreDeleteTimeSeriesPlan(path));
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new MetadataException(e);
}
}
}
- return preDeletedNum;
+ return new Pair<>(preDeletedNum, isAllLogicalView.get());
}
private void recoverPreDeleteTimeseries(PartialPath path) throws
MetadataException {
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionPBTreeImpl.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionPBTreeImpl.java
index 4dbfaf5c3bf..f8659a4d02d 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionPBTreeImpl.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionPBTreeImpl.java
@@ -103,6 +103,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
import static org.apache.tsfile.common.constant.TsFileConstant.PATH_SEPARATOR;
@@ -803,27 +804,29 @@ public class SchemaRegionPBTreeImpl implements
ISchemaRegion {
}
@Override
- public long constructSchemaBlackList(PathPatternTree patternTree) throws
MetadataException {
+ public Pair<Long, Boolean> constructSchemaBlackList(final PathPatternTree
patternTree)
+ throws MetadataException {
long preDeletedNum = 0;
- for (PartialPath pathPattern : patternTree.getAllPathPatterns()) {
- // Given pathPatterns may match one timeseries multi times, which may
results in the
- // preDeletedNum larger than the actual num of timeseries. It doesn't
matter since the main
- // purpose is to check whether there's timeseries to be deleted.
- List<PartialPath> paths = mtree.constructSchemaBlackList(pathPattern);
+ final AtomicBoolean isAllLogicalView = new AtomicBoolean(true);
+ for (final PartialPath pathPattern : patternTree.getAllPathPatterns()) {
+ // Given pathPatterns may match one time series multi times, which may
results in the
+ // preDeletedNum larger than the actual num of time series. It doesn't
matter since the main
+ // purpose is to check whether there's time series to be deleted.
+ final List<PartialPath> paths =
mtree.constructSchemaBlackList(pathPattern, isAllLogicalView);
preDeletedNum += paths.size();
- for (PartialPath path : paths) {
+ for (final PartialPath path : paths) {
try {
writeToMLog(SchemaRegionWritePlanFactory.getPreDeleteTimeSeriesPlan(path));
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new MetadataException(e);
}
}
}
- return preDeletedNum;
+ return new Pair<>(preDeletedNum, isAllLogicalView.get());
}
- private void recoverPreDeleteTimeseries(PartialPath path) throws
MetadataException {
- mtree.constructSchemaBlackList(path);
+ private void recoverPreDeleteTimeseries(final PartialPath path) throws
MetadataException {
+ mtree.constructSchemaBlackList(path, new AtomicBoolean(true));
}
@Override
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/mem/MTreeBelowSGMemoryImpl.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/mem/MTreeBelowSGMemoryImpl.java
index c1a977d0300..615e83aaf19 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/mem/MTreeBelowSGMemoryImpl.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/mem/MTreeBelowSGMemoryImpl.java
@@ -90,6 +90,7 @@ import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
import java.util.function.Function;
@@ -576,14 +577,18 @@ public class MTreeBelowSGMemoryImpl {
&& node.getChildren().isEmpty();
}
- public List<PartialPath> constructSchemaBlackList(PartialPath pathPattern)
+ public List<PartialPath> constructSchemaBlackList(
+ final PartialPath pathPattern, final AtomicBoolean isAllLogicalView)
throws MetadataException {
- List<PartialPath> result = new ArrayList<>();
- try (MeasurementUpdater<IMemMNode> updater =
+ final List<PartialPath> result = new ArrayList<>();
+ try (final MeasurementUpdater<IMemMNode> updater =
new MeasurementUpdater<IMemMNode>(
rootNode, pathPattern, store, false,
SchemaConstant.ALL_MATCH_SCOPE) {
- protected void updateMeasurement(IMeasurementMNode<IMemMNode> node) {
+ protected void updateMeasurement(final IMeasurementMNode<IMemMNode>
node) {
+ if (!node.isLogicalView()) {
+ isAllLogicalView.set(false);
+ }
node.setPreDeleted(true);
result.add(getPartialPathFromRootToNode(node.getAsMNode()));
}
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/MTreeBelowSGCachedImpl.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/MTreeBelowSGCachedImpl.java
index 12af832364c..b1237304e5c 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/MTreeBelowSGCachedImpl.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/MTreeBelowSGCachedImpl.java
@@ -88,6 +88,7 @@ import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
import java.util.function.Function;
@@ -686,15 +687,19 @@ public class MTreeBelowSGCachedImpl {
}
}
- public List<PartialPath> constructSchemaBlackList(PartialPath pathPattern)
+ public List<PartialPath> constructSchemaBlackList(
+ final PartialPath pathPattern, final AtomicBoolean isAllLogicalView)
throws MetadataException {
- List<PartialPath> result = new ArrayList<>();
- try (MeasurementUpdater<ICachedMNode> updater =
+ final List<PartialPath> result = new ArrayList<>();
+ try (final MeasurementUpdater<ICachedMNode> updater =
new MeasurementUpdater<ICachedMNode>(
rootNode, pathPattern, store, false,
SchemaConstant.ALL_MATCH_SCOPE) {
- protected void updateMeasurement(IMeasurementMNode<ICachedMNode>
node)
+ protected void updateMeasurement(final
IMeasurementMNode<ICachedMNode> node)
throws MetadataException {
+ if (!node.isLogicalView()) {
+ isAllLogicalView.set(false);
+ }
store.updateMNode(
node.getAsMNode(), o ->
o.getAsMeasurementMNode().setPreDeleted(true));
result.add(getPartialPathFromRootToNode(node.getAsMNode()));
diff --git
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionAliasAndTagTest.java
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionAliasAndTagTest.java
index eed9691156b..0d2dcd674a0 100644
---
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionAliasAndTagTest.java
+++
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionAliasAndTagTest.java
@@ -549,17 +549,17 @@ public class SchemaRegionAliasAndTagTest extends
AbstractSchemaRegionTest {
SchemaRegionTestUtil.showTimeseries(
schemaRegion, new PartialPath("root.sg.wf01.wt01.v1.temp"));
Assert.assertEquals(1, result.size());
- // delete timeseries
- PathPatternTree patternTree = new PathPatternTree();
+ // Delete timeseries
+ final PathPatternTree patternTree = new PathPatternTree();
patternTree.appendFullPath(new PartialPath("root.sg.wf01.wt01.v1.temp"));
patternTree.constructTree();
- Assert.assertTrue(schemaRegion.constructSchemaBlackList(patternTree) >=
1);
+
Assert.assertTrue(schemaRegion.constructSchemaBlackList(patternTree).getLeft()
>= 1);
schemaRegion.deleteTimeseriesInBlackList(patternTree);
result =
SchemaRegionTestUtil.showTimeseries(
schemaRegion, new PartialPath("root.sg.wf01.wt01.v1.temp"));
Assert.assertEquals(0, result.size());
- } catch (Exception e) {
+ } catch (final Exception e) {
logger.error(e.getMessage(), e);
Assert.fail(e.getMessage());
}
diff --git
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionBasicTest.java
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionBasicTest.java
index 99ce0715495..9e74729cab7 100644
---
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionBasicTest.java
+++
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionBasicTest.java
@@ -40,6 +40,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.file.metadata.enums.CompressionType;
import org.apache.tsfile.file.metadata.enums.TSEncoding;
+import org.apache.tsfile.utils.Pair;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
@@ -203,7 +204,7 @@ public class SchemaRegionBasicTest extends
AbstractSchemaRegionTest {
patternTree.appendPathPattern(new PartialPath("root.sg.wf01.wt01.**"));
patternTree.constructTree();
- Assert.assertEquals(2, schemaRegion.constructSchemaBlackList(patternTree));
+ Assert.assertEquals(new Pair<>(2L, false),
schemaRegion.constructSchemaBlackList(patternTree));
Assert.assertTrue(
schemaRegion
@@ -376,7 +377,7 @@ public class SchemaRegionBasicTest extends
AbstractSchemaRegionTest {
patternTree.appendPathPattern(new PartialPath("root.sg.wf01.*.status"));
patternTree.appendPathPattern(new
PartialPath("root.sg.wf02.wt01.temperature"));
patternTree.constructTree();
- Assert.assertTrue(schemaRegion.constructSchemaBlackList(patternTree) >= 4);
+
Assert.assertTrue(schemaRegion.constructSchemaBlackList(patternTree).getLeft()
>= 4);
Assert.assertEquals(
new HashSet<>(
Arrays.asList(
diff --git
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionTemplateTest.java
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionTemplateTest.java
index 555a081f001..b1efefbd917 100644
---
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionTemplateTest.java
+++
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionTemplateTest.java
@@ -34,6 +34,7 @@ import org.apache.iotdb.db.schemaengine.template.Template;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.file.metadata.enums.CompressionType;
import org.apache.tsfile.file.metadata.enums.TSEncoding;
+import org.apache.tsfile.utils.Pair;
import org.junit.Assert;
import org.junit.Test;
@@ -238,9 +239,9 @@ public class SchemaRegionTemplateTest extends
AbstractSchemaRegionTest {
@Test
public void testDeleteSchemaWithTemplate() throws Exception {
- ISchemaRegion schemaRegion = getSchemaRegion("root.db", 0);
- int templateId = 1;
- Template template =
+ final ISchemaRegion schemaRegion = getSchemaRegion("root.db", 0);
+ final int templateId = 1;
+ final Template template =
new Template(
"t1",
Arrays.asList("s1", "s2"),
@@ -255,9 +256,11 @@ public class SchemaRegionTemplateTest extends
AbstractSchemaRegionTest {
template);
Assert.assertEquals(
- 0, SchemaRegionTestUtil.deleteTimeSeries(schemaRegion, new
PartialPath("root.db.d1.s1")));
+ new Pair<>(0L, true),
+ SchemaRegionTestUtil.deleteTimeSeries(schemaRegion, new
PartialPath("root.db.d1.s1")));
Assert.assertEquals(
- 0, SchemaRegionTestUtil.deleteTimeSeries(schemaRegion, new
PartialPath("root.db.d1.s3")));
+ new Pair<>(0L, true),
+ SchemaRegionTestUtil.deleteTimeSeries(schemaRegion, new
PartialPath("root.db.d1.s3")));
PathPatternTree patternTree = new PathPatternTree();
patternTree.appendFullPath(new PartialPath("root.db.d1.s1"));
diff --git
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionTestUtil.java
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionTestUtil.java
index 53a567c1927..528335009b9 100644
---
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionTestUtil.java
+++
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionTestUtil.java
@@ -37,6 +37,7 @@ import org.apache.iotdb.db.schemaengine.template.Template;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.file.metadata.enums.CompressionType;
import org.apache.tsfile.file.metadata.enums.TSEncoding;
+import org.apache.tsfile.utils.Pair;
import java.util.ArrayList;
import java.util.Arrays;
@@ -368,13 +369,13 @@ public class SchemaRegionTestUtil {
return result;
}
- public static long deleteTimeSeries(ISchemaRegion schemaRegion, PartialPath
pathPattern)
- throws MetadataException {
- PathPatternTree patternTree = new PathPatternTree();
+ public static Pair<Long, Boolean> deleteTimeSeries(
+ final ISchemaRegion schemaRegion, final PartialPath pathPattern) throws
MetadataException {
+ final PathPatternTree patternTree = new PathPatternTree();
patternTree.appendPathPattern(pathPattern);
patternTree.constructTree();
- long num = schemaRegion.constructSchemaBlackList(patternTree);
+ final Pair<Long, Boolean> numIsViewPair =
schemaRegion.constructSchemaBlackList(patternTree);
schemaRegion.deleteTimeseriesInBlackList(patternTree);
- return num;
+ return numIsViewPair;
}
}
diff --git
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaStatisticsTest.java
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaStatisticsTest.java
index 3ec8febe272..14bb5d726a1 100644
---
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaStatisticsTest.java
+++
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaStatisticsTest.java
@@ -56,31 +56,31 @@ public class SchemaStatisticsTest extends
AbstractSchemaRegionTest {
@Test
public void testPBTreeMemoryStatistics() throws Exception {
- ISchemaRegion schemaRegion1 = getSchemaRegion("root.sg1", 0);
- ISchemaEngineStatistics engineStatistics =
+ final ISchemaRegion schemaRegion1 = getSchemaRegion("root.sg1", 0);
+ final ISchemaEngineStatistics engineStatistics =
SchemaEngine.getInstance().getSchemaEngineStatistics();
SchemaRegionTestUtil.createSimpleTimeseriesByList(
schemaRegion1, Arrays.asList("root.sg1.n.s0", "root.sg1.n.v.d1.s1",
"root.sg1.n.v.d2.s2"));
SchemaRegionTestUtil.createSimpleTimeseriesByList(
schemaRegion1, Arrays.asList("root.sg1.d0.s0"));
- PathPatternTree patternTree = new PathPatternTree();
+ final PathPatternTree patternTree = new PathPatternTree();
patternTree.appendPathPattern(new PartialPath("root.**.s1"));
patternTree.appendPathPattern(new PartialPath("root.**.s2"));
patternTree.constructTree();
- Assert.assertTrue(schemaRegion1.constructSchemaBlackList(patternTree) >=
1);
+
Assert.assertTrue(schemaRegion1.constructSchemaBlackList(patternTree).getLeft()
>= 1);
schemaRegion1.deleteTimeseriesInBlackList(patternTree);
if (testParams.getTestModeName().equals("PBTree-PartialMemory")
|| testParams.getTestModeName().equals("PBTree-NonMemory")) {
- IMNodeFactory<ICachedMNode> nodeFactory =
+ final IMNodeFactory<ICachedMNode> nodeFactory =
MNodeFactoryLoader.getInstance().getCachedMNodeIMNodeFactory();
// wait release and flush task
Thread.sleep(6000);
// schemaRegion1
- IMNode<ICachedMNode> sg1 = nodeFactory.createDatabaseMNode(null, "sg1");
+ final IMNode<ICachedMNode> sg1 = nodeFactory.createDatabaseMNode(null,
"sg1");
sg1.setFullPath("root.sg1");
- long size1 = sg1.estimateSize();
+ final long size1 = sg1.estimateSize();
if (size1 !=
schemaRegion1.getSchemaRegionStatistics().getRegionMemoryUsage()) {
// There are two possibilities here in PartialMemory mode:
// 1. only the "sg1" node remains
@@ -100,47 +100,48 @@ public class SchemaStatisticsTest extends
AbstractSchemaRegionTest {
@Test
public void testMemoryStatistics2() throws Exception {
- ISchemaRegion schemaRegion1 = getSchemaRegion("root.sg1", 0);
- ISchemaRegion schemaRegion2 = getSchemaRegion("root.sg2", 1);
- ISchemaEngineStatistics engineStatistics =
+ final ISchemaRegion schemaRegion1 = getSchemaRegion("root.sg1", 0);
+ final ISchemaRegion schemaRegion2 = getSchemaRegion("root.sg2", 1);
+ final ISchemaEngineStatistics engineStatistics =
SchemaEngine.getInstance().getSchemaEngineStatistics();
SchemaRegionTestUtil.createSimpleTimeseriesByList(
schemaRegion1, Arrays.asList("root.sg1.v.d0", "root.sg1.d1.v.s1",
"root.sg1.d1.s2.v.t1"));
SchemaRegionTestUtil.createSimpleTimeseriesByList(
schemaRegion2, Arrays.asList("root.sg2.d1.v.s3", "root.sg2.d2.v.s1",
"root.sg2.d2.v.s2"));
- PathPatternTree patternTree = new PathPatternTree();
+ final PathPatternTree patternTree = new PathPatternTree();
patternTree.appendPathPattern(new PartialPath("root.**.s1"));
patternTree.constructTree();
- Assert.assertTrue(schemaRegion1.constructSchemaBlackList(patternTree) >=
1);
- Assert.assertTrue(schemaRegion2.constructSchemaBlackList(patternTree) >=
1);
+
Assert.assertTrue(schemaRegion1.constructSchemaBlackList(patternTree).getLeft()
>= 1);
+
Assert.assertTrue(schemaRegion2.constructSchemaBlackList(patternTree).getLeft()
>= 1);
schemaRegion1.deleteTimeseriesInBlackList(patternTree);
schemaRegion2.deleteTimeseriesInBlackList(patternTree);
if (testParams.getTestModeName().equals("PBTree-PartialMemory")
|| testParams.getTestModeName().equals("PBTree-NonMemory")) {
- IMNodeFactory<?> nodeFactory =
MNodeFactoryLoader.getInstance().getCachedMNodeIMNodeFactory();
+ final IMNodeFactory<?> nodeFactory =
+ MNodeFactoryLoader.getInstance().getCachedMNodeIMNodeFactory();
// wait release and flush task
Thread.sleep(1000);
// schemaRegion1
- IMNode<?> sg1 = nodeFactory.createDatabaseMNode(null, "sg1");
+ final IMNode<?> sg1 = nodeFactory.createDatabaseMNode(null, "sg1");
sg1.setFullPath("root.sg1");
- long size1 = sg1.estimateSize();
+ final long size1 = sg1.estimateSize();
Assert.assertEquals(size1,
schemaRegion1.getSchemaRegionStatistics().getRegionMemoryUsage());
// schemaRegion2
- IMNode<?> sg2 = nodeFactory.createDatabaseMNode(null, "sg2");
+ final IMNode<?> sg2 = nodeFactory.createDatabaseMNode(null, "sg2");
sg2.setFullPath("root.sg2");
long size2 = sg2.estimateSize();
Assert.assertEquals(size2,
schemaRegion2.getSchemaRegionStatistics().getRegionMemoryUsage());
Assert.assertEquals(size1 + size2, engineStatistics.getMemoryUsage());
} else {
- IMNodeFactory nodeFactory =
+ final IMNodeFactory nodeFactory =
testParams.getSchemaEngineMode().equals("Memory")
? MNodeFactoryLoader.getInstance().getMemMNodeIMNodeFactory()
: MNodeFactoryLoader.getInstance().getCachedMNodeIMNodeFactory();
// schemaRegion1
- IMNode<?> sg1 = nodeFactory.createDatabaseMNode(null, "sg1");
+ final IMNode<?> sg1 = nodeFactory.createDatabaseMNode(null, "sg1");
sg1.setFullPath("root.sg1");
long size1 = sg1.estimateSize();
IMNode<?> tmp = nodeFactory.createDeviceMNode(sg1, "v");
@@ -170,7 +171,7 @@ public class SchemaStatisticsTest extends
AbstractSchemaRegionTest {
.estimateSize();
Assert.assertEquals(size1,
schemaRegion1.getSchemaRegionStatistics().getRegionMemoryUsage());
// schemaRegion2
- IMNode<?> sg2 = nodeFactory.createDatabaseMNode(null, "sg2");
+ final IMNode<?> sg2 = nodeFactory.createDatabaseMNode(null, "sg2");
sg2.setFullPath("root.sg2");
long size2 = sg2.estimateSize();
tmp = nodeFactory.createInternalMNode(sg2, "d1");
@@ -209,37 +210,37 @@ public class SchemaStatisticsTest extends
AbstractSchemaRegionTest {
@Test
public void testMemoryStatistics() throws Exception {
- ISchemaRegion schemaRegion1 = getSchemaRegion("root.sg1", 0);
- ISchemaRegion schemaRegion2 = getSchemaRegion("root.sg2", 1);
- ISchemaEngineStatistics engineStatistics =
+ final ISchemaRegion schemaRegion1 = getSchemaRegion("root.sg1", 0);
+ final ISchemaRegion schemaRegion2 = getSchemaRegion("root.sg2", 1);
+ final ISchemaEngineStatistics engineStatistics =
SchemaEngine.getInstance().getSchemaEngineStatistics();
SchemaRegionTestUtil.createSimpleTimeseriesByList(
schemaRegion1, Arrays.asList("root.sg1.d0", "root.sg1.d1.s1",
"root.sg1.d1.s2.t1"));
SchemaRegionTestUtil.createSimpleTimeseriesByList(
schemaRegion2, Arrays.asList("root.sg2.d1.s3", "root.sg2.d2.s1",
"root.sg2.d2.s2"));
- PathPatternTree patternTree = new PathPatternTree();
+ final PathPatternTree patternTree = new PathPatternTree();
patternTree.appendPathPattern(new PartialPath("root.**.s1"));
patternTree.constructTree();
- Assert.assertTrue(schemaRegion1.constructSchemaBlackList(patternTree) >=
1);
- Assert.assertTrue(schemaRegion2.constructSchemaBlackList(patternTree) >=
1);
+
Assert.assertTrue(schemaRegion1.constructSchemaBlackList(patternTree).getLeft()
>= 1);
+
Assert.assertTrue(schemaRegion2.constructSchemaBlackList(patternTree).getLeft()
>= 1);
schemaRegion1.deleteTimeseriesInBlackList(patternTree);
schemaRegion2.deleteTimeseriesInBlackList(patternTree);
if (testParams.getTestModeName().equals("PBTree-PartialMemory")
|| testParams.getTestModeName().equals("PBTree-NonMemory")) {
- IMNodeFactory<ICachedMNode> nodeFactory =
+ final IMNodeFactory<ICachedMNode> nodeFactory =
MNodeFactoryLoader.getInstance().getCachedMNodeIMNodeFactory();
// wait release and flush task
Thread.sleep(1000);
// schemaRegion1
- IMNode<ICachedMNode> sg1 = nodeFactory.createDatabaseDeviceMNode(null,
"sg1");
+ final IMNode<ICachedMNode> sg1 =
nodeFactory.createDatabaseDeviceMNode(null, "sg1");
sg1.setFullPath("root.sg1");
- long size1 = sg1.estimateSize();
+ final long size1 = sg1.estimateSize();
if (sg1.estimateSize() !=
schemaRegion1.getSchemaRegionStatistics().getRegionMemoryUsage()) {
// "d0" or "d1" node may remain in PartialMemory mode
Assert.assertEquals("PBTree-PartialMemory",
testParams.getTestModeName());
- long d0ExistSize =
+ final long d0ExistSize =
size1
+ nodeFactory
.createMeasurementMNode(
@@ -249,7 +250,7 @@ public class SchemaStatisticsTest extends
AbstractSchemaRegionTest {
"d0", TSDataType.INT64, TSEncoding.PLAIN,
CompressionType.SNAPPY),
null)
.estimateSize();
- long d1ExistSize =
+ final long d1ExistSize =
size1 + nodeFactory.createInternalMNode(sg1.getAsMNode(),
"d1").estimateSize();
Assert.assertTrue(
d0ExistSize ==
schemaRegion1.getSchemaRegionStatistics().getRegionMemoryUsage()
@@ -261,18 +262,18 @@ public class SchemaStatisticsTest extends
AbstractSchemaRegionTest {
size1,
schemaRegion1.getSchemaRegionStatistics().getRegionMemoryUsage());
}
// schemaRegion2
- IMNode<?> sg2 = nodeFactory.createDatabaseMNode(null, "sg2");
+ final IMNode<?> sg2 = nodeFactory.createDatabaseMNode(null, "sg2");
sg2.setFullPath("root.sg2");
- long size2 = sg2.estimateSize();
+ final long size2 = sg2.estimateSize();
Assert.assertEquals(size2,
schemaRegion2.getSchemaRegionStatistics().getRegionMemoryUsage());
Assert.assertEquals(size1 + size2, engineStatistics.getMemoryUsage());
} else {
- IMNodeFactory nodeFactory =
+ final IMNodeFactory nodeFactory =
testParams.getSchemaEngineMode().equals("Memory")
? MNodeFactoryLoader.getInstance().getMemMNodeIMNodeFactory()
: MNodeFactoryLoader.getInstance().getCachedMNodeIMNodeFactory();
// schemaRegion1
- IMNode<?> sg1 = nodeFactory.createDatabaseDeviceMNode(null, "sg1");
+ final IMNode<?> sg1 = nodeFactory.createDatabaseDeviceMNode(null, "sg1");
sg1.setFullPath("root.sg1");
long size1 = sg1.estimateSize();
IMNode<?> tmp =
@@ -298,7 +299,7 @@ public class SchemaStatisticsTest extends
AbstractSchemaRegionTest {
.estimateSize();
Assert.assertEquals(size1,
schemaRegion1.getSchemaRegionStatistics().getRegionMemoryUsage());
// schemaRegion2
- IMNode<?> sg2 = nodeFactory.createDatabaseMNode(null, "sg2");
+ final IMNode<?> sg2 = nodeFactory.createDatabaseMNode(null, "sg2");
sg2.setFullPath("root.sg2");
long size2 = sg2.estimateSize();
tmp = nodeFactory.createDeviceMNode(sg2, "d1");
@@ -344,20 +345,20 @@ public class SchemaStatisticsTest extends
AbstractSchemaRegionTest {
@Test
public void testSeriesNumStatistics() throws Exception {
- ISchemaRegion schemaRegion1 = getSchemaRegion("root.sg1", 0);
- ISchemaRegion schemaRegion2 = getSchemaRegion("root.sg2", 1);
- ISchemaEngineStatistics engineStatistics =
+ final ISchemaRegion schemaRegion1 = getSchemaRegion("root.sg1", 0);
+ final ISchemaRegion schemaRegion2 = getSchemaRegion("root.sg2", 1);
+ final ISchemaEngineStatistics engineStatistics =
SchemaEngine.getInstance().getSchemaEngineStatistics();
SchemaRegionTestUtil.createSimpleTimeseriesByList(
schemaRegion1, Arrays.asList("root.sg1.d0", "root.sg1.d1.s1",
"root.sg1.d1.s2.t1"));
SchemaRegionTestUtil.createSimpleTimeseriesByList(
schemaRegion2, Arrays.asList("root.sg2.d1.s3", "root.sg2.d2.s1",
"root.sg2.d2.s2"));
- PathPatternTree patternTree = new PathPatternTree();
+ final PathPatternTree patternTree = new PathPatternTree();
patternTree.appendPathPattern(new PartialPath("root.**.s1"));
patternTree.constructTree();
- Assert.assertTrue(schemaRegion1.constructSchemaBlackList(patternTree) >=
1);
- Assert.assertTrue(schemaRegion2.constructSchemaBlackList(patternTree) >=
1);
+
Assert.assertTrue(schemaRegion1.constructSchemaBlackList(patternTree).getLeft()
>= 1);
+
Assert.assertTrue(schemaRegion2.constructSchemaBlackList(patternTree).getLeft()
>= 1);
schemaRegion1.deleteTimeseriesInBlackList(patternTree);
schemaRegion2.deleteTimeseriesInBlackList(patternTree);
@@ -369,9 +370,9 @@ public class SchemaStatisticsTest extends
AbstractSchemaRegionTest {
@Test
public void testDeviceNumStatistics() throws Exception {
- ISchemaRegion schemaRegion1 = getSchemaRegion("root.sg1", 0);
- ISchemaRegion schemaRegion2 = getSchemaRegion("root.sg2", 1);
- ISchemaEngineStatistics engineStatistics =
+ final ISchemaRegion schemaRegion1 = getSchemaRegion("root.sg1", 0);
+ final ISchemaRegion schemaRegion2 = getSchemaRegion("root.sg2", 1);
+ final ISchemaEngineStatistics engineStatistics =
SchemaEngine.getInstance().getSchemaEngineStatistics();
SchemaRegionTestUtil.createSimpleTimeseriesByList(
@@ -380,29 +381,30 @@ public class SchemaStatisticsTest extends
AbstractSchemaRegionTest {
schemaRegion2, Arrays.asList("root.sg2.d1.s3", "root.sg2.d2.s1",
"root.sg2.d2.s2"));
SchemaRegionTestUtil.createSimpleTimeseriesByList(
schemaRegion2, Collections.singletonList("root.sg2.s1"));
- // check series number
+ // Check device number
Assert.assertEquals(3,
schemaRegion1.getSchemaRegionStatistics().getDevicesNumber());
Assert.assertEquals(3,
schemaRegion2.getSchemaRegionStatistics().getDevicesNumber());
- PathPatternTree patternTree = new PathPatternTree();
+ final PathPatternTree patternTree = new PathPatternTree();
patternTree.appendPathPattern(new PartialPath("root.**.s1"));
patternTree.constructTree();
- Assert.assertTrue(schemaRegion1.constructSchemaBlackList(patternTree) >=
1);
- Assert.assertTrue(schemaRegion2.constructSchemaBlackList(patternTree) >=
1);
+
Assert.assertTrue(schemaRegion1.constructSchemaBlackList(patternTree).getLeft()
>= 1);
+
Assert.assertTrue(schemaRegion2.constructSchemaBlackList(patternTree).getLeft()
>= 1);
schemaRegion1.deleteTimeseriesInBlackList(patternTree);
schemaRegion2.deleteTimeseriesInBlackList(patternTree);
- // check series number
+ // Check device number
Assert.assertEquals(2,
schemaRegion1.getSchemaRegionStatistics().getDevicesNumber());
Assert.assertEquals(2,
schemaRegion2.getSchemaRegionStatistics().getDevicesNumber());
+ Assert.assertEquals(4, engineStatistics.getTotalDevicesNumber());
}
@Test
public void testPBTreeNodeStatistics() throws Exception {
if (testParams.getSchemaEngineMode().equals("PBTree")) {
- ISchemaRegion schemaRegion1 = getSchemaRegion("root.sg1", 0);
- ISchemaRegion schemaRegion2 = getSchemaRegion("root.sg2", 1);
- CachedSchemaEngineStatistics engineStatistics =
+ final ISchemaRegion schemaRegion1 = getSchemaRegion("root.sg1", 0);
+ final ISchemaRegion schemaRegion2 = getSchemaRegion("root.sg2", 1);
+ final CachedSchemaEngineStatistics engineStatistics =
SchemaEngine.getInstance()
.getSchemaEngineStatistics()
.getAsCachedSchemaEngineStatistics();
@@ -410,18 +412,18 @@ public class SchemaStatisticsTest extends
AbstractSchemaRegionTest {
schemaRegion1, Arrays.asList("root.sg1.d0", "root.sg1.d1.s1",
"root.sg1.d1.s2.t1"));
SchemaRegionTestUtil.createSimpleTimeseriesByList(
schemaRegion2, Arrays.asList("root.sg2.d1.s3", "root.sg2.d2.s1",
"root.sg2.d2.s2"));
- PathPatternTree patternTree = new PathPatternTree();
+ final PathPatternTree patternTree = new PathPatternTree();
patternTree.appendPathPattern(new PartialPath("root.**.s1"));
patternTree.constructTree();
- Assert.assertTrue(schemaRegion1.constructSchemaBlackList(patternTree) >=
1);
- Assert.assertTrue(schemaRegion2.constructSchemaBlackList(patternTree) >=
1);
+
Assert.assertTrue(schemaRegion1.constructSchemaBlackList(patternTree).getLeft()
>= 1);
+
Assert.assertTrue(schemaRegion2.constructSchemaBlackList(patternTree).getLeft()
>= 1);
schemaRegion1.deleteTimeseriesInBlackList(patternTree);
schemaRegion2.deleteTimeseriesInBlackList(patternTree);
Thread.sleep(1000);
- CachedSchemaRegionStatistics cachedRegionStatistics1 =
+ final CachedSchemaRegionStatistics cachedRegionStatistics1 =
schemaRegion1.getSchemaRegionStatistics().getAsCachedSchemaRegionStatistics();
- CachedSchemaRegionStatistics cachedRegionStatistics2 =
+ final CachedSchemaRegionStatistics cachedRegionStatistics2 =
schemaRegion2.getSchemaRegionStatistics().getAsCachedSchemaRegionStatistics();
// check correctness of statistics
if (testParams.getCachedMNodeSize() > 3) {
diff --git
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/node/role/IMeasurementMNode.java
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/node/role/IMeasurementMNode.java
index 0aac6e3d5ef..84e7e157fb8 100644
---
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/node/role/IMeasurementMNode.java
+++
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/node/role/IMeasurementMNode.java
@@ -47,5 +47,5 @@ public interface IMeasurementMNode<N extends IMNode<N>>
extends IMNode<N> {
MeasurementPath getMeasurementPath();
- public abstract boolean isLogicalView();
+ boolean isLogicalView();
}