xtern commented on code in PR #7134:
URL: https://github.com/apache/ignite-3/pull/7134#discussion_r2601627799
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/PrepareServiceImpl.java:
##########
@@ -1116,81 +1136,118 @@ void statisticsChanged(int tableId) {
}
void start() {
- planUpdater.scheduleAtFixedRate(() -> {
- if (statPerTableChanges.isEmpty()) {
- return;
- }
+ staleRowsCheckIntervalSeconds.listen(configListener);
- if (!inProgress.compareAndSet(false, true)) {
- return;
- }
+ int intervalSeconds = staleRowsCheckIntervalSeconds.value();
- for (int tableId : statPerTableChanges) {
- Set<Entry<CacheKey, CompletableFuture<PlanInfo>>>
cachedEntries = cache.entrySet();
+ schedule(intervalSeconds);
+ }
- for (Map.Entry<CacheKey, CompletableFuture<PlanInfo>> ent
: cachedEntries) {
- CacheKey key = ent.getKey();
- CompletableFuture<PlanInfo> fut = ent.getValue();
- int currentCatalogVersion =
catalogVersionSupplier.getAsInt();
+ void stop() {
+ staleRowsCheckIntervalSeconds.stopListen(configListener);
+ if (scheduledFuture != null) {
+ scheduledFuture.cancel(false);
+ }
+ }
- if (currentCatalogVersion == key.catalogVersion() &&
isCompletedSuccessfully(fut)) {
- // no wait, already completed
- PlanInfo info = fut.join();
+ private CompletableFuture<?>
listener(ConfigurationNotificationEvent<Integer> value) {
+ Integer seconds = value.newValue();
+ assert seconds != null;
- if (info.sources.contains(tableId)) {
- info.invalidate();
- }
- }
- }
+ if (!Objects.equals(seconds, value.oldValue())) {
+ int interval = Math.max(1, seconds / 2);
Review Comment:
why we using `value / 2` ?
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/PrepareServiceImpl.java:
##########
@@ -1116,81 +1136,118 @@ void statisticsChanged(int tableId) {
}
void start() {
- planUpdater.scheduleAtFixedRate(() -> {
- if (statPerTableChanges.isEmpty()) {
- return;
- }
+ staleRowsCheckIntervalSeconds.listen(configListener);
- if (!inProgress.compareAndSet(false, true)) {
- return;
- }
+ int intervalSeconds = staleRowsCheckIntervalSeconds.value();
- for (int tableId : statPerTableChanges) {
- Set<Entry<CacheKey, CompletableFuture<PlanInfo>>>
cachedEntries = cache.entrySet();
+ schedule(intervalSeconds);
+ }
- for (Map.Entry<CacheKey, CompletableFuture<PlanInfo>> ent
: cachedEntries) {
- CacheKey key = ent.getKey();
- CompletableFuture<PlanInfo> fut = ent.getValue();
- int currentCatalogVersion =
catalogVersionSupplier.getAsInt();
+ void stop() {
+ staleRowsCheckIntervalSeconds.stopListen(configListener);
+ if (scheduledFuture != null) {
+ scheduledFuture.cancel(false);
+ }
+ }
- if (currentCatalogVersion == key.catalogVersion() &&
isCompletedSuccessfully(fut)) {
- // no wait, already completed
- PlanInfo info = fut.join();
+ private CompletableFuture<?>
listener(ConfigurationNotificationEvent<Integer> value) {
+ Integer seconds = value.newValue();
+ assert seconds != null;
- if (info.sources.contains(tableId)) {
- info.invalidate();
- }
- }
- }
+ if (!Objects.equals(seconds, value.oldValue())) {
+ int interval = Math.max(1, seconds / 2);
Review Comment:
why we're using `value / 2` ?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]