Skip to content

Commit 1ee0f89

Browse files
committed
code formatting
1 parent f051a1f commit 1ee0f89

5 files changed

Lines changed: 29 additions & 19 deletions

File tree

.unreleased/pr_9903

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Implements: #9903 Incremental refresh for refresh_continuous_aggregate()

tsl/src/bgw_policy/continuous_aggregate_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
#include "bgw_policy/job_api.h"
2222
#include "bgw_policy/policies_v2.h"
2323
#include "bgw_policy/policy_utils.h"
24+
#include "continuous_aggs/refresh.h"
2425
#include "dimension.h"
2526
#include "guc.h"
2627
#include "jsonb_utils.h"
2728
#include "policy_config.h"
2829
#include "policy_utils.h"
2930
#include "time_utils.h"
30-
#include "continuous_aggs/refresh.h"
3131
#include "ts_catalog/continuous_agg.h"
3232

3333
/* Default max runtime for a continuous aggregate jobs is unlimited for now */

tsl/src/continuous_aggs/create.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ tsl_process_continuous_agg_viewstmt(Node *node, const char *query_string, void *
900900
&refresh_window,
901901
context,
902902
false, /* force */
903-
false /* extend_last_bucket */);
903+
false /* extend_last_bucket */);
904904
}
905905

906906
return DDL_DONE;

tsl/src/continuous_aggs/refresh.c

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -683,34 +683,44 @@ continuous_agg_refresh(PG_FUNCTION_ARGS)
683683

684684
int32 v = ts_jsonb_get_int32_field(options, POL_REFRESH_CONF_KEY_BUCKETS_PER_BATCH, &found);
685685
if (found)
686+
{
686687
buckets_per_batch = v;
688+
}
687689

688690
v = ts_jsonb_get_int32_field(options,
689691
POL_REFRESH_CONF_KEY_MAX_BATCHES_PER_EXECUTION,
690692
&found);
691693
if (found)
694+
{
692695
max_batches_per_execution = v;
696+
}
693697

694698
bool b =
695699
ts_jsonb_get_bool_field(options, POL_REFRESH_CONF_KEY_REFRESH_NEWEST_FIRST, &found);
696700
if (found)
701+
{
697702
refresh_newest_first = b;
703+
}
698704
}
699705

700706
if (buckets_per_batch < 0)
707+
{
701708
ereport(ERROR,
702709
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
703710
errmsg("invalid buckets per batch"),
704711
errdetail("buckets_per_batch: %d", buckets_per_batch),
705712
errhint("The buckets per batch should be greater than or equal to zero.")));
713+
}
706714

707715
if (max_batches_per_execution < 0)
716+
{
708717
ereport(ERROR,
709718
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
710719
errmsg("invalid max batches per execution"),
711720
errdetail("max_batches_per_execution: %d", max_batches_per_execution),
712721
errhint(
713722
"The max batches per execution should be greater than or equal to zero.")));
723+
}
714724

715725
ContinuousAggRefreshContext context = {
716726
.callctx = CAGG_REFRESH_WINDOW,
@@ -1125,8 +1135,7 @@ continuous_agg_refresh_single_window(const ContinuousAgg *cagg_arg,
11251135
* own independent SPI session and commits independently (non-atomic).
11261136
*/
11271137
void
1128-
continuous_agg_refresh_internal(const ContinuousAgg *cagg,
1129-
const InternalTimeRange *refresh_window,
1138+
continuous_agg_refresh_internal(const ContinuousAgg *cagg, const InternalTimeRange *refresh_window,
11301139
ContinuousAggRefreshContext context, bool force,
11311140
bool extend_last_bucket)
11321141
{
@@ -1144,12 +1153,11 @@ continuous_agg_refresh_internal(const ContinuousAgg *cagg,
11441153

11451154
if (context.buckets_per_batch > 0)
11461155
{
1147-
refresh_window_list =
1148-
continuous_agg_split_refresh_window(cagg,
1149-
refresh_window,
1150-
context.buckets_per_batch,
1151-
context.refresh_newest_first,
1152-
force);
1156+
refresh_window_list = continuous_agg_split_refresh_window(cagg,
1157+
refresh_window,
1158+
context.buckets_per_batch,
1159+
context.refresh_newest_first,
1160+
force);
11531161
}
11541162

11551163
if (refresh_window_list == NIL)
@@ -1162,7 +1170,9 @@ continuous_agg_refresh_internal(const ContinuousAgg *cagg,
11621170
/* Batched windows are already bucket-aligned by the split function */
11631171
bucketing_refresh_window = false;
11641172
if (context.callctx == CAGG_REFRESH_POLICY)
1173+
{
11651174
context.callctx = CAGG_REFRESH_POLICY_BATCHED;
1175+
}
11661176
}
11671177

11681178
context.number_of_batches = list_length(refresh_window_list);
@@ -1186,11 +1196,13 @@ continuous_agg_refresh_internal(const ContinuousAgg *cagg,
11861196
processing_batch == context.number_of_batches);
11871197

11881198
if (context.number_of_batches > 1)
1199+
{
11891200
elog(DEBUG1,
11901201
"refreshing continuous aggregate \"%s\" in window [ %s, %s ]",
11911202
NameStr(cagg->data.user_view_name),
11921203
ts_internal_to_time_string(batch_window->start, batch_window->type),
11931204
ts_internal_to_time_string(batch_window->end, batch_window->type));
1205+
}
11941206

11951207
bool refreshed = continuous_agg_refresh_single_window(cagg,
11961208
batch_window,
@@ -1356,14 +1368,12 @@ continuous_agg_split_refresh_window(const ContinuousAgg *cagg,
13561368
* 5. If the batch overlaps with both then it's a valid batch to be processed
13571369
* 6. If the batch overlaps with only one of them then it's not a valid batch to be processed
13581370
* 7. If the batch does not overlap with any of them then it's not a valid batch to be processed
1359-
*/
1360-
/*
1371+
*
13611372
* When force is true, skip the invalidation log filter since forced refresh
13621373
* synthesizes invalidations per-window and there may be no existing log entries.
13631374
* Only filter on dimension slices (chunks with data).
13641375
*/
1365-
const char *query_str_template = force ?
1366-
" \
1376+
const char *query_str_template = force ? " \
13671377
WITH dimension_slices AS ( \
13681378
SELECT \
13691379
range_start AS start, \
@@ -1392,9 +1402,8 @@ continuous_agg_split_refresh_window(const ContinuousAgg *cagg,
13921402
pg_catalog.int8range(dimension_slices.start, dimension_slices.end) \
13931403
) \
13941404
ORDER BY \
1395-
refresh_start %s;"
1396-
:
1397-
" \
1405+
refresh_start %s;" :
1406+
" \
13981407
WITH dimension_slices AS ( \
13991408
SELECT \
14001409
range_start AS start, \

tsl/src/continuous_aggs/refresh.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ extern void continuous_agg_refresh_internal(const ContinuousAgg *cagg,
2525
bool extend_last_bucket);
2626
extern List *continuous_agg_split_refresh_window(const ContinuousAgg *cagg,
2727
const InternalTimeRange *original_refresh_window,
28-
int32 buckets_per_batch,
29-
bool refresh_newest_first, bool force);
28+
int32 buckets_per_batch, bool refresh_newest_first,
29+
bool force);
3030
InternalTimeRange
3131
compute_circumscribed_bucketed_refresh_window(const InternalTimeRange *const refresh_window,
3232
const ContinuousAggBucketFunction *bucket_function);

0 commit comments

Comments
 (0)