1 | /* | |
2 | * Copyright OpenSearch Contributors | |
3 | * SPDX-License-Identifier: Apache-2.0 | |
4 | */ | |
5 | ||
6 | ||
7 | package org.opensearch.sql.expression.window.frame; | |
8 | ||
9 | import com.google.common.collect.PeekingIterator; | |
10 | import java.util.Iterator; | |
11 | import java.util.List; | |
12 | import org.opensearch.sql.data.model.ExprValue; | |
13 | import org.opensearch.sql.expression.Expression; | |
14 | import org.opensearch.sql.expression.env.Environment; | |
15 | ||
16 | /** | |
17 | * Window frame that represents a subset of a window which is all data accessible to | |
18 | * the window function when calculation. Basically there are 3 types of window frame: | |
19 | * 1) Entire window frame that holds all data of the window | |
20 | * 2) Cumulative window frame that accumulates one row by another | |
21 | * 3) Sliding window frame that maintains a sliding window of fixed size | |
22 | * Note that which type of window frame is used is determined by both window function itself | |
23 | * and frame definition in a window definition. | |
24 | */ | |
25 | public interface WindowFrame extends Environment<Expression, ExprValue>, Iterator<List<ExprValue>> { | |
26 | ||
27 | @Override | |
28 | default ExprValue resolve(Expression var) { | |
29 |
1
1. resolve : replaced return value with null for org/opensearch/sql/expression/window/frame/WindowFrame::resolve → KILLED |
return var.valueOf(current().bindingTuples()); |
30 | } | |
31 | ||
32 | /** | |
33 | * Check is current row the beginning of a new partition according to window definition. | |
34 | * @return true if a new partition begins here, otherwise false. | |
35 | */ | |
36 | boolean isNewPartition(); | |
37 | ||
38 | /** | |
39 | * Load one or more rows as window function calculation needed. | |
40 | * @param iterator peeking iterator that can peek next element without moving iterator | |
41 | */ | |
42 | void load(PeekingIterator<ExprValue> iterator); | |
43 | ||
44 | /** | |
45 | * Get current data row for giving window operator chance to get rows preloaded into frame. | |
46 | * @return data row | |
47 | */ | |
48 | ExprValue current(); | |
49 | ||
50 | } | |
Mutations | ||
29 |
1.1 |