Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,34 @@ $else$
$type$ get$Type$(int valueIndex);
$endif$

/**
* Checks if this block has the given value at valueIndex. If at this index we have a
* multivalue, then it returns true if any values match.
*
* @param valueIndex the index at which we should check the value(s)
* @param value the value to check against
*/
default boolean hasValue(int valueIndex, $type$ value) {
final var count = getValueCount(valueIndex);
final var startIndex = getFirstValueIndex(valueIndex);
$if(BytesRef)$
var ref = new BytesRef();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd pass the scratch in for this in BytesRefBlock. One scratch per position feels like a lot.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes, long day. Renamed it to position.

I've moved the scratch up one level though in the back of my mind I do wonder if we'll have a net gain from this as we might just break escape analysis 'a stack too far' so to speak.

$endif$
for (int index = startIndex; index < startIndex + count; index++) {
$if(BytesRef)$
ref = getBytesRef(index, ref);
if (value.equals(ref)) {
return true;
}
$else$
if (value == get$Type$(index)) {
return true;
}
$endif$
}
return false;
}

@Override
$Type$Vector asVector();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ POINT (12.6493508684508 55.6285017221528) | 13686180 | 427683 | 1336

geohashLiteralMv
required_capability: spatial_grid_types
required_capability: fn_mv_contains
required_capability: fn_mv_contains_v1

ROW location = TO_GEOPOINT("POINT(12.6493508684508 55.6285017221528)")
| EVAL geohash4 = ST_GEOHASH(location, 4),
Expand Down Expand Up @@ -580,7 +580,7 @@ POINT (12.6493508684508 55.6285017221528) | 1152921508901814277 | 86469113060261

geotileLiteralMv
required_capability: spatial_grid_types
required_capability: fn_mv_contains
required_capability: fn_mv_contains_v1

ROW location = TO_GEOPOINT("POINT(12.6493508684508 55.6285017221528)")
| EVAL geotile4 = ST_GEOTILE(location, 4),
Expand Down Expand Up @@ -996,7 +996,7 @@ POINT (12.6493508684508 55.6285017221528) | 595020895127339007 | 590517321269772

geohexLiteralMv
required_capability: spatial_grid_types
required_capability: fn_mv_contains
required_capability: fn_mv_contains_v1

ROW location = TO_GEOPOINT("POINT(12.6493508684508 55.6285017221528)")
| EVAL geohex4 = ST_GEOHEX(location, 4),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2054,7 +2054,7 @@ null | 0
;

mvContains
required_capability: fn_mv_contains
required_capability: fn_mv_contains_v1
// tag::mv_contains[]
ROW set = ["a", "b", "c"], element = "a"
| EVAL set_contains_element = mv_contains(set, element)
Expand All @@ -2068,7 +2068,7 @@ set:keyword | element:keyword | set_contains_element:boolean
;

mvContains_bothsides
required_capability: fn_mv_contains
required_capability: fn_mv_contains_v1
// tag::mv_contains_bothsides[]
ROW setA = ["a","c"], setB = ["a", "b", "c"]
| EVAL a_subset_of_b = mv_contains(setB, setA)
Expand All @@ -2083,7 +2083,7 @@ setA:keyword | setB:keyword | a_subset_of_b:boolean | b_subset_of_a:boolean
;

mvContainsCombinations
required_capability: fn_mv_contains
required_capability: fn_mv_contains_v1

ROW a = "a", b = ["a", "b", "c"], n = null
| EVAL aa = mv_contains(a, a),
Expand All @@ -2100,33 +2100,36 @@ a | [a, b, c] | null | true | true | false | true
;

mvContainsCombinations_multirow
required_capability: fn_mv_contains
required_capability: fn_mv_contains_v1

ROW row_number = [1,2,3,4,5], element = "e", n = null, setA = ["b","d"], setB = ["a", "c", "e"]
ROW row_number = [0,1,2,3,4,5], element = "e", n = null, emptyStringSet = [""], setA = ["b","d"], setB = ["a", "c", "e"]
| MV_EXPAND row_number
| EVAL superset = CASE(
row_number == 1, ["a","e"],
row_number == 2, ["b","d"],
row_number == 3, null,
row_number == 4, ["a","e","c","b","d"],
row_number == 5, ["a","d","c","b","e"],
row_number == 0, ["a","e"],
row_number == 1, ["b","d"],
row_number == 2, null,
row_number == 3, ["a","e","c","b","d"],
row_number == 4, ["a","d","c","b","e"],
row_number == 5, ["a","d","c","b","","e"],
null)
| EVAL contains_element = mv_contains(superset, element),
contains_null = mv_contains(superset, n),
contains_setA = mv_contains(superset, setA),
contains_setB = mv_contains(superset, setB)
| EVAL contains_element = mv_contains(superset, element),
contains_null = mv_contains(superset, n),
contains_emptyStringSet = mv_contains(superset, emptyStringSet),
contains_setA = mv_contains(superset, setA),
contains_setB = mv_contains(superset, setB)
;

row_number:INTEGER | element:keyword | n:null | setA:keyword | setB:keyword | superset:keyword |contains_element:boolean | contains_null:boolean | contains_setA:boolean | contains_setB:boolean
1 | "e" | null | ["b","d"] | ["a", "c", "e"] | ["a","e"] | true | true | false | false
2 | "e" | null | ["b","d"] | ["a", "c", "e"] | ["b","d"] | false | true | true | false
3 | "e" | null | ["b","d"] | ["a", "c", "e"] | null | false | true | false | false
4 | "e" | null | ["b","d"] | ["a", "c", "e"] | ["a","e","c","b","d"] | true | true | true | true
5 | "e" | null | ["b","d"] | ["a", "c", "e"] | ["a","d","c","b","e"] | true | true | true | true
row_number:INTEGER | element:keyword | n:null | emptyStringSet:keyword | setA:keyword | setB:keyword | superset:keyword |contains_element:boolean | contains_null:boolean | contains_emptyStringSet:boolean | contains_setA:boolean | contains_setB:boolean
0 | "e" | null | [""] | ["b","d"] | ["a", "c", "e"] | ["a","e"] | true | true | false | false | false
1 | "e" | null | [""] | ["b","d"] | ["a", "c", "e"] | ["b","d"] | false | true | false | true | false
2 | "e" | null | [""] | ["b","d"] | ["a", "c", "e"] | null | false | true | false | false | false
3 | "e" | null | [""] | ["b","d"] | ["a", "c", "e"] | ["a","e","c","b","d"] | true | true | false | true | true
4 | "e" | null | [""] | ["b","d"] | ["a", "c", "e"] | ["a","d","c","b","e"] | true | true | false | true | true
5 | "e" | null | [""] | ["b","d"] | ["a", "c", "e"] | ["a","d","c","b","","e"] | true | true | true | true | true
;

mvContains_where
required_capability: fn_mv_contains
required_capability: fn_mv_contains_v1
// tag::mv_contains_where[]
FROM airports
| WHERE mv_contains(type, ["major","military"]) AND scalerank == 9
Expand Down
Loading