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 @@ -168,7 +168,7 @@ public void clear() {
memoryUsage.getAndSet(0);
measurementNumber.getAndSet(0);
devicesNumber.getAndSet(0);
viewNumber.getAndAdd(0);
viewNumber.getAndSet(0);
templateUsage.forEach(
(templateId, cnt) -> schemaEngineStatistics.deactivateTemplate(templateId, cnt));
templateUsage.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public enum SchemaRegionPlanType {
ACTIVATE_TEMPLATE_IN_CLUSTER((byte) 63),
PRE_DELETE_TIMESERIES_IN_CLUSTER((byte) 64),
ROLLBACK_PRE_DELETE_TIMESERIES((byte) 65),

// endregion

PRE_DEACTIVATE_TEMPLATE((byte) 0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -857,8 +857,8 @@ public void createLogicalView(ICreateLogicalViewPlan plan) throws MetadataExcept
regionStatistics.getGlobalMemoryUsage(), regionStatistics.getGlobalSeriesNumber());
}

final List<PartialPath> pathList = plan.getViewPathList();
try {
List<PartialPath> pathList = plan.getViewPathList();
Map<PartialPath, ViewExpression> viewPathToSourceMap =
plan.getViewPathToSourceExpressionMap();
for (PartialPath path : pathList) {
Expand All @@ -873,7 +873,7 @@ public void createLogicalView(ICreateLogicalViewPlan plan) throws MetadataExcept
throw new RuntimeException(e);
}
// update statistics
regionStatistics.addView(1L);
regionStatistics.addView(pathList.size());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,15 @@ public boolean hasNext() {
if (skipPreDeletedSchema
&& nextMatchedNode.isMeasurement()
&& nextMatchedNode.getAsMeasurementMNode().isPreDeleted()) {
releaseSkippedNode(nextMatchedNode);
nextMatchedNode = null;
}
}
return true;
}

protected abstract void releaseSkippedNode(final N node);

@Override
public N next() {
if (!hasNext()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.iotdb.db.schemaengine.schemaregion.mtree.impl.mem.mnode.iterator;

import org.apache.iotdb.commons.exception.MetadataException;
Expand All @@ -30,11 +31,16 @@
// only use for IConfigMNode and IMemMNode
public class MemoryTraverserIterator<N extends IMNode<N>> extends AbstractTraverserIterator<N> {
public MemoryTraverserIterator(
IMTreeStore<N> store,
IDeviceMNode<N> parent,
Map<Integer, Template> templateMap,
IMNodeFactory<N> nodeFactory)
final IMTreeStore<N> store,
final IDeviceMNode<N> parent,
final Map<Integer, Template> templateMap,
final IMNodeFactory<N> nodeFactory)
throws MetadataException {
super(store, parent, templateMap, nodeFactory);
}

@Override
protected void releaseSkippedNode(final N node) {
// Do nothing
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,11 @@ public void close() {
}
super.close();
}

@Override
protected void releaseSkippedNode(final ICachedMNode node) {
if (usingDirectChildrenIterator) {
store.unPin(node);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,16 @@ public WrappedSegment(ByteBuffer buffer, boolean override) {
}
}

public WrappedSegment(ByteBuffer buffer) throws RecordDuplicatedException {
public WrappedSegment(ByteBuffer buffer) {
this(buffer, true);
}

@TestOnly
public WrappedSegment(int size) throws RecordDuplicatedException {
public WrappedSegment(int size) {
this(ByteBuffer.allocate(size));
}

public static ISegment<ByteBuffer, ICachedMNode> initAsSegment(ByteBuffer buffer)
throws RecordDuplicatedException {
public static ISegment<ByteBuffer, ICachedMNode> initAsSegment(ByteBuffer buffer) {
if (buffer == null) {
return null;
}
Expand Down Expand Up @@ -559,7 +558,6 @@ public Queue<ICachedMNode> getAllRecords() throws MetadataException {

@Override
public int updateRecord(String key, ByteBuffer uBuffer) throws MetadataException {

int idx = binarySearchOnKeys(key);
if (idx < 0) {
throw new MetadataException(String.format("Record[key:%s] Not Existed.", key));
Expand Down Expand Up @@ -614,8 +612,8 @@ public int removeRecord(String key) {
}

// shift offsets forward
if (idx != recordNum) {
int shift = recordNum - idx;
if (idx != recordNum - 1) {
int shift = recordNum - idx - 1;
this.buffer.position(SchemaFileConfig.SEG_HEADER_SIZE + idx * 2);
ShortBuffer lb = this.buffer.asReadOnlyBuffer().asShortBuffer();
lb.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.iotdb.db.conf.IoTDBConfig;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.schemaengine.schemaregion.ISchemaRegion;
import org.apache.iotdb.db.schemaengine.schemaregion.SchemaRegionPlanType;
import org.apache.iotdb.db.schemaengine.schemaregion.read.resp.info.ISchemaInfo;
import org.apache.iotdb.db.schemaengine.schemaregion.read.resp.info.ITimeSeriesSchemaInfo;
import org.apache.iotdb.db.schemaengine.schemaregion.write.req.SchemaRegionWritePlanFactory;
Expand All @@ -40,6 +41,7 @@
import org.junit.Test;

import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
Expand Down Expand Up @@ -229,4 +231,14 @@
config.setSchemaRegionConsensusProtocolClass(schemaRegionConsensusProtocolClass);
}
}

@Test
public void testSchemaRegionPlanType() throws Exception {

Check warning on line 236 in iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionManagementTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the declaration of thrown exception 'java.lang.Exception', as it cannot be thrown from method's body.

See more on https://sonarcloud.io/project/issues?id=apache_iotdb&issues=AZ1MEuX1_cRLGSbP2tYw&open=AZ1MEuX1_cRLGSbP2tYw&pullRequest=17420
Assert.assertEquals(
SchemaRegionPlanType.values().length,
Arrays.stream(SchemaRegionPlanType.values())
.map(SchemaRegionPlanType::getPlanType)
.distinct()
.count());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ public static List<SchemaFilter> extract(SchemaFilter schemaFilter, SchemaFilter
}

private static void internalExtract(
List<SchemaFilter> result, SchemaFilter schemaFilter, SchemaFilterType filterType) {
final List<SchemaFilter> result,
final SchemaFilter schemaFilter,
final SchemaFilterType filterType) {
if (schemaFilter == null) {
return;
}
if (schemaFilter.getSchemaFilterType().equals(filterType)) {
result.add(schemaFilter);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,9 @@ public void deserialize(InputStream bufferedInputStream)
public void clear() {
ttlCacheTree.removeAllChildren();
ttlCacheTree.addChild(IoTDBConstant.MULTI_LEVEL_PATH_WILDCARD, Long.MAX_VALUE);

// root.**
ttlCount = 1;
}

static class CacheNode {
Expand Down
Loading