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 2021/08/22 07:56:02 UTC
[GitHub] [iotdb] zyk990424 commented on a change in pull request #3796: [IOTDB-1543] LastCache for Template and Vector
zyk990424 commented on a change in pull request #3796:
URL: https://github.com/apache/iotdb/pull/3796#discussion_r693460925
##########
File path: server/src/main/java/org/apache/iotdb/db/metadata/mnode/MeasurementMNode.java
##########
@@ -153,42 +154,20 @@ public void setTriggerExecutor(TriggerExecutor triggerExecutor) {
}
@Override
- public TimeValuePair getCachedLast() {
- return cachedLastValuePair;
- }
-
- /**
- * update last point cache
- *
- * @param timeValuePair last point
- * @param highPriorityUpdate whether it's a high priority update
- * @param latestFlushedTime latest flushed time
- */
- @Override
- public synchronized void updateCachedLast(
- TimeValuePair timeValuePair, boolean highPriorityUpdate, Long latestFlushedTime) {
- if (timeValuePair == null || timeValuePair.getValue() == null) {
- return;
- }
-
- if (cachedLastValuePair == null) {
- // If no cached last, (1) a last query (2) an unseq insertion or (3) a seq insertion will
- // update cache.
- if (!highPriorityUpdate || latestFlushedTime <= timeValuePair.getTimestamp()) {
- cachedLastValuePair =
- new TimeValuePair(timeValuePair.getTimestamp(), timeValuePair.getValue());
+ public ILastCacheEntry getLastCacheEntry() {
+ if (lastCacheEntry == null) {
+ synchronized (this) {
+ if (lastCacheEntry == null) {
+ lastCacheEntry = new LastCacheEntry();
+ }
Review comment:
To avoid multi threads creating different lastCacheEntries on one MeasurementMNode, such control is necessary, otherwise entry merge should be considered. Volatile is important as well. Thanks for suggestions.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org