You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2020/06/05 02:46:23 UTC
[GitHub] [incubator-iotdb] JackieTien97 opened a new pull request #1315: [IOTDB-744] Support upsert alias
JackieTien97 opened a new pull request #1315:
URL: https://github.com/apache/incubator-iotdb/pull/1315
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-iotdb] sonarcloud[bot] commented on pull request #1315: [IOTDB-744] Support upsert alias
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on pull request #1315:
URL: https://github.com/apache/incubator-iotdb/pull/1315#issuecomment-639260691
Kudos, SonarCloud Quality Gate passed!
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug.png' alt='Bug' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=BUG) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=BUG)
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability.png' alt='Vulnerability' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=VULNERABILITY) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=VULNERABILITY) (and [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot.png' alt='Security Hotspot' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=SECURITY_HOTSPOT) to review)
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell.png' alt='Code Smell' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=CODE_SMELL) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=CODE_SMELL) [2 Code Smells](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=CODE_SMELL)
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo.png' alt='No Coverage information' width='16' height='16' />](https://sonarcloud.io/component_measures?id=apache_incubator-iotdb&pullRequest=1315) No Coverage information
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3.png' alt='0.0%' width='16' height='16' />](https://sonarcloud.io/component_measures?id=apache_incubator-iotdb&pullRequest=1315&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_incubator-iotdb&pullRequest=1315&metric=new_duplicated_lines_density&view=list)
<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/message_warning.png' alt='warning' width='16' height='16' /> The version of Java (1.8.0_242) you have used to run this analysis is deprecated and we will stop accepting it from October 2020. Please update to at least Java 11.
Read more [here](https://sonarcloud.io/documentation/upcoming/)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-iotdb] sonarcloud[bot] commented on pull request #1315: [IOTDB-744] Support upsert alias
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on pull request #1315:
URL: https://github.com/apache/incubator-iotdb/pull/1315#issuecomment-639229537
Kudos, SonarCloud Quality Gate passed!
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug.png' alt='Bug' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=BUG) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=BUG)
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability.png' alt='Vulnerability' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=VULNERABILITY) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=VULNERABILITY) (and [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot.png' alt='Security Hotspot' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=SECURITY_HOTSPOT) to review)
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell.png' alt='Code Smell' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=CODE_SMELL) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=CODE_SMELL) [2 Code Smells](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=CODE_SMELL)
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo.png' alt='No Coverage information' width='16' height='16' />](https://sonarcloud.io/component_measures?id=apache_incubator-iotdb&pullRequest=1315) No Coverage information
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3.png' alt='0.0%' width='16' height='16' />](https://sonarcloud.io/component_measures?id=apache_incubator-iotdb&pullRequest=1315&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_incubator-iotdb&pullRequest=1315&metric=new_duplicated_lines_density&view=list)
<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/message_warning.png' alt='warning' width='16' height='16' /> The version of Java (1.8.0_242) you have used to run this analysis is deprecated and we will stop accepting it from October 2020. Please update to at least Java 11.
Read more [here](https://sonarcloud.io/documentation/upcoming/)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #1315: [IOTDB-744] Support upsert alias
Posted by GitBox <gi...@apache.org>.
Alima777 commented on a change in pull request #1315:
URL: https://github.com/apache/incubator-iotdb/pull/1315#discussion_r435666783
##########
File path: server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
##########
@@ -1010,62 +1031,97 @@ public void changeOffset(String path, long offset) throws MetadataException {
}
}
+ public void changeAlias(String path, String alias) throws MetadataException {
+ lock.writeLock().lock();
+ try {
+ LeafMNode leafMNode = (LeafMNode) mtree.getNodeByPath(path);
+ leafMNode.getParent().deleteAliasChild(leafMNode.getAlias());
+ leafMNode.getParent().addAlias(alias, leafMNode);
+ leafMNode.setAlias(alias);
+ } finally {
+ lock.writeLock().unlock();
+ }
+ }
+
/**
* upsert tags and attributes key-value for the timeseries if the key has existed, just use the
* new value to update it.
*
+ * @param alias newly added alias
* @param tagsMap newly added tags map
* @param attributesMap newly added attributes map
* @param fullPath timeseries
*/
- public void upsertTagsAndAttributes(
- Map<String, String> tagsMap, Map<String, String> attributesMap, String fullPath)
- throws MetadataException, IOException {
+ public void upsertTagsAndAttributes(String alias, Map<String, String> tagsMap,
+ Map<String, String> attributesMap, String fullPath) throws MetadataException, IOException {
lock.writeLock().lock();
try {
MNode mNode = mtree.getNodeByPath(fullPath);
if (!(mNode instanceof LeafMNode)) {
throw new PathNotExistException(fullPath);
}
LeafMNode leafMNode = (LeafMNode) mNode;
+ // upsert alias
+ if (alias != null) {
+ if (leafMNode.getParent().hasChild(alias)) {
+ throw new MetadataException("The alias already exits.");
Review comment:
I think, if the alias exists, just keep it and do the next instead of throwing an exception is better. What do you think? And a typo: exist
##########
File path: server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
##########
@@ -1010,62 +1031,97 @@ public void changeOffset(String path, long offset) throws MetadataException {
}
}
+ public void changeAlias(String path, String alias) throws MetadataException {
+ lock.writeLock().lock();
+ try {
+ LeafMNode leafMNode = (LeafMNode) mtree.getNodeByPath(path);
+ leafMNode.getParent().deleteAliasChild(leafMNode.getAlias());
+ leafMNode.getParent().addAlias(alias, leafMNode);
+ leafMNode.setAlias(alias);
+ } finally {
+ lock.writeLock().unlock();
+ }
+ }
+
/**
* upsert tags and attributes key-value for the timeseries if the key has existed, just use the
* new value to update it.
*
+ * @param alias newly added alias
* @param tagsMap newly added tags map
* @param attributesMap newly added attributes map
* @param fullPath timeseries
*/
- public void upsertTagsAndAttributes(
- Map<String, String> tagsMap, Map<String, String> attributesMap, String fullPath)
- throws MetadataException, IOException {
+ public void upsertTagsAndAttributes(String alias, Map<String, String> tagsMap,
+ Map<String, String> attributesMap, String fullPath) throws MetadataException, IOException {
lock.writeLock().lock();
try {
MNode mNode = mtree.getNodeByPath(fullPath);
if (!(mNode instanceof LeafMNode)) {
throw new PathNotExistException(fullPath);
}
LeafMNode leafMNode = (LeafMNode) mNode;
+ // upsert alias
+ if (alias != null) {
+ if (leafMNode.getParent().hasChild(alias)) {
+ throw new MetadataException("The alias already exits.");
+ }
+ if (leafMNode.getAlias() != null) {
+ leafMNode.getParent().deleteAliasChild(leafMNode.getAlias());
+ leafMNode.getParent().addAlias(alias, leafMNode);
+ leafMNode.setAlias(alias);
+ // persist to WAL
+ logWriter.changeAlias(fullPath, alias);
+ }
+ }
+ //
Review comment:
Add a comment or delete this.
##########
File path: server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
##########
@@ -1010,62 +1031,97 @@ public void changeOffset(String path, long offset) throws MetadataException {
}
}
+ public void changeAlias(String path, String alias) throws MetadataException {
+ lock.writeLock().lock();
+ try {
+ LeafMNode leafMNode = (LeafMNode) mtree.getNodeByPath(path);
+ leafMNode.getParent().deleteAliasChild(leafMNode.getAlias());
+ leafMNode.getParent().addAlias(alias, leafMNode);
+ leafMNode.setAlias(alias);
+ } finally {
+ lock.writeLock().unlock();
+ }
+ }
+
/**
* upsert tags and attributes key-value for the timeseries if the key has existed, just use the
* new value to update it.
*
+ * @param alias newly added alias
* @param tagsMap newly added tags map
* @param attributesMap newly added attributes map
* @param fullPath timeseries
*/
- public void upsertTagsAndAttributes(
- Map<String, String> tagsMap, Map<String, String> attributesMap, String fullPath)
- throws MetadataException, IOException {
+ public void upsertTagsAndAttributes(String alias, Map<String, String> tagsMap,
+ Map<String, String> attributesMap, String fullPath) throws MetadataException, IOException {
lock.writeLock().lock();
try {
MNode mNode = mtree.getNodeByPath(fullPath);
if (!(mNode instanceof LeafMNode)) {
throw new PathNotExistException(fullPath);
}
LeafMNode leafMNode = (LeafMNode) mNode;
+ // upsert alias
+ if (alias != null) {
+ if (leafMNode.getParent().hasChild(alias)) {
+ throw new MetadataException("The alias already exits.");
+ }
+ if (leafMNode.getAlias() != null) {
+ leafMNode.getParent().deleteAliasChild(leafMNode.getAlias());
+ leafMNode.getParent().addAlias(alias, leafMNode);
+ leafMNode.setAlias(alias);
+ // persist to WAL
+ logWriter.changeAlias(fullPath, alias);
+ }
+ }
+ //
+ if (tagsMap == null && attributesMap == null) {
+ return;
+ }
// no tag or attribute, we need to add a new record in log
if (leafMNode.getOffset() < 0) {
long offset = tagLogFile.write(tagsMap, attributesMap);
logWriter.changeOffset(fullPath, offset);
leafMNode.setOffset(offset);
// update inverted Index map
- for (Entry<String, String> entry : tagsMap.entrySet()) {
- tagIndex.computeIfAbsent(entry.getKey(), k -> new HashMap<>())
- .computeIfAbsent(entry.getValue(), v -> new HashSet<>()).add(leafMNode);
+ if (tagsMap != null) {
Review comment:
Is this limit is needed?
##########
File path: server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
##########
@@ -1010,62 +1031,97 @@ public void changeOffset(String path, long offset) throws MetadataException {
}
}
+ public void changeAlias(String path, String alias) throws MetadataException {
+ lock.writeLock().lock();
+ try {
+ LeafMNode leafMNode = (LeafMNode) mtree.getNodeByPath(path);
+ leafMNode.getParent().deleteAliasChild(leafMNode.getAlias());
+ leafMNode.getParent().addAlias(alias, leafMNode);
+ leafMNode.setAlias(alias);
+ } finally {
+ lock.writeLock().unlock();
+ }
+ }
+
/**
* upsert tags and attributes key-value for the timeseries if the key has existed, just use the
* new value to update it.
*
+ * @param alias newly added alias
* @param tagsMap newly added tags map
* @param attributesMap newly added attributes map
* @param fullPath timeseries
*/
- public void upsertTagsAndAttributes(
- Map<String, String> tagsMap, Map<String, String> attributesMap, String fullPath)
- throws MetadataException, IOException {
+ public void upsertTagsAndAttributes(String alias, Map<String, String> tagsMap,
+ Map<String, String> attributesMap, String fullPath) throws MetadataException, IOException {
lock.writeLock().lock();
try {
MNode mNode = mtree.getNodeByPath(fullPath);
if (!(mNode instanceof LeafMNode)) {
throw new PathNotExistException(fullPath);
}
LeafMNode leafMNode = (LeafMNode) mNode;
+ // upsert alias
+ if (alias != null) {
+ if (leafMNode.getParent().hasChild(alias)) {
+ throw new MetadataException("The alias already exits.");
+ }
+ if (leafMNode.getAlias() != null) {
+ leafMNode.getParent().deleteAliasChild(leafMNode.getAlias());
+ leafMNode.getParent().addAlias(alias, leafMNode);
+ leafMNode.setAlias(alias);
+ // persist to WAL
+ logWriter.changeAlias(fullPath, alias);
+ }
+ }
+ //
+ if (tagsMap == null && attributesMap == null) {
+ return;
+ }
// no tag or attribute, we need to add a new record in log
if (leafMNode.getOffset() < 0) {
long offset = tagLogFile.write(tagsMap, attributesMap);
logWriter.changeOffset(fullPath, offset);
leafMNode.setOffset(offset);
// update inverted Index map
- for (Entry<String, String> entry : tagsMap.entrySet()) {
- tagIndex.computeIfAbsent(entry.getKey(), k -> new HashMap<>())
- .computeIfAbsent(entry.getValue(), v -> new HashSet<>()).add(leafMNode);
+ if (tagsMap != null) {
+ for (Entry<String, String> entry : tagsMap.entrySet()) {
+ tagIndex.computeIfAbsent(entry.getKey(), k -> new HashMap<>())
+ .computeIfAbsent(entry.getValue(), v -> new HashSet<>()).add(leafMNode);
+ }
}
return;
}
Pair<Map<String, String>, Map<String, String>> pair =
tagLogFile.read(config.getTagAttributeTotalSize(), leafMNode.getOffset());
- for (Entry<String, String> entry : tagsMap.entrySet()) {
- String key = entry.getKey();
- String value = entry.getValue();
- String beforeValue = pair.left.get(key);
- pair.left.put(key, value);
- // 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 (tagsMap != null) {
Review comment:
Same as above.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-iotdb] sonarcloud[bot] removed a comment on pull request #1315: [IOTDB-744] Support upsert alias
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] removed a comment on pull request #1315:
URL: https://github.com/apache/incubator-iotdb/pull/1315#issuecomment-639237872
Kudos, SonarCloud Quality Gate passed!
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug.png' alt='Bug' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=BUG) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=BUG)
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability.png' alt='Vulnerability' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=VULNERABILITY) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=VULNERABILITY) (and [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot.png' alt='Security Hotspot' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=SECURITY_HOTSPOT) to review)
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell.png' alt='Code Smell' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=CODE_SMELL) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=CODE_SMELL) [2 Code Smells](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=CODE_SMELL)
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo.png' alt='No Coverage information' width='16' height='16' />](https://sonarcloud.io/component_measures?id=apache_incubator-iotdb&pullRequest=1315) No Coverage information
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3.png' alt='0.0%' width='16' height='16' />](https://sonarcloud.io/component_measures?id=apache_incubator-iotdb&pullRequest=1315&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_incubator-iotdb&pullRequest=1315&metric=new_duplicated_lines_density&view=list)
<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/message_warning.png' alt='warning' width='16' height='16' /> The version of Java (1.8.0_242) you have used to run this analysis is deprecated and we will stop accepting it from October 2020. Please update to at least Java 11.
Read more [here](https://sonarcloud.io/documentation/upcoming/)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-iotdb] sonarcloud[bot] commented on pull request #1315: [IOTDB-744] Support upsert alias
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on pull request #1315:
URL: https://github.com/apache/incubator-iotdb/pull/1315#issuecomment-639237872
Kudos, SonarCloud Quality Gate passed!
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug.png' alt='Bug' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=BUG) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=BUG)
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability.png' alt='Vulnerability' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=VULNERABILITY) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=VULNERABILITY) (and [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot.png' alt='Security Hotspot' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=SECURITY_HOTSPOT) to review)
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell.png' alt='Code Smell' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=CODE_SMELL) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=CODE_SMELL) [2 Code Smells](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=CODE_SMELL)
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo.png' alt='No Coverage information' width='16' height='16' />](https://sonarcloud.io/component_measures?id=apache_incubator-iotdb&pullRequest=1315) No Coverage information
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3.png' alt='0.0%' width='16' height='16' />](https://sonarcloud.io/component_measures?id=apache_incubator-iotdb&pullRequest=1315&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_incubator-iotdb&pullRequest=1315&metric=new_duplicated_lines_density&view=list)
<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/message_warning.png' alt='warning' width='16' height='16' /> The version of Java (1.8.0_242) you have used to run this analysis is deprecated and we will stop accepting it from October 2020. Please update to at least Java 11.
Read more [here](https://sonarcloud.io/documentation/upcoming/)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-iotdb] qiaojialin commented on a change in pull request #1315: [IOTDB-744] Support upsert alias
Posted by GitBox <gi...@apache.org>.
qiaojialin commented on a change in pull request #1315:
URL: https://github.com/apache/incubator-iotdb/pull/1315#discussion_r435679004
##########
File path: server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
##########
@@ -1010,62 +1031,97 @@ public void changeOffset(String path, long offset) throws MetadataException {
}
}
+ public void changeAlias(String path, String alias) throws MetadataException {
+ lock.writeLock().lock();
+ try {
+ LeafMNode leafMNode = (LeafMNode) mtree.getNodeByPath(path);
+ leafMNode.getParent().deleteAliasChild(leafMNode.getAlias());
+ leafMNode.getParent().addAlias(alias, leafMNode);
+ leafMNode.setAlias(alias);
+ } finally {
+ lock.writeLock().unlock();
+ }
+ }
+
/**
* upsert tags and attributes key-value for the timeseries if the key has existed, just use the
* new value to update it.
*
+ * @param alias newly added alias
* @param tagsMap newly added tags map
* @param attributesMap newly added attributes map
* @param fullPath timeseries
*/
- public void upsertTagsAndAttributes(
- Map<String, String> tagsMap, Map<String, String> attributesMap, String fullPath)
- throws MetadataException, IOException {
+ public void upsertTagsAndAttributes(String alias, Map<String, String> tagsMap,
+ Map<String, String> attributesMap, String fullPath) throws MetadataException, IOException {
lock.writeLock().lock();
try {
MNode mNode = mtree.getNodeByPath(fullPath);
if (!(mNode instanceof LeafMNode)) {
throw new PathNotExistException(fullPath);
}
LeafMNode leafMNode = (LeafMNode) mNode;
+ // upsert alias
+ if (alias != null) {
+ if (leafMNode.getParent().hasChild(alias)) {
+ throw new MetadataException("The alias already exits.");
Review comment:
Yes!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #1315: [IOTDB-744] Support upsert alias
Posted by GitBox <gi...@apache.org>.
Alima777 commented on a change in pull request #1315:
URL: https://github.com/apache/incubator-iotdb/pull/1315#discussion_r435668037
##########
File path: server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
##########
@@ -1010,62 +1031,97 @@ public void changeOffset(String path, long offset) throws MetadataException {
}
}
+ public void changeAlias(String path, String alias) throws MetadataException {
+ lock.writeLock().lock();
+ try {
+ LeafMNode leafMNode = (LeafMNode) mtree.getNodeByPath(path);
+ leafMNode.getParent().deleteAliasChild(leafMNode.getAlias());
+ leafMNode.getParent().addAlias(alias, leafMNode);
+ leafMNode.setAlias(alias);
+ } finally {
+ lock.writeLock().unlock();
+ }
+ }
+
/**
* upsert tags and attributes key-value for the timeseries if the key has existed, just use the
* new value to update it.
*
+ * @param alias newly added alias
* @param tagsMap newly added tags map
* @param attributesMap newly added attributes map
* @param fullPath timeseries
*/
- public void upsertTagsAndAttributes(
- Map<String, String> tagsMap, Map<String, String> attributesMap, String fullPath)
- throws MetadataException, IOException {
+ public void upsertTagsAndAttributes(String alias, Map<String, String> tagsMap,
+ Map<String, String> attributesMap, String fullPath) throws MetadataException, IOException {
lock.writeLock().lock();
try {
MNode mNode = mtree.getNodeByPath(fullPath);
if (!(mNode instanceof LeafMNode)) {
throw new PathNotExistException(fullPath);
}
LeafMNode leafMNode = (LeafMNode) mNode;
+ // upsert alias
+ if (alias != null) {
+ if (leafMNode.getParent().hasChild(alias)) {
+ throw new MetadataException("The alias already exits.");
+ }
+ if (leafMNode.getAlias() != null) {
+ leafMNode.getParent().deleteAliasChild(leafMNode.getAlias());
+ leafMNode.getParent().addAlias(alias, leafMNode);
+ leafMNode.setAlias(alias);
+ // persist to WAL
+ logWriter.changeAlias(fullPath, alias);
+ }
+ }
+ //
+ if (tagsMap == null && attributesMap == null) {
+ return;
+ }
// no tag or attribute, we need to add a new record in log
if (leafMNode.getOffset() < 0) {
long offset = tagLogFile.write(tagsMap, attributesMap);
logWriter.changeOffset(fullPath, offset);
leafMNode.setOffset(offset);
// update inverted Index map
- for (Entry<String, String> entry : tagsMap.entrySet()) {
- tagIndex.computeIfAbsent(entry.getKey(), k -> new HashMap<>())
- .computeIfAbsent(entry.getValue(), v -> new HashSet<>()).add(leafMNode);
+ if (tagsMap != null) {
Review comment:
Is this limit needed?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-iotdb] JackieTien97 commented on a change in pull request #1315: [IOTDB-744] Support upsert alias
Posted by GitBox <gi...@apache.org>.
JackieTien97 commented on a change in pull request #1315:
URL: https://github.com/apache/incubator-iotdb/pull/1315#discussion_r435686688
##########
File path: server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
##########
@@ -1010,62 +1031,97 @@ public void changeOffset(String path, long offset) throws MetadataException {
}
}
+ public void changeAlias(String path, String alias) throws MetadataException {
+ lock.writeLock().lock();
+ try {
+ LeafMNode leafMNode = (LeafMNode) mtree.getNodeByPath(path);
+ leafMNode.getParent().deleteAliasChild(leafMNode.getAlias());
+ leafMNode.getParent().addAlias(alias, leafMNode);
+ leafMNode.setAlias(alias);
+ } finally {
+ lock.writeLock().unlock();
+ }
+ }
+
/**
* upsert tags and attributes key-value for the timeseries if the key has existed, just use the
* new value to update it.
*
+ * @param alias newly added alias
* @param tagsMap newly added tags map
* @param attributesMap newly added attributes map
* @param fullPath timeseries
*/
- public void upsertTagsAndAttributes(
- Map<String, String> tagsMap, Map<String, String> attributesMap, String fullPath)
- throws MetadataException, IOException {
+ public void upsertTagsAndAttributes(String alias, Map<String, String> tagsMap,
+ Map<String, String> attributesMap, String fullPath) throws MetadataException, IOException {
lock.writeLock().lock();
try {
MNode mNode = mtree.getNodeByPath(fullPath);
if (!(mNode instanceof LeafMNode)) {
throw new PathNotExistException(fullPath);
}
LeafMNode leafMNode = (LeafMNode) mNode;
+ // upsert alias
+ if (alias != null) {
+ if (leafMNode.getParent().hasChild(alias)) {
+ throw new MetadataException("The alias already exits.");
+ }
+ if (leafMNode.getAlias() != null) {
+ leafMNode.getParent().deleteAliasChild(leafMNode.getAlias());
+ leafMNode.getParent().addAlias(alias, leafMNode);
+ leafMNode.setAlias(alias);
+ // persist to WAL
+ logWriter.changeAlias(fullPath, alias);
+ }
+ }
+ //
+ if (tagsMap == null && attributesMap == null) {
+ return;
+ }
// no tag or attribute, we need to add a new record in log
if (leafMNode.getOffset() < 0) {
long offset = tagLogFile.write(tagsMap, attributesMap);
logWriter.changeOffset(fullPath, offset);
leafMNode.setOffset(offset);
// update inverted Index map
- for (Entry<String, String> entry : tagsMap.entrySet()) {
- tagIndex.computeIfAbsent(entry.getKey(), k -> new HashMap<>())
- .computeIfAbsent(entry.getValue(), v -> new HashSet<>()).add(leafMNode);
+ if (tagsMap != null) {
Review comment:
Yes, Or the `tagsMap.entrySet()` will throw NullPointerException
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-iotdb] JackieTien97 commented on a change in pull request #1315: [IOTDB-744] Support upsert alias
Posted by GitBox <gi...@apache.org>.
JackieTien97 commented on a change in pull request #1315:
URL: https://github.com/apache/incubator-iotdb/pull/1315#discussion_r435686841
##########
File path: server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
##########
@@ -1010,62 +1031,97 @@ public void changeOffset(String path, long offset) throws MetadataException {
}
}
+ public void changeAlias(String path, String alias) throws MetadataException {
+ lock.writeLock().lock();
+ try {
+ LeafMNode leafMNode = (LeafMNode) mtree.getNodeByPath(path);
+ leafMNode.getParent().deleteAliasChild(leafMNode.getAlias());
+ leafMNode.getParent().addAlias(alias, leafMNode);
+ leafMNode.setAlias(alias);
+ } finally {
+ lock.writeLock().unlock();
+ }
+ }
+
/**
* upsert tags and attributes key-value for the timeseries if the key has existed, just use the
* new value to update it.
*
+ * @param alias newly added alias
* @param tagsMap newly added tags map
* @param attributesMap newly added attributes map
* @param fullPath timeseries
*/
- public void upsertTagsAndAttributes(
- Map<String, String> tagsMap, Map<String, String> attributesMap, String fullPath)
- throws MetadataException, IOException {
+ public void upsertTagsAndAttributes(String alias, Map<String, String> tagsMap,
+ Map<String, String> attributesMap, String fullPath) throws MetadataException, IOException {
lock.writeLock().lock();
try {
MNode mNode = mtree.getNodeByPath(fullPath);
if (!(mNode instanceof LeafMNode)) {
throw new PathNotExistException(fullPath);
}
LeafMNode leafMNode = (LeafMNode) mNode;
+ // upsert alias
+ if (alias != null) {
+ if (leafMNode.getParent().hasChild(alias)) {
+ throw new MetadataException("The alias already exits.");
Review comment:
fix
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-iotdb] sonarcloud[bot] removed a comment on pull request #1315: [IOTDB-744] Support upsert alias
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] removed a comment on pull request #1315:
URL: https://github.com/apache/incubator-iotdb/pull/1315#issuecomment-639229537
Kudos, SonarCloud Quality Gate passed!
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug.png' alt='Bug' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=BUG) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=BUG)
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability.png' alt='Vulnerability' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=VULNERABILITY) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=VULNERABILITY) (and [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot.png' alt='Security Hotspot' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=SECURITY_HOTSPOT) to review)
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell.png' alt='Code Smell' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=CODE_SMELL) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=CODE_SMELL) [2 Code Smells](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=1315&resolved=false&types=CODE_SMELL)
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo.png' alt='No Coverage information' width='16' height='16' />](https://sonarcloud.io/component_measures?id=apache_incubator-iotdb&pullRequest=1315) No Coverage information
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3.png' alt='0.0%' width='16' height='16' />](https://sonarcloud.io/component_measures?id=apache_incubator-iotdb&pullRequest=1315&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_incubator-iotdb&pullRequest=1315&metric=new_duplicated_lines_density&view=list)
<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/message_warning.png' alt='warning' width='16' height='16' /> The version of Java (1.8.0_242) you have used to run this analysis is deprecated and we will stop accepting it from October 2020. Please update to at least Java 11.
Read more [here](https://sonarcloud.io/documentation/upcoming/)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-iotdb] qiaojialin merged pull request #1315: [IOTDB-744] Support upsert alias
Posted by GitBox <gi...@apache.org>.
qiaojialin merged pull request #1315:
URL: https://github.com/apache/incubator-iotdb/pull/1315
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org