-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
** DONOT MERGE ** Enabling queryplan cache by default (#24673)
* Enabling queryplan cache by default - Queryplan cache, an LRU cache of size 1000 would try to cache query plan for simple queries
- Loading branch information
Showing
9 changed files
with
85 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...ure-cosmos/src/main/java/com/azure/cosmos/implementation/caches/SizeLimitingLRUCache.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
package com.azure.cosmos.implementation.caches; | ||
|
||
import com.azure.cosmos.implementation.query.PartitionedQueryExecutionInfo; | ||
|
||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* LRU Cache using LinkedHashMap that limits the number of entries | ||
*/ | ||
public class SizeLimitingLRUCache extends LinkedHashMap<String, PartitionedQueryExecutionInfo> { | ||
|
||
private static final long serialVersionUID = 1L; | ||
private final int maxEntries; | ||
|
||
public SizeLimitingLRUCache(int maxEntries) { | ||
this.maxEntries = maxEntries; | ||
} | ||
|
||
public SizeLimitingLRUCache(int initialCapacity, float loadFactor, int maxEntries) { | ||
super(initialCapacity, loadFactor); | ||
this.maxEntries = maxEntries; | ||
} | ||
|
||
public SizeLimitingLRUCache( | ||
Map<? extends String, ? extends PartitionedQueryExecutionInfo> m, int maxEntries) { | ||
super(m); | ||
this.maxEntries = maxEntries; | ||
} | ||
|
||
public SizeLimitingLRUCache(int initialCapacity, float loadFactor, boolean accessOrder, int maxEntries) { | ||
super(initialCapacity, loadFactor, accessOrder); | ||
this.maxEntries = maxEntries; | ||
} | ||
|
||
public SizeLimitingLRUCache(int initialCapacity, int maxEntries) { | ||
super(initialCapacity); | ||
this.maxEntries = maxEntries; | ||
} | ||
|
||
@Override | ||
protected boolean removeEldestEntry( | ||
Map.Entry<String, PartitionedQueryExecutionInfo> eldest) { | ||
return size() > maxEntries; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters