You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2020/06/12 06:57:53 UTC
[incubator-iotdb] branch rel/0.10 updated: add more remove tag log
(#1350)
This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch rel/0.10
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/rel/0.10 by this push:
new bc661da add more remove tag log (#1350)
bc661da is described below
commit bc661dae8036662d338cd277bd34edd20d8cef37
Author: Jackie Tien <Ja...@foxmail.com>
AuthorDate: Fri Jun 12 14:57:37 2020 +0800
add more remove tag log (#1350)
---
.../org/apache/iotdb/db/metadata/MManager.java | 115 +++++++++++++++++----
1 file changed, 96 insertions(+), 19 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java b/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
index 5995fc8..9c20c8e 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
@@ -435,6 +435,12 @@ public class MManager {
for (Entry<String, String> entry : tagMap.entrySet()) {
if (tagIndex.containsKey(entry.getKey()) && tagIndex.get(entry.getKey())
.containsKey(entry.getValue())) {
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format(
+ "Delete: TimeSeries %s is removed from tag inverted index, "
+ + "tag key is %s, tag value is %s, tlog offset is %d",
+ node.getFullPath(), entry.getKey(), entry.getValue(), node.getOffset()));
+ }
tagIndex.get(entry.getKey()).get(entry.getValue()).remove(node);
if (tagIndex.get(entry.getKey()).get(entry.getValue()).isEmpty()) {
tagIndex.get(entry.getKey()).remove(entry.getValue());
@@ -443,11 +449,11 @@ public class MManager {
}
}
} else {
- if (logger.isWarnEnabled()) {
- logger.warn(String.format(
- "TimeSeries %s's tag info has been removed from tag inverted index before "
- + "deleting it, tag key is %s, tag value is %s",
- node.getFullPath(), entry.getKey(), entry.getValue()));
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format(
+ "Delete: TimeSeries %s's tag info has been removed from tag inverted index before "
+ + "deleting it, tag key is %s, tag value is %s, tlog offset is %d, contains key %b",
+ node.getFullPath(), entry.getKey(), entry.getValue(), node.getOffset(), tagIndex.containsKey(entry.getKey())));
}
}
}
@@ -526,12 +532,15 @@ public class MManager {
lock.writeLock().lock();
try {
for (String storageGroup : storageGroups) {
+
+ // clear cached MNode
+ mNodeCache.clear();
+
// try to delete storage group
List<LeafMNode> leafMNodes = mtree.deleteStorageGroup(storageGroup);
for (LeafMNode leafMNode : leafMNodes) {
removeFromTagInvertedIndex(leafMNode);
}
- mNodeCache.clear();
if (config.isEnableParameterAdapter()) {
IoTDBConfigDynamicAdapter.getInstance().addOrDeleteStorageGroup(-1);
@@ -750,6 +759,7 @@ public class MManager {
throw new MetadataException("The key " + plan.getKey() + " is not a tag.");
}
Set<LeafMNode> allMatchedNodes = new TreeSet<>(Comparator.comparing(MNode::getFullPath));
+
if (plan.isContains()) {
for (Entry<String, Set<LeafMNode>> entry : value2Node.entrySet()) {
String tagValue = entry.getKey();
@@ -1118,9 +1128,26 @@ public class MManager {
// if the key has existed and the value is not equal to the new one
// we should remove before key-value from inverted index map
if (beforeValue != null && !beforeValue.equals(value)) {
- tagIndex.get(key).get(beforeValue).remove(leafMNode);
- if (tagIndex.get(key).get(beforeValue).isEmpty()) {
- tagIndex.get(key).remove(beforeValue);
+
+ if (tagIndex.containsKey(key) && tagIndex.get(key).containsKey(beforeValue)) {
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format(
+ "Upsert: TimeSeries %s is removed from tag inverted index, "
+ + "tag key is %s, tag value is %s, tlog offset is %d",
+ leafMNode.getFullPath(), key, beforeValue, leafMNode.getOffset()));
+ }
+
+ tagIndex.get(key).get(beforeValue).remove(leafMNode);
+ if (tagIndex.get(key).get(beforeValue).isEmpty()) {
+ tagIndex.get(key).remove(beforeValue);
+ }
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format(
+ "Upsert: TimeSeries %s's tag info has been removed from tag inverted index "
+ + "before deleting it, tag key is %s, tag value is %s, tlog offset is %d, contains key %b",
+ leafMNode.getFullPath(), key, beforeValue, leafMNode.getOffset(), tagIndex.containsKey(key)));
+ }
}
}
@@ -1132,9 +1159,7 @@ public class MManager {
}
}
}
- if (tagsMap != null) {
- pair.left.putAll(tagsMap);
- }
+
pair.right.putAll(attributesMap);
// persist the change to disk
@@ -1281,13 +1306,30 @@ public class MManager {
String key = entry.getKey();
String value = entry.getValue();
// change the tag inverted index map
- tagIndex.get(key).get(value).remove(leafMNode);
- if (tagIndex.get(key).get(value).isEmpty()) {
- tagIndex.get(key).remove(value);
- if (tagIndex.get(key).isEmpty()) {
- tagIndex.remove(key);
+ if (tagIndex.containsKey(key) && tagIndex.get(key).containsKey(value)) {
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format(
+ "Drop: TimeSeries %s is removed from tag inverted index, "
+ + "tag key is %s, tag value is %s, tlog offset is %d",
+ leafMNode.getFullPath(), entry.getKey(), entry.getValue(), leafMNode.getOffset()));
+ }
+
+ tagIndex.get(key).get(value).remove(leafMNode);
+ if (tagIndex.get(key).get(value).isEmpty()) {
+ tagIndex.get(key).remove(value);
+ if (tagIndex.get(key).isEmpty()) {
+ tagIndex.remove(key);
+ }
+ }
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format(
+ "Drop: TimeSeries %s's tag info has been removed from tag inverted index "
+ + "before deleting it, tag key is %s, tag value is %s, tlog offset is %d, contains key %b",
+ leafMNode.getFullPath(), key, value, leafMNode.getOffset(), tagIndex.containsKey(key)));
}
}
+
}
} finally {
lock.writeLock().unlock();
@@ -1345,7 +1387,24 @@ public class MManager {
String beforeValue = entry.getValue();
String currentValue = newTagValue.get(key);
// change the tag inverted index map
- tagIndex.get(key).get(beforeValue).remove(leafMNode);
+ if (tagIndex.containsKey(key) && tagIndex.get(key).containsKey(beforeValue)) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format(
+ "Set: TimeSeries %s is removed from tag inverted index, "
+ + "tag key is %s, tag value is %s, tlog offset is %d",
+ leafMNode.getFullPath(), entry.getKey(), beforeValue, leafMNode.getOffset()));
+ }
+
+ tagIndex.get(key).get(beforeValue).remove(leafMNode);
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format(
+ "Set: TimeSeries %s's tag info has been removed from tag inverted index "
+ + "before deleting it, tag key is %s, tag value is %s, tlog offset is %d, contains key %b",
+ leafMNode.getFullPath(), key, beforeValue, leafMNode.getOffset(), tagIndex.containsKey(key)));
+ }
+ }
tagIndex.computeIfAbsent(key, k -> new HashMap<>())
.computeIfAbsent(currentValue, k -> new HashSet<>()).add(leafMNode);
}
@@ -1392,7 +1451,25 @@ public class MManager {
// persist the change to disk
tagLogFile.write(pair.left, pair.right, leafMNode.getOffset());
// change the tag inverted index map
- tagIndex.get(oldKey).get(value).remove(leafMNode);
+ if (tagIndex.containsKey(oldKey) && tagIndex.get(oldKey).containsKey(value)) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format(
+ "Rename: TimeSeries %s is removed from tag inverted index, "
+ + "tag key is %s, tag value is %s, tlog offset is %d",
+ leafMNode.getFullPath(), oldKey, value, leafMNode.getOffset()));
+ }
+
+ tagIndex.get(oldKey).get(value).remove(leafMNode);
+
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format(
+ "Rename: TimeSeries %s's tag info has been removed from tag inverted index "
+ + "before deleting it, tag key is %s, tag value is %s, tlog offset is %d, contains key %b",
+ leafMNode.getFullPath(), oldKey, value, leafMNode.getOffset(), tagIndex.containsKey(oldKey)));
+ }
+ }
tagIndex.computeIfAbsent(newKey, k -> new HashMap<>())
.computeIfAbsent(value, k -> new HashSet<>()).add(leafMNode);
} else if (pair.right.containsKey(oldKey)) {