diff --git a/Input/input_berlinmod.csv b/Input/input_berlinmod.csv new file mode 100644 index 0000000000..753a68124b --- /dev/null +++ b/Input/input_berlinmod.csv @@ -0,0 +1,21 @@ +1735711200,100,4.3517,50.8503 +1735711200,300,4.2000,50.7500 +1735711201,200,4.3060,50.8270 +1735711202,100,4.3517,50.8503 +1735711202,300,4.2000,50.7500 +1735711203,200,4.3060,50.8270 +1735711204,100,4.3517,50.8503 +1735711204,300,4.2000,50.7500 +1735711205,200,4.3060,50.8270 +1735711206,100,4.3517,50.8503 +1735711206,300,4.2000,50.7500 +1735711207,200,4.3060,50.8270 +1735711208,100,4.3517,50.8503 +1735711208,300,4.2000,50.7500 +1735711209,200,4.3060,50.8270 +1735711210,100,4.3517,50.8503 +1735711210,300,4.2000,50.7500 +1735711211,200,4.3060,50.8270 +1735711212,100,4.3517,50.8503 +1735711212,300,4.2000,50.7500 +1735711213,200,4.3060,50.8270 diff --git a/Queries/berlinmod/q1_continuous.yaml b/Queries/berlinmod/q1_continuous.yaml new file mode 100644 index 0000000000..49786049e8 --- /dev/null +++ b/Queries/berlinmod/q1_continuous.yaml @@ -0,0 +1,47 @@ +# BerlinMOD-Q1 — continuous form +# "Which vehicles have appeared in the stream?" +# Per 1-second sliding bucket: emit (start, end, vehicle_id, event-count-in-bucket). +# Reading N rows over consecutive buckets enumerates the distinct-vehicles-seen set. + +query: | + SELECT start, + end, + vehicle_id, + COUNT(time_utc) AS events + FROM berlinmod_stream + GROUP BY vehicle_id + WINDOW SLIDING(time_utc, SIZE 1 SEC, ADVANCE BY 1 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$VEHICLE_ID, type: UINT64 } + - { name: BERLINMOD_STREAM$EVENTS, type: UINT64 } + config: + file_path: "/workspace/Output/output_berlinmod_q1_continuous.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q1_snapshot.yaml b/Queries/berlinmod/q1_snapshot.yaml new file mode 100644 index 0000000000..4fa9c05d63 --- /dev/null +++ b/Queries/berlinmod/q1_snapshot.yaml @@ -0,0 +1,46 @@ +# BerlinMOD-Q1 — snapshot form +# "At each 5-second tick, list of distinct vehicles seen in the tick window." +# Streaming approximation of the batch BerlinMOD-Q1 snapshot at time T. + +query: | + SELECT start, + end, + vehicle_id, + COUNT(time_utc) AS events + FROM berlinmod_stream + GROUP BY vehicle_id + WINDOW TUMBLING(time_utc, SIZE 5 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$VEHICLE_ID, type: UINT64 } + - { name: BERLINMOD_STREAM$EVENTS, type: UINT64 } + config: + file_path: "/workspace/Output/output_berlinmod_q1_snapshot.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q1_windowed.yaml b/Queries/berlinmod/q1_windowed.yaml new file mode 100644 index 0000000000..2d25214d24 --- /dev/null +++ b/Queries/berlinmod/q1_windowed.yaml @@ -0,0 +1,46 @@ +# BerlinMOD-Q1 — windowed form +# "Per 10-second tumbling window, distinct vehicles seen." +# Emits one row per (window, vehicle) seen; reading N rows per window = distinctCount. + +query: | + SELECT start, + end, + vehicle_id, + COUNT(time_utc) AS events + FROM berlinmod_stream + GROUP BY vehicle_id + WINDOW TUMBLING(time_utc, SIZE 10 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$VEHICLE_ID, type: UINT64 } + - { name: BERLINMOD_STREAM$EVENTS, type: UINT64 } + config: + file_path: "/workspace/Output/output_berlinmod_q1_windowed.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q2_continuous.yaml b/Queries/berlinmod/q2_continuous.yaml new file mode 100644 index 0000000000..1d89420d19 --- /dev/null +++ b/Queries/berlinmod/q2_continuous.yaml @@ -0,0 +1,44 @@ +# BerlinMOD-Q2 — continuous form +# "Where is vehicle X (= 200) right now?" +# Per 1-second sliding bucket, emit a trajectory snippet for vehicle X. + +query: | + SELECT start, + end, + TEMPORAL_SEQUENCE(gps_lon, gps_lat, time_utc) AS trajectory + FROM berlinmod_stream + WHERE vehicle_id = UINT64(200) + WINDOW SLIDING(time_utc, SIZE 1 SEC, ADVANCE BY 1 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$TRAJECTORY, type: VARSIZED } + config: + file_path: "/workspace/Output/output_berlinmod_q2_continuous.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q2_snapshot.yaml b/Queries/berlinmod/q2_snapshot.yaml new file mode 100644 index 0000000000..af0946bb57 --- /dev/null +++ b/Queries/berlinmod/q2_snapshot.yaml @@ -0,0 +1,43 @@ +# BerlinMOD-Q2 — snapshot form +# "At each 5-second tick, snapshot of vehicle X's (= 200) trajectory in the tick." + +query: | + SELECT start, + end, + TEMPORAL_SEQUENCE(gps_lon, gps_lat, time_utc) AS trajectory + FROM berlinmod_stream + WHERE vehicle_id = UINT64(200) + WINDOW TUMBLING(time_utc, SIZE 5 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$TRAJECTORY, type: VARSIZED } + config: + file_path: "/workspace/Output/output_berlinmod_q2_snapshot.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q2_windowed.yaml b/Queries/berlinmod/q2_windowed.yaml new file mode 100644 index 0000000000..d2ae83bc8c --- /dev/null +++ b/Queries/berlinmod/q2_windowed.yaml @@ -0,0 +1,43 @@ +# BerlinMOD-Q2 — windowed form +# "Per 10-second tumbling window, trajectory of vehicle X (= 200)." + +query: | + SELECT start, + end, + TEMPORAL_SEQUENCE(gps_lon, gps_lat, time_utc) AS trajectory + FROM berlinmod_stream + WHERE vehicle_id = UINT64(200) + WINDOW TUMBLING(time_utc, SIZE 10 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$TRAJECTORY, type: VARSIZED } + config: + file_path: "/workspace/Output/output_berlinmod_q2_windowed.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q3_continuous.yaml b/Queries/berlinmod/q3_continuous.yaml new file mode 100644 index 0000000000..bfae2d7c81 --- /dev/null +++ b/Queries/berlinmod/q3_continuous.yaml @@ -0,0 +1,49 @@ +# BerlinMOD-Q3 — continuous form +# "Vehicles within 5 km of Brussels city centre, right now." +# Per 1-second sliding bucket, emit (start, end, vehicle_id) for events near P. + +query: | + SELECT start, + end, + vehicle_id + FROM berlinmod_stream + WHERE edwithin_tgeo_geo(gps_lon, + gps_lat, + time_utc, + 'SRID=4326;POINT(4.3517 50.8503)', + FLOAT64(5000.0)) = INT32(1) + GROUP BY vehicle_id + WINDOW SLIDING(time_utc, SIZE 1 SEC, ADVANCE BY 1 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$VEHICLE_ID, type: UINT64 } + config: + file_path: "/workspace/Output/output_berlinmod_q3_continuous.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q3_snapshot.yaml b/Queries/berlinmod/q3_snapshot.yaml new file mode 100644 index 0000000000..673373d1ea --- /dev/null +++ b/Queries/berlinmod/q3_snapshot.yaml @@ -0,0 +1,50 @@ +# BerlinMOD-Q3 — snapshot form +# "At each 5-second tick, distinct vehicles within 5 km of P." + +query: | + SELECT start, + end, + vehicle_id, + COUNT(time_utc) AS events_near_p + FROM berlinmod_stream + WHERE edwithin_tgeo_geo(gps_lon, + gps_lat, + time_utc, + 'SRID=4326;POINT(4.3517 50.8503)', + FLOAT64(5000.0)) = INT32(1) + GROUP BY vehicle_id + WINDOW TUMBLING(time_utc, SIZE 5 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$VEHICLE_ID, type: UINT64 } + - { name: BERLINMOD_STREAM$EVENTS_NEAR_P, type: UINT64 } + config: + file_path: "/workspace/Output/output_berlinmod_q3_snapshot.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q3_windowed.yaml b/Queries/berlinmod/q3_windowed.yaml new file mode 100644 index 0000000000..3d54f1aa75 --- /dev/null +++ b/Queries/berlinmod/q3_windowed.yaml @@ -0,0 +1,50 @@ +# BerlinMOD-Q3 — windowed form +# "Per 10-second tumbling window, distinct vehicles within 5 km of P." + +query: | + SELECT start, + end, + vehicle_id, + COUNT(time_utc) AS events_near_p + FROM berlinmod_stream + WHERE edwithin_tgeo_geo(gps_lon, + gps_lat, + time_utc, + 'SRID=4326;POINT(4.3517 50.8503)', + FLOAT64(5000.0)) = INT32(1) + GROUP BY vehicle_id + WINDOW TUMBLING(time_utc, SIZE 10 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$VEHICLE_ID, type: UINT64 } + - { name: BERLINMOD_STREAM$EVENTS_NEAR_P, type: UINT64 } + config: + file_path: "/workspace/Output/output_berlinmod_q3_windowed.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q4_continuous.yaml b/Queries/berlinmod/q4_continuous.yaml new file mode 100644 index 0000000000..03b1e852e9 --- /dev/null +++ b/Queries/berlinmod/q4_continuous.yaml @@ -0,0 +1,49 @@ +# BerlinMOD-Q4 — continuous form +# "Vehicles currently inside region R (Brussels centre rectangle)." +# R encoded as polygon; edwithin with d=0 ≡ "inside the polygon". + +query: | + SELECT start, + end, + vehicle_id + FROM berlinmod_stream + WHERE edwithin_tgeo_geo(gps_lon, + gps_lat, + time_utc, + 'SRID=4326;POLYGON((4.30 50.84, 4.36 50.84, 4.36 50.86, 4.30 50.86, 4.30 50.84))', + FLOAT64(0.0)) = INT32(1) + GROUP BY vehicle_id + WINDOW SLIDING(time_utc, SIZE 1 SEC, ADVANCE BY 1 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$VEHICLE_ID, type: UINT64 } + config: + file_path: "/workspace/Output/output_berlinmod_q4_continuous.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q4_snapshot.yaml b/Queries/berlinmod/q4_snapshot.yaml new file mode 100644 index 0000000000..f9042070b1 --- /dev/null +++ b/Queries/berlinmod/q4_snapshot.yaml @@ -0,0 +1,50 @@ +# BerlinMOD-Q4 — snapshot form +# "At each 5-second tick, distinct vehicles inside region R." + +query: | + SELECT start, + end, + vehicle_id, + COUNT(time_utc) AS events_in_r + FROM berlinmod_stream + WHERE edwithin_tgeo_geo(gps_lon, + gps_lat, + time_utc, + 'SRID=4326;POLYGON((4.30 50.84, 4.36 50.84, 4.36 50.86, 4.30 50.86, 4.30 50.84))', + FLOAT64(0.0)) = INT32(1) + GROUP BY vehicle_id + WINDOW TUMBLING(time_utc, SIZE 5 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$VEHICLE_ID, type: UINT64 } + - { name: BERLINMOD_STREAM$EVENTS_IN_R, type: UINT64 } + config: + file_path: "/workspace/Output/output_berlinmod_q4_snapshot.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q4_windowed.yaml b/Queries/berlinmod/q4_windowed.yaml new file mode 100644 index 0000000000..17162eafbb --- /dev/null +++ b/Queries/berlinmod/q4_windowed.yaml @@ -0,0 +1,51 @@ +# BerlinMOD-Q4 — windowed form +# "Per 10-second tumbling window, distinct vehicles inside region R." +# Intra-window scoping: a vehicle present inside R during the window is reported. + +query: | + SELECT start, + end, + vehicle_id, + COUNT(time_utc) AS events_in_r + FROM berlinmod_stream + WHERE edwithin_tgeo_geo(gps_lon, + gps_lat, + time_utc, + 'SRID=4326;POLYGON((4.30 50.84, 4.36 50.84, 4.36 50.86, 4.30 50.86, 4.30 50.84))', + FLOAT64(0.0)) = INT32(1) + GROUP BY vehicle_id + WINDOW TUMBLING(time_utc, SIZE 10 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$VEHICLE_ID, type: UINT64 } + - { name: BERLINMOD_STREAM$EVENTS_IN_R, type: UINT64 } + config: + file_path: "/workspace/Output/output_berlinmod_q4_windowed.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q5_continuous.yaml b/Queries/berlinmod/q5_continuous.yaml new file mode 100644 index 0000000000..8287754a03 --- /dev/null +++ b/Queries/berlinmod/q5_continuous.yaml @@ -0,0 +1,51 @@ +# BerlinMOD-Q5 — continuous form (FULL) +# "Pairs of vehicles meeting near P." Per-second sliding window over the events +# pre-filtered by upstream edwithin_tgeo_geo to the near-P set; the +# PAIR_MEETING aggregation enumerates pairs of vehicles inside the window and +# emits the BerlinMOD-Q5 answer directly (vid_a, vid_b, ts, "<=dMeet" tag) +# with dMeet = 200 m passed as the explicit fifth aggregation argument. + +query: | + SELECT start, + end, + PAIR_MEETING(gps_lon, gps_lat, time_utc, vehicle_id, 200.0) AS meeting_pairs + FROM berlinmod_stream + WHERE edwithin_tgeo_geo(gps_lon, + gps_lat, + time_utc, + 'SRID=4326;POINT(4.3517 50.8503)', + FLOAT64(2000.0)) = INT32(1) + WINDOW SLIDING(time_utc, SIZE 1 SEC, ADVANCE BY 1 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$MEETING_PAIRS, type: VARSIZED } + config: + file_path: "/workspace/Output/output_berlinmod_q5_continuous.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q5_snapshot.yaml b/Queries/berlinmod/q5_snapshot.yaml new file mode 100644 index 0000000000..7eb2276e43 --- /dev/null +++ b/Queries/berlinmod/q5_snapshot.yaml @@ -0,0 +1,50 @@ +# BerlinMOD-Q5 — snapshot form (FULL) +# "Pairs of vehicles meeting near P." Per-5s tumbling-tick window over the +# events pre-filtered by upstream edwithin_tgeo_geo to the near-P set; +# PAIR_MEETING emits the per-tick meeting pairs as a VARSIZED string. The +# snapshot at time T equals the batch BerlinMOD-Q5 result up to T. + +query: | + SELECT start, + end, + PAIR_MEETING(gps_lon, gps_lat, time_utc, vehicle_id, 200.0) AS meeting_pairs + FROM berlinmod_stream + WHERE edwithin_tgeo_geo(gps_lon, + gps_lat, + time_utc, + 'SRID=4326;POINT(4.3517 50.8503)', + FLOAT64(2000.0)) = INT32(1) + WINDOW TUMBLING(time_utc, SIZE 5 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$MEETING_PAIRS, type: VARSIZED } + config: + file_path: "/workspace/Output/output_berlinmod_q5_snapshot.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q5_windowed.yaml b/Queries/berlinmod/q5_windowed.yaml new file mode 100644 index 0000000000..66fec0814d --- /dev/null +++ b/Queries/berlinmod/q5_windowed.yaml @@ -0,0 +1,50 @@ +# BerlinMOD-Q5 — windowed form (FULL) +# "Pairs of vehicles meeting near P." Per-10s tumbling window over the events +# pre-filtered by upstream edwithin_tgeo_geo to the near-P set; PAIR_MEETING +# emits the per-window meeting pairs (vid_a, vid_b, ts, "<=dMeet" tag) with +# dMeet = 200 m passed as the explicit fifth aggregation argument. + +query: | + SELECT start, + end, + PAIR_MEETING(gps_lon, gps_lat, time_utc, vehicle_id, 200.0) AS meeting_pairs + FROM berlinmod_stream + WHERE edwithin_tgeo_geo(gps_lon, + gps_lat, + time_utc, + 'SRID=4326;POINT(4.3517 50.8503)', + FLOAT64(2000.0)) = INT32(1) + WINDOW TUMBLING(time_utc, SIZE 10 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$MEETING_PAIRS, type: VARSIZED } + config: + file_path: "/workspace/Output/output_berlinmod_q5_windowed.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q6_continuous.yaml b/Queries/berlinmod/q6_continuous.yaml new file mode 100644 index 0000000000..7b13911408 --- /dev/null +++ b/Queries/berlinmod/q6_continuous.yaml @@ -0,0 +1,48 @@ +# BerlinMOD-Q6 — continuous form (FULL) +# "Cumulative distance travelled per vehicle." Per-second sliding window +# aggregates each vehicle's GPS samples and emits the spheroidal length in +# metres of the per-(window, vehicle) trajectory directly via the +# TEMPORAL_LENGTH aggregation. + +query: | + SELECT start, + end, + vehicle_id, + TEMPORAL_LENGTH(gps_lon, gps_lat, time_utc) AS cumulative_distance + FROM berlinmod_stream + GROUP BY vehicle_id + WINDOW SLIDING(time_utc, SIZE 1 SEC, ADVANCE BY 1 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$VEHICLE_ID, type: UINT64 } + - { name: BERLINMOD_STREAM$CUMULATIVE_DISTANCE, type: FLOAT64 } + config: + file_path: "/workspace/Output/output_berlinmod_q6_continuous.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q6_snapshot.yaml b/Queries/berlinmod/q6_snapshot.yaml new file mode 100644 index 0000000000..b8e20b3ffe --- /dev/null +++ b/Queries/berlinmod/q6_snapshot.yaml @@ -0,0 +1,49 @@ +# BerlinMOD-Q6 — snapshot form (FULL) +# "Cumulative distance travelled per vehicle." Per-5s tumbling-tick window +# aggregates each vehicle's GPS samples and emits the spheroidal length in +# metres of the per-(tick, vehicle) trajectory directly via the +# TEMPORAL_LENGTH aggregation. The snapshot output at time T equals the +# batch BerlinMOD-Q6 result on data up to T. + +query: | + SELECT start, + end, + vehicle_id, + TEMPORAL_LENGTH(gps_lon, gps_lat, time_utc) AS cumulative_distance + FROM berlinmod_stream + GROUP BY vehicle_id + WINDOW TUMBLING(time_utc, SIZE 5 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$VEHICLE_ID, type: UINT64 } + - { name: BERLINMOD_STREAM$CUMULATIVE_DISTANCE, type: FLOAT64 } + config: + file_path: "/workspace/Output/output_berlinmod_q6_snapshot.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q6_windowed.yaml b/Queries/berlinmod/q6_windowed.yaml new file mode 100644 index 0000000000..749c3ba1bb --- /dev/null +++ b/Queries/berlinmod/q6_windowed.yaml @@ -0,0 +1,48 @@ +# BerlinMOD-Q6 — windowed form (FULL) +# "Cumulative distance travelled per vehicle." Per-10s tumbling window +# aggregates each vehicle's GPS samples and emits the spheroidal length in +# metres of the per-(window, vehicle) trajectory directly via the +# TEMPORAL_LENGTH aggregation. + +query: | + SELECT start, + end, + vehicle_id, + TEMPORAL_LENGTH(gps_lon, gps_lat, time_utc) AS cumulative_distance + FROM berlinmod_stream + GROUP BY vehicle_id + WINDOW TUMBLING(time_utc, SIZE 10 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$VEHICLE_ID, type: UINT64 } + - { name: BERLINMOD_STREAM$CUMULATIVE_DISTANCE, type: FLOAT64 } + config: + file_path: "/workspace/Output/output_berlinmod_q6_windowed.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q7_poi1_continuous.yaml b/Queries/berlinmod/q7_poi1_continuous.yaml new file mode 100644 index 0000000000..36a7f2418d --- /dev/null +++ b/Queries/berlinmod/q7_poi1_continuous.yaml @@ -0,0 +1,53 @@ +# BerlinMOD-Q7 — continuous form, POI 1 (4.3517, 50.8503, r=2000.0m) +# "Per (window or tick), the first event in the window where each vehicle is +# within the POI's radius — i.e. the per-window first passage through POI 1." +# One YAML per (POI, form). Consumer reads the 3-POI fan-out to recover the +# full per-(vehicle, POI) first-passage matrix. + +query: | + SELECT start, + end, + vehicle_id, + MIN(time_utc) AS first_passage_time + FROM berlinmod_stream + WHERE edwithin_tgeo_geo(gps_lon, + gps_lat, + time_utc, + 'SRID=4326;POINT(4.3517 50.8503)', + FLOAT64(2000.0)) = INT32(1) + GROUP BY vehicle_id + WINDOW SLIDING(time_utc, SIZE 1 SEC, ADVANCE BY 1 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$VEHICLE_ID, type: UINT64 } + - { name: BERLINMOD_STREAM$FIRST_PASSAGE_TIME, type: UINT64 } + config: + file_path: "/workspace/Output/output_berlinmod_q7_poi1_continuous.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q7_poi1_snapshot.yaml b/Queries/berlinmod/q7_poi1_snapshot.yaml new file mode 100644 index 0000000000..2e0f7acb9f --- /dev/null +++ b/Queries/berlinmod/q7_poi1_snapshot.yaml @@ -0,0 +1,53 @@ +# BerlinMOD-Q7 — snapshot form, POI 1 (4.3517, 50.8503, r=2000.0m) +# "Per (window or tick), the first event in the window where each vehicle is +# within the POI's radius — i.e. the per-window first passage through POI 1." +# One YAML per (POI, form). Consumer reads the 3-POI fan-out to recover the +# full per-(vehicle, POI) first-passage matrix. + +query: | + SELECT start, + end, + vehicle_id, + MIN(time_utc) AS first_passage_time + FROM berlinmod_stream + WHERE edwithin_tgeo_geo(gps_lon, + gps_lat, + time_utc, + 'SRID=4326;POINT(4.3517 50.8503)', + FLOAT64(2000.0)) = INT32(1) + GROUP BY vehicle_id + WINDOW TUMBLING(time_utc, SIZE 5 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$VEHICLE_ID, type: UINT64 } + - { name: BERLINMOD_STREAM$FIRST_PASSAGE_TIME, type: UINT64 } + config: + file_path: "/workspace/Output/output_berlinmod_q7_poi1_snapshot.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q7_poi1_windowed.yaml b/Queries/berlinmod/q7_poi1_windowed.yaml new file mode 100644 index 0000000000..b81dec6c1e --- /dev/null +++ b/Queries/berlinmod/q7_poi1_windowed.yaml @@ -0,0 +1,53 @@ +# BerlinMOD-Q7 — windowed form, POI 1 (4.3517, 50.8503, r=2000.0m) +# "Per (window or tick), the first event in the window where each vehicle is +# within the POI's radius — i.e. the per-window first passage through POI 1." +# One YAML per (POI, form). Consumer reads the 3-POI fan-out to recover the +# full per-(vehicle, POI) first-passage matrix. + +query: | + SELECT start, + end, + vehicle_id, + MIN(time_utc) AS first_passage_time + FROM berlinmod_stream + WHERE edwithin_tgeo_geo(gps_lon, + gps_lat, + time_utc, + 'SRID=4326;POINT(4.3517 50.8503)', + FLOAT64(2000.0)) = INT32(1) + GROUP BY vehicle_id + WINDOW TUMBLING(time_utc, SIZE 10 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$VEHICLE_ID, type: UINT64 } + - { name: BERLINMOD_STREAM$FIRST_PASSAGE_TIME, type: UINT64 } + config: + file_path: "/workspace/Output/output_berlinmod_q7_poi1_windowed.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q7_poi2_continuous.yaml b/Queries/berlinmod/q7_poi2_continuous.yaml new file mode 100644 index 0000000000..043c82680c --- /dev/null +++ b/Queries/berlinmod/q7_poi2_continuous.yaml @@ -0,0 +1,53 @@ +# BerlinMOD-Q7 — continuous form, POI 2 (4.3060, 50.8270, r=1000.0m) +# "Per (window or tick), the first event in the window where each vehicle is +# within the POI's radius — i.e. the per-window first passage through POI 2." +# One YAML per (POI, form). Consumer reads the 3-POI fan-out to recover the +# full per-(vehicle, POI) first-passage matrix. + +query: | + SELECT start, + end, + vehicle_id, + MIN(time_utc) AS first_passage_time + FROM berlinmod_stream + WHERE edwithin_tgeo_geo(gps_lon, + gps_lat, + time_utc, + 'SRID=4326;POINT(4.3060 50.8270)', + FLOAT64(1000.0)) = INT32(1) + GROUP BY vehicle_id + WINDOW SLIDING(time_utc, SIZE 1 SEC, ADVANCE BY 1 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$VEHICLE_ID, type: UINT64 } + - { name: BERLINMOD_STREAM$FIRST_PASSAGE_TIME, type: UINT64 } + config: + file_path: "/workspace/Output/output_berlinmod_q7_poi2_continuous.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q7_poi2_snapshot.yaml b/Queries/berlinmod/q7_poi2_snapshot.yaml new file mode 100644 index 0000000000..82ad22bcd3 --- /dev/null +++ b/Queries/berlinmod/q7_poi2_snapshot.yaml @@ -0,0 +1,53 @@ +# BerlinMOD-Q7 — snapshot form, POI 2 (4.3060, 50.8270, r=1000.0m) +# "Per (window or tick), the first event in the window where each vehicle is +# within the POI's radius — i.e. the per-window first passage through POI 2." +# One YAML per (POI, form). Consumer reads the 3-POI fan-out to recover the +# full per-(vehicle, POI) first-passage matrix. + +query: | + SELECT start, + end, + vehicle_id, + MIN(time_utc) AS first_passage_time + FROM berlinmod_stream + WHERE edwithin_tgeo_geo(gps_lon, + gps_lat, + time_utc, + 'SRID=4326;POINT(4.3060 50.8270)', + FLOAT64(1000.0)) = INT32(1) + GROUP BY vehicle_id + WINDOW TUMBLING(time_utc, SIZE 5 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$VEHICLE_ID, type: UINT64 } + - { name: BERLINMOD_STREAM$FIRST_PASSAGE_TIME, type: UINT64 } + config: + file_path: "/workspace/Output/output_berlinmod_q7_poi2_snapshot.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q7_poi2_windowed.yaml b/Queries/berlinmod/q7_poi2_windowed.yaml new file mode 100644 index 0000000000..6925ba5480 --- /dev/null +++ b/Queries/berlinmod/q7_poi2_windowed.yaml @@ -0,0 +1,53 @@ +# BerlinMOD-Q7 — windowed form, POI 2 (4.3060, 50.8270, r=1000.0m) +# "Per (window or tick), the first event in the window where each vehicle is +# within the POI's radius — i.e. the per-window first passage through POI 2." +# One YAML per (POI, form). Consumer reads the 3-POI fan-out to recover the +# full per-(vehicle, POI) first-passage matrix. + +query: | + SELECT start, + end, + vehicle_id, + MIN(time_utc) AS first_passage_time + FROM berlinmod_stream + WHERE edwithin_tgeo_geo(gps_lon, + gps_lat, + time_utc, + 'SRID=4326;POINT(4.3060 50.8270)', + FLOAT64(1000.0)) = INT32(1) + GROUP BY vehicle_id + WINDOW TUMBLING(time_utc, SIZE 10 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$VEHICLE_ID, type: UINT64 } + - { name: BERLINMOD_STREAM$FIRST_PASSAGE_TIME, type: UINT64 } + config: + file_path: "/workspace/Output/output_berlinmod_q7_poi2_windowed.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q7_poi3_continuous.yaml b/Queries/berlinmod/q7_poi3_continuous.yaml new file mode 100644 index 0000000000..414d8133d8 --- /dev/null +++ b/Queries/berlinmod/q7_poi3_continuous.yaml @@ -0,0 +1,53 @@ +# BerlinMOD-Q7 — continuous form, POI 3 (4.2100, 50.7600, r=2000.0m) +# "Per (window or tick), the first event in the window where each vehicle is +# within the POI's radius — i.e. the per-window first passage through POI 3." +# One YAML per (POI, form). Consumer reads the 3-POI fan-out to recover the +# full per-(vehicle, POI) first-passage matrix. + +query: | + SELECT start, + end, + vehicle_id, + MIN(time_utc) AS first_passage_time + FROM berlinmod_stream + WHERE edwithin_tgeo_geo(gps_lon, + gps_lat, + time_utc, + 'SRID=4326;POINT(4.2100 50.7600)', + FLOAT64(2000.0)) = INT32(1) + GROUP BY vehicle_id + WINDOW SLIDING(time_utc, SIZE 1 SEC, ADVANCE BY 1 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$VEHICLE_ID, type: UINT64 } + - { name: BERLINMOD_STREAM$FIRST_PASSAGE_TIME, type: UINT64 } + config: + file_path: "/workspace/Output/output_berlinmod_q7_poi3_continuous.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q7_poi3_snapshot.yaml b/Queries/berlinmod/q7_poi3_snapshot.yaml new file mode 100644 index 0000000000..141a9b853b --- /dev/null +++ b/Queries/berlinmod/q7_poi3_snapshot.yaml @@ -0,0 +1,53 @@ +# BerlinMOD-Q7 — snapshot form, POI 3 (4.2100, 50.7600, r=2000.0m) +# "Per (window or tick), the first event in the window where each vehicle is +# within the POI's radius — i.e. the per-window first passage through POI 3." +# One YAML per (POI, form). Consumer reads the 3-POI fan-out to recover the +# full per-(vehicle, POI) first-passage matrix. + +query: | + SELECT start, + end, + vehicle_id, + MIN(time_utc) AS first_passage_time + FROM berlinmod_stream + WHERE edwithin_tgeo_geo(gps_lon, + gps_lat, + time_utc, + 'SRID=4326;POINT(4.2100 50.7600)', + FLOAT64(2000.0)) = INT32(1) + GROUP BY vehicle_id + WINDOW TUMBLING(time_utc, SIZE 5 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$VEHICLE_ID, type: UINT64 } + - { name: BERLINMOD_STREAM$FIRST_PASSAGE_TIME, type: UINT64 } + config: + file_path: "/workspace/Output/output_berlinmod_q7_poi3_snapshot.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q7_poi3_windowed.yaml b/Queries/berlinmod/q7_poi3_windowed.yaml new file mode 100644 index 0000000000..a8ecb36c3f --- /dev/null +++ b/Queries/berlinmod/q7_poi3_windowed.yaml @@ -0,0 +1,53 @@ +# BerlinMOD-Q7 — windowed form, POI 3 (4.2100, 50.7600, r=2000.0m) +# "Per (window or tick), the first event in the window where each vehicle is +# within the POI's radius — i.e. the per-window first passage through POI 3." +# One YAML per (POI, form). Consumer reads the 3-POI fan-out to recover the +# full per-(vehicle, POI) first-passage matrix. + +query: | + SELECT start, + end, + vehicle_id, + MIN(time_utc) AS first_passage_time + FROM berlinmod_stream + WHERE edwithin_tgeo_geo(gps_lon, + gps_lat, + time_utc, + 'SRID=4326;POINT(4.2100 50.7600)', + FLOAT64(2000.0)) = INT32(1) + GROUP BY vehicle_id + WINDOW TUMBLING(time_utc, SIZE 10 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$VEHICLE_ID, type: UINT64 } + - { name: BERLINMOD_STREAM$FIRST_PASSAGE_TIME, type: UINT64 } + config: + file_path: "/workspace/Output/output_berlinmod_q7_poi3_windowed.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q8_continuous.yaml b/Queries/berlinmod/q8_continuous.yaml new file mode 100644 index 0000000000..6821fa9639 --- /dev/null +++ b/Queries/berlinmod/q8_continuous.yaml @@ -0,0 +1,53 @@ +# BerlinMOD-Q8 — continuous form (FULL) +# "Vehicles within d of road segment (LINESTRING)." Uses edwithin_tgeo_geo with +# a LINESTRING geometry — MEOS supports the within-radius predicate against any +# geometry (POINT, POLYGON, LINESTRING), so no new MobilityNebula PhysicalFunction +# is required. The segment runs from (4.30, 50.83) to (4.36, 50.87) with d = 5 km. + +query: | + SELECT start, + end, + vehicle_id, + COUNT(time_utc) AS events_near_segment + FROM berlinmod_stream + WHERE edwithin_tgeo_geo(gps_lon, + gps_lat, + time_utc, + 'SRID=4326;LINESTRING(4.30 50.83, 4.36 50.87)', + FLOAT64(5000.0)) = INT32(1) + GROUP BY vehicle_id + WINDOW SLIDING(time_utc, SIZE 1 SEC, ADVANCE BY 1 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$VEHICLE_ID, type: UINT64 } + - { name: BERLINMOD_STREAM$EVENTS_NEAR_SEGMENT, type: UINT64 } + config: + file_path: "/workspace/Output/output_berlinmod_q8_continuous.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q8_snapshot.yaml b/Queries/berlinmod/q8_snapshot.yaml new file mode 100644 index 0000000000..41241b53eb --- /dev/null +++ b/Queries/berlinmod/q8_snapshot.yaml @@ -0,0 +1,53 @@ +# BerlinMOD-Q8 — snapshot form (FULL) +# "Vehicles within d of road segment (LINESTRING)." Uses edwithin_tgeo_geo with +# a LINESTRING geometry — MEOS supports the within-radius predicate against any +# geometry (POINT, POLYGON, LINESTRING), so no new MobilityNebula PhysicalFunction +# is required. The segment runs from (4.30, 50.83) to (4.36, 50.87) with d = 5 km. + +query: | + SELECT start, + end, + vehicle_id, + COUNT(time_utc) AS events_near_segment + FROM berlinmod_stream + WHERE edwithin_tgeo_geo(gps_lon, + gps_lat, + time_utc, + 'SRID=4326;LINESTRING(4.30 50.83, 4.36 50.87)', + FLOAT64(5000.0)) = INT32(1) + GROUP BY vehicle_id + WINDOW TUMBLING(time_utc, SIZE 5 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$VEHICLE_ID, type: UINT64 } + - { name: BERLINMOD_STREAM$EVENTS_NEAR_SEGMENT, type: UINT64 } + config: + file_path: "/workspace/Output/output_berlinmod_q8_snapshot.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q8_windowed.yaml b/Queries/berlinmod/q8_windowed.yaml new file mode 100644 index 0000000000..f448eb5ae2 --- /dev/null +++ b/Queries/berlinmod/q8_windowed.yaml @@ -0,0 +1,53 @@ +# BerlinMOD-Q8 — windowed form (FULL) +# "Vehicles within d of road segment (LINESTRING)." Uses edwithin_tgeo_geo with +# a LINESTRING geometry — MEOS supports the within-radius predicate against any +# geometry (POINT, POLYGON, LINESTRING), so no new MobilityNebula PhysicalFunction +# is required. The segment runs from (4.30, 50.83) to (4.36, 50.87) with d = 5 km. + +query: | + SELECT start, + end, + vehicle_id, + COUNT(time_utc) AS events_near_segment + FROM berlinmod_stream + WHERE edwithin_tgeo_geo(gps_lon, + gps_lat, + time_utc, + 'SRID=4326;LINESTRING(4.30 50.83, 4.36 50.87)', + FLOAT64(5000.0)) = INT32(1) + GROUP BY vehicle_id + WINDOW TUMBLING(time_utc, SIZE 10 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$VEHICLE_ID, type: UINT64 } + - { name: BERLINMOD_STREAM$EVENTS_NEAR_SEGMENT, type: UINT64 } + config: + file_path: "/workspace/Output/output_berlinmod_q8_windowed.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q9_continuous.yaml b/Queries/berlinmod/q9_continuous.yaml new file mode 100644 index 0000000000..fc78c4728e --- /dev/null +++ b/Queries/berlinmod/q9_continuous.yaml @@ -0,0 +1,46 @@ +# BerlinMOD-Q9 — continuous form (FULL) +# "Distance between vehicles X (= 100) and Y (= 200) at time T." Per-second +# sliding window. CROSS_DISTANCE picks the latest known position of each +# target vehicle (vidA = 100, vidB = 200 passed as the explicit fifth and sixth aggregation arguments) inside +# the window and returns the spheroidal distance between them in metres. +# Returns NaN if either vehicle has no observation in the window. + +query: | + SELECT start, + end, + CROSS_DISTANCE(gps_lon, gps_lat, time_utc, vehicle_id, 100, 200) AS distance_metres + FROM berlinmod_stream + WINDOW SLIDING(time_utc, SIZE 1 SEC, ADVANCE BY 1 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$DISTANCE_METRES, type: FLOAT64 } + config: + file_path: "/workspace/Output/output_berlinmod_q9_continuous.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q9_snapshot.yaml b/Queries/berlinmod/q9_snapshot.yaml new file mode 100644 index 0000000000..54a4294f23 --- /dev/null +++ b/Queries/berlinmod/q9_snapshot.yaml @@ -0,0 +1,46 @@ +# BerlinMOD-Q9 — snapshot form (FULL) +# "Distance between vehicles X (= 100) and Y (= 200) at time T." Per-5s +# tumbling-tick window. CROSS_DISTANCE returns the spheroidal distance +# between the two vehicles' latest known positions at the tick, or NaN if +# either is unobserved. (vidA, vidB) = (100, 200) passed as the explicit fifth and sixth aggregation arguments. The snapshot at time T equals the batch BerlinMOD-Q9 result up +# to T. + +query: | + SELECT start, + end, + CROSS_DISTANCE(gps_lon, gps_lat, time_utc, vehicle_id, 100, 200) AS distance_metres + FROM berlinmod_stream + WINDOW TUMBLING(time_utc, SIZE 5 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$DISTANCE_METRES, type: FLOAT64 } + config: + file_path: "/workspace/Output/output_berlinmod_q9_snapshot.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/Queries/berlinmod/q9_windowed.yaml b/Queries/berlinmod/q9_windowed.yaml new file mode 100644 index 0000000000..820127a407 --- /dev/null +++ b/Queries/berlinmod/q9_windowed.yaml @@ -0,0 +1,45 @@ +# BerlinMOD-Q9 — windowed form (FULL) +# "Distance between vehicles X (= 100) and Y (= 200) at time T." Per-10s +# tumbling window. CROSS_DISTANCE returns the spheroidal distance between +# the two vehicles' latest known positions in the window, or NaN if either +# is unobserved. (vidA, vidB) = (100, 200) passed as the explicit fifth and sixth aggregation arguments. + +query: | + SELECT start, + end, + CROSS_DISTANCE(gps_lon, gps_lat, time_utc, vehicle_id, 100, 200) AS distance_metres + FROM berlinmod_stream + WINDOW TUMBLING(time_utc, SIZE 10 SEC) + INTO file_sink; + +sinks: + - name: FILE_SINK + type: File + schema: + - { name: BERLINMOD_STREAM$START, type: UINT64 } + - { name: BERLINMOD_STREAM$END, type: UINT64 } + - { name: BERLINMOD_STREAM$DISTANCE_METRES, type: FLOAT64 } + config: + file_path: "/workspace/Output/output_berlinmod_q9_windowed.csv" + input_format: CSV + +logical: + - name: BERLINMOD_STREAM + schema: + - { name: TIME_UTC, type: UINT64 } + - { name: VEHICLE_ID, type: UINT64 } + - { name: GPS_LON, type: FLOAT64 } + - { name: GPS_LAT, type: FLOAT64 } + +physical: + - logical: BERLINMOD_STREAM + type: TCP + parser_config: + type: CSV + field_delimiter: "," + tuple_delimiter: "\n" + source_config: + socket_host: "host.docker.internal" + socket_port: "32325" + socket_type: "SOCK_STREAM" + socket_domain: "AF_INET" diff --git a/docs/berlinmod-streaming-forms.md b/docs/berlinmod-streaming-forms.md new file mode 100644 index 0000000000..4ba6276903 --- /dev/null +++ b/docs/berlinmod-streaming-forms.md @@ -0,0 +1,114 @@ +# BerlinMOD streaming forms on MobilityNebula + +Additive scaffold for the **BerlinMOD-9 × 3 streaming forms** parity contract — same shape as the SQL-layer BerlinMOD-9 ([MobilityDB-BerlinMOD](https://github.com/MobilityDB/MobilityDB-BerlinMOD)) and matching the [MobilityFlink PR #3](https://github.com/MobilityDB/MobilityFlink/pull/3) and [MobilityKafka PR #1](https://github.com/MobilityDB/MobilityKafka/pull/1) coverage on the NebulaStream runtime. + +This page lives **alongside** the existing SNCB query series ([Query0..Query5](../Queries/) + [sncb_brake_monitoring](../Queries/sncb_brake_monitoring.yaml)); the SNCB Q-series and BerlinMOD-9 are sibling parity sets, not a replacement. + +## Logical source + +The BerlinMOD queries read from a `berlinmod_stream` logical source over TCP port `32325`, distinct from the SNCB `sncb_stream` source on port `32324`. Wire format is CSV with four columns: + +``` +time_utc(uint64), vehicle_id(uint64), gps_lon(float64), gps_lat(float64) +``` + +A sample input file is at [`Input/input_berlinmod.csv`](../Input/input_berlinmod.csv) (3 vehicles × 21 events over 14 simulated seconds). + +## The three streaming forms + +For each BerlinMOD reference query Q, three NebulaStream YAMLs realize the form contract: + +| Form | NebulaStream pattern | Semantic | +|---|---|---| +| **continuous** | `WINDOW SLIDING(time_utc, SIZE 1 SEC, ADVANCE BY 1 SEC)` | per-event-bucket emission; consumers see a continuous stream of per-second events | +| **windowed** | `WINDOW TUMBLING(time_utc, SIZE 10 SEC)` | per-10s aggregation; one row per (window, group) | +| **snapshot** | `WINDOW TUMBLING(time_utc, SIZE 5 SEC)` | per-5s tick state; one row per (tick, group). Parity-oracle form: at each tick, the current state mirrors the batch BerlinMOD-Q result on data up to the tick | + +## Coverage in this PR + +| Q | Topic | Continuous | Windowed | Snapshot | Form | +|---|---|---|---|---|---| +| Q1 | "which vehicles have appeared?" | ✓ | ✓ | ✓ | full | +| Q2 | "where is vehicle X (= 200) at time T?" | ✓ | ✓ | ✓ | full | +| Q3 | "vehicles within 5 km of Brussels city centre?" | ✓ | ✓ | ✓ | full | +| Q4 | "vehicles inside Brussels-centre rectangle R?" | ✓ | ✓ | ✓ | full | +| Q5 | "pairs of vehicles meeting near P" | ✓ | ✓ | ✓ | full (via PAIR_MEETING aggregation) | +| Q6 | "cumulative distance per vehicle" | ✓ | ✓ | ✓ | full (via TEMPORAL_LENGTH aggregation) | +| Q7 | "first passage of each vehicle through each POI" | ✓ | ✓ | ✓ | full (per-POI fan-out) | +| Q8 | "vehicles close to a road segment (LINESTRING)" | ✓ | ✓ | ✓ | full | +| Q9 | "distance between vehicles X and Y at time T" | ✓ | ✓ | ✓ | full (via CROSS_DISTANCE aggregation) | + +**27 of 27 cells** covered as scaffold YAMLs. **All 27 cells are full** — every BerlinMOD-Q semantic is computed entirely inside NebulaStream. The matrix is closed. + +### Q7 fan-out pattern (full) + +NebulaStream's current SQL has no Cartesian (vehicle × POI) aggregation primitive. Q7 is therefore expressed as **one YAML per (POI, form)** — three POIs × three forms = nine YAML files. Each YAML emits the per-(window, vehicle) first-passage time for its single POI; consumers read the three POI-specific output files per form to recover the full per-(vehicle, POI) matrix. POI ids: `1` = Brussels city centre (4.3517, 50.8503, r=2 km), `2` = Anderlecht (4.3060, 50.8270, r=1 km), `3` = south of Brussels (4.2100, 50.7600, r=2 km). + +### Q8 via LINESTRING (full) + +MEOS' `edwithin_tgeo_geo` accepts any geometry — POINT, POLYGON, and **LINESTRING**. Q8 (vehicles within d of a road segment) is therefore expressible as a single direct predicate against a `LINESTRING(s1, s2)` geometry, no new MobilityNebula PhysicalFunction required. The segment runs from (4.30, 50.83) to (4.36, 50.87) with d = 5 km in the scaffold. + +### Q6 full via TEMPORAL_LENGTH aggregation + +The Q6 × 3 cells are full as of this scaffold: they use the new `TEMPORAL_LENGTH(lon, lat, ts)` aggregation, which lifts the same (lon, lat, ts) tuples as `TEMPORAL_SEQUENCE` and lowers them through a MEOS `tpoint_length(Temporal*)` call to a single `FLOAT64` result — the spheroidal length in metres of the per-(window, group) trajectory. Logical, physical, parser, and lowering wiring all live in this PR. + +### Q5 full via PAIR_MEETING aggregation + +Q5 takes four input fields (lon, lat, timestamp, vehicle_id) and emits a VARSIZED string-encoded list of meeting pairs `"vid_a,vid_b,ts,<=dMeet; …"`. Upstream `edwithin_tgeo_geo` pre-filters events to the near-P set; the aggregation's `lift` step writes per-event (lon, lat, ts, vehicle_id) into a PagedVector, and the `lower` step builds a per-vehicle latest-position map, enumerates pairs in stable order, calls MEOS' `geog_dwithin` with `dMeet = 200 m` hardcoded for the scaffold, and emits pairs that meet. Future PR can parameterize `dMeet` via a constant input. + +### Q9 full via CROSS_DISTANCE aggregation + +Q9 takes the same four input fields and emits a FLOAT64 — the spheroidal distance between the two target vehicles (VID_A = 100, VID_B = 200 hardcoded) at their latest known positions in the window. NaN when either is unobserved. Implemented via the MEOS `nad_tgeo_tgeo` path over single-instant tgeompoints. Future PR can parameterize (VID_A, VID_B). + +## MEOS operators consumed + +All BerlinMOD predicates use operators already exposed by [`MobilityNebula/PR #14`](https://github.com/MobilityDB/MobilityNebula/pull/14) (and follow-up operator-add PRs): + +| Operator | YAMLs using it | +|---|---| +| `edwithin_tgeo_geo(lon, lat, t, geom, d)` | Q3 × 3 forms (radius predicate, `POINT`), Q4 × 3 forms (region containment, `POLYGON` with `d=0.0`), Q5 × 3 forms (upstream near-P filter), Q8 × 3 forms (segment predicate, `LINESTRING`) | +| `TEMPORAL_SEQUENCE(lon, lat, t)` (aggregation) | Q2 × 3 forms (per-window trajectory) | +| `TEMPORAL_LENGTH(lon, lat, t)` (aggregation, MEOS `tpoint_length` under the hood) | Q6 × 3 forms (cumulative distance) | +| `PAIR_MEETING(lon, lat, t, vehicle_id)` (aggregation, MEOS `geog_dwithin` per pair under the hood) | Q5 × 3 forms (meeting pairs) | +| `CROSS_DISTANCE(lon, lat, t, vehicle_id)` (aggregation, MEOS `nad_tgeo_tgeo` under the hood) | Q9 × 3 forms (cross-vehicle distance) | + +`PAIR_MEETING` and `CROSS_DISTANCE` are added by this PR (and `TEMPORAL_LENGTH` is added by the parent #16); the rest are pre-existing. + +## Streaming-semantics tier overlay + +Each BerlinMOD-Q in this scaffold falls into one of the four streaming-execution tiers used by the per-binding wirings work across the ecosystem. The vocabulary is the closed 7-value set proposed for the MEOS-API catalog as `objectModel.streamingSemantics` (see the MEOS-API #10 sibling-facet RFC). + +The mapping makes the cross-binding picture explicit — a Q's tier on NebulaStream is the same tier it would land in on Flink / Kafka. The right-most column points to the equivalent generic wiring on Flink (where adopters consume the v4 baseline through generic DataStream wrappers). + +| Tier | BerlinMOD-Q | NebulaStream realization | Equivalent Flink wiring | +|---|---|---|---| +| `stateless` | Q1 (distinct-vehicle observation) | Simple SQL aggregation; no MEOS handle | `MeosStatelessMap` / `MeosStatelessFilter` | +| `bounded-state` | Q2, Q3, Q4, Q7 (per-vehicle / per-POI predicate state), Q8 | Aggregations that hold per-key latest position (TEMPORAL_SEQUENCE pattern); single MEOS-temporal evaluation | `MeosBoundedStateMap` (per-key `ValueState`) | +| `windowed` | Q6 (per-window trajectory length) | Custom MEOS aggregation closing the window once and emitting a scalar (`TEMPORAL_LENGTH`) | `MeosWindowedAggregate` (window-close-only) | +| `cross-stream` | Q5 (pair meeting), Q9 (cross-vehicle distance) | Four-field aggregations holding per-(vehicle-pair) state inside one operator (`PAIR_MEETING`, `CROSS_DISTANCE`) — same row-set sees all vehicles, so the "stream-self-join" is a single-aggregation enumeration rather than two streams | `MeosCrossStreamJoin` (`KeyedStream.intervalJoin`) | +| `io-meta` / `sequence-only` | — | not exercised by the BerlinMOD-9 set | n/a | + +### Why the cross-stream tier looks different on NebulaStream + +On Flink, the cross-stream tier maps to `KeyedStream.intervalJoin(other)` — two distinct keyed streams paired within a time bound. On NebulaStream, the same semantic is realized inside a single windowed aggregation that holds per-(vehicle-pair) state and enumerates pairs at window close. The two are equivalent: both materialize the Cartesian-product evaluation, just at different points in the operator topology. The tier classification is on the **MEOS semantic**, not on the engine pattern — and Q5 / Q9 are unambiguously `cross-stream` regardless of which engine realizes them. + +### Why Q7 is bounded-state, not windowed + +Q7 ("first passage of each vehicle through each POI") would naturally read as windowed (per-window minimum). It's classified bounded-state here because the NebulaStream scaffold expresses it as a per-POI fan-out (one YAML per POI), each YAML computing the per-vehicle latest-known position predicate and selecting the per-(vehicle, POI) earliest qualifying timestamp inside the window. The state per (vehicle, POI) is bounded; no per-window reduction across the full sequence is needed. + +## Sibling parity references + +- **MobilityFlink** — same nine queries × three forms on Flink. Original scaffold landed; the per-tier wiring infrastructure that mechanically wraps any of the 2,097 generated MEOS facade methods into Flink DataStream operators lives in the [`org.mobilitydb.flink.meos.wirings`](https://github.com/MobilityDB/MobilityFlink/blob/main/flink-processor/src/main/java/org/mobilitydb/flink/meos/wirings) package (5 generic classes covering 100% of the streamable + io-meta surface; a capstone demo composes all four tiers into one pipeline). +- **MobilityKafka** — same nine queries × three forms on Kafka Streams, with a codegen mirror of the MEOS facade in [`org.mobilitydb.kafka.meos`](https://github.com/MobilityDB/MobilityKafka/blob/main/kafka-streams-app/src/main/java/org/mobilitydb/kafka/meos). +- **MobilityDB-BerlinMOD** — batch BerlinMOD-9 cross-platform reports; the snapshot form on the streaming side converges to those outputs as the watermark advances. + +## Running + +Each YAML follows the same pattern as the SNCB queries (TCP CSV source, file sink). The expected execution flow: + +1. Start NebulaStream (or `MobilityNebula` docker-runtime). +2. Stream the sample CSV from `Input/input_berlinmod.csv` over TCP port `32325` (e.g. via `nc -l -p 32325 < Input/input_berlinmod.csv` or the project's existing TCP-source tooling). +3. Submit one of the YAMLs to the NebulaStream coordinator. +4. The output appears in `/workspace/Output/output_berlinmod__
.csv`. + +YAML structure has been validated with `python3 -c "import yaml; yaml.safe_load(open(f))"` for every file. Runtime verification is gated on the NebulaStream test harness; the YAMLs are intentionally additive and the SNCB Q-series remains untouched. diff --git a/grpc/SerializableVariantDescriptor.proto b/grpc/SerializableVariantDescriptor.proto index 97b9ff1894..af7f32c8b6 100644 --- a/grpc/SerializableVariantDescriptor.proto +++ b/grpc/SerializableVariantDescriptor.proto @@ -66,6 +66,7 @@ message SerializableAggregationFunction { string type = 1; SerializableFunction on_field = 2; SerializableFunction as_field = 3; + repeated SerializableFunction extra_fields = 4; } message AggregationFunctionList { diff --git a/nes-logical-operators/include/Functions/Meos/TemporalAContainsGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalAContainsGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..befa25d025 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalAContainsGeometryLogicalFunction.hpp @@ -0,0 +1,55 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-contains between a single-instant tgeompoint and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `acontains_tgeo_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalAContainsGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalAContainsGeometry"; + + TemporalAContainsGeometryLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalAContainsTCbufferCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalAContainsTCbufferCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..4d5df38d20 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalAContainsTCbufferCbufferLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event a-contains between a single-instant tcbuffer and a static Cbuffer literal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `acontains_tcbuffer_cbuffer`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalAContainsTCbufferCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalAContainsTCbufferCbuffer"; + + TemporalAContainsTCbufferCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction cbufferLit); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalAContainsTCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalAContainsTCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..08658e6eeb --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalAContainsTCbufferLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-contains between a single-instant tcbuffer and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `acontains_tcbuffer_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalAContainsTCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalAContainsTCbuffer"; + + TemporalAContainsTCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalAContainsTGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalAContainsTGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..11e0269fa6 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalAContainsTGeometryLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-contains between two single-instant tgeompoints. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `acontains_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalAContainsTGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalAContainsTGeometry"; + + TemporalAContainsTGeometryLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalAContainsTNpointGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalAContainsTNpointGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..6526ba51a5 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalAContainsTNpointGeometryLogicalFunction.hpp @@ -0,0 +1,55 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-contains between a single-instant tgeompoint resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint and a static geometry (network SRID). + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `acontains_tgeo_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalAContainsTNpointGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalAContainsTNpointGeometry"; + + TemporalAContainsTNpointGeometryLogicalFunction(LogicalFunction rid, + LogicalFunction fraction, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalAContainsTNpointTNpointLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalAContainsTNpointTNpointLogicalFunction.hpp new file mode 100644 index 0000000000..7954d1e7ba --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalAContainsTNpointTNpointLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-contains between two single-instant tgeompoints, each resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `acontains_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalAContainsTNpointTNpointLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalAContainsTNpointTNpoint"; + + TemporalAContainsTNpointTNpointLogicalFunction(LogicalFunction ridA, + LogicalFunction fractionA, + LogicalFunction tsA, + LogicalFunction ridB, + LogicalFunction fractionB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalAContainsTPoseGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalAContainsTPoseGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..5549006050 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalAContainsTPoseGeometryLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-contains between a single-instant tpose (converted to tgeompoint at runtime) and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `acontains_tgeo_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalAContainsTPoseGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalAContainsTPoseGeometry"; + + TemporalAContainsTPoseGeometryLogicalFunction(LogicalFunction x, + LogicalFunction y, + LogicalFunction theta, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalAContainsTPoseTPoseLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalAContainsTPoseTPoseLogicalFunction.hpp new file mode 100644 index 0000000000..0d3be51f5d --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalAContainsTPoseTPoseLogicalFunction.hpp @@ -0,0 +1,59 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-contains between two single-instant tgeompoints, each lifted from a tpose (x,y,theta,ts) via tpose_to_tpoint composition. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `acontains_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalAContainsTPoseTPoseLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalAContainsTPoseTPose"; + + TemporalAContainsTPoseTPoseLogicalFunction(LogicalFunction xA, + LogicalFunction yA, + LogicalFunction thetaA, + LogicalFunction tsA, + LogicalFunction xB, + LogicalFunction yB, + LogicalFunction thetaB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalACoversTCbufferCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalACoversTCbufferCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..b31942cd4c --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalACoversTCbufferCbufferLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event a-covers between a single-instant tcbuffer and a static Cbuffer literal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `acovers_tcbuffer_cbuffer`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalACoversTCbufferCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalACoversTCbufferCbuffer"; + + TemporalACoversTCbufferCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction cbufferLit); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalACoversTCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalACoversTCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..049120245b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalACoversTCbufferLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-covers between a single-instant tcbuffer and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `acovers_tcbuffer_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalACoversTCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalACoversTCbuffer"; + + TemporalACoversTCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalADWithinGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalADWithinGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..3c86fa2235 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalADWithinGeometryLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-distance-within between a single-instant tgeompoint and a static geometry under a static threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `adwithin_tgeo_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalADWithinGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalADWithinGeometry"; + + TemporalADWithinGeometryLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction timestamp, + LogicalFunction geometry, + LogicalFunction dist); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalADWithinTCbufferCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalADWithinTCbufferCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..7988b574d8 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalADWithinTCbufferCbufferLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-distance-within between a single-instant tcbuffer and a static Cbuffer under a fixed threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `adwithin_tcbuffer_cbuffer`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalADWithinTCbufferCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalADWithinTCbufferCbuffer"; + + TemporalADWithinTCbufferCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction cbufferLit, + LogicalFunction dist); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalADWithinTCbufferGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalADWithinTCbufferGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..b0b66abcf2 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalADWithinTCbufferGeometryLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-distance-within between a single-instant tcbuffer and a static geometry under a fixed threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `adwithin_tcbuffer_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalADWithinTCbufferGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalADWithinTCbufferGeometry"; + + TemporalADWithinTCbufferGeometryLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction geometry, + LogicalFunction dist); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalADWithinTCbufferTCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalADWithinTCbufferTCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..fb614afa7e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalADWithinTCbufferTCbufferLogicalFunction.hpp @@ -0,0 +1,60 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-distance-within between two single-instant tcbuffers under a fixed threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `adwithin_tcbuffer_tcbuffer`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalADWithinTCbufferTCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalADWithinTCbufferTCbuffer"; + + TemporalADWithinTCbufferTCbufferLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction radiusA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction radiusB, + LogicalFunction tsB, + LogicalFunction dist); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalADWithinTGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalADWithinTGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..2b4fa97a65 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalADWithinTGeometryLogicalFunction.hpp @@ -0,0 +1,58 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-distance-within between two single-instant tgeompoints under a static threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `adwithin_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalADWithinTGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalADWithinTGeometry"; + + TemporalADWithinTGeometryLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction tsB, + LogicalFunction dist); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalADisjointGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalADisjointGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..c0cd1f10af --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalADisjointGeometryLogicalFunction.hpp @@ -0,0 +1,55 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-disjoint between a single-instant tgeompoint and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `adisjoint_tgeo_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalADisjointGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalADisjointGeometry"; + + TemporalADisjointGeometryLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalADisjointTCbufferCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalADisjointTCbufferCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..b8b99390c2 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalADisjointTCbufferCbufferLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event a-disjoint between a single-instant tcbuffer and a static Cbuffer literal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `adisjoint_tcbuffer_cbuffer`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalADisjointTCbufferCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalADisjointTCbufferCbuffer"; + + TemporalADisjointTCbufferCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction cbufferLit); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalADisjointTCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalADisjointTCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..15f38ab811 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalADisjointTCbufferLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-disjoint between a single-instant tcbuffer and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `adisjoint_tcbuffer_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalADisjointTCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalADisjointTCbuffer"; + + TemporalADisjointTCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalADisjointTCbufferTCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalADisjointTCbufferTCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..3878738bdb --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalADisjointTCbufferTCbufferLogicalFunction.hpp @@ -0,0 +1,59 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-disjoint between two single-instant tcbuffers. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `adisjoint_tcbuffer_tcbuffer`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalADisjointTCbufferTCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalADisjointTCbufferTCbuffer"; + + TemporalADisjointTCbufferTCbufferLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction radiusA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction radiusB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalADisjointTGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalADisjointTGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..9c4bd41719 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalADisjointTGeometryLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-disjoint between two single-instant tgeompoints. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `adisjoint_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalADisjointTGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalADisjointTGeometry"; + + TemporalADisjointTGeometryLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalADisjointTNpointGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalADisjointTNpointGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..3f7e16f0dd --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalADisjointTNpointGeometryLogicalFunction.hpp @@ -0,0 +1,55 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-disjoint between a single-instant tgeompoint resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint and a static geometry (network SRID). + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `adisjoint_tgeo_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalADisjointTNpointGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalADisjointTNpointGeometry"; + + TemporalADisjointTNpointGeometryLogicalFunction(LogicalFunction rid, + LogicalFunction fraction, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalADisjointTNpointTNpointLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalADisjointTNpointTNpointLogicalFunction.hpp new file mode 100644 index 0000000000..e1fbe4311c --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalADisjointTNpointTNpointLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-disjoint between two single-instant tgeompoints, each resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `adisjoint_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalADisjointTNpointTNpointLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalADisjointTNpointTNpoint"; + + TemporalADisjointTNpointTNpointLogicalFunction(LogicalFunction ridA, + LogicalFunction fractionA, + LogicalFunction tsA, + LogicalFunction ridB, + LogicalFunction fractionB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalADisjointTPoseGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalADisjointTPoseGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..60ff7aa1fa --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalADisjointTPoseGeometryLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-disjoint between a single-instant tpose (converted to tgeompoint at runtime) and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `adisjoint_tgeo_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalADisjointTPoseGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalADisjointTPoseGeometry"; + + TemporalADisjointTPoseGeometryLogicalFunction(LogicalFunction x, + LogicalFunction y, + LogicalFunction theta, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalADisjointTPoseTPoseLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalADisjointTPoseTPoseLogicalFunction.hpp new file mode 100644 index 0000000000..ddb1392b4c --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalADisjointTPoseTPoseLogicalFunction.hpp @@ -0,0 +1,59 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-disjoint between two single-instant tgeompoints, each lifted from a tpose (x,y,theta,ts) via tpose_to_tpoint composition. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `adisjoint_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalADisjointTPoseTPoseLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalADisjointTPoseTPose"; + + TemporalADisjointTPoseTPoseLogicalFunction(LogicalFunction xA, + LogicalFunction yA, + LogicalFunction thetaA, + LogicalFunction tsA, + LogicalFunction xB, + LogicalFunction yB, + LogicalFunction thetaB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalAIntersectsTCbufferCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalAIntersectsTCbufferCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..5f594a8994 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalAIntersectsTCbufferCbufferLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event a-intersects between a single-instant tcbuffer and a static Cbuffer literal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `aintersects_tcbuffer_cbuffer`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalAIntersectsTCbufferCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalAIntersectsTCbufferCbuffer"; + + TemporalAIntersectsTCbufferCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction cbufferLit); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalAIntersectsTCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalAIntersectsTCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..84c421ccb7 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalAIntersectsTCbufferLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-intersects between a single-instant tcbuffer and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `aintersects_tcbuffer_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalAIntersectsTCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalAIntersectsTCbuffer"; + + TemporalAIntersectsTCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalAIntersectsTCbufferTCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalAIntersectsTCbufferTCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..0336ab9814 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalAIntersectsTCbufferTCbufferLogicalFunction.hpp @@ -0,0 +1,59 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-intersects between two single-instant tcbuffers. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `aintersects_tcbuffer_tcbuffer`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalAIntersectsTCbufferTCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalAIntersectsTCbufferTCbuffer"; + + TemporalAIntersectsTCbufferTCbufferLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction radiusA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction radiusB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalAIntersectsTGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalAIntersectsTGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..d8b516893f --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalAIntersectsTGeometryLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-intersects between two single-instant tgeompoints. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `aintersects_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalAIntersectsTGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalAIntersectsTGeometry"; + + TemporalAIntersectsTGeometryLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalAIntersectsTNpointGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalAIntersectsTNpointGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..5ccd1fba4e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalAIntersectsTNpointGeometryLogicalFunction.hpp @@ -0,0 +1,55 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-intersects between a single-instant tgeompoint resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint and a static geometry (network SRID). + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `aintersects_tgeo_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalAIntersectsTNpointGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalAIntersectsTNpointGeometry"; + + TemporalAIntersectsTNpointGeometryLogicalFunction(LogicalFunction rid, + LogicalFunction fraction, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalAIntersectsTNpointTNpointLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalAIntersectsTNpointTNpointLogicalFunction.hpp new file mode 100644 index 0000000000..8df5eaff52 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalAIntersectsTNpointTNpointLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-intersects between two single-instant tgeompoints, each resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `aintersects_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalAIntersectsTNpointTNpointLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalAIntersectsTNpointTNpoint"; + + TemporalAIntersectsTNpointTNpointLogicalFunction(LogicalFunction ridA, + LogicalFunction fractionA, + LogicalFunction tsA, + LogicalFunction ridB, + LogicalFunction fractionB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalAIntersectsTPoseGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalAIntersectsTPoseGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..f0090c8dcb --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalAIntersectsTPoseGeometryLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-intersects between a single-instant tpose (converted to tgeompoint at runtime) and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `aintersects_tgeo_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalAIntersectsTPoseGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalAIntersectsTPoseGeometry"; + + TemporalAIntersectsTPoseGeometryLogicalFunction(LogicalFunction x, + LogicalFunction y, + LogicalFunction theta, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalAIntersectsTPoseTPoseLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalAIntersectsTPoseTPoseLogicalFunction.hpp new file mode 100644 index 0000000000..d1daf8fee2 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalAIntersectsTPoseTPoseLogicalFunction.hpp @@ -0,0 +1,59 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-intersects between two single-instant tgeompoints, each lifted from a tpose (x,y,theta,ts) via tpose_to_tpoint composition. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `aintersects_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalAIntersectsTPoseTPoseLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalAIntersectsTPoseTPose"; + + TemporalAIntersectsTPoseTPoseLogicalFunction(LogicalFunction xA, + LogicalFunction yA, + LogicalFunction thetaA, + LogicalFunction tsA, + LogicalFunction xB, + LogicalFunction yB, + LogicalFunction thetaB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalATouchesGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalATouchesGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..e09b1b451c --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalATouchesGeometryLogicalFunction.hpp @@ -0,0 +1,55 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-touches between a single-instant tgeompoint and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `atouches_tgeo_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalATouchesGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalATouchesGeometry"; + + TemporalATouchesGeometryLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalATouchesTCbufferCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalATouchesTCbufferCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..5fec7b4429 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalATouchesTCbufferCbufferLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event a-touches between a single-instant tcbuffer and a static Cbuffer literal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `atouches_tcbuffer_cbuffer`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalATouchesTCbufferCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalATouchesTCbufferCbuffer"; + + TemporalATouchesTCbufferCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction cbufferLit); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalATouchesTCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalATouchesTCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..60f184df97 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalATouchesTCbufferLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-touches between a single-instant tcbuffer and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `atouches_tcbuffer_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalATouchesTCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalATouchesTCbuffer"; + + TemporalATouchesTCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalATouchesTCbufferTCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalATouchesTCbufferTCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..d16ae69b45 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalATouchesTCbufferTCbufferLogicalFunction.hpp @@ -0,0 +1,59 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-touches between two single-instant tcbuffers. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `atouches_tcbuffer_tcbuffer`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalATouchesTCbufferTCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalATouchesTCbufferTCbuffer"; + + TemporalATouchesTCbufferTCbufferLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction radiusA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction radiusB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalATouchesTGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalATouchesTGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..3add11b95e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalATouchesTGeometryLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-touches between two single-instant tgeompoints. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `atouches_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalATouchesTGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalATouchesTGeometry"; + + TemporalATouchesTGeometryLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalATouchesTNpointGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalATouchesTNpointGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..e8df1927b3 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalATouchesTNpointGeometryLogicalFunction.hpp @@ -0,0 +1,55 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-touches between a single-instant tgeompoint resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint and a static geometry (network SRID). + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `atouches_tgeo_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalATouchesTNpointGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalATouchesTNpointGeometry"; + + TemporalATouchesTNpointGeometryLogicalFunction(LogicalFunction rid, + LogicalFunction fraction, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalATouchesTNpointTNpointLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalATouchesTNpointTNpointLogicalFunction.hpp new file mode 100644 index 0000000000..43e2799ce2 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalATouchesTNpointTNpointLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-touches between two single-instant tgeompoints, each resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `atouches_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalATouchesTNpointTNpointLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalATouchesTNpointTNpoint"; + + TemporalATouchesTNpointTNpointLogicalFunction(LogicalFunction ridA, + LogicalFunction fractionA, + LogicalFunction tsA, + LogicalFunction ridB, + LogicalFunction fractionB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalATouchesTPoseGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalATouchesTPoseGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..89c52948f4 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalATouchesTPoseGeometryLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-touches between a single-instant tpose (converted to tgeompoint at runtime) and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `atouches_tgeo_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalATouchesTPoseGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalATouchesTPoseGeometry"; + + TemporalATouchesTPoseGeometryLogicalFunction(LogicalFunction x, + LogicalFunction y, + LogicalFunction theta, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalATouchesTPoseTPoseLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalATouchesTPoseTPoseLogicalFunction.hpp new file mode 100644 index 0000000000..859b8a2620 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalATouchesTPoseTPoseLogicalFunction.hpp @@ -0,0 +1,59 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always-touches between two single-instant tgeompoints, each lifted from a tpose (x,y,theta,ts) via tpose_to_tpoint composition. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `atouches_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalATouchesTPoseTPoseLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalATouchesTPoseTPose"; + + TemporalATouchesTPoseTPoseLogicalFunction(LogicalFunction xA, + LogicalFunction yA, + LogicalFunction thetaA, + LogicalFunction tsA, + LogicalFunction xB, + LogicalFunction yB, + LogicalFunction thetaB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalAtGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalAtGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..7ee01fee21 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalAtGeometryLogicalFunction.hpp @@ -0,0 +1,55 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event spatial restriction: 1 if the single-instant tgeompoint survives clipping by the static geometry, 0 if clipped. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tgeo_at_geom`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalAtGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalAtGeometry"; + + TemporalAtGeometryLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEContainsTCbufferCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEContainsTCbufferCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..13e3ef68b1 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEContainsTCbufferCbufferLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event e-contains between a single-instant tcbuffer and a static Cbuffer literal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `econtains_tcbuffer_cbuffer`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEContainsTCbufferCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEContainsTCbufferCbuffer"; + + TemporalEContainsTCbufferCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction cbufferLit); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEContainsTCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEContainsTCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..ffe92fd484 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEContainsTCbufferLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-contains between a single-instant tcbuffer and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `econtains_tcbuffer_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEContainsTCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEContainsTCbuffer"; + + TemporalEContainsTCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEContainsTGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEContainsTGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..1b4d6c68ae --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEContainsTGeometryLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-contains between two single-instant tgeompoints built from event fields. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `econtains_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEContainsTGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEContainsTGeometry"; + + TemporalEContainsTGeometryLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEContainsTNpointGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEContainsTNpointGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..dcb7df1d40 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEContainsTNpointGeometryLogicalFunction.hpp @@ -0,0 +1,55 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-contains between a single-instant tgeompoint resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint and a static geometry (network SRID). + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `econtains_tgeo_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEContainsTNpointGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEContainsTNpointGeometry"; + + TemporalEContainsTNpointGeometryLogicalFunction(LogicalFunction rid, + LogicalFunction fraction, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEContainsTNpointTNpointLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEContainsTNpointTNpointLogicalFunction.hpp new file mode 100644 index 0000000000..88fdcb7b38 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEContainsTNpointTNpointLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-contains between two single-instant tgeompoints, each resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `econtains_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEContainsTNpointTNpointLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEContainsTNpointTNpoint"; + + TemporalEContainsTNpointTNpointLogicalFunction(LogicalFunction ridA, + LogicalFunction fractionA, + LogicalFunction tsA, + LogicalFunction ridB, + LogicalFunction fractionB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEContainsTPoseGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEContainsTPoseGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..73aa69109d --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEContainsTPoseGeometryLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-contains between a single-instant tpose (converted to tgeompoint at runtime) and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `econtains_tgeo_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEContainsTPoseGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEContainsTPoseGeometry"; + + TemporalEContainsTPoseGeometryLogicalFunction(LogicalFunction x, + LogicalFunction y, + LogicalFunction theta, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEContainsTPoseTPoseLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEContainsTPoseTPoseLogicalFunction.hpp new file mode 100644 index 0000000000..4bbf3dc62e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEContainsTPoseTPoseLogicalFunction.hpp @@ -0,0 +1,59 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-contains between two single-instant tgeompoints, each lifted from a tpose (x,y,theta,ts) via tpose_to_tpoint composition. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `econtains_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEContainsTPoseTPoseLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEContainsTPoseTPose"; + + TemporalEContainsTPoseTPoseLogicalFunction(LogicalFunction xA, + LogicalFunction yA, + LogicalFunction thetaA, + LogicalFunction tsA, + LogicalFunction xB, + LogicalFunction yB, + LogicalFunction thetaB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalECoversGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalECoversGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..790cf4c60a --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalECoversGeometryLogicalFunction.hpp @@ -0,0 +1,55 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-covers between a single-instant tgeompoint and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ecovers_tgeo_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalECoversGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalECoversGeometry"; + + TemporalECoversGeometryLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalECoversTCbufferCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalECoversTCbufferCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..78f0758734 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalECoversTCbufferCbufferLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event e-covers between a single-instant tcbuffer and a static Cbuffer literal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ecovers_tcbuffer_cbuffer`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalECoversTCbufferCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalECoversTCbufferCbuffer"; + + TemporalECoversTCbufferCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction cbufferLit); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalECoversTCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalECoversTCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..2ad42ed992 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalECoversTCbufferLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-covers between a single-instant tcbuffer and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ecovers_tcbuffer_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalECoversTCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalECoversTCbuffer"; + + TemporalECoversTCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalECoversTCbufferTCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalECoversTCbufferTCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..a94bb794ad --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalECoversTCbufferTCbufferLogicalFunction.hpp @@ -0,0 +1,59 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-covers between two single-instant tcbuffers. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ecovers_tcbuffer_tcbuffer`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalECoversTCbufferTCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalECoversTCbufferTCbuffer"; + + TemporalECoversTCbufferTCbufferLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction radiusA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction radiusB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalECoversTGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalECoversTGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..2b3ae2ad52 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalECoversTGeometryLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-covers between two single-instant tgeompoints. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ecovers_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalECoversTGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalECoversTGeometry"; + + TemporalECoversTGeometryLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalECoversTNpointGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalECoversTNpointGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..af7d68f77a --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalECoversTNpointGeometryLogicalFunction.hpp @@ -0,0 +1,55 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-covers between a single-instant tgeompoint resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint and a static geometry (network SRID). + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ecovers_tgeo_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalECoversTNpointGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalECoversTNpointGeometry"; + + TemporalECoversTNpointGeometryLogicalFunction(LogicalFunction rid, + LogicalFunction fraction, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalECoversTNpointTNpointLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalECoversTNpointTNpointLogicalFunction.hpp new file mode 100644 index 0000000000..e335da1314 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalECoversTNpointTNpointLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-covers between two single-instant tgeompoints, each resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ecovers_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalECoversTNpointTNpointLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalECoversTNpointTNpoint"; + + TemporalECoversTNpointTNpointLogicalFunction(LogicalFunction ridA, + LogicalFunction fractionA, + LogicalFunction tsA, + LogicalFunction ridB, + LogicalFunction fractionB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalECoversTPoseGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalECoversTPoseGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..977c14e7d7 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalECoversTPoseGeometryLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-covers between a single-instant tpose (converted to tgeompoint at runtime) and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ecovers_tgeo_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalECoversTPoseGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalECoversTPoseGeometry"; + + TemporalECoversTPoseGeometryLogicalFunction(LogicalFunction x, + LogicalFunction y, + LogicalFunction theta, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalECoversTPoseTPoseLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalECoversTPoseTPoseLogicalFunction.hpp new file mode 100644 index 0000000000..08e315d7fc --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalECoversTPoseTPoseLogicalFunction.hpp @@ -0,0 +1,59 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-covers between two single-instant tgeompoints, each lifted from a tpose (x,y,theta,ts) via tpose_to_tpoint composition. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ecovers_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalECoversTPoseTPoseLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalECoversTPoseTPose"; + + TemporalECoversTPoseTPoseLogicalFunction(LogicalFunction xA, + LogicalFunction yA, + LogicalFunction thetaA, + LogicalFunction tsA, + LogicalFunction xB, + LogicalFunction yB, + LogicalFunction thetaB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEDWithinTCbufferCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEDWithinTCbufferCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..dfd5c6af39 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEDWithinTCbufferCbufferLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-distance-within between a single-instant tcbuffer and a static Cbuffer under a fixed threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `edwithin_tcbuffer_cbuffer`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEDWithinTCbufferCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEDWithinTCbufferCbuffer"; + + TemporalEDWithinTCbufferCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction cbufferLit, + LogicalFunction dist); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEDWithinTCbufferGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEDWithinTCbufferGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..c71ab578a8 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEDWithinTCbufferGeometryLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-distance-within between a single-instant tcbuffer and a static geometry under a fixed threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `edwithin_tcbuffer_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEDWithinTCbufferGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEDWithinTCbufferGeometry"; + + TemporalEDWithinTCbufferGeometryLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction geometry, + LogicalFunction dist); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEDWithinTCbufferTCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEDWithinTCbufferTCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..0d61f30c9e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEDWithinTCbufferTCbufferLogicalFunction.hpp @@ -0,0 +1,60 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-distance-within between two single-instant tcbuffers under a fixed threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `edwithin_tcbuffer_tcbuffer`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEDWithinTCbufferTCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEDWithinTCbufferTCbuffer"; + + TemporalEDWithinTCbufferTCbufferLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction radiusA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction radiusB, + LogicalFunction tsB, + LogicalFunction dist); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEDWithinTGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEDWithinTGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..c11bae445a --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEDWithinTGeometryLogicalFunction.hpp @@ -0,0 +1,58 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-distance-within between two single-instant tgeompoints under a static threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `edwithin_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEDWithinTGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEDWithinTGeometry"; + + TemporalEDWithinTGeometryLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction tsB, + LogicalFunction dist); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEDisjointGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEDisjointGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..4f2f5b5fce --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEDisjointGeometryLogicalFunction.hpp @@ -0,0 +1,55 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-disjoint between a single-instant tgeompoint built from event fields and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `edisjoint_tgeo_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEDisjointGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEDisjointGeometry"; + + TemporalEDisjointGeometryLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEDisjointTCbufferCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEDisjointTCbufferCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..173896af8c --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEDisjointTCbufferCbufferLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event e-disjoint between a single-instant tcbuffer and a static Cbuffer literal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `edisjoint_tcbuffer_cbuffer`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEDisjointTCbufferCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEDisjointTCbufferCbuffer"; + + TemporalEDisjointTCbufferCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction cbufferLit); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEDisjointTCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEDisjointTCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..35ea8a1620 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEDisjointTCbufferLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-disjoint between a single-instant tcbuffer and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `edisjoint_tcbuffer_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEDisjointTCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEDisjointTCbuffer"; + + TemporalEDisjointTCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEDisjointTGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEDisjointTGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..8120f3f4e0 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEDisjointTGeometryLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-disjoint between two single-instant tgeompoints. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `edisjoint_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEDisjointTGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEDisjointTGeometry"; + + TemporalEDisjointTGeometryLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEDisjointTNpointGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEDisjointTNpointGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..b7f729fb1f --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEDisjointTNpointGeometryLogicalFunction.hpp @@ -0,0 +1,55 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-disjoint between a single-instant tgeompoint resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint and a static geometry (network SRID). + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `edisjoint_tgeo_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEDisjointTNpointGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEDisjointTNpointGeometry"; + + TemporalEDisjointTNpointGeometryLogicalFunction(LogicalFunction rid, + LogicalFunction fraction, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEDisjointTNpointTNpointLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEDisjointTNpointTNpointLogicalFunction.hpp new file mode 100644 index 0000000000..71d133db39 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEDisjointTNpointTNpointLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-disjoint between two single-instant tgeompoints, each resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `edisjoint_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEDisjointTNpointTNpointLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEDisjointTNpointTNpoint"; + + TemporalEDisjointTNpointTNpointLogicalFunction(LogicalFunction ridA, + LogicalFunction fractionA, + LogicalFunction tsA, + LogicalFunction ridB, + LogicalFunction fractionB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEDisjointTPoseGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEDisjointTPoseGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..730141ed5a --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEDisjointTPoseGeometryLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-disjoint between a single-instant tpose (converted to tgeompoint at runtime) and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `edisjoint_tgeo_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEDisjointTPoseGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEDisjointTPoseGeometry"; + + TemporalEDisjointTPoseGeometryLogicalFunction(LogicalFunction x, + LogicalFunction y, + LogicalFunction theta, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEDisjointTPoseTPoseLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEDisjointTPoseTPoseLogicalFunction.hpp new file mode 100644 index 0000000000..143a9c1d87 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEDisjointTPoseTPoseLogicalFunction.hpp @@ -0,0 +1,59 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-disjoint between two single-instant tgeompoints, each lifted from a tpose (x,y,theta,ts) via tpose_to_tpoint composition. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `edisjoint_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEDisjointTPoseTPoseLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEDisjointTPoseTPose"; + + TemporalEDisjointTPoseTPoseLogicalFunction(LogicalFunction xA, + LogicalFunction yA, + LogicalFunction thetaA, + LogicalFunction tsA, + LogicalFunction xB, + LogicalFunction yB, + LogicalFunction thetaB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEIntersectsGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEIntersectsGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..f1dc79267b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEIntersectsGeometryLogicalFunction.hpp @@ -0,0 +1,55 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-intersects between a single-instant tgeompoint and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `eintersects_tgeo_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEIntersectsGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEIntersectsGeometry"; + + TemporalEIntersectsGeometryLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEIntersectsTCbufferCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEIntersectsTCbufferCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..af40b6f91b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEIntersectsTCbufferCbufferLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event e-intersects between a single-instant tcbuffer and a static Cbuffer literal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `eintersects_tcbuffer_cbuffer`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEIntersectsTCbufferCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEIntersectsTCbufferCbuffer"; + + TemporalEIntersectsTCbufferCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction cbufferLit); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEIntersectsTCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEIntersectsTCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..95018248ea --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEIntersectsTCbufferLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-intersects between a single-instant tcbuffer and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `eintersects_tcbuffer_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEIntersectsTCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEIntersectsTCbuffer"; + + TemporalEIntersectsTCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEIntersectsTCbufferTCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEIntersectsTCbufferTCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..bc05a7a5e9 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEIntersectsTCbufferTCbufferLogicalFunction.hpp @@ -0,0 +1,59 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-intersects between two single-instant tcbuffers. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `eintersects_tcbuffer_tcbuffer`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEIntersectsTCbufferTCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEIntersectsTCbufferTCbuffer"; + + TemporalEIntersectsTCbufferTCbufferLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction radiusA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction radiusB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEIntersectsTGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEIntersectsTGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..e17c6b0bd6 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEIntersectsTGeometryLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-intersects between two single-instant tgeompoints. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `eintersects_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEIntersectsTGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEIntersectsTGeometry"; + + TemporalEIntersectsTGeometryLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEIntersectsTNpointGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEIntersectsTNpointGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..7864a70d67 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEIntersectsTNpointGeometryLogicalFunction.hpp @@ -0,0 +1,55 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-intersects between a single-instant tgeompoint resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint and a static geometry (network SRID). + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `eintersects_tgeo_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEIntersectsTNpointGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEIntersectsTNpointGeometry"; + + TemporalEIntersectsTNpointGeometryLogicalFunction(LogicalFunction rid, + LogicalFunction fraction, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEIntersectsTNpointTNpointLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEIntersectsTNpointTNpointLogicalFunction.hpp new file mode 100644 index 0000000000..6f6c83b43c --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEIntersectsTNpointTNpointLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-intersects between two single-instant tgeompoints, each resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `eintersects_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEIntersectsTNpointTNpointLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEIntersectsTNpointTNpoint"; + + TemporalEIntersectsTNpointTNpointLogicalFunction(LogicalFunction ridA, + LogicalFunction fractionA, + LogicalFunction tsA, + LogicalFunction ridB, + LogicalFunction fractionB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEIntersectsTPoseGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEIntersectsTPoseGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..b4c52c3ccd --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEIntersectsTPoseGeometryLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-intersects between a single-instant tpose (converted to tgeompoint at runtime) and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `eintersects_tgeo_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEIntersectsTPoseGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEIntersectsTPoseGeometry"; + + TemporalEIntersectsTPoseGeometryLogicalFunction(LogicalFunction x, + LogicalFunction y, + LogicalFunction theta, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalEIntersectsTPoseTPoseLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalEIntersectsTPoseTPoseLogicalFunction.hpp new file mode 100644 index 0000000000..9e2616bbb8 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalEIntersectsTPoseTPoseLogicalFunction.hpp @@ -0,0 +1,59 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-intersects between two single-instant tgeompoints, each lifted from a tpose (x,y,theta,ts) via tpose_to_tpoint composition. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `eintersects_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalEIntersectsTPoseTPoseLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalEIntersectsTPoseTPose"; + + TemporalEIntersectsTPoseTPoseLogicalFunction(LogicalFunction xA, + LogicalFunction yA, + LogicalFunction thetaA, + LogicalFunction tsA, + LogicalFunction xB, + LogicalFunction yB, + LogicalFunction thetaB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalETouchesGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalETouchesGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..b4de81e708 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalETouchesGeometryLogicalFunction.hpp @@ -0,0 +1,55 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-touches between a single-instant tgeompoint and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `etouches_tgeo_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalETouchesGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalETouchesGeometry"; + + TemporalETouchesGeometryLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalETouchesTCbufferCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalETouchesTCbufferCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..38a7780533 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalETouchesTCbufferCbufferLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event e-touches between a single-instant tcbuffer and a static Cbuffer literal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `etouches_tcbuffer_cbuffer`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalETouchesTCbufferCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalETouchesTCbufferCbuffer"; + + TemporalETouchesTCbufferCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction cbufferLit); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalETouchesTCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalETouchesTCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..10a92cf799 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalETouchesTCbufferLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-touches between a single-instant tcbuffer and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `etouches_tcbuffer_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalETouchesTCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalETouchesTCbuffer"; + + TemporalETouchesTCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalETouchesTCbufferTCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalETouchesTCbufferTCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..2d98ec176e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalETouchesTCbufferTCbufferLogicalFunction.hpp @@ -0,0 +1,59 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-touches between two single-instant tcbuffers. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `etouches_tcbuffer_tcbuffer`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalETouchesTCbufferTCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalETouchesTCbufferTCbuffer"; + + TemporalETouchesTCbufferTCbufferLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction radiusA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction radiusB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalETouchesTGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalETouchesTGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..5eb6e97c27 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalETouchesTGeometryLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-touches between two single-instant tgeompoints. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `etouches_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalETouchesTGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalETouchesTGeometry"; + + TemporalETouchesTGeometryLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalETouchesTNpointGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalETouchesTNpointGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..0f01748aa0 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalETouchesTNpointGeometryLogicalFunction.hpp @@ -0,0 +1,55 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-touches between a single-instant tgeompoint resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint and a static geometry (network SRID). + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `etouches_tgeo_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalETouchesTNpointGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalETouchesTNpointGeometry"; + + TemporalETouchesTNpointGeometryLogicalFunction(LogicalFunction rid, + LogicalFunction fraction, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalETouchesTNpointTNpointLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalETouchesTNpointTNpointLogicalFunction.hpp new file mode 100644 index 0000000000..e23a751a6c --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalETouchesTNpointTNpointLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-touches between two single-instant tgeompoints, each resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `etouches_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalETouchesTNpointTNpointLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalETouchesTNpointTNpoint"; + + TemporalETouchesTNpointTNpointLogicalFunction(LogicalFunction ridA, + LogicalFunction fractionA, + LogicalFunction tsA, + LogicalFunction ridB, + LogicalFunction fractionB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalETouchesTPoseGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalETouchesTPoseGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..02fdd23fd4 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalETouchesTPoseGeometryLogicalFunction.hpp @@ -0,0 +1,56 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-touches between a single-instant tpose (converted to tgeompoint at runtime) and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `etouches_tgeo_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalETouchesTPoseGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalETouchesTPoseGeometry"; + + TemporalETouchesTPoseGeometryLogicalFunction(LogicalFunction x, + LogicalFunction y, + LogicalFunction theta, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalETouchesTPoseTPoseLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalETouchesTPoseTPoseLogicalFunction.hpp new file mode 100644 index 0000000000..9baa5a9f0a --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalETouchesTPoseTPoseLogicalFunction.hpp @@ -0,0 +1,59 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever-touches between two single-instant tgeompoints, each lifted from a tpose (x,y,theta,ts) via tpose_to_tpoint composition. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `etouches_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalETouchesTPoseTPoseLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalETouchesTPoseTPose"; + + TemporalETouchesTPoseTPoseLogicalFunction(LogicalFunction xA, + LogicalFunction yA, + LogicalFunction thetaA, + LogicalFunction tsA, + LogicalFunction xB, + LogicalFunction yB, + LogicalFunction thetaB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalMinusGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalMinusGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..9b6a9dac3c --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalMinusGeometryLogicalFunction.hpp @@ -0,0 +1,55 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event spatial subtraction: 1 if the single-instant tgeompoint survives subtraction of the static geometry, 0 if removed. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tgeo_minus_geom`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalMinusGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalMinusGeometry"; + + TemporalMinusGeometryLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalNADFloatScalarLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalNADFloatScalarLogicalFunction.hpp new file mode 100644 index 0000000000..a27098d8aa --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalNADFloatScalarLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event nearest-approach distance between a single-instant tfloat and a scalar double. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `nad_tfloat_float`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalNADFloatScalarLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalNADFloatScalar"; + + TemporalNADFloatScalarLogicalFunction(LogicalFunction value, + LogicalFunction timestamp, + LogicalFunction scalar); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalNADGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalNADGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..0d07c705f4 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalNADGeometryLogicalFunction.hpp @@ -0,0 +1,55 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event nearest-approach distance between a single-instant tgeompoint and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `nad_tgeo_geo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalNADGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalNADGeometry"; + + TemporalNADGeometryLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction timestamp, + LogicalFunction geometry); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalNADIntScalarLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalNADIntScalarLogicalFunction.hpp new file mode 100644 index 0000000000..df72137b9d --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalNADIntScalarLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event nearest-approach distance between a single-instant tint and a scalar int. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `nad_tint_int`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalNADIntScalarLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalNADIntScalar"; + + TemporalNADIntScalarLogicalFunction(LogicalFunction value, + LogicalFunction timestamp, + LogicalFunction scalar); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalNADTFloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalNADTFloatLogicalFunction.hpp new file mode 100644 index 0000000000..c64dc6d755 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalNADTFloatLogicalFunction.hpp @@ -0,0 +1,55 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event nearest-approach distance between two single-instant tfloats. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `nad_tfloat_tfloat`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalNADTFloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalNADTFloat"; + + TemporalNADTFloatLogicalFunction(LogicalFunction valueA, + LogicalFunction tsA, + LogicalFunction valueB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalNADTGeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalNADTGeometryLogicalFunction.hpp new file mode 100644 index 0000000000..1e8991e419 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalNADTGeometryLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event nearest-approach distance between two single-instant tgeompoints. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `nad_tgeo_tgeo`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalNADTGeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalNADTGeometry"; + + TemporalNADTGeometryLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalNADTIntLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalNADTIntLogicalFunction.hpp new file mode 100644 index 0000000000..88d5d68e7e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalNADTIntLogicalFunction.hpp @@ -0,0 +1,55 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event nearest-approach distance between two single-instant tints. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `nad_tint_tint`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TemporalNADTIntLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalNADTInt"; + + TemporalNADTIntLogicalFunction(LogicalFunction valueA, + LogicalFunction tsA, + LogicalFunction valueB, + LogicalFunction tsB); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/CrossDistanceAggregationLogicalFunction.hpp b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/CrossDistanceAggregationLogicalFunction.hpp new file mode 100644 index 0000000000..7d5cfae0a2 --- /dev/null +++ b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/CrossDistanceAggregationLogicalFunction.hpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include + +namespace NES +{ + +/** + * @brief Logical-plan side of the CROSS_DISTANCE aggregation (BerlinMOD-Q9). + * + * Four input fields (lon, lat, timestamp, vehicle_id) + per-aggregation `(vidA, vidB)` + * target-vehicle pair (the two integer constants identifying which vehicles to compute + * the distance between). Final aggregate stamp = FLOAT64 (spheroidal distance in metres + * between the two vehicles' latest known positions in the window; NaN if either is + * unobserved). See `CrossDistanceAggregationPhysicalFunction`. + * + * @note The Registrar deserialize path receives only the 5 field args (lon, lat, ts, + * vid, asField) and reconstructs the aggregation with the `DEFAULT_VID_A` / + * `DEFAULT_VID_B` constants. Round-trip Serde fidelity for the vidA/vidB values is a + * follow-up; mirrors PairMeeting #19's same Serde caveat (the proto carries only + * SerializableFunction-typed fields in `extra_fields`). + */ +class CrossDistanceAggregationLogicalFunction : public WindowAggregationLogicalFunction +{ +public: + /// BerlinMOD-scaffold defaults; mirror `CrossDistanceAggregationPhysicalFunction`. + /// Used by the Registrar deserialize path; the parser path always supplies + /// explicit values. + static constexpr uint64_t DEFAULT_VID_A = 100; + static constexpr uint64_t DEFAULT_VID_B = 200; + + static std::shared_ptr + create(const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& vehicleIdField, + uint64_t vidA, + uint64_t vidB); + + CrossDistanceAggregationLogicalFunction( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& vehicleIdField, + const FieldAccessLogicalFunction& asField, + uint64_t vidA, + uint64_t vidB); + + void inferStamp(const Schema& schema) override; + ~CrossDistanceAggregationLogicalFunction() override = default; + [[nodiscard]] NES::SerializableAggregationFunction serialize() const override; + [[nodiscard]] std::string_view getName() const noexcept override; + [[nodiscard]] bool requiresSequentialAggregation() const { return true; } + + [[nodiscard]] const FieldAccessLogicalFunction& getLonField() const noexcept { return lonField; } + [[nodiscard]] const FieldAccessLogicalFunction& getLatField() const noexcept { return latField; } + [[nodiscard]] const FieldAccessLogicalFunction& getTimestampField() const noexcept { return timestampField; } + [[nodiscard]] const FieldAccessLogicalFunction& getVehicleIdField() const noexcept { return vehicleIdField; } + [[nodiscard]] uint64_t getVidA() const noexcept { return vidA; } + [[nodiscard]] uint64_t getVidB() const noexcept { return vidB; } + +private: + static constexpr std::string_view NAME = "CrossDistance"; + static constexpr DataType::Type partialAggregateStampType = DataType::Type::UNDEFINED; + static constexpr DataType::Type finalAggregateStampType = DataType::Type::FLOAT64; + + FieldAccessLogicalFunction lonField; + FieldAccessLogicalFunction latField; + FieldAccessLogicalFunction timestampField; + FieldAccessLogicalFunction vehicleIdField; + uint64_t vidA; + uint64_t vidB; +}; +} diff --git a/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/PairMeetingAggregationLogicalFunction.hpp b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/PairMeetingAggregationLogicalFunction.hpp new file mode 100644 index 0000000000..bd08ee96cd --- /dev/null +++ b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/PairMeetingAggregationLogicalFunction.hpp @@ -0,0 +1,83 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +namespace NES +{ + +/** + * @brief Logical-plan side of the PAIR_MEETING aggregation (BerlinMOD-Q5). + * + * Four input fields (lon, lat, timestamp, vehicle_id) + per-aggregation + * `dMeetMetres` constant (the meeting-distance threshold, e.g. 200.0 in the + * BerlinMOD scaffold). Final aggregate stamp = VARSIZED (string-encoded list of + * meeting pairs). See `PairMeetingAggregationPhysicalFunction` for the + * lift / combine / lower path. + * + * @note The Registrar deserialize path receives only the 5 field args (lon, lat, + * ts, vid, asField) and reconstructs the aggregation with the + * `DEFAULT_DMEET_METRES` constant. Round-trip Serde fidelity for the dMeet + * value is a follow-up — it requires adding a new field to + * `SerializableAggregationFunction` (the proto currently carries only + * SerializableFunction-typed fields in `extra_fields`). + */ +class PairMeetingAggregationLogicalFunction : public WindowAggregationLogicalFunction +{ +public: + /// BerlinMOD-scaffold default; mirrors `PairMeetingAggregationPhysicalFunction::DEFAULT_DMEET_METRES`. + /// Used by the Registrar deserialize path; the parser path always supplies an explicit value. + static constexpr double DEFAULT_DMEET_METRES = 200.0; + + static std::shared_ptr + create(const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& vehicleIdField, + double dMeetMetres); + + PairMeetingAggregationLogicalFunction( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& vehicleIdField, + const FieldAccessLogicalFunction& asField, + double dMeetMetres); + + void inferStamp(const Schema& schema) override; + ~PairMeetingAggregationLogicalFunction() override = default; + [[nodiscard]] NES::SerializableAggregationFunction serialize() const override; + [[nodiscard]] std::string_view getName() const noexcept override; + [[nodiscard]] bool requiresSequentialAggregation() const { return true; } + + [[nodiscard]] const FieldAccessLogicalFunction& getLonField() const noexcept { return lonField; } + [[nodiscard]] const FieldAccessLogicalFunction& getLatField() const noexcept { return latField; } + [[nodiscard]] const FieldAccessLogicalFunction& getTimestampField() const noexcept { return timestampField; } + [[nodiscard]] const FieldAccessLogicalFunction& getVehicleIdField() const noexcept { return vehicleIdField; } + [[nodiscard]] double getDMeetMetres() const noexcept { return dMeetMetres; } + +private: + static constexpr std::string_view NAME = "PairMeeting"; + static constexpr DataType::Type partialAggregateStampType = DataType::Type::UNDEFINED; + static constexpr DataType::Type finalAggregateStampType = DataType::Type::VARSIZED; + + FieldAccessLogicalFunction lonField; + FieldAccessLogicalFunction latField; + FieldAccessLogicalFunction timestampField; + FieldAccessLogicalFunction vehicleIdField; + double dMeetMetres; +}; +} diff --git a/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalEndTimestampAggregationLogicalFunction.hpp b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalEndTimestampAggregationLogicalFunction.hpp new file mode 100644 index 0000000000..4a96356da5 --- /dev/null +++ b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalEndTimestampAggregationLogicalFunction.hpp @@ -0,0 +1,60 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +namespace NES +{ + +/** + * @brief TimestampTz (MEOS μs-since-2000) of the last instant in the per-(window, group) tgeo trajectory. + * + * Three-input (lon, lat, ts) tgeo aggregation. Lift accumulates the events + * into a paged vector; lower assembles the per-(window, group) trajectory + * and calls MEOS `temporal_end_timestamptz` to fold it to a single scalar. + */ +class TemporalEndTimestampAggregationLogicalFunction : public WindowAggregationLogicalFunction +{ +public: + static std::shared_ptr + create(const FieldAccessLogicalFunction& lonField, const FieldAccessLogicalFunction& latField, const FieldAccessLogicalFunction& timestampField); + + TemporalEndTimestampAggregationLogicalFunction( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField); + + void inferStamp(const Schema& schema) override; + ~TemporalEndTimestampAggregationLogicalFunction() override = default; + [[nodiscard]] NES::SerializableAggregationFunction serialize() const override; + [[nodiscard]] std::string_view getName() const noexcept override; + [[nodiscard]] bool requiresSequentialAggregation() const { return true; } + + [[nodiscard]] const FieldAccessLogicalFunction& getLonField() const noexcept { return lonField; } + [[nodiscard]] const FieldAccessLogicalFunction& getLatField() const noexcept { return latField; } + [[nodiscard]] const FieldAccessLogicalFunction& getTimestampField() const noexcept { return timestampField; } + +private: + static constexpr std::string_view NAME = "TemporalEndTimestamp"; + static constexpr DataType::Type partialAggregateStampType = DataType::Type::UNDEFINED; + static constexpr DataType::Type finalAggregateStampType = DataType::Type::INT64; + + FieldAccessLogicalFunction lonField; + FieldAccessLogicalFunction latField; + FieldAccessLogicalFunction timestampField; +}; +} diff --git a/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalLengthAggregationLogicalFunction.hpp b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalLengthAggregationLogicalFunction.hpp new file mode 100644 index 0000000000..b2225f7240 --- /dev/null +++ b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalLengthAggregationLogicalFunction.hpp @@ -0,0 +1,64 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +namespace NES +{ + +/** + * @brief Logical-plan side of the TEMPORAL_LENGTH aggregation. + * + * Takes three input fields (longitude, latitude, timestamp) and produces a + * single FLOAT64 result: the spheroidal length in metres of the per-(window, + * group) trajectory built from the lifted tuples. + * + * Same shape as TemporalSequenceAggregationLogicalFunctionV2; only the final + * aggregate stamp type differs (FLOAT64 here vs VARSIZED there). Closes the + * MobilityNebula BerlinMOD-Q6 partial→full gap. + */ +class TemporalLengthAggregationLogicalFunction : public WindowAggregationLogicalFunction +{ +public: + static std::shared_ptr + create(const FieldAccessLogicalFunction& lonField, const FieldAccessLogicalFunction& latField, const FieldAccessLogicalFunction& timestampField); + + TemporalLengthAggregationLogicalFunction( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField); + + void inferStamp(const Schema& schema) override; + ~TemporalLengthAggregationLogicalFunction() override = default; + [[nodiscard]] NES::SerializableAggregationFunction serialize() const override; + [[nodiscard]] std::string_view getName() const noexcept override; + [[nodiscard]] bool requiresSequentialAggregation() const { return true; } + + [[nodiscard]] const FieldAccessLogicalFunction& getLonField() const noexcept { return lonField; } + [[nodiscard]] const FieldAccessLogicalFunction& getLatField() const noexcept { return latField; } + [[nodiscard]] const FieldAccessLogicalFunction& getTimestampField() const noexcept { return timestampField; } + +private: + static constexpr std::string_view NAME = "TemporalLength"; + static constexpr DataType::Type partialAggregateStampType = DataType::Type::UNDEFINED; + static constexpr DataType::Type finalAggregateStampType = DataType::Type::FLOAT64; + + FieldAccessLogicalFunction lonField; + FieldAccessLogicalFunction latField; + FieldAccessLogicalFunction timestampField; +}; +} diff --git a/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalLowerIncAggregationLogicalFunction.hpp b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalLowerIncAggregationLogicalFunction.hpp new file mode 100644 index 0000000000..a989d2b98c --- /dev/null +++ b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalLowerIncAggregationLogicalFunction.hpp @@ -0,0 +1,60 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +namespace NES +{ + +/** + * @brief True if the per-(window, group) tgeo trajectory's lower period bound is inclusive. + * + * Three-input (lon, lat, ts) tgeo aggregation. Lift accumulates the events + * into a paged vector; lower assembles the per-(window, group) trajectory + * and calls MEOS `temporal_lower_inc` to fold it to a single scalar. + */ +class TemporalLowerIncAggregationLogicalFunction : public WindowAggregationLogicalFunction +{ +public: + static std::shared_ptr + create(const FieldAccessLogicalFunction& lonField, const FieldAccessLogicalFunction& latField, const FieldAccessLogicalFunction& timestampField); + + TemporalLowerIncAggregationLogicalFunction( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField); + + void inferStamp(const Schema& schema) override; + ~TemporalLowerIncAggregationLogicalFunction() override = default; + [[nodiscard]] NES::SerializableAggregationFunction serialize() const override; + [[nodiscard]] std::string_view getName() const noexcept override; + [[nodiscard]] bool requiresSequentialAggregation() const { return true; } + + [[nodiscard]] const FieldAccessLogicalFunction& getLonField() const noexcept { return lonField; } + [[nodiscard]] const FieldAccessLogicalFunction& getLatField() const noexcept { return latField; } + [[nodiscard]] const FieldAccessLogicalFunction& getTimestampField() const noexcept { return timestampField; } + +private: + static constexpr std::string_view NAME = "TemporalLowerInc"; + static constexpr DataType::Type partialAggregateStampType = DataType::Type::UNDEFINED; + static constexpr DataType::Type finalAggregateStampType = DataType::Type::BOOLEAN; + + FieldAccessLogicalFunction lonField; + FieldAccessLogicalFunction latField; + FieldAccessLogicalFunction timestampField; +}; +} diff --git a/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalNumInstantsAggregationLogicalFunction.hpp b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalNumInstantsAggregationLogicalFunction.hpp new file mode 100644 index 0000000000..38bf81b966 --- /dev/null +++ b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalNumInstantsAggregationLogicalFunction.hpp @@ -0,0 +1,60 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +namespace NES +{ + +/** + * @brief Per-(window, group) count of instants in the assembled tgeo trajectory. + * + * Three-input (lon, lat, ts) tgeo aggregation. Lift accumulates the events + * into a paged vector; lower assembles the per-(window, group) trajectory + * and calls MEOS `temporal_num_instants` to fold it to a single scalar. + */ +class TemporalNumInstantsAggregationLogicalFunction : public WindowAggregationLogicalFunction +{ +public: + static std::shared_ptr + create(const FieldAccessLogicalFunction& lonField, const FieldAccessLogicalFunction& latField, const FieldAccessLogicalFunction& timestampField); + + TemporalNumInstantsAggregationLogicalFunction( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField); + + void inferStamp(const Schema& schema) override; + ~TemporalNumInstantsAggregationLogicalFunction() override = default; + [[nodiscard]] NES::SerializableAggregationFunction serialize() const override; + [[nodiscard]] std::string_view getName() const noexcept override; + [[nodiscard]] bool requiresSequentialAggregation() const { return true; } + + [[nodiscard]] const FieldAccessLogicalFunction& getLonField() const noexcept { return lonField; } + [[nodiscard]] const FieldAccessLogicalFunction& getLatField() const noexcept { return latField; } + [[nodiscard]] const FieldAccessLogicalFunction& getTimestampField() const noexcept { return timestampField; } + +private: + static constexpr std::string_view NAME = "TemporalNumInstants"; + static constexpr DataType::Type partialAggregateStampType = DataType::Type::UNDEFINED; + static constexpr DataType::Type finalAggregateStampType = DataType::Type::INT32; + + FieldAccessLogicalFunction lonField; + FieldAccessLogicalFunction latField; + FieldAccessLogicalFunction timestampField; +}; +} diff --git a/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalNumSequencesAggregationLogicalFunction.hpp b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalNumSequencesAggregationLogicalFunction.hpp new file mode 100644 index 0000000000..bdf1f5841d --- /dev/null +++ b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalNumSequencesAggregationLogicalFunction.hpp @@ -0,0 +1,60 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +namespace NES +{ + +/** + * @brief Per-(window, group) count of sub-sequences in the assembled tgeo trajectory. + * + * Three-input (lon, lat, ts) tgeo aggregation. Lift accumulates the events + * into a paged vector; lower assembles the per-(window, group) trajectory + * and calls MEOS `temporal_num_sequences` to fold it to a single scalar. + */ +class TemporalNumSequencesAggregationLogicalFunction : public WindowAggregationLogicalFunction +{ +public: + static std::shared_ptr + create(const FieldAccessLogicalFunction& lonField, const FieldAccessLogicalFunction& latField, const FieldAccessLogicalFunction& timestampField); + + TemporalNumSequencesAggregationLogicalFunction( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField); + + void inferStamp(const Schema& schema) override; + ~TemporalNumSequencesAggregationLogicalFunction() override = default; + [[nodiscard]] NES::SerializableAggregationFunction serialize() const override; + [[nodiscard]] std::string_view getName() const noexcept override; + [[nodiscard]] bool requiresSequentialAggregation() const { return true; } + + [[nodiscard]] const FieldAccessLogicalFunction& getLonField() const noexcept { return lonField; } + [[nodiscard]] const FieldAccessLogicalFunction& getLatField() const noexcept { return latField; } + [[nodiscard]] const FieldAccessLogicalFunction& getTimestampField() const noexcept { return timestampField; } + +private: + static constexpr std::string_view NAME = "TemporalNumSequences"; + static constexpr DataType::Type partialAggregateStampType = DataType::Type::UNDEFINED; + static constexpr DataType::Type finalAggregateStampType = DataType::Type::INT32; + + FieldAccessLogicalFunction lonField; + FieldAccessLogicalFunction latField; + FieldAccessLogicalFunction timestampField; +}; +} diff --git a/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalNumTimestampsAggregationLogicalFunction.hpp b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalNumTimestampsAggregationLogicalFunction.hpp new file mode 100644 index 0000000000..9bce42486c --- /dev/null +++ b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalNumTimestampsAggregationLogicalFunction.hpp @@ -0,0 +1,60 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +namespace NES +{ + +/** + * @brief Per-(window, group) count of distinct timestamps in the assembled tgeo trajectory. + * + * Three-input (lon, lat, ts) tgeo aggregation. Lift accumulates the events + * into a paged vector; lower assembles the per-(window, group) trajectory + * and calls MEOS `temporal_num_timestamps` to fold it to a single scalar. + */ +class TemporalNumTimestampsAggregationLogicalFunction : public WindowAggregationLogicalFunction +{ +public: + static std::shared_ptr + create(const FieldAccessLogicalFunction& lonField, const FieldAccessLogicalFunction& latField, const FieldAccessLogicalFunction& timestampField); + + TemporalNumTimestampsAggregationLogicalFunction( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField); + + void inferStamp(const Schema& schema) override; + ~TemporalNumTimestampsAggregationLogicalFunction() override = default; + [[nodiscard]] NES::SerializableAggregationFunction serialize() const override; + [[nodiscard]] std::string_view getName() const noexcept override; + [[nodiscard]] bool requiresSequentialAggregation() const { return true; } + + [[nodiscard]] const FieldAccessLogicalFunction& getLonField() const noexcept { return lonField; } + [[nodiscard]] const FieldAccessLogicalFunction& getLatField() const noexcept { return latField; } + [[nodiscard]] const FieldAccessLogicalFunction& getTimestampField() const noexcept { return timestampField; } + +private: + static constexpr std::string_view NAME = "TemporalNumTimestamps"; + static constexpr DataType::Type partialAggregateStampType = DataType::Type::UNDEFINED; + static constexpr DataType::Type finalAggregateStampType = DataType::Type::INT32; + + FieldAccessLogicalFunction lonField; + FieldAccessLogicalFunction latField; + FieldAccessLogicalFunction timestampField; +}; +} diff --git a/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalStartTimestampAggregationLogicalFunction.hpp b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalStartTimestampAggregationLogicalFunction.hpp new file mode 100644 index 0000000000..bb4f329ba1 --- /dev/null +++ b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalStartTimestampAggregationLogicalFunction.hpp @@ -0,0 +1,60 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +namespace NES +{ + +/** + * @brief TimestampTz (MEOS μs-since-2000) of the first instant in the per-(window, group) tgeo trajectory. + * + * Three-input (lon, lat, ts) tgeo aggregation. Lift accumulates the events + * into a paged vector; lower assembles the per-(window, group) trajectory + * and calls MEOS `temporal_start_timestamptz` to fold it to a single scalar. + */ +class TemporalStartTimestampAggregationLogicalFunction : public WindowAggregationLogicalFunction +{ +public: + static std::shared_ptr + create(const FieldAccessLogicalFunction& lonField, const FieldAccessLogicalFunction& latField, const FieldAccessLogicalFunction& timestampField); + + TemporalStartTimestampAggregationLogicalFunction( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField); + + void inferStamp(const Schema& schema) override; + ~TemporalStartTimestampAggregationLogicalFunction() override = default; + [[nodiscard]] NES::SerializableAggregationFunction serialize() const override; + [[nodiscard]] std::string_view getName() const noexcept override; + [[nodiscard]] bool requiresSequentialAggregation() const { return true; } + + [[nodiscard]] const FieldAccessLogicalFunction& getLonField() const noexcept { return lonField; } + [[nodiscard]] const FieldAccessLogicalFunction& getLatField() const noexcept { return latField; } + [[nodiscard]] const FieldAccessLogicalFunction& getTimestampField() const noexcept { return timestampField; } + +private: + static constexpr std::string_view NAME = "TemporalStartTimestamp"; + static constexpr DataType::Type partialAggregateStampType = DataType::Type::UNDEFINED; + static constexpr DataType::Type finalAggregateStampType = DataType::Type::INT64; + + FieldAccessLogicalFunction lonField; + FieldAccessLogicalFunction latField; + FieldAccessLogicalFunction timestampField; +}; +} diff --git a/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTFloatAvgValueAggregationLogicalFunction.hpp b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTFloatAvgValueAggregationLogicalFunction.hpp new file mode 100644 index 0000000000..7ccfcf08cf --- /dev/null +++ b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTFloatAvgValueAggregationLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +namespace NES +{ + +/** + * @brief Arithmetic mean of all instant values in the per-(window, group) tfloat sequence. + * + * Two-input (value, ts) tnumber aggregation. Lift accumulates the events + * into a paged vector; lower assembles the per-(window, group) tnumber + * sequence and calls MEOS `tfloat_avg_value` to fold it to a single scalar. + */ +class TemporalTFloatAvgValueAggregationLogicalFunction : public WindowAggregationLogicalFunction +{ +public: + static std::shared_ptr + create(const FieldAccessLogicalFunction& valueField, const FieldAccessLogicalFunction& timestampField); + + TemporalTFloatAvgValueAggregationLogicalFunction( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField); + + void inferStamp(const Schema& schema) override; + ~TemporalTFloatAvgValueAggregationLogicalFunction() override = default; + [[nodiscard]] NES::SerializableAggregationFunction serialize() const override; + [[nodiscard]] std::string_view getName() const noexcept override; + [[nodiscard]] bool requiresSequentialAggregation() const { return true; } + + [[nodiscard]] const FieldAccessLogicalFunction& getValueField() const noexcept { return valueField; } + [[nodiscard]] const FieldAccessLogicalFunction& getTimestampField() const noexcept { return timestampField; } + +private: + static constexpr std::string_view NAME = "TemporalTFloatAvgValue"; + static constexpr DataType::Type partialAggregateStampType = DataType::Type::UNDEFINED; + static constexpr DataType::Type finalAggregateStampType = DataType::Type::FLOAT64; + + FieldAccessLogicalFunction valueField; + FieldAccessLogicalFunction timestampField; +}; +} diff --git a/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTFloatEndValueAggregationLogicalFunction.hpp b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTFloatEndValueAggregationLogicalFunction.hpp new file mode 100644 index 0000000000..0ae6b94884 --- /dev/null +++ b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTFloatEndValueAggregationLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +namespace NES +{ + +/** + * @brief Value at the last instant of the per-(window, group) tfloat sequence. + * + * Two-input (value, ts) tnumber aggregation. Lift accumulates the events + * into a paged vector; lower assembles the per-(window, group) tnumber + * sequence and calls MEOS `tfloat_end_value` to fold it to a single scalar. + */ +class TemporalTFloatEndValueAggregationLogicalFunction : public WindowAggregationLogicalFunction +{ +public: + static std::shared_ptr + create(const FieldAccessLogicalFunction& valueField, const FieldAccessLogicalFunction& timestampField); + + TemporalTFloatEndValueAggregationLogicalFunction( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField); + + void inferStamp(const Schema& schema) override; + ~TemporalTFloatEndValueAggregationLogicalFunction() override = default; + [[nodiscard]] NES::SerializableAggregationFunction serialize() const override; + [[nodiscard]] std::string_view getName() const noexcept override; + [[nodiscard]] bool requiresSequentialAggregation() const { return true; } + + [[nodiscard]] const FieldAccessLogicalFunction& getValueField() const noexcept { return valueField; } + [[nodiscard]] const FieldAccessLogicalFunction& getTimestampField() const noexcept { return timestampField; } + +private: + static constexpr std::string_view NAME = "TemporalTFloatEndValue"; + static constexpr DataType::Type partialAggregateStampType = DataType::Type::UNDEFINED; + static constexpr DataType::Type finalAggregateStampType = DataType::Type::FLOAT64; + + FieldAccessLogicalFunction valueField; + FieldAccessLogicalFunction timestampField; +}; +} diff --git a/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTFloatMaxValueAggregationLogicalFunction.hpp b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTFloatMaxValueAggregationLogicalFunction.hpp new file mode 100644 index 0000000000..89d95846f3 --- /dev/null +++ b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTFloatMaxValueAggregationLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +namespace NES +{ + +/** + * @brief Maximum value across instants of the per-(window, group) tfloat sequence. + * + * Two-input (value, ts) tnumber aggregation. Lift accumulates the events + * into a paged vector; lower assembles the per-(window, group) tnumber + * sequence and calls MEOS `tfloat_max_value` to fold it to a single scalar. + */ +class TemporalTFloatMaxValueAggregationLogicalFunction : public WindowAggregationLogicalFunction +{ +public: + static std::shared_ptr + create(const FieldAccessLogicalFunction& valueField, const FieldAccessLogicalFunction& timestampField); + + TemporalTFloatMaxValueAggregationLogicalFunction( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField); + + void inferStamp(const Schema& schema) override; + ~TemporalTFloatMaxValueAggregationLogicalFunction() override = default; + [[nodiscard]] NES::SerializableAggregationFunction serialize() const override; + [[nodiscard]] std::string_view getName() const noexcept override; + [[nodiscard]] bool requiresSequentialAggregation() const { return true; } + + [[nodiscard]] const FieldAccessLogicalFunction& getValueField() const noexcept { return valueField; } + [[nodiscard]] const FieldAccessLogicalFunction& getTimestampField() const noexcept { return timestampField; } + +private: + static constexpr std::string_view NAME = "TemporalTFloatMaxValue"; + static constexpr DataType::Type partialAggregateStampType = DataType::Type::UNDEFINED; + static constexpr DataType::Type finalAggregateStampType = DataType::Type::FLOAT64; + + FieldAccessLogicalFunction valueField; + FieldAccessLogicalFunction timestampField; +}; +} diff --git a/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTFloatMinValueAggregationLogicalFunction.hpp b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTFloatMinValueAggregationLogicalFunction.hpp new file mode 100644 index 0000000000..7dff67a09c --- /dev/null +++ b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTFloatMinValueAggregationLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +namespace NES +{ + +/** + * @brief Minimum value across instants of the per-(window, group) tfloat sequence. + * + * Two-input (value, ts) tnumber aggregation. Lift accumulates the events + * into a paged vector; lower assembles the per-(window, group) tnumber + * sequence and calls MEOS `tfloat_min_value` to fold it to a single scalar. + */ +class TemporalTFloatMinValueAggregationLogicalFunction : public WindowAggregationLogicalFunction +{ +public: + static std::shared_ptr + create(const FieldAccessLogicalFunction& valueField, const FieldAccessLogicalFunction& timestampField); + + TemporalTFloatMinValueAggregationLogicalFunction( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField); + + void inferStamp(const Schema& schema) override; + ~TemporalTFloatMinValueAggregationLogicalFunction() override = default; + [[nodiscard]] NES::SerializableAggregationFunction serialize() const override; + [[nodiscard]] std::string_view getName() const noexcept override; + [[nodiscard]] bool requiresSequentialAggregation() const { return true; } + + [[nodiscard]] const FieldAccessLogicalFunction& getValueField() const noexcept { return valueField; } + [[nodiscard]] const FieldAccessLogicalFunction& getTimestampField() const noexcept { return timestampField; } + +private: + static constexpr std::string_view NAME = "TemporalTFloatMinValue"; + static constexpr DataType::Type partialAggregateStampType = DataType::Type::UNDEFINED; + static constexpr DataType::Type finalAggregateStampType = DataType::Type::FLOAT64; + + FieldAccessLogicalFunction valueField; + FieldAccessLogicalFunction timestampField; +}; +} diff --git a/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTFloatStartValueAggregationLogicalFunction.hpp b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTFloatStartValueAggregationLogicalFunction.hpp new file mode 100644 index 0000000000..c297491191 --- /dev/null +++ b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTFloatStartValueAggregationLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +namespace NES +{ + +/** + * @brief Value at the first instant of the per-(window, group) tfloat sequence. + * + * Two-input (value, ts) tnumber aggregation. Lift accumulates the events + * into a paged vector; lower assembles the per-(window, group) tnumber + * sequence and calls MEOS `tfloat_start_value` to fold it to a single scalar. + */ +class TemporalTFloatStartValueAggregationLogicalFunction : public WindowAggregationLogicalFunction +{ +public: + static std::shared_ptr + create(const FieldAccessLogicalFunction& valueField, const FieldAccessLogicalFunction& timestampField); + + TemporalTFloatStartValueAggregationLogicalFunction( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField); + + void inferStamp(const Schema& schema) override; + ~TemporalTFloatStartValueAggregationLogicalFunction() override = default; + [[nodiscard]] NES::SerializableAggregationFunction serialize() const override; + [[nodiscard]] std::string_view getName() const noexcept override; + [[nodiscard]] bool requiresSequentialAggregation() const { return true; } + + [[nodiscard]] const FieldAccessLogicalFunction& getValueField() const noexcept { return valueField; } + [[nodiscard]] const FieldAccessLogicalFunction& getTimestampField() const noexcept { return timestampField; } + +private: + static constexpr std::string_view NAME = "TemporalTFloatStartValue"; + static constexpr DataType::Type partialAggregateStampType = DataType::Type::UNDEFINED; + static constexpr DataType::Type finalAggregateStampType = DataType::Type::FLOAT64; + + FieldAccessLogicalFunction valueField; + FieldAccessLogicalFunction timestampField; +}; +} diff --git a/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTIntAvgValueAggregationLogicalFunction.hpp b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTIntAvgValueAggregationLogicalFunction.hpp new file mode 100644 index 0000000000..4843237715 --- /dev/null +++ b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTIntAvgValueAggregationLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +namespace NES +{ + +/** + * @brief Arithmetic mean (as double) of all instant values in the per-(window, group) tint sequence. + * + * Two-input (value, ts) tnumber aggregation. Lift accumulates the events + * into a paged vector; lower assembles the per-(window, group) tnumber + * sequence and calls MEOS `tnumber_avg_value` to fold it to a single scalar. + */ +class TemporalTIntAvgValueAggregationLogicalFunction : public WindowAggregationLogicalFunction +{ +public: + static std::shared_ptr + create(const FieldAccessLogicalFunction& valueField, const FieldAccessLogicalFunction& timestampField); + + TemporalTIntAvgValueAggregationLogicalFunction( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField); + + void inferStamp(const Schema& schema) override; + ~TemporalTIntAvgValueAggregationLogicalFunction() override = default; + [[nodiscard]] NES::SerializableAggregationFunction serialize() const override; + [[nodiscard]] std::string_view getName() const noexcept override; + [[nodiscard]] bool requiresSequentialAggregation() const { return true; } + + [[nodiscard]] const FieldAccessLogicalFunction& getValueField() const noexcept { return valueField; } + [[nodiscard]] const FieldAccessLogicalFunction& getTimestampField() const noexcept { return timestampField; } + +private: + static constexpr std::string_view NAME = "TemporalTIntAvgValue"; + static constexpr DataType::Type partialAggregateStampType = DataType::Type::UNDEFINED; + static constexpr DataType::Type finalAggregateStampType = DataType::Type::FLOAT64; + + FieldAccessLogicalFunction valueField; + FieldAccessLogicalFunction timestampField; +}; +} diff --git a/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTIntEndValueAggregationLogicalFunction.hpp b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTIntEndValueAggregationLogicalFunction.hpp new file mode 100644 index 0000000000..9334823987 --- /dev/null +++ b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTIntEndValueAggregationLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +namespace NES +{ + +/** + * @brief Value at the last instant of the per-(window, group) tint sequence. + * + * Two-input (value, ts) tnumber aggregation. Lift accumulates the events + * into a paged vector; lower assembles the per-(window, group) tnumber + * sequence and calls MEOS `tint_end_value` to fold it to a single scalar. + */ +class TemporalTIntEndValueAggregationLogicalFunction : public WindowAggregationLogicalFunction +{ +public: + static std::shared_ptr + create(const FieldAccessLogicalFunction& valueField, const FieldAccessLogicalFunction& timestampField); + + TemporalTIntEndValueAggregationLogicalFunction( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField); + + void inferStamp(const Schema& schema) override; + ~TemporalTIntEndValueAggregationLogicalFunction() override = default; + [[nodiscard]] NES::SerializableAggregationFunction serialize() const override; + [[nodiscard]] std::string_view getName() const noexcept override; + [[nodiscard]] bool requiresSequentialAggregation() const { return true; } + + [[nodiscard]] const FieldAccessLogicalFunction& getValueField() const noexcept { return valueField; } + [[nodiscard]] const FieldAccessLogicalFunction& getTimestampField() const noexcept { return timestampField; } + +private: + static constexpr std::string_view NAME = "TemporalTIntEndValue"; + static constexpr DataType::Type partialAggregateStampType = DataType::Type::UNDEFINED; + static constexpr DataType::Type finalAggregateStampType = DataType::Type::INT32; + + FieldAccessLogicalFunction valueField; + FieldAccessLogicalFunction timestampField; +}; +} diff --git a/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTIntMaxValueAggregationLogicalFunction.hpp b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTIntMaxValueAggregationLogicalFunction.hpp new file mode 100644 index 0000000000..0864562b80 --- /dev/null +++ b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTIntMaxValueAggregationLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +namespace NES +{ + +/** + * @brief Maximum value across instants of the per-(window, group) tint sequence. + * + * Two-input (value, ts) tnumber aggregation. Lift accumulates the events + * into a paged vector; lower assembles the per-(window, group) tnumber + * sequence and calls MEOS `tint_max_value` to fold it to a single scalar. + */ +class TemporalTIntMaxValueAggregationLogicalFunction : public WindowAggregationLogicalFunction +{ +public: + static std::shared_ptr + create(const FieldAccessLogicalFunction& valueField, const FieldAccessLogicalFunction& timestampField); + + TemporalTIntMaxValueAggregationLogicalFunction( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField); + + void inferStamp(const Schema& schema) override; + ~TemporalTIntMaxValueAggregationLogicalFunction() override = default; + [[nodiscard]] NES::SerializableAggregationFunction serialize() const override; + [[nodiscard]] std::string_view getName() const noexcept override; + [[nodiscard]] bool requiresSequentialAggregation() const { return true; } + + [[nodiscard]] const FieldAccessLogicalFunction& getValueField() const noexcept { return valueField; } + [[nodiscard]] const FieldAccessLogicalFunction& getTimestampField() const noexcept { return timestampField; } + +private: + static constexpr std::string_view NAME = "TemporalTIntMaxValue"; + static constexpr DataType::Type partialAggregateStampType = DataType::Type::UNDEFINED; + static constexpr DataType::Type finalAggregateStampType = DataType::Type::INT32; + + FieldAccessLogicalFunction valueField; + FieldAccessLogicalFunction timestampField; +}; +} diff --git a/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTIntMinValueAggregationLogicalFunction.hpp b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTIntMinValueAggregationLogicalFunction.hpp new file mode 100644 index 0000000000..49756e9127 --- /dev/null +++ b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTIntMinValueAggregationLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +namespace NES +{ + +/** + * @brief Minimum value across instants of the per-(window, group) tint sequence. + * + * Two-input (value, ts) tnumber aggregation. Lift accumulates the events + * into a paged vector; lower assembles the per-(window, group) tnumber + * sequence and calls MEOS `tint_min_value` to fold it to a single scalar. + */ +class TemporalTIntMinValueAggregationLogicalFunction : public WindowAggregationLogicalFunction +{ +public: + static std::shared_ptr + create(const FieldAccessLogicalFunction& valueField, const FieldAccessLogicalFunction& timestampField); + + TemporalTIntMinValueAggregationLogicalFunction( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField); + + void inferStamp(const Schema& schema) override; + ~TemporalTIntMinValueAggregationLogicalFunction() override = default; + [[nodiscard]] NES::SerializableAggregationFunction serialize() const override; + [[nodiscard]] std::string_view getName() const noexcept override; + [[nodiscard]] bool requiresSequentialAggregation() const { return true; } + + [[nodiscard]] const FieldAccessLogicalFunction& getValueField() const noexcept { return valueField; } + [[nodiscard]] const FieldAccessLogicalFunction& getTimestampField() const noexcept { return timestampField; } + +private: + static constexpr std::string_view NAME = "TemporalTIntMinValue"; + static constexpr DataType::Type partialAggregateStampType = DataType::Type::UNDEFINED; + static constexpr DataType::Type finalAggregateStampType = DataType::Type::INT32; + + FieldAccessLogicalFunction valueField; + FieldAccessLogicalFunction timestampField; +}; +} diff --git a/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTIntStartValueAggregationLogicalFunction.hpp b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTIntStartValueAggregationLogicalFunction.hpp new file mode 100644 index 0000000000..686b062cce --- /dev/null +++ b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTIntStartValueAggregationLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +namespace NES +{ + +/** + * @brief Value at the first instant of the per-(window, group) tint sequence. + * + * Two-input (value, ts) tnumber aggregation. Lift accumulates the events + * into a paged vector; lower assembles the per-(window, group) tnumber + * sequence and calls MEOS `tint_start_value` to fold it to a single scalar. + */ +class TemporalTIntStartValueAggregationLogicalFunction : public WindowAggregationLogicalFunction +{ +public: + static std::shared_ptr + create(const FieldAccessLogicalFunction& valueField, const FieldAccessLogicalFunction& timestampField); + + TemporalTIntStartValueAggregationLogicalFunction( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField); + + void inferStamp(const Schema& schema) override; + ~TemporalTIntStartValueAggregationLogicalFunction() override = default; + [[nodiscard]] NES::SerializableAggregationFunction serialize() const override; + [[nodiscard]] std::string_view getName() const noexcept override; + [[nodiscard]] bool requiresSequentialAggregation() const { return true; } + + [[nodiscard]] const FieldAccessLogicalFunction& getValueField() const noexcept { return valueField; } + [[nodiscard]] const FieldAccessLogicalFunction& getTimestampField() const noexcept { return timestampField; } + +private: + static constexpr std::string_view NAME = "TemporalTIntStartValue"; + static constexpr DataType::Type partialAggregateStampType = DataType::Type::UNDEFINED; + static constexpr DataType::Type finalAggregateStampType = DataType::Type::INT32; + + FieldAccessLogicalFunction valueField; + FieldAccessLogicalFunction timestampField; +}; +} diff --git a/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTNumberIntegralAggregationLogicalFunction.hpp b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTNumberIntegralAggregationLogicalFunction.hpp new file mode 100644 index 0000000000..f536962786 --- /dev/null +++ b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTNumberIntegralAggregationLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +namespace NES +{ + +/** + * @brief Time-weighted integral (area under the value-vs-time curve) of the per-(window, group) tfloat sequence. + * + * Two-input (value, ts) tnumber aggregation. Lift accumulates the events + * into a paged vector; lower assembles the per-(window, group) tnumber + * sequence and calls MEOS `tnumber_integral` to fold it to a single scalar. + */ +class TemporalTNumberIntegralAggregationLogicalFunction : public WindowAggregationLogicalFunction +{ +public: + static std::shared_ptr + create(const FieldAccessLogicalFunction& valueField, const FieldAccessLogicalFunction& timestampField); + + TemporalTNumberIntegralAggregationLogicalFunction( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField); + + void inferStamp(const Schema& schema) override; + ~TemporalTNumberIntegralAggregationLogicalFunction() override = default; + [[nodiscard]] NES::SerializableAggregationFunction serialize() const override; + [[nodiscard]] std::string_view getName() const noexcept override; + [[nodiscard]] bool requiresSequentialAggregation() const { return true; } + + [[nodiscard]] const FieldAccessLogicalFunction& getValueField() const noexcept { return valueField; } + [[nodiscard]] const FieldAccessLogicalFunction& getTimestampField() const noexcept { return timestampField; } + +private: + static constexpr std::string_view NAME = "TemporalTNumberIntegral"; + static constexpr DataType::Type partialAggregateStampType = DataType::Type::UNDEFINED; + static constexpr DataType::Type finalAggregateStampType = DataType::Type::FLOAT64; + + FieldAccessLogicalFunction valueField; + FieldAccessLogicalFunction timestampField; +}; +} diff --git a/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTNumberTwAvgAggregationLogicalFunction.hpp b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTNumberTwAvgAggregationLogicalFunction.hpp new file mode 100644 index 0000000000..2b5c6aa3e7 --- /dev/null +++ b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTNumberTwAvgAggregationLogicalFunction.hpp @@ -0,0 +1,57 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +namespace NES +{ + +/** + * @brief Time-weighted average of values across the per-(window, group) tfloat sequence. + * + * Two-input (value, ts) tnumber aggregation. Lift accumulates the events + * into a paged vector; lower assembles the per-(window, group) tnumber + * sequence and calls MEOS `tnumber_twavg` to fold it to a single scalar. + */ +class TemporalTNumberTwAvgAggregationLogicalFunction : public WindowAggregationLogicalFunction +{ +public: + static std::shared_ptr + create(const FieldAccessLogicalFunction& valueField, const FieldAccessLogicalFunction& timestampField); + + TemporalTNumberTwAvgAggregationLogicalFunction( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField); + + void inferStamp(const Schema& schema) override; + ~TemporalTNumberTwAvgAggregationLogicalFunction() override = default; + [[nodiscard]] NES::SerializableAggregationFunction serialize() const override; + [[nodiscard]] std::string_view getName() const noexcept override; + [[nodiscard]] bool requiresSequentialAggregation() const { return true; } + + [[nodiscard]] const FieldAccessLogicalFunction& getValueField() const noexcept { return valueField; } + [[nodiscard]] const FieldAccessLogicalFunction& getTimestampField() const noexcept { return timestampField; } + +private: + static constexpr std::string_view NAME = "TemporalTNumberTwAvg"; + static constexpr DataType::Type partialAggregateStampType = DataType::Type::UNDEFINED; + static constexpr DataType::Type finalAggregateStampType = DataType::Type::FLOAT64; + + FieldAccessLogicalFunction valueField; + FieldAccessLogicalFunction timestampField; +}; +} diff --git a/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTPointIsSimpleAggregationLogicalFunction.hpp b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTPointIsSimpleAggregationLogicalFunction.hpp new file mode 100644 index 0000000000..07be63f5ff --- /dev/null +++ b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalTPointIsSimpleAggregationLogicalFunction.hpp @@ -0,0 +1,60 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +namespace NES +{ + +/** + * @brief True if the per-(window, group) tgeo trajectory does not self-intersect. + * + * Three-input (lon, lat, ts) tgeo aggregation. Lift accumulates the events + * into a paged vector; lower assembles the per-(window, group) trajectory + * and calls MEOS `tpoint_is_simple` to fold it to a single scalar. + */ +class TemporalTPointIsSimpleAggregationLogicalFunction : public WindowAggregationLogicalFunction +{ +public: + static std::shared_ptr + create(const FieldAccessLogicalFunction& lonField, const FieldAccessLogicalFunction& latField, const FieldAccessLogicalFunction& timestampField); + + TemporalTPointIsSimpleAggregationLogicalFunction( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField); + + void inferStamp(const Schema& schema) override; + ~TemporalTPointIsSimpleAggregationLogicalFunction() override = default; + [[nodiscard]] NES::SerializableAggregationFunction serialize() const override; + [[nodiscard]] std::string_view getName() const noexcept override; + [[nodiscard]] bool requiresSequentialAggregation() const { return true; } + + [[nodiscard]] const FieldAccessLogicalFunction& getLonField() const noexcept { return lonField; } + [[nodiscard]] const FieldAccessLogicalFunction& getLatField() const noexcept { return latField; } + [[nodiscard]] const FieldAccessLogicalFunction& getTimestampField() const noexcept { return timestampField; } + +private: + static constexpr std::string_view NAME = "TemporalTPointIsSimple"; + static constexpr DataType::Type partialAggregateStampType = DataType::Type::UNDEFINED; + static constexpr DataType::Type finalAggregateStampType = DataType::Type::BOOLEAN; + + FieldAccessLogicalFunction lonField; + FieldAccessLogicalFunction latField; + FieldAccessLogicalFunction timestampField; +}; +} diff --git a/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalUpperIncAggregationLogicalFunction.hpp b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalUpperIncAggregationLogicalFunction.hpp new file mode 100644 index 0000000000..e1ccea7b47 --- /dev/null +++ b/nes-logical-operators/include/Operators/Windows/Aggregations/Meos/TemporalUpperIncAggregationLogicalFunction.hpp @@ -0,0 +1,60 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +namespace NES +{ + +/** + * @brief True if the per-(window, group) tgeo trajectory's upper period bound is inclusive. + * + * Three-input (lon, lat, ts) tgeo aggregation. Lift accumulates the events + * into a paged vector; lower assembles the per-(window, group) trajectory + * and calls MEOS `temporal_upper_inc` to fold it to a single scalar. + */ +class TemporalUpperIncAggregationLogicalFunction : public WindowAggregationLogicalFunction +{ +public: + static std::shared_ptr + create(const FieldAccessLogicalFunction& lonField, const FieldAccessLogicalFunction& latField, const FieldAccessLogicalFunction& timestampField); + + TemporalUpperIncAggregationLogicalFunction( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField); + + void inferStamp(const Schema& schema) override; + ~TemporalUpperIncAggregationLogicalFunction() override = default; + [[nodiscard]] NES::SerializableAggregationFunction serialize() const override; + [[nodiscard]] std::string_view getName() const noexcept override; + [[nodiscard]] bool requiresSequentialAggregation() const { return true; } + + [[nodiscard]] const FieldAccessLogicalFunction& getLonField() const noexcept { return lonField; } + [[nodiscard]] const FieldAccessLogicalFunction& getLatField() const noexcept { return latField; } + [[nodiscard]] const FieldAccessLogicalFunction& getTimestampField() const noexcept { return timestampField; } + +private: + static constexpr std::string_view NAME = "TemporalUpperInc"; + static constexpr DataType::Type partialAggregateStampType = DataType::Type::UNDEFINED; + static constexpr DataType::Type finalAggregateStampType = DataType::Type::BOOLEAN; + + FieldAccessLogicalFunction lonField; + FieldAccessLogicalFunction latField; + FieldAccessLogicalFunction timestampField; +}; +} diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 474ba11608..0c75c58715 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -18,3 +18,98 @@ add_plugin(TemporalAIntersectsGeometry LogicalFunction nes-logical-operators Tem add_plugin(TemporalEContainsGeometry LogicalFunction nes-logical-operators TemporalEContainsGeometryLogicalFunction.cpp) add_plugin(TemporalEDWithinGeometry LogicalFunction nes-logical-operators TemporalEDWithinGeometryLogicalFunction.cpp) add_plugin(TemporalAtStBox LogicalFunction nes-logical-operators TemporalAtStBoxLogicalFunction.cpp) +add_plugin(TemporalEDisjointGeometry LogicalFunction nes-logical-operators TemporalEDisjointGeometryLogicalFunction.cpp) +add_plugin(TemporalATouchesGeometry LogicalFunction nes-logical-operators TemporalATouchesGeometryLogicalFunction.cpp) +add_plugin(TemporalECoversGeometry LogicalFunction nes-logical-operators TemporalECoversGeometryLogicalFunction.cpp) +add_plugin(TemporalAContainsGeometry LogicalFunction nes-logical-operators TemporalAContainsGeometryLogicalFunction.cpp) +add_plugin(TemporalETouchesGeometry LogicalFunction nes-logical-operators TemporalETouchesGeometryLogicalFunction.cpp) +add_plugin(TemporalADisjointGeometry LogicalFunction nes-logical-operators TemporalADisjointGeometryLogicalFunction.cpp) +add_plugin(TemporalEIntersectsGeometry LogicalFunction nes-logical-operators TemporalEIntersectsGeometryLogicalFunction.cpp) +add_plugin(TemporalEContainsTGeometry LogicalFunction nes-logical-operators TemporalEContainsTGeometryLogicalFunction.cpp) +add_plugin(TemporalECoversTGeometry LogicalFunction nes-logical-operators TemporalECoversTGeometryLogicalFunction.cpp) +add_plugin(TemporalEDisjointTGeometry LogicalFunction nes-logical-operators TemporalEDisjointTGeometryLogicalFunction.cpp) +add_plugin(TemporalEIntersectsTGeometry LogicalFunction nes-logical-operators TemporalEIntersectsTGeometryLogicalFunction.cpp) +add_plugin(TemporalETouchesTGeometry LogicalFunction nes-logical-operators TemporalETouchesTGeometryLogicalFunction.cpp) +add_plugin(TemporalAContainsTGeometry LogicalFunction nes-logical-operators TemporalAContainsTGeometryLogicalFunction.cpp) +add_plugin(TemporalADisjointTGeometry LogicalFunction nes-logical-operators TemporalADisjointTGeometryLogicalFunction.cpp) +add_plugin(TemporalAIntersectsTGeometry LogicalFunction nes-logical-operators TemporalAIntersectsTGeometryLogicalFunction.cpp) +add_plugin(TemporalATouchesTGeometry LogicalFunction nes-logical-operators TemporalATouchesTGeometryLogicalFunction.cpp) +add_plugin(TemporalNADGeometry LogicalFunction nes-logical-operators TemporalNADGeometryLogicalFunction.cpp) +add_plugin(TemporalNADTGeometry LogicalFunction nes-logical-operators TemporalNADTGeometryLogicalFunction.cpp) +add_plugin(TemporalEDWithinTGeometry LogicalFunction nes-logical-operators TemporalEDWithinTGeometryLogicalFunction.cpp) +add_plugin(TemporalADWithinGeometry LogicalFunction nes-logical-operators TemporalADWithinGeometryLogicalFunction.cpp) +add_plugin(TemporalADWithinTGeometry LogicalFunction nes-logical-operators TemporalADWithinTGeometryLogicalFunction.cpp) +add_plugin(TemporalNADFloatScalar LogicalFunction nes-logical-operators TemporalNADFloatScalarLogicalFunction.cpp) +add_plugin(TemporalNADIntScalar LogicalFunction nes-logical-operators TemporalNADIntScalarLogicalFunction.cpp) +add_plugin(TemporalNADTFloat LogicalFunction nes-logical-operators TemporalNADTFloatLogicalFunction.cpp) +add_plugin(TemporalNADTInt LogicalFunction nes-logical-operators TemporalNADTIntLogicalFunction.cpp) +add_plugin(TemporalAtGeometry LogicalFunction nes-logical-operators TemporalAtGeometryLogicalFunction.cpp) +add_plugin(TemporalMinusGeometry LogicalFunction nes-logical-operators TemporalMinusGeometryLogicalFunction.cpp) +add_plugin(TemporalEContainsTCbuffer LogicalFunction nes-logical-operators TemporalEContainsTCbufferLogicalFunction.cpp) +add_plugin(TemporalECoversTCbuffer LogicalFunction nes-logical-operators TemporalECoversTCbufferLogicalFunction.cpp) +add_plugin(TemporalEDisjointTCbuffer LogicalFunction nes-logical-operators TemporalEDisjointTCbufferLogicalFunction.cpp) +add_plugin(TemporalEIntersectsTCbuffer LogicalFunction nes-logical-operators TemporalEIntersectsTCbufferLogicalFunction.cpp) +add_plugin(TemporalETouchesTCbuffer LogicalFunction nes-logical-operators TemporalETouchesTCbufferLogicalFunction.cpp) +add_plugin(TemporalAContainsTCbuffer LogicalFunction nes-logical-operators TemporalAContainsTCbufferLogicalFunction.cpp) +add_plugin(TemporalACoversTCbuffer LogicalFunction nes-logical-operators TemporalACoversTCbufferLogicalFunction.cpp) +add_plugin(TemporalADisjointTCbuffer LogicalFunction nes-logical-operators TemporalADisjointTCbufferLogicalFunction.cpp) +add_plugin(TemporalAIntersectsTCbuffer LogicalFunction nes-logical-operators TemporalAIntersectsTCbufferLogicalFunction.cpp) +add_plugin(TemporalATouchesTCbuffer LogicalFunction nes-logical-operators TemporalATouchesTCbufferLogicalFunction.cpp) +add_plugin(TemporalEContainsTCbufferCbuffer LogicalFunction nes-logical-operators TemporalEContainsTCbufferCbufferLogicalFunction.cpp) +add_plugin(TemporalECoversTCbufferCbuffer LogicalFunction nes-logical-operators TemporalECoversTCbufferCbufferLogicalFunction.cpp) +add_plugin(TemporalEDisjointTCbufferCbuffer LogicalFunction nes-logical-operators TemporalEDisjointTCbufferCbufferLogicalFunction.cpp) +add_plugin(TemporalEIntersectsTCbufferCbuffer LogicalFunction nes-logical-operators TemporalEIntersectsTCbufferCbufferLogicalFunction.cpp) +add_plugin(TemporalETouchesTCbufferCbuffer LogicalFunction nes-logical-operators TemporalETouchesTCbufferCbufferLogicalFunction.cpp) +add_plugin(TemporalAContainsTCbufferCbuffer LogicalFunction nes-logical-operators TemporalAContainsTCbufferCbufferLogicalFunction.cpp) +add_plugin(TemporalACoversTCbufferCbuffer LogicalFunction nes-logical-operators TemporalACoversTCbufferCbufferLogicalFunction.cpp) +add_plugin(TemporalADisjointTCbufferCbuffer LogicalFunction nes-logical-operators TemporalADisjointTCbufferCbufferLogicalFunction.cpp) +add_plugin(TemporalAIntersectsTCbufferCbuffer LogicalFunction nes-logical-operators TemporalAIntersectsTCbufferCbufferLogicalFunction.cpp) +add_plugin(TemporalATouchesTCbufferCbuffer LogicalFunction nes-logical-operators TemporalATouchesTCbufferCbufferLogicalFunction.cpp) +add_plugin(TemporalADisjointTCbufferTCbuffer LogicalFunction nes-logical-operators TemporalADisjointTCbufferTCbufferLogicalFunction.cpp) +add_plugin(TemporalAIntersectsTCbufferTCbuffer LogicalFunction nes-logical-operators TemporalAIntersectsTCbufferTCbufferLogicalFunction.cpp) +add_plugin(TemporalATouchesTCbufferTCbuffer LogicalFunction nes-logical-operators TemporalATouchesTCbufferTCbufferLogicalFunction.cpp) +add_plugin(TemporalECoversTCbufferTCbuffer LogicalFunction nes-logical-operators TemporalECoversTCbufferTCbufferLogicalFunction.cpp) +add_plugin(TemporalEIntersectsTCbufferTCbuffer LogicalFunction nes-logical-operators TemporalEIntersectsTCbufferTCbufferLogicalFunction.cpp) +add_plugin(TemporalETouchesTCbufferTCbuffer LogicalFunction nes-logical-operators TemporalETouchesTCbufferTCbufferLogicalFunction.cpp) +add_plugin(TemporalEDWithinTCbufferGeometry LogicalFunction nes-logical-operators TemporalEDWithinTCbufferGeometryLogicalFunction.cpp) +add_plugin(TemporalADWithinTCbufferGeometry LogicalFunction nes-logical-operators TemporalADWithinTCbufferGeometryLogicalFunction.cpp) +add_plugin(TemporalEDWithinTCbufferCbuffer LogicalFunction nes-logical-operators TemporalEDWithinTCbufferCbufferLogicalFunction.cpp) +add_plugin(TemporalADWithinTCbufferCbuffer LogicalFunction nes-logical-operators TemporalADWithinTCbufferCbufferLogicalFunction.cpp) +add_plugin(TemporalEDWithinTCbufferTCbuffer LogicalFunction nes-logical-operators TemporalEDWithinTCbufferTCbufferLogicalFunction.cpp) +add_plugin(TemporalADWithinTCbufferTCbuffer LogicalFunction nes-logical-operators TemporalADWithinTCbufferTCbufferLogicalFunction.cpp) +add_plugin(TemporalEContainsTPoseGeometry LogicalFunction nes-logical-operators TemporalEContainsTPoseGeometryLogicalFunction.cpp) +add_plugin(TemporalECoversTPoseGeometry LogicalFunction nes-logical-operators TemporalECoversTPoseGeometryLogicalFunction.cpp) +add_plugin(TemporalEDisjointTPoseGeometry LogicalFunction nes-logical-operators TemporalEDisjointTPoseGeometryLogicalFunction.cpp) +add_plugin(TemporalEIntersectsTPoseGeometry LogicalFunction nes-logical-operators TemporalEIntersectsTPoseGeometryLogicalFunction.cpp) +add_plugin(TemporalETouchesTPoseGeometry LogicalFunction nes-logical-operators TemporalETouchesTPoseGeometryLogicalFunction.cpp) +add_plugin(TemporalAContainsTPoseGeometry LogicalFunction nes-logical-operators TemporalAContainsTPoseGeometryLogicalFunction.cpp) +add_plugin(TemporalADisjointTPoseGeometry LogicalFunction nes-logical-operators TemporalADisjointTPoseGeometryLogicalFunction.cpp) +add_plugin(TemporalAIntersectsTPoseGeometry LogicalFunction nes-logical-operators TemporalAIntersectsTPoseGeometryLogicalFunction.cpp) +add_plugin(TemporalATouchesTPoseGeometry LogicalFunction nes-logical-operators TemporalATouchesTPoseGeometryLogicalFunction.cpp) +add_plugin(TemporalEContainsTPoseTPose LogicalFunction nes-logical-operators TemporalEContainsTPoseTPoseLogicalFunction.cpp) +add_plugin(TemporalECoversTPoseTPose LogicalFunction nes-logical-operators TemporalECoversTPoseTPoseLogicalFunction.cpp) +add_plugin(TemporalEDisjointTPoseTPose LogicalFunction nes-logical-operators TemporalEDisjointTPoseTPoseLogicalFunction.cpp) +add_plugin(TemporalEIntersectsTPoseTPose LogicalFunction nes-logical-operators TemporalEIntersectsTPoseTPoseLogicalFunction.cpp) +add_plugin(TemporalETouchesTPoseTPose LogicalFunction nes-logical-operators TemporalETouchesTPoseTPoseLogicalFunction.cpp) +add_plugin(TemporalAContainsTPoseTPose LogicalFunction nes-logical-operators TemporalAContainsTPoseTPoseLogicalFunction.cpp) +add_plugin(TemporalADisjointTPoseTPose LogicalFunction nes-logical-operators TemporalADisjointTPoseTPoseLogicalFunction.cpp) +add_plugin(TemporalAIntersectsTPoseTPose LogicalFunction nes-logical-operators TemporalAIntersectsTPoseTPoseLogicalFunction.cpp) +add_plugin(TemporalATouchesTPoseTPose LogicalFunction nes-logical-operators TemporalATouchesTPoseTPoseLogicalFunction.cpp) +add_plugin(TemporalEContainsTNpointGeometry LogicalFunction nes-logical-operators TemporalEContainsTNpointGeometryLogicalFunction.cpp) +add_plugin(TemporalEContainsTNpointTNpoint LogicalFunction nes-logical-operators TemporalEContainsTNpointTNpointLogicalFunction.cpp) +add_plugin(TemporalECoversTNpointGeometry LogicalFunction nes-logical-operators TemporalECoversTNpointGeometryLogicalFunction.cpp) +add_plugin(TemporalECoversTNpointTNpoint LogicalFunction nes-logical-operators TemporalECoversTNpointTNpointLogicalFunction.cpp) +add_plugin(TemporalEDisjointTNpointGeometry LogicalFunction nes-logical-operators TemporalEDisjointTNpointGeometryLogicalFunction.cpp) +add_plugin(TemporalEDisjointTNpointTNpoint LogicalFunction nes-logical-operators TemporalEDisjointTNpointTNpointLogicalFunction.cpp) +add_plugin(TemporalEIntersectsTNpointGeometry LogicalFunction nes-logical-operators TemporalEIntersectsTNpointGeometryLogicalFunction.cpp) +add_plugin(TemporalEIntersectsTNpointTNpoint LogicalFunction nes-logical-operators TemporalEIntersectsTNpointTNpointLogicalFunction.cpp) +add_plugin(TemporalETouchesTNpointGeometry LogicalFunction nes-logical-operators TemporalETouchesTNpointGeometryLogicalFunction.cpp) +add_plugin(TemporalETouchesTNpointTNpoint LogicalFunction nes-logical-operators TemporalETouchesTNpointTNpointLogicalFunction.cpp) +add_plugin(TemporalAContainsTNpointGeometry LogicalFunction nes-logical-operators TemporalAContainsTNpointGeometryLogicalFunction.cpp) +add_plugin(TemporalAContainsTNpointTNpoint LogicalFunction nes-logical-operators TemporalAContainsTNpointTNpointLogicalFunction.cpp) +add_plugin(TemporalADisjointTNpointGeometry LogicalFunction nes-logical-operators TemporalADisjointTNpointGeometryLogicalFunction.cpp) +add_plugin(TemporalADisjointTNpointTNpoint LogicalFunction nes-logical-operators TemporalADisjointTNpointTNpointLogicalFunction.cpp) +add_plugin(TemporalAIntersectsTNpointGeometry LogicalFunction nes-logical-operators TemporalAIntersectsTNpointGeometryLogicalFunction.cpp) +add_plugin(TemporalAIntersectsTNpointTNpoint LogicalFunction nes-logical-operators TemporalAIntersectsTNpointTNpointLogicalFunction.cpp) +add_plugin(TemporalATouchesTNpointGeometry LogicalFunction nes-logical-operators TemporalATouchesTNpointGeometryLogicalFunction.cpp) +add_plugin(TemporalATouchesTNpointTNpoint LogicalFunction nes-logical-operators TemporalATouchesTNpointTNpointLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/TemporalAContainsGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalAContainsGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..9a8c15f5a3 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalAContainsGeometryLogicalFunction.cpp @@ -0,0 +1,131 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalAContainsGeometryLogicalFunction::TemporalAContainsGeometryLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(4); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalAContainsGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalAContainsGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalAContainsGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalAContainsGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, "TemporalAContainsGeometryLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalAContainsGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalAContainsGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalAContainsGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalAContainsGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalAContainsGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalAContainsGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "TemporalAContainsGeometryLogicalFunction requires 4 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + return TemporalAContainsGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalAContainsTCbufferCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalAContainsTCbufferCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..2da42f0ade --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalAContainsTCbufferCbufferLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalAContainsTCbufferCbufferLogicalFunction::TemporalAContainsTCbufferCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction cbufferLit) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(cbufferLit)); +} + +DataType TemporalAContainsTCbufferCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalAContainsTCbufferCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalAContainsTCbufferCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalAContainsTCbufferCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalAContainsTCbufferCbufferLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalAContainsTCbufferCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalAContainsTCbufferCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalAContainsTCbufferCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalAContainsTCbufferCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalAContainsTCbufferCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalAContainsTCbufferCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalAContainsTCbufferCbufferLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalAContainsTCbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalAContainsTCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalAContainsTCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..6f68820e93 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalAContainsTCbufferLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalAContainsTCbufferLogicalFunction::TemporalAContainsTCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalAContainsTCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalAContainsTCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalAContainsTCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalAContainsTCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalAContainsTCbufferLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalAContainsTCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalAContainsTCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalAContainsTCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalAContainsTCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalAContainsTCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalAContainsTCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalAContainsTCbufferLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalAContainsTCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalAContainsTGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalAContainsTGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..4d06e3ee93 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalAContainsTGeometryLogicalFunction.cpp @@ -0,0 +1,137 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalAContainsTGeometryLogicalFunction::TemporalAContainsTGeometryLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lonA)); + parameters.push_back(std::move(latA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(lonB)); + parameters.push_back(std::move(latB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalAContainsTGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalAContainsTGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalAContainsTGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalAContainsTGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, "TemporalAContainsTGeometryLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalAContainsTGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalAContainsTGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalAContainsTGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalAContainsTGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalAContainsTGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalAContainsTGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "TemporalAContainsTGeometryLogicalFunction requires 6 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + return TemporalAContainsTGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalAContainsTNpointGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalAContainsTNpointGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..dba3ab64a2 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalAContainsTNpointGeometryLogicalFunction.cpp @@ -0,0 +1,131 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalAContainsTNpointGeometryLogicalFunction::TemporalAContainsTNpointGeometryLogicalFunction(LogicalFunction rid, + LogicalFunction fraction, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(4); + parameters.push_back(std::move(rid)); + parameters.push_back(std::move(fraction)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalAContainsTNpointGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalAContainsTNpointGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalAContainsTNpointGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalAContainsTNpointGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, "TemporalAContainsTNpointGeometryLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalAContainsTNpointGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalAContainsTNpointGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalAContainsTNpointGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalAContainsTNpointGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalAContainsTNpointGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalAContainsTNpointGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "TemporalAContainsTNpointGeometryLogicalFunction requires 4 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + return TemporalAContainsTNpointGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalAContainsTNpointTNpointLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalAContainsTNpointTNpointLogicalFunction.cpp new file mode 100644 index 0000000000..cdfed10b7b --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalAContainsTNpointTNpointLogicalFunction.cpp @@ -0,0 +1,137 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalAContainsTNpointTNpointLogicalFunction::TemporalAContainsTNpointTNpointLogicalFunction(LogicalFunction ridA, + LogicalFunction fractionA, + LogicalFunction tsA, + LogicalFunction ridB, + LogicalFunction fractionB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(6); + parameters.push_back(std::move(ridA)); + parameters.push_back(std::move(fractionA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(ridB)); + parameters.push_back(std::move(fractionB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalAContainsTNpointTNpointLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalAContainsTNpointTNpointLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalAContainsTNpointTNpointLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalAContainsTNpointTNpointLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, "TemporalAContainsTNpointTNpointLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalAContainsTNpointTNpointLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalAContainsTNpointTNpointLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalAContainsTNpointTNpointLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalAContainsTNpointTNpointLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalAContainsTNpointTNpointLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalAContainsTNpointTNpointLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "TemporalAContainsTNpointTNpointLogicalFunction requires 6 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + return TemporalAContainsTNpointTNpointLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalAContainsTPoseGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalAContainsTPoseGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..a6f30574fd --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalAContainsTPoseGeometryLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalAContainsTPoseGeometryLogicalFunction::TemporalAContainsTPoseGeometryLogicalFunction(LogicalFunction x, + LogicalFunction y, + LogicalFunction theta, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalAContainsTPoseGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalAContainsTPoseGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalAContainsTPoseGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalAContainsTPoseGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalAContainsTPoseGeometryLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalAContainsTPoseGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalAContainsTPoseGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalAContainsTPoseGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalAContainsTPoseGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalAContainsTPoseGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalAContainsTPoseGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalAContainsTPoseGeometryLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalAContainsTPoseGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalAContainsTPoseTPoseLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalAContainsTPoseTPoseLogicalFunction.cpp new file mode 100644 index 0000000000..5e9e42c95d --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalAContainsTPoseTPoseLogicalFunction.cpp @@ -0,0 +1,143 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalAContainsTPoseTPoseLogicalFunction::TemporalAContainsTPoseTPoseLogicalFunction(LogicalFunction xA, + LogicalFunction yA, + LogicalFunction thetaA, + LogicalFunction tsA, + LogicalFunction xB, + LogicalFunction yB, + LogicalFunction thetaB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(8); + parameters.push_back(std::move(xA)); + parameters.push_back(std::move(yA)); + parameters.push_back(std::move(thetaA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(xB)); + parameters.push_back(std::move(yB)); + parameters.push_back(std::move(thetaB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalAContainsTPoseTPoseLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalAContainsTPoseTPoseLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalAContainsTPoseTPoseLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalAContainsTPoseTPoseLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, "TemporalAContainsTPoseTPoseLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalAContainsTPoseTPoseLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalAContainsTPoseTPoseLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalAContainsTPoseTPoseLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalAContainsTPoseTPoseLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalAContainsTPoseTPoseLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalAContainsTPoseTPoseLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "TemporalAContainsTPoseTPoseLogicalFunction requires 8 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + auto arg6 = std::move(arguments.children[6]); + auto arg7 = std::move(arguments.children[7]); + return TemporalAContainsTPoseTPoseLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalACoversTCbufferCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalACoversTCbufferCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..0d0124fbdc --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalACoversTCbufferCbufferLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalACoversTCbufferCbufferLogicalFunction::TemporalACoversTCbufferCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction cbufferLit) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(cbufferLit)); +} + +DataType TemporalACoversTCbufferCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalACoversTCbufferCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalACoversTCbufferCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalACoversTCbufferCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalACoversTCbufferCbufferLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalACoversTCbufferCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalACoversTCbufferCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalACoversTCbufferCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalACoversTCbufferCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalACoversTCbufferCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalACoversTCbufferCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalACoversTCbufferCbufferLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalACoversTCbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalACoversTCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalACoversTCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..318be3f43f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalACoversTCbufferLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalACoversTCbufferLogicalFunction::TemporalACoversTCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalACoversTCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalACoversTCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalACoversTCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalACoversTCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalACoversTCbufferLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalACoversTCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalACoversTCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalACoversTCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalACoversTCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalACoversTCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalACoversTCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalACoversTCbufferLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalACoversTCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalADWithinGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalADWithinGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..82cf67f471 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalADWithinGeometryLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalADWithinGeometryLogicalFunction::TemporalADWithinGeometryLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction timestamp, + LogicalFunction geometry, + LogicalFunction dist) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); + parameters.push_back(std::move(dist)); +} + +DataType TemporalADWithinGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalADWithinGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalADWithinGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalADWithinGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalADWithinGeometryLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalADWithinGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalADWithinGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalADWithinGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalADWithinGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalADWithinGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalADWithinGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalADWithinGeometryLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalADWithinGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalADWithinTCbufferCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalADWithinTCbufferCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..a998242c29 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalADWithinTCbufferCbufferLogicalFunction.cpp @@ -0,0 +1,137 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalADWithinTCbufferCbufferLogicalFunction::TemporalADWithinTCbufferCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction cbufferLit, + LogicalFunction dist) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(cbufferLit)); + parameters.push_back(std::move(dist)); +} + +DataType TemporalADWithinTCbufferCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalADWithinTCbufferCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalADWithinTCbufferCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalADWithinTCbufferCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, "TemporalADWithinTCbufferCbufferLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalADWithinTCbufferCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalADWithinTCbufferCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalADWithinTCbufferCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalADWithinTCbufferCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalADWithinTCbufferCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalADWithinTCbufferCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "TemporalADWithinTCbufferCbufferLogicalFunction requires 6 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + return TemporalADWithinTCbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalADWithinTCbufferGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalADWithinTCbufferGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..d9845de832 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalADWithinTCbufferGeometryLogicalFunction.cpp @@ -0,0 +1,137 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalADWithinTCbufferGeometryLogicalFunction::TemporalADWithinTCbufferGeometryLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction geometry, + LogicalFunction dist) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); + parameters.push_back(std::move(dist)); +} + +DataType TemporalADWithinTCbufferGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalADWithinTCbufferGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalADWithinTCbufferGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalADWithinTCbufferGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, "TemporalADWithinTCbufferGeometryLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalADWithinTCbufferGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalADWithinTCbufferGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalADWithinTCbufferGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalADWithinTCbufferGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalADWithinTCbufferGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalADWithinTCbufferGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "TemporalADWithinTCbufferGeometryLogicalFunction requires 6 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + return TemporalADWithinTCbufferGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalADWithinTCbufferTCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalADWithinTCbufferTCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..edbe1be762 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalADWithinTCbufferTCbufferLogicalFunction.cpp @@ -0,0 +1,146 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalADWithinTCbufferTCbufferLogicalFunction::TemporalADWithinTCbufferTCbufferLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction radiusA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction radiusB, + LogicalFunction tsB, + LogicalFunction dist) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(9); + parameters.push_back(std::move(lonA)); + parameters.push_back(std::move(latA)); + parameters.push_back(std::move(radiusA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(lonB)); + parameters.push_back(std::move(latB)); + parameters.push_back(std::move(radiusB)); + parameters.push_back(std::move(tsB)); + parameters.push_back(std::move(dist)); +} + +DataType TemporalADWithinTCbufferTCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalADWithinTCbufferTCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalADWithinTCbufferTCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalADWithinTCbufferTCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 9, "TemporalADWithinTCbufferTCbufferLogicalFunction requires 9 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalADWithinTCbufferTCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalADWithinTCbufferTCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalADWithinTCbufferTCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalADWithinTCbufferTCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalADWithinTCbufferTCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalADWithinTCbufferTCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 9, + "TemporalADWithinTCbufferTCbufferLogicalFunction requires 9 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + auto arg6 = std::move(arguments.children[6]); + auto arg7 = std::move(arguments.children[7]); + auto arg8 = std::move(arguments.children[8]); + return TemporalADWithinTCbufferTCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7), std::move(arg8)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalADWithinTGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalADWithinTGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..52cbdbb012 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalADWithinTGeometryLogicalFunction.cpp @@ -0,0 +1,140 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalADWithinTGeometryLogicalFunction::TemporalADWithinTGeometryLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction tsB, + LogicalFunction dist) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(7); + parameters.push_back(std::move(lonA)); + parameters.push_back(std::move(latA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(lonB)); + parameters.push_back(std::move(latB)); + parameters.push_back(std::move(tsB)); + parameters.push_back(std::move(dist)); +} + +DataType TemporalADWithinTGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalADWithinTGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalADWithinTGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalADWithinTGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, "TemporalADWithinTGeometryLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalADWithinTGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalADWithinTGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalADWithinTGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalADWithinTGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalADWithinTGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalADWithinTGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "TemporalADWithinTGeometryLogicalFunction requires 7 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + auto arg6 = std::move(arguments.children[6]); + return TemporalADWithinTGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalADisjointGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalADisjointGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..009c4e88fe --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalADisjointGeometryLogicalFunction.cpp @@ -0,0 +1,131 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalADisjointGeometryLogicalFunction::TemporalADisjointGeometryLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(4); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalADisjointGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalADisjointGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalADisjointGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalADisjointGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, "TemporalADisjointGeometryLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalADisjointGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalADisjointGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalADisjointGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalADisjointGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalADisjointGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalADisjointGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "TemporalADisjointGeometryLogicalFunction requires 4 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + return TemporalADisjointGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalADisjointTCbufferCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalADisjointTCbufferCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..acc246bdd7 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalADisjointTCbufferCbufferLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalADisjointTCbufferCbufferLogicalFunction::TemporalADisjointTCbufferCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction cbufferLit) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(cbufferLit)); +} + +DataType TemporalADisjointTCbufferCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalADisjointTCbufferCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalADisjointTCbufferCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalADisjointTCbufferCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalADisjointTCbufferCbufferLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalADisjointTCbufferCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalADisjointTCbufferCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalADisjointTCbufferCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalADisjointTCbufferCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalADisjointTCbufferCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalADisjointTCbufferCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalADisjointTCbufferCbufferLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalADisjointTCbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalADisjointTCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalADisjointTCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..55f4e95f0e --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalADisjointTCbufferLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalADisjointTCbufferLogicalFunction::TemporalADisjointTCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalADisjointTCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalADisjointTCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalADisjointTCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalADisjointTCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalADisjointTCbufferLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalADisjointTCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalADisjointTCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalADisjointTCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalADisjointTCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalADisjointTCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalADisjointTCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalADisjointTCbufferLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalADisjointTCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalADisjointTCbufferTCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalADisjointTCbufferTCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..8f4ab3c01c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalADisjointTCbufferTCbufferLogicalFunction.cpp @@ -0,0 +1,143 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalADisjointTCbufferTCbufferLogicalFunction::TemporalADisjointTCbufferTCbufferLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction radiusA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction radiusB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(8); + parameters.push_back(std::move(lonA)); + parameters.push_back(std::move(latA)); + parameters.push_back(std::move(radiusA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(lonB)); + parameters.push_back(std::move(latB)); + parameters.push_back(std::move(radiusB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalADisjointTCbufferTCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalADisjointTCbufferTCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalADisjointTCbufferTCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalADisjointTCbufferTCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, "TemporalADisjointTCbufferTCbufferLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalADisjointTCbufferTCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalADisjointTCbufferTCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalADisjointTCbufferTCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalADisjointTCbufferTCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalADisjointTCbufferTCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalADisjointTCbufferTCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "TemporalADisjointTCbufferTCbufferLogicalFunction requires 8 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + auto arg6 = std::move(arguments.children[6]); + auto arg7 = std::move(arguments.children[7]); + return TemporalADisjointTCbufferTCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalADisjointTGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalADisjointTGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..7dddd831d5 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalADisjointTGeometryLogicalFunction.cpp @@ -0,0 +1,137 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalADisjointTGeometryLogicalFunction::TemporalADisjointTGeometryLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lonA)); + parameters.push_back(std::move(latA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(lonB)); + parameters.push_back(std::move(latB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalADisjointTGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalADisjointTGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalADisjointTGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalADisjointTGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, "TemporalADisjointTGeometryLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalADisjointTGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalADisjointTGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalADisjointTGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalADisjointTGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalADisjointTGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalADisjointTGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "TemporalADisjointTGeometryLogicalFunction requires 6 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + return TemporalADisjointTGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalADisjointTNpointGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalADisjointTNpointGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..5173527fd2 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalADisjointTNpointGeometryLogicalFunction.cpp @@ -0,0 +1,131 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalADisjointTNpointGeometryLogicalFunction::TemporalADisjointTNpointGeometryLogicalFunction(LogicalFunction rid, + LogicalFunction fraction, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(4); + parameters.push_back(std::move(rid)); + parameters.push_back(std::move(fraction)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalADisjointTNpointGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalADisjointTNpointGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalADisjointTNpointGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalADisjointTNpointGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, "TemporalADisjointTNpointGeometryLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalADisjointTNpointGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalADisjointTNpointGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalADisjointTNpointGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalADisjointTNpointGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalADisjointTNpointGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalADisjointTNpointGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "TemporalADisjointTNpointGeometryLogicalFunction requires 4 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + return TemporalADisjointTNpointGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalADisjointTNpointTNpointLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalADisjointTNpointTNpointLogicalFunction.cpp new file mode 100644 index 0000000000..ec1295c537 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalADisjointTNpointTNpointLogicalFunction.cpp @@ -0,0 +1,137 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalADisjointTNpointTNpointLogicalFunction::TemporalADisjointTNpointTNpointLogicalFunction(LogicalFunction ridA, + LogicalFunction fractionA, + LogicalFunction tsA, + LogicalFunction ridB, + LogicalFunction fractionB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(6); + parameters.push_back(std::move(ridA)); + parameters.push_back(std::move(fractionA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(ridB)); + parameters.push_back(std::move(fractionB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalADisjointTNpointTNpointLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalADisjointTNpointTNpointLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalADisjointTNpointTNpointLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalADisjointTNpointTNpointLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, "TemporalADisjointTNpointTNpointLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalADisjointTNpointTNpointLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalADisjointTNpointTNpointLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalADisjointTNpointTNpointLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalADisjointTNpointTNpointLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalADisjointTNpointTNpointLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalADisjointTNpointTNpointLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "TemporalADisjointTNpointTNpointLogicalFunction requires 6 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + return TemporalADisjointTNpointTNpointLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalADisjointTPoseGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalADisjointTPoseGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..69aed0913d --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalADisjointTPoseGeometryLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalADisjointTPoseGeometryLogicalFunction::TemporalADisjointTPoseGeometryLogicalFunction(LogicalFunction x, + LogicalFunction y, + LogicalFunction theta, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalADisjointTPoseGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalADisjointTPoseGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalADisjointTPoseGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalADisjointTPoseGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalADisjointTPoseGeometryLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalADisjointTPoseGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalADisjointTPoseGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalADisjointTPoseGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalADisjointTPoseGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalADisjointTPoseGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalADisjointTPoseGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalADisjointTPoseGeometryLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalADisjointTPoseGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalADisjointTPoseTPoseLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalADisjointTPoseTPoseLogicalFunction.cpp new file mode 100644 index 0000000000..3b2c24176c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalADisjointTPoseTPoseLogicalFunction.cpp @@ -0,0 +1,143 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalADisjointTPoseTPoseLogicalFunction::TemporalADisjointTPoseTPoseLogicalFunction(LogicalFunction xA, + LogicalFunction yA, + LogicalFunction thetaA, + LogicalFunction tsA, + LogicalFunction xB, + LogicalFunction yB, + LogicalFunction thetaB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(8); + parameters.push_back(std::move(xA)); + parameters.push_back(std::move(yA)); + parameters.push_back(std::move(thetaA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(xB)); + parameters.push_back(std::move(yB)); + parameters.push_back(std::move(thetaB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalADisjointTPoseTPoseLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalADisjointTPoseTPoseLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalADisjointTPoseTPoseLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalADisjointTPoseTPoseLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, "TemporalADisjointTPoseTPoseLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalADisjointTPoseTPoseLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalADisjointTPoseTPoseLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalADisjointTPoseTPoseLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalADisjointTPoseTPoseLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalADisjointTPoseTPoseLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalADisjointTPoseTPoseLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "TemporalADisjointTPoseTPoseLogicalFunction requires 8 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + auto arg6 = std::move(arguments.children[6]); + auto arg7 = std::move(arguments.children[7]); + return TemporalADisjointTPoseTPoseLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalAIntersectsTCbufferCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalAIntersectsTCbufferCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..2a03cb7e49 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalAIntersectsTCbufferCbufferLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalAIntersectsTCbufferCbufferLogicalFunction::TemporalAIntersectsTCbufferCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction cbufferLit) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(cbufferLit)); +} + +DataType TemporalAIntersectsTCbufferCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalAIntersectsTCbufferCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalAIntersectsTCbufferCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalAIntersectsTCbufferCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalAIntersectsTCbufferCbufferLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalAIntersectsTCbufferCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalAIntersectsTCbufferCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalAIntersectsTCbufferCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalAIntersectsTCbufferCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalAIntersectsTCbufferCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalAIntersectsTCbufferCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalAIntersectsTCbufferCbufferLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalAIntersectsTCbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalAIntersectsTCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalAIntersectsTCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..b4ecf5418a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalAIntersectsTCbufferLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalAIntersectsTCbufferLogicalFunction::TemporalAIntersectsTCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalAIntersectsTCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalAIntersectsTCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalAIntersectsTCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalAIntersectsTCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalAIntersectsTCbufferLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalAIntersectsTCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalAIntersectsTCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalAIntersectsTCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalAIntersectsTCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalAIntersectsTCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalAIntersectsTCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalAIntersectsTCbufferLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalAIntersectsTCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalAIntersectsTCbufferTCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalAIntersectsTCbufferTCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..03b451f801 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalAIntersectsTCbufferTCbufferLogicalFunction.cpp @@ -0,0 +1,143 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalAIntersectsTCbufferTCbufferLogicalFunction::TemporalAIntersectsTCbufferTCbufferLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction radiusA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction radiusB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(8); + parameters.push_back(std::move(lonA)); + parameters.push_back(std::move(latA)); + parameters.push_back(std::move(radiusA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(lonB)); + parameters.push_back(std::move(latB)); + parameters.push_back(std::move(radiusB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalAIntersectsTCbufferTCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalAIntersectsTCbufferTCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalAIntersectsTCbufferTCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalAIntersectsTCbufferTCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, "TemporalAIntersectsTCbufferTCbufferLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalAIntersectsTCbufferTCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalAIntersectsTCbufferTCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalAIntersectsTCbufferTCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalAIntersectsTCbufferTCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalAIntersectsTCbufferTCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalAIntersectsTCbufferTCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "TemporalAIntersectsTCbufferTCbufferLogicalFunction requires 8 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + auto arg6 = std::move(arguments.children[6]); + auto arg7 = std::move(arguments.children[7]); + return TemporalAIntersectsTCbufferTCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalAIntersectsTGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalAIntersectsTGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..9b842b294b --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalAIntersectsTGeometryLogicalFunction.cpp @@ -0,0 +1,137 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalAIntersectsTGeometryLogicalFunction::TemporalAIntersectsTGeometryLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lonA)); + parameters.push_back(std::move(latA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(lonB)); + parameters.push_back(std::move(latB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalAIntersectsTGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalAIntersectsTGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalAIntersectsTGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalAIntersectsTGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, "TemporalAIntersectsTGeometryLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalAIntersectsTGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalAIntersectsTGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalAIntersectsTGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalAIntersectsTGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalAIntersectsTGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalAIntersectsTGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "TemporalAIntersectsTGeometryLogicalFunction requires 6 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + return TemporalAIntersectsTGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalAIntersectsTNpointGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalAIntersectsTNpointGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..80ce0a3854 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalAIntersectsTNpointGeometryLogicalFunction.cpp @@ -0,0 +1,131 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalAIntersectsTNpointGeometryLogicalFunction::TemporalAIntersectsTNpointGeometryLogicalFunction(LogicalFunction rid, + LogicalFunction fraction, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(4); + parameters.push_back(std::move(rid)); + parameters.push_back(std::move(fraction)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalAIntersectsTNpointGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalAIntersectsTNpointGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalAIntersectsTNpointGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalAIntersectsTNpointGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, "TemporalAIntersectsTNpointGeometryLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalAIntersectsTNpointGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalAIntersectsTNpointGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalAIntersectsTNpointGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalAIntersectsTNpointGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalAIntersectsTNpointGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalAIntersectsTNpointGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "TemporalAIntersectsTNpointGeometryLogicalFunction requires 4 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + return TemporalAIntersectsTNpointGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalAIntersectsTNpointTNpointLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalAIntersectsTNpointTNpointLogicalFunction.cpp new file mode 100644 index 0000000000..a69a301c05 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalAIntersectsTNpointTNpointLogicalFunction.cpp @@ -0,0 +1,137 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalAIntersectsTNpointTNpointLogicalFunction::TemporalAIntersectsTNpointTNpointLogicalFunction(LogicalFunction ridA, + LogicalFunction fractionA, + LogicalFunction tsA, + LogicalFunction ridB, + LogicalFunction fractionB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(6); + parameters.push_back(std::move(ridA)); + parameters.push_back(std::move(fractionA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(ridB)); + parameters.push_back(std::move(fractionB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalAIntersectsTNpointTNpointLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalAIntersectsTNpointTNpointLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalAIntersectsTNpointTNpointLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalAIntersectsTNpointTNpointLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, "TemporalAIntersectsTNpointTNpointLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalAIntersectsTNpointTNpointLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalAIntersectsTNpointTNpointLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalAIntersectsTNpointTNpointLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalAIntersectsTNpointTNpointLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalAIntersectsTNpointTNpointLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalAIntersectsTNpointTNpointLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "TemporalAIntersectsTNpointTNpointLogicalFunction requires 6 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + return TemporalAIntersectsTNpointTNpointLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalAIntersectsTPoseGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalAIntersectsTPoseGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..e152146e01 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalAIntersectsTPoseGeometryLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalAIntersectsTPoseGeometryLogicalFunction::TemporalAIntersectsTPoseGeometryLogicalFunction(LogicalFunction x, + LogicalFunction y, + LogicalFunction theta, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalAIntersectsTPoseGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalAIntersectsTPoseGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalAIntersectsTPoseGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalAIntersectsTPoseGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalAIntersectsTPoseGeometryLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalAIntersectsTPoseGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalAIntersectsTPoseGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalAIntersectsTPoseGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalAIntersectsTPoseGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalAIntersectsTPoseGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalAIntersectsTPoseGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalAIntersectsTPoseGeometryLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalAIntersectsTPoseGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalAIntersectsTPoseTPoseLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalAIntersectsTPoseTPoseLogicalFunction.cpp new file mode 100644 index 0000000000..c8e82a659f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalAIntersectsTPoseTPoseLogicalFunction.cpp @@ -0,0 +1,143 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalAIntersectsTPoseTPoseLogicalFunction::TemporalAIntersectsTPoseTPoseLogicalFunction(LogicalFunction xA, + LogicalFunction yA, + LogicalFunction thetaA, + LogicalFunction tsA, + LogicalFunction xB, + LogicalFunction yB, + LogicalFunction thetaB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(8); + parameters.push_back(std::move(xA)); + parameters.push_back(std::move(yA)); + parameters.push_back(std::move(thetaA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(xB)); + parameters.push_back(std::move(yB)); + parameters.push_back(std::move(thetaB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalAIntersectsTPoseTPoseLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalAIntersectsTPoseTPoseLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalAIntersectsTPoseTPoseLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalAIntersectsTPoseTPoseLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, "TemporalAIntersectsTPoseTPoseLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalAIntersectsTPoseTPoseLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalAIntersectsTPoseTPoseLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalAIntersectsTPoseTPoseLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalAIntersectsTPoseTPoseLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalAIntersectsTPoseTPoseLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalAIntersectsTPoseTPoseLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "TemporalAIntersectsTPoseTPoseLogicalFunction requires 8 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + auto arg6 = std::move(arguments.children[6]); + auto arg7 = std::move(arguments.children[7]); + return TemporalAIntersectsTPoseTPoseLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalATouchesGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalATouchesGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..759c8b3f5d --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalATouchesGeometryLogicalFunction.cpp @@ -0,0 +1,131 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalATouchesGeometryLogicalFunction::TemporalATouchesGeometryLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(4); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalATouchesGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalATouchesGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalATouchesGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalATouchesGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, "TemporalATouchesGeometryLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalATouchesGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalATouchesGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalATouchesGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalATouchesGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalATouchesGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalATouchesGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "TemporalATouchesGeometryLogicalFunction requires 4 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + return TemporalATouchesGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalATouchesTCbufferCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalATouchesTCbufferCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..ec3f86da77 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalATouchesTCbufferCbufferLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalATouchesTCbufferCbufferLogicalFunction::TemporalATouchesTCbufferCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction cbufferLit) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(cbufferLit)); +} + +DataType TemporalATouchesTCbufferCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalATouchesTCbufferCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalATouchesTCbufferCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalATouchesTCbufferCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalATouchesTCbufferCbufferLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalATouchesTCbufferCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalATouchesTCbufferCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalATouchesTCbufferCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalATouchesTCbufferCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalATouchesTCbufferCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalATouchesTCbufferCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalATouchesTCbufferCbufferLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalATouchesTCbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalATouchesTCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalATouchesTCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..a36e1aabf2 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalATouchesTCbufferLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalATouchesTCbufferLogicalFunction::TemporalATouchesTCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalATouchesTCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalATouchesTCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalATouchesTCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalATouchesTCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalATouchesTCbufferLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalATouchesTCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalATouchesTCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalATouchesTCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalATouchesTCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalATouchesTCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalATouchesTCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalATouchesTCbufferLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalATouchesTCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalATouchesTCbufferTCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalATouchesTCbufferTCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..e2603392e2 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalATouchesTCbufferTCbufferLogicalFunction.cpp @@ -0,0 +1,143 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalATouchesTCbufferTCbufferLogicalFunction::TemporalATouchesTCbufferTCbufferLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction radiusA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction radiusB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(8); + parameters.push_back(std::move(lonA)); + parameters.push_back(std::move(latA)); + parameters.push_back(std::move(radiusA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(lonB)); + parameters.push_back(std::move(latB)); + parameters.push_back(std::move(radiusB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalATouchesTCbufferTCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalATouchesTCbufferTCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalATouchesTCbufferTCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalATouchesTCbufferTCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, "TemporalATouchesTCbufferTCbufferLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalATouchesTCbufferTCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalATouchesTCbufferTCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalATouchesTCbufferTCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalATouchesTCbufferTCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalATouchesTCbufferTCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalATouchesTCbufferTCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "TemporalATouchesTCbufferTCbufferLogicalFunction requires 8 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + auto arg6 = std::move(arguments.children[6]); + auto arg7 = std::move(arguments.children[7]); + return TemporalATouchesTCbufferTCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalATouchesTGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalATouchesTGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..35ab303505 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalATouchesTGeometryLogicalFunction.cpp @@ -0,0 +1,137 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalATouchesTGeometryLogicalFunction::TemporalATouchesTGeometryLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lonA)); + parameters.push_back(std::move(latA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(lonB)); + parameters.push_back(std::move(latB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalATouchesTGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalATouchesTGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalATouchesTGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalATouchesTGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, "TemporalATouchesTGeometryLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalATouchesTGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalATouchesTGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalATouchesTGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalATouchesTGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalATouchesTGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalATouchesTGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "TemporalATouchesTGeometryLogicalFunction requires 6 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + return TemporalATouchesTGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalATouchesTNpointGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalATouchesTNpointGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..e0af8cb32e --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalATouchesTNpointGeometryLogicalFunction.cpp @@ -0,0 +1,131 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalATouchesTNpointGeometryLogicalFunction::TemporalATouchesTNpointGeometryLogicalFunction(LogicalFunction rid, + LogicalFunction fraction, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(4); + parameters.push_back(std::move(rid)); + parameters.push_back(std::move(fraction)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalATouchesTNpointGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalATouchesTNpointGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalATouchesTNpointGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalATouchesTNpointGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, "TemporalATouchesTNpointGeometryLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalATouchesTNpointGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalATouchesTNpointGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalATouchesTNpointGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalATouchesTNpointGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalATouchesTNpointGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalATouchesTNpointGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "TemporalATouchesTNpointGeometryLogicalFunction requires 4 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + return TemporalATouchesTNpointGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalATouchesTNpointTNpointLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalATouchesTNpointTNpointLogicalFunction.cpp new file mode 100644 index 0000000000..bb7257d12b --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalATouchesTNpointTNpointLogicalFunction.cpp @@ -0,0 +1,137 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalATouchesTNpointTNpointLogicalFunction::TemporalATouchesTNpointTNpointLogicalFunction(LogicalFunction ridA, + LogicalFunction fractionA, + LogicalFunction tsA, + LogicalFunction ridB, + LogicalFunction fractionB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(6); + parameters.push_back(std::move(ridA)); + parameters.push_back(std::move(fractionA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(ridB)); + parameters.push_back(std::move(fractionB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalATouchesTNpointTNpointLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalATouchesTNpointTNpointLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalATouchesTNpointTNpointLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalATouchesTNpointTNpointLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, "TemporalATouchesTNpointTNpointLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalATouchesTNpointTNpointLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalATouchesTNpointTNpointLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalATouchesTNpointTNpointLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalATouchesTNpointTNpointLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalATouchesTNpointTNpointLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalATouchesTNpointTNpointLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "TemporalATouchesTNpointTNpointLogicalFunction requires 6 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + return TemporalATouchesTNpointTNpointLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalATouchesTPoseGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalATouchesTPoseGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..e3a8a01cb0 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalATouchesTPoseGeometryLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalATouchesTPoseGeometryLogicalFunction::TemporalATouchesTPoseGeometryLogicalFunction(LogicalFunction x, + LogicalFunction y, + LogicalFunction theta, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalATouchesTPoseGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalATouchesTPoseGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalATouchesTPoseGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalATouchesTPoseGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalATouchesTPoseGeometryLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalATouchesTPoseGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalATouchesTPoseGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalATouchesTPoseGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalATouchesTPoseGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalATouchesTPoseGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalATouchesTPoseGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalATouchesTPoseGeometryLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalATouchesTPoseGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalATouchesTPoseTPoseLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalATouchesTPoseTPoseLogicalFunction.cpp new file mode 100644 index 0000000000..9890aa1413 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalATouchesTPoseTPoseLogicalFunction.cpp @@ -0,0 +1,143 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalATouchesTPoseTPoseLogicalFunction::TemporalATouchesTPoseTPoseLogicalFunction(LogicalFunction xA, + LogicalFunction yA, + LogicalFunction thetaA, + LogicalFunction tsA, + LogicalFunction xB, + LogicalFunction yB, + LogicalFunction thetaB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(8); + parameters.push_back(std::move(xA)); + parameters.push_back(std::move(yA)); + parameters.push_back(std::move(thetaA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(xB)); + parameters.push_back(std::move(yB)); + parameters.push_back(std::move(thetaB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalATouchesTPoseTPoseLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalATouchesTPoseTPoseLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalATouchesTPoseTPoseLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalATouchesTPoseTPoseLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, "TemporalATouchesTPoseTPoseLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalATouchesTPoseTPoseLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalATouchesTPoseTPoseLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalATouchesTPoseTPoseLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalATouchesTPoseTPoseLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalATouchesTPoseTPoseLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalATouchesTPoseTPoseLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "TemporalATouchesTPoseTPoseLogicalFunction requires 8 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + auto arg6 = std::move(arguments.children[6]); + auto arg7 = std::move(arguments.children[7]); + return TemporalATouchesTPoseTPoseLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalAtGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalAtGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..78225ad55a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalAtGeometryLogicalFunction.cpp @@ -0,0 +1,131 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalAtGeometryLogicalFunction::TemporalAtGeometryLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(4); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalAtGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalAtGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalAtGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalAtGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, "TemporalAtGeometryLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalAtGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalAtGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalAtGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalAtGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalAtGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalAtGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "TemporalAtGeometryLogicalFunction requires 4 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + return TemporalAtGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEContainsTCbufferCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEContainsTCbufferCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..751e6d8265 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEContainsTCbufferCbufferLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEContainsTCbufferCbufferLogicalFunction::TemporalEContainsTCbufferCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction cbufferLit) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(cbufferLit)); +} + +DataType TemporalEContainsTCbufferCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEContainsTCbufferCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEContainsTCbufferCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEContainsTCbufferCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalEContainsTCbufferCbufferLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEContainsTCbufferCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEContainsTCbufferCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEContainsTCbufferCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEContainsTCbufferCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEContainsTCbufferCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEContainsTCbufferCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalEContainsTCbufferCbufferLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalEContainsTCbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEContainsTCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEContainsTCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..524a54acc9 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEContainsTCbufferLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEContainsTCbufferLogicalFunction::TemporalEContainsTCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalEContainsTCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEContainsTCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEContainsTCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEContainsTCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalEContainsTCbufferLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEContainsTCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEContainsTCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEContainsTCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEContainsTCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEContainsTCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEContainsTCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalEContainsTCbufferLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalEContainsTCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEContainsTGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEContainsTGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..fd500aa892 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEContainsTGeometryLogicalFunction.cpp @@ -0,0 +1,137 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEContainsTGeometryLogicalFunction::TemporalEContainsTGeometryLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lonA)); + parameters.push_back(std::move(latA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(lonB)); + parameters.push_back(std::move(latB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalEContainsTGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEContainsTGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEContainsTGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEContainsTGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, "TemporalEContainsTGeometryLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEContainsTGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEContainsTGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEContainsTGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEContainsTGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEContainsTGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEContainsTGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "TemporalEContainsTGeometryLogicalFunction requires 6 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + return TemporalEContainsTGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEContainsTNpointGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEContainsTNpointGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..213e4cb9fa --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEContainsTNpointGeometryLogicalFunction.cpp @@ -0,0 +1,131 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEContainsTNpointGeometryLogicalFunction::TemporalEContainsTNpointGeometryLogicalFunction(LogicalFunction rid, + LogicalFunction fraction, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(4); + parameters.push_back(std::move(rid)); + parameters.push_back(std::move(fraction)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalEContainsTNpointGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEContainsTNpointGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEContainsTNpointGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEContainsTNpointGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, "TemporalEContainsTNpointGeometryLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEContainsTNpointGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEContainsTNpointGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEContainsTNpointGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEContainsTNpointGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEContainsTNpointGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEContainsTNpointGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "TemporalEContainsTNpointGeometryLogicalFunction requires 4 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + return TemporalEContainsTNpointGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEContainsTNpointTNpointLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEContainsTNpointTNpointLogicalFunction.cpp new file mode 100644 index 0000000000..4e1321c7b2 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEContainsTNpointTNpointLogicalFunction.cpp @@ -0,0 +1,137 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEContainsTNpointTNpointLogicalFunction::TemporalEContainsTNpointTNpointLogicalFunction(LogicalFunction ridA, + LogicalFunction fractionA, + LogicalFunction tsA, + LogicalFunction ridB, + LogicalFunction fractionB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(6); + parameters.push_back(std::move(ridA)); + parameters.push_back(std::move(fractionA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(ridB)); + parameters.push_back(std::move(fractionB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalEContainsTNpointTNpointLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEContainsTNpointTNpointLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEContainsTNpointTNpointLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEContainsTNpointTNpointLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, "TemporalEContainsTNpointTNpointLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEContainsTNpointTNpointLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEContainsTNpointTNpointLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEContainsTNpointTNpointLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEContainsTNpointTNpointLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEContainsTNpointTNpointLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEContainsTNpointTNpointLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "TemporalEContainsTNpointTNpointLogicalFunction requires 6 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + return TemporalEContainsTNpointTNpointLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEContainsTPoseGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEContainsTPoseGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..a8a961578e --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEContainsTPoseGeometryLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEContainsTPoseGeometryLogicalFunction::TemporalEContainsTPoseGeometryLogicalFunction(LogicalFunction x, + LogicalFunction y, + LogicalFunction theta, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalEContainsTPoseGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEContainsTPoseGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEContainsTPoseGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEContainsTPoseGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalEContainsTPoseGeometryLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEContainsTPoseGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEContainsTPoseGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEContainsTPoseGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEContainsTPoseGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEContainsTPoseGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEContainsTPoseGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalEContainsTPoseGeometryLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalEContainsTPoseGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEContainsTPoseTPoseLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEContainsTPoseTPoseLogicalFunction.cpp new file mode 100644 index 0000000000..f66a1b707c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEContainsTPoseTPoseLogicalFunction.cpp @@ -0,0 +1,143 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEContainsTPoseTPoseLogicalFunction::TemporalEContainsTPoseTPoseLogicalFunction(LogicalFunction xA, + LogicalFunction yA, + LogicalFunction thetaA, + LogicalFunction tsA, + LogicalFunction xB, + LogicalFunction yB, + LogicalFunction thetaB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(8); + parameters.push_back(std::move(xA)); + parameters.push_back(std::move(yA)); + parameters.push_back(std::move(thetaA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(xB)); + parameters.push_back(std::move(yB)); + parameters.push_back(std::move(thetaB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalEContainsTPoseTPoseLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEContainsTPoseTPoseLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEContainsTPoseTPoseLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEContainsTPoseTPoseLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, "TemporalEContainsTPoseTPoseLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEContainsTPoseTPoseLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEContainsTPoseTPoseLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEContainsTPoseTPoseLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEContainsTPoseTPoseLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEContainsTPoseTPoseLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEContainsTPoseTPoseLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "TemporalEContainsTPoseTPoseLogicalFunction requires 8 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + auto arg6 = std::move(arguments.children[6]); + auto arg7 = std::move(arguments.children[7]); + return TemporalEContainsTPoseTPoseLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalECoversGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalECoversGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..81aa2b3517 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalECoversGeometryLogicalFunction.cpp @@ -0,0 +1,131 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalECoversGeometryLogicalFunction::TemporalECoversGeometryLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(4); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalECoversGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalECoversGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalECoversGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalECoversGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, "TemporalECoversGeometryLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalECoversGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalECoversGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalECoversGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalECoversGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalECoversGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalECoversGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "TemporalECoversGeometryLogicalFunction requires 4 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + return TemporalECoversGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalECoversTCbufferCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalECoversTCbufferCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..597c515778 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalECoversTCbufferCbufferLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalECoversTCbufferCbufferLogicalFunction::TemporalECoversTCbufferCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction cbufferLit) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(cbufferLit)); +} + +DataType TemporalECoversTCbufferCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalECoversTCbufferCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalECoversTCbufferCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalECoversTCbufferCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalECoversTCbufferCbufferLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalECoversTCbufferCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalECoversTCbufferCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalECoversTCbufferCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalECoversTCbufferCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalECoversTCbufferCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalECoversTCbufferCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalECoversTCbufferCbufferLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalECoversTCbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalECoversTCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalECoversTCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..804ae61c1a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalECoversTCbufferLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalECoversTCbufferLogicalFunction::TemporalECoversTCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalECoversTCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalECoversTCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalECoversTCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalECoversTCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalECoversTCbufferLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalECoversTCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalECoversTCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalECoversTCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalECoversTCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalECoversTCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalECoversTCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalECoversTCbufferLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalECoversTCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalECoversTCbufferTCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalECoversTCbufferTCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..af07fbd259 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalECoversTCbufferTCbufferLogicalFunction.cpp @@ -0,0 +1,143 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalECoversTCbufferTCbufferLogicalFunction::TemporalECoversTCbufferTCbufferLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction radiusA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction radiusB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(8); + parameters.push_back(std::move(lonA)); + parameters.push_back(std::move(latA)); + parameters.push_back(std::move(radiusA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(lonB)); + parameters.push_back(std::move(latB)); + parameters.push_back(std::move(radiusB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalECoversTCbufferTCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalECoversTCbufferTCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalECoversTCbufferTCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalECoversTCbufferTCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, "TemporalECoversTCbufferTCbufferLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalECoversTCbufferTCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalECoversTCbufferTCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalECoversTCbufferTCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalECoversTCbufferTCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalECoversTCbufferTCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalECoversTCbufferTCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "TemporalECoversTCbufferTCbufferLogicalFunction requires 8 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + auto arg6 = std::move(arguments.children[6]); + auto arg7 = std::move(arguments.children[7]); + return TemporalECoversTCbufferTCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalECoversTGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalECoversTGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..403a0ec62c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalECoversTGeometryLogicalFunction.cpp @@ -0,0 +1,137 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalECoversTGeometryLogicalFunction::TemporalECoversTGeometryLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lonA)); + parameters.push_back(std::move(latA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(lonB)); + parameters.push_back(std::move(latB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalECoversTGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalECoversTGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalECoversTGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalECoversTGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, "TemporalECoversTGeometryLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalECoversTGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalECoversTGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalECoversTGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalECoversTGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalECoversTGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalECoversTGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "TemporalECoversTGeometryLogicalFunction requires 6 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + return TemporalECoversTGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalECoversTNpointGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalECoversTNpointGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..970db8715f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalECoversTNpointGeometryLogicalFunction.cpp @@ -0,0 +1,131 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalECoversTNpointGeometryLogicalFunction::TemporalECoversTNpointGeometryLogicalFunction(LogicalFunction rid, + LogicalFunction fraction, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(4); + parameters.push_back(std::move(rid)); + parameters.push_back(std::move(fraction)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalECoversTNpointGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalECoversTNpointGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalECoversTNpointGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalECoversTNpointGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, "TemporalECoversTNpointGeometryLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalECoversTNpointGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalECoversTNpointGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalECoversTNpointGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalECoversTNpointGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalECoversTNpointGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalECoversTNpointGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "TemporalECoversTNpointGeometryLogicalFunction requires 4 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + return TemporalECoversTNpointGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalECoversTNpointTNpointLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalECoversTNpointTNpointLogicalFunction.cpp new file mode 100644 index 0000000000..70503741a2 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalECoversTNpointTNpointLogicalFunction.cpp @@ -0,0 +1,137 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalECoversTNpointTNpointLogicalFunction::TemporalECoversTNpointTNpointLogicalFunction(LogicalFunction ridA, + LogicalFunction fractionA, + LogicalFunction tsA, + LogicalFunction ridB, + LogicalFunction fractionB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(6); + parameters.push_back(std::move(ridA)); + parameters.push_back(std::move(fractionA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(ridB)); + parameters.push_back(std::move(fractionB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalECoversTNpointTNpointLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalECoversTNpointTNpointLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalECoversTNpointTNpointLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalECoversTNpointTNpointLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, "TemporalECoversTNpointTNpointLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalECoversTNpointTNpointLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalECoversTNpointTNpointLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalECoversTNpointTNpointLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalECoversTNpointTNpointLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalECoversTNpointTNpointLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalECoversTNpointTNpointLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "TemporalECoversTNpointTNpointLogicalFunction requires 6 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + return TemporalECoversTNpointTNpointLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalECoversTPoseGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalECoversTPoseGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..5b5099171d --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalECoversTPoseGeometryLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalECoversTPoseGeometryLogicalFunction::TemporalECoversTPoseGeometryLogicalFunction(LogicalFunction x, + LogicalFunction y, + LogicalFunction theta, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalECoversTPoseGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalECoversTPoseGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalECoversTPoseGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalECoversTPoseGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalECoversTPoseGeometryLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalECoversTPoseGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalECoversTPoseGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalECoversTPoseGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalECoversTPoseGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalECoversTPoseGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalECoversTPoseGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalECoversTPoseGeometryLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalECoversTPoseGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalECoversTPoseTPoseLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalECoversTPoseTPoseLogicalFunction.cpp new file mode 100644 index 0000000000..a046acb75e --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalECoversTPoseTPoseLogicalFunction.cpp @@ -0,0 +1,143 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalECoversTPoseTPoseLogicalFunction::TemporalECoversTPoseTPoseLogicalFunction(LogicalFunction xA, + LogicalFunction yA, + LogicalFunction thetaA, + LogicalFunction tsA, + LogicalFunction xB, + LogicalFunction yB, + LogicalFunction thetaB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(8); + parameters.push_back(std::move(xA)); + parameters.push_back(std::move(yA)); + parameters.push_back(std::move(thetaA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(xB)); + parameters.push_back(std::move(yB)); + parameters.push_back(std::move(thetaB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalECoversTPoseTPoseLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalECoversTPoseTPoseLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalECoversTPoseTPoseLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalECoversTPoseTPoseLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, "TemporalECoversTPoseTPoseLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalECoversTPoseTPoseLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalECoversTPoseTPoseLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalECoversTPoseTPoseLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalECoversTPoseTPoseLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalECoversTPoseTPoseLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalECoversTPoseTPoseLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "TemporalECoversTPoseTPoseLogicalFunction requires 8 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + auto arg6 = std::move(arguments.children[6]); + auto arg7 = std::move(arguments.children[7]); + return TemporalECoversTPoseTPoseLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEDWithinTCbufferCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEDWithinTCbufferCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..546b40aa37 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEDWithinTCbufferCbufferLogicalFunction.cpp @@ -0,0 +1,137 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEDWithinTCbufferCbufferLogicalFunction::TemporalEDWithinTCbufferCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction cbufferLit, + LogicalFunction dist) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(cbufferLit)); + parameters.push_back(std::move(dist)); +} + +DataType TemporalEDWithinTCbufferCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEDWithinTCbufferCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEDWithinTCbufferCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEDWithinTCbufferCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, "TemporalEDWithinTCbufferCbufferLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEDWithinTCbufferCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEDWithinTCbufferCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEDWithinTCbufferCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEDWithinTCbufferCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEDWithinTCbufferCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEDWithinTCbufferCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "TemporalEDWithinTCbufferCbufferLogicalFunction requires 6 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + return TemporalEDWithinTCbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEDWithinTCbufferGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEDWithinTCbufferGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..554a1d78d0 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEDWithinTCbufferGeometryLogicalFunction.cpp @@ -0,0 +1,137 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEDWithinTCbufferGeometryLogicalFunction::TemporalEDWithinTCbufferGeometryLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction geometry, + LogicalFunction dist) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); + parameters.push_back(std::move(dist)); +} + +DataType TemporalEDWithinTCbufferGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEDWithinTCbufferGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEDWithinTCbufferGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEDWithinTCbufferGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, "TemporalEDWithinTCbufferGeometryLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEDWithinTCbufferGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEDWithinTCbufferGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEDWithinTCbufferGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEDWithinTCbufferGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEDWithinTCbufferGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEDWithinTCbufferGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "TemporalEDWithinTCbufferGeometryLogicalFunction requires 6 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + return TemporalEDWithinTCbufferGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEDWithinTCbufferTCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEDWithinTCbufferTCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..8a5a4b2dcc --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEDWithinTCbufferTCbufferLogicalFunction.cpp @@ -0,0 +1,146 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEDWithinTCbufferTCbufferLogicalFunction::TemporalEDWithinTCbufferTCbufferLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction radiusA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction radiusB, + LogicalFunction tsB, + LogicalFunction dist) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(9); + parameters.push_back(std::move(lonA)); + parameters.push_back(std::move(latA)); + parameters.push_back(std::move(radiusA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(lonB)); + parameters.push_back(std::move(latB)); + parameters.push_back(std::move(radiusB)); + parameters.push_back(std::move(tsB)); + parameters.push_back(std::move(dist)); +} + +DataType TemporalEDWithinTCbufferTCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEDWithinTCbufferTCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEDWithinTCbufferTCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEDWithinTCbufferTCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 9, "TemporalEDWithinTCbufferTCbufferLogicalFunction requires 9 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEDWithinTCbufferTCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEDWithinTCbufferTCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEDWithinTCbufferTCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEDWithinTCbufferTCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEDWithinTCbufferTCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEDWithinTCbufferTCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 9, + "TemporalEDWithinTCbufferTCbufferLogicalFunction requires 9 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + auto arg6 = std::move(arguments.children[6]); + auto arg7 = std::move(arguments.children[7]); + auto arg8 = std::move(arguments.children[8]); + return TemporalEDWithinTCbufferTCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7), std::move(arg8)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEDWithinTGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEDWithinTGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..9b97bf4afe --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEDWithinTGeometryLogicalFunction.cpp @@ -0,0 +1,140 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEDWithinTGeometryLogicalFunction::TemporalEDWithinTGeometryLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction tsB, + LogicalFunction dist) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(7); + parameters.push_back(std::move(lonA)); + parameters.push_back(std::move(latA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(lonB)); + parameters.push_back(std::move(latB)); + parameters.push_back(std::move(tsB)); + parameters.push_back(std::move(dist)); +} + +DataType TemporalEDWithinTGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEDWithinTGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEDWithinTGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEDWithinTGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, "TemporalEDWithinTGeometryLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEDWithinTGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEDWithinTGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEDWithinTGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEDWithinTGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEDWithinTGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEDWithinTGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "TemporalEDWithinTGeometryLogicalFunction requires 7 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + auto arg6 = std::move(arguments.children[6]); + return TemporalEDWithinTGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEDisjointGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEDisjointGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..29e31baade --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEDisjointGeometryLogicalFunction.cpp @@ -0,0 +1,131 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEDisjointGeometryLogicalFunction::TemporalEDisjointGeometryLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(4); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalEDisjointGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEDisjointGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEDisjointGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEDisjointGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, "TemporalEDisjointGeometryLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEDisjointGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEDisjointGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEDisjointGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEDisjointGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEDisjointGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEDisjointGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "TemporalEDisjointGeometryLogicalFunction requires 4 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + return TemporalEDisjointGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEDisjointTCbufferCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEDisjointTCbufferCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..0fba1df67c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEDisjointTCbufferCbufferLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEDisjointTCbufferCbufferLogicalFunction::TemporalEDisjointTCbufferCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction cbufferLit) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(cbufferLit)); +} + +DataType TemporalEDisjointTCbufferCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEDisjointTCbufferCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEDisjointTCbufferCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEDisjointTCbufferCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalEDisjointTCbufferCbufferLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEDisjointTCbufferCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEDisjointTCbufferCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEDisjointTCbufferCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEDisjointTCbufferCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEDisjointTCbufferCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEDisjointTCbufferCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalEDisjointTCbufferCbufferLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalEDisjointTCbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEDisjointTCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEDisjointTCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..e6a286c286 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEDisjointTCbufferLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEDisjointTCbufferLogicalFunction::TemporalEDisjointTCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalEDisjointTCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEDisjointTCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEDisjointTCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEDisjointTCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalEDisjointTCbufferLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEDisjointTCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEDisjointTCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEDisjointTCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEDisjointTCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEDisjointTCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEDisjointTCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalEDisjointTCbufferLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalEDisjointTCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEDisjointTGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEDisjointTGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..454a19f2ac --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEDisjointTGeometryLogicalFunction.cpp @@ -0,0 +1,137 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEDisjointTGeometryLogicalFunction::TemporalEDisjointTGeometryLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lonA)); + parameters.push_back(std::move(latA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(lonB)); + parameters.push_back(std::move(latB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalEDisjointTGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEDisjointTGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEDisjointTGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEDisjointTGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, "TemporalEDisjointTGeometryLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEDisjointTGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEDisjointTGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEDisjointTGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEDisjointTGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEDisjointTGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEDisjointTGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "TemporalEDisjointTGeometryLogicalFunction requires 6 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + return TemporalEDisjointTGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEDisjointTNpointGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEDisjointTNpointGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..cbd9b1a6d0 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEDisjointTNpointGeometryLogicalFunction.cpp @@ -0,0 +1,131 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEDisjointTNpointGeometryLogicalFunction::TemporalEDisjointTNpointGeometryLogicalFunction(LogicalFunction rid, + LogicalFunction fraction, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(4); + parameters.push_back(std::move(rid)); + parameters.push_back(std::move(fraction)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalEDisjointTNpointGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEDisjointTNpointGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEDisjointTNpointGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEDisjointTNpointGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, "TemporalEDisjointTNpointGeometryLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEDisjointTNpointGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEDisjointTNpointGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEDisjointTNpointGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEDisjointTNpointGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEDisjointTNpointGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEDisjointTNpointGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "TemporalEDisjointTNpointGeometryLogicalFunction requires 4 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + return TemporalEDisjointTNpointGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEDisjointTNpointTNpointLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEDisjointTNpointTNpointLogicalFunction.cpp new file mode 100644 index 0000000000..be7e1341a9 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEDisjointTNpointTNpointLogicalFunction.cpp @@ -0,0 +1,137 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEDisjointTNpointTNpointLogicalFunction::TemporalEDisjointTNpointTNpointLogicalFunction(LogicalFunction ridA, + LogicalFunction fractionA, + LogicalFunction tsA, + LogicalFunction ridB, + LogicalFunction fractionB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(6); + parameters.push_back(std::move(ridA)); + parameters.push_back(std::move(fractionA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(ridB)); + parameters.push_back(std::move(fractionB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalEDisjointTNpointTNpointLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEDisjointTNpointTNpointLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEDisjointTNpointTNpointLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEDisjointTNpointTNpointLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, "TemporalEDisjointTNpointTNpointLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEDisjointTNpointTNpointLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEDisjointTNpointTNpointLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEDisjointTNpointTNpointLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEDisjointTNpointTNpointLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEDisjointTNpointTNpointLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEDisjointTNpointTNpointLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "TemporalEDisjointTNpointTNpointLogicalFunction requires 6 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + return TemporalEDisjointTNpointTNpointLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEDisjointTPoseGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEDisjointTPoseGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..34d0974c49 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEDisjointTPoseGeometryLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEDisjointTPoseGeometryLogicalFunction::TemporalEDisjointTPoseGeometryLogicalFunction(LogicalFunction x, + LogicalFunction y, + LogicalFunction theta, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalEDisjointTPoseGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEDisjointTPoseGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEDisjointTPoseGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEDisjointTPoseGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalEDisjointTPoseGeometryLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEDisjointTPoseGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEDisjointTPoseGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEDisjointTPoseGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEDisjointTPoseGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEDisjointTPoseGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEDisjointTPoseGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalEDisjointTPoseGeometryLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalEDisjointTPoseGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEDisjointTPoseTPoseLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEDisjointTPoseTPoseLogicalFunction.cpp new file mode 100644 index 0000000000..4f6d937e17 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEDisjointTPoseTPoseLogicalFunction.cpp @@ -0,0 +1,143 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEDisjointTPoseTPoseLogicalFunction::TemporalEDisjointTPoseTPoseLogicalFunction(LogicalFunction xA, + LogicalFunction yA, + LogicalFunction thetaA, + LogicalFunction tsA, + LogicalFunction xB, + LogicalFunction yB, + LogicalFunction thetaB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(8); + parameters.push_back(std::move(xA)); + parameters.push_back(std::move(yA)); + parameters.push_back(std::move(thetaA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(xB)); + parameters.push_back(std::move(yB)); + parameters.push_back(std::move(thetaB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalEDisjointTPoseTPoseLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEDisjointTPoseTPoseLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEDisjointTPoseTPoseLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEDisjointTPoseTPoseLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, "TemporalEDisjointTPoseTPoseLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEDisjointTPoseTPoseLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEDisjointTPoseTPoseLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEDisjointTPoseTPoseLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEDisjointTPoseTPoseLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEDisjointTPoseTPoseLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEDisjointTPoseTPoseLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "TemporalEDisjointTPoseTPoseLogicalFunction requires 8 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + auto arg6 = std::move(arguments.children[6]); + auto arg7 = std::move(arguments.children[7]); + return TemporalEDisjointTPoseTPoseLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEIntersectsGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEIntersectsGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..5c9410391a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEIntersectsGeometryLogicalFunction.cpp @@ -0,0 +1,131 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEIntersectsGeometryLogicalFunction::TemporalEIntersectsGeometryLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(4); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalEIntersectsGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEIntersectsGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEIntersectsGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEIntersectsGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, "TemporalEIntersectsGeometryLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEIntersectsGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEIntersectsGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEIntersectsGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEIntersectsGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEIntersectsGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEIntersectsGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "TemporalEIntersectsGeometryLogicalFunction requires 4 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + return TemporalEIntersectsGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEIntersectsTCbufferCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEIntersectsTCbufferCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..bc74a2ced1 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEIntersectsTCbufferCbufferLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEIntersectsTCbufferCbufferLogicalFunction::TemporalEIntersectsTCbufferCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction cbufferLit) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(cbufferLit)); +} + +DataType TemporalEIntersectsTCbufferCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEIntersectsTCbufferCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEIntersectsTCbufferCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEIntersectsTCbufferCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalEIntersectsTCbufferCbufferLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEIntersectsTCbufferCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEIntersectsTCbufferCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEIntersectsTCbufferCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEIntersectsTCbufferCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEIntersectsTCbufferCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEIntersectsTCbufferCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalEIntersectsTCbufferCbufferLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalEIntersectsTCbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEIntersectsTCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEIntersectsTCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..24706e36ad --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEIntersectsTCbufferLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEIntersectsTCbufferLogicalFunction::TemporalEIntersectsTCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalEIntersectsTCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEIntersectsTCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEIntersectsTCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEIntersectsTCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalEIntersectsTCbufferLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEIntersectsTCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEIntersectsTCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEIntersectsTCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEIntersectsTCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEIntersectsTCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEIntersectsTCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalEIntersectsTCbufferLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalEIntersectsTCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEIntersectsTCbufferTCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEIntersectsTCbufferTCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..b156bc2db6 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEIntersectsTCbufferTCbufferLogicalFunction.cpp @@ -0,0 +1,143 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEIntersectsTCbufferTCbufferLogicalFunction::TemporalEIntersectsTCbufferTCbufferLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction radiusA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction radiusB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(8); + parameters.push_back(std::move(lonA)); + parameters.push_back(std::move(latA)); + parameters.push_back(std::move(radiusA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(lonB)); + parameters.push_back(std::move(latB)); + parameters.push_back(std::move(radiusB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalEIntersectsTCbufferTCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEIntersectsTCbufferTCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEIntersectsTCbufferTCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEIntersectsTCbufferTCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, "TemporalEIntersectsTCbufferTCbufferLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEIntersectsTCbufferTCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEIntersectsTCbufferTCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEIntersectsTCbufferTCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEIntersectsTCbufferTCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEIntersectsTCbufferTCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEIntersectsTCbufferTCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "TemporalEIntersectsTCbufferTCbufferLogicalFunction requires 8 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + auto arg6 = std::move(arguments.children[6]); + auto arg7 = std::move(arguments.children[7]); + return TemporalEIntersectsTCbufferTCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEIntersectsTGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEIntersectsTGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..51bdd9f33b --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEIntersectsTGeometryLogicalFunction.cpp @@ -0,0 +1,137 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEIntersectsTGeometryLogicalFunction::TemporalEIntersectsTGeometryLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lonA)); + parameters.push_back(std::move(latA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(lonB)); + parameters.push_back(std::move(latB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalEIntersectsTGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEIntersectsTGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEIntersectsTGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEIntersectsTGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, "TemporalEIntersectsTGeometryLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEIntersectsTGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEIntersectsTGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEIntersectsTGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEIntersectsTGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEIntersectsTGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEIntersectsTGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "TemporalEIntersectsTGeometryLogicalFunction requires 6 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + return TemporalEIntersectsTGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEIntersectsTNpointGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEIntersectsTNpointGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..5860977c20 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEIntersectsTNpointGeometryLogicalFunction.cpp @@ -0,0 +1,131 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEIntersectsTNpointGeometryLogicalFunction::TemporalEIntersectsTNpointGeometryLogicalFunction(LogicalFunction rid, + LogicalFunction fraction, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(4); + parameters.push_back(std::move(rid)); + parameters.push_back(std::move(fraction)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalEIntersectsTNpointGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEIntersectsTNpointGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEIntersectsTNpointGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEIntersectsTNpointGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, "TemporalEIntersectsTNpointGeometryLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEIntersectsTNpointGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEIntersectsTNpointGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEIntersectsTNpointGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEIntersectsTNpointGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEIntersectsTNpointGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEIntersectsTNpointGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "TemporalEIntersectsTNpointGeometryLogicalFunction requires 4 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + return TemporalEIntersectsTNpointGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEIntersectsTNpointTNpointLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEIntersectsTNpointTNpointLogicalFunction.cpp new file mode 100644 index 0000000000..dff7a41b5d --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEIntersectsTNpointTNpointLogicalFunction.cpp @@ -0,0 +1,137 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEIntersectsTNpointTNpointLogicalFunction::TemporalEIntersectsTNpointTNpointLogicalFunction(LogicalFunction ridA, + LogicalFunction fractionA, + LogicalFunction tsA, + LogicalFunction ridB, + LogicalFunction fractionB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(6); + parameters.push_back(std::move(ridA)); + parameters.push_back(std::move(fractionA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(ridB)); + parameters.push_back(std::move(fractionB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalEIntersectsTNpointTNpointLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEIntersectsTNpointTNpointLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEIntersectsTNpointTNpointLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEIntersectsTNpointTNpointLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, "TemporalEIntersectsTNpointTNpointLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEIntersectsTNpointTNpointLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEIntersectsTNpointTNpointLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEIntersectsTNpointTNpointLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEIntersectsTNpointTNpointLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEIntersectsTNpointTNpointLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEIntersectsTNpointTNpointLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "TemporalEIntersectsTNpointTNpointLogicalFunction requires 6 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + return TemporalEIntersectsTNpointTNpointLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEIntersectsTPoseGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEIntersectsTPoseGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..124a9204ac --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEIntersectsTPoseGeometryLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEIntersectsTPoseGeometryLogicalFunction::TemporalEIntersectsTPoseGeometryLogicalFunction(LogicalFunction x, + LogicalFunction y, + LogicalFunction theta, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalEIntersectsTPoseGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEIntersectsTPoseGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEIntersectsTPoseGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEIntersectsTPoseGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalEIntersectsTPoseGeometryLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEIntersectsTPoseGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEIntersectsTPoseGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEIntersectsTPoseGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEIntersectsTPoseGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEIntersectsTPoseGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEIntersectsTPoseGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalEIntersectsTPoseGeometryLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalEIntersectsTPoseGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalEIntersectsTPoseTPoseLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalEIntersectsTPoseTPoseLogicalFunction.cpp new file mode 100644 index 0000000000..75a8a8665c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalEIntersectsTPoseTPoseLogicalFunction.cpp @@ -0,0 +1,143 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalEIntersectsTPoseTPoseLogicalFunction::TemporalEIntersectsTPoseTPoseLogicalFunction(LogicalFunction xA, + LogicalFunction yA, + LogicalFunction thetaA, + LogicalFunction tsA, + LogicalFunction xB, + LogicalFunction yB, + LogicalFunction thetaB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(8); + parameters.push_back(std::move(xA)); + parameters.push_back(std::move(yA)); + parameters.push_back(std::move(thetaA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(xB)); + parameters.push_back(std::move(yB)); + parameters.push_back(std::move(thetaB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalEIntersectsTPoseTPoseLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalEIntersectsTPoseTPoseLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalEIntersectsTPoseTPoseLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalEIntersectsTPoseTPoseLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, "TemporalEIntersectsTPoseTPoseLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalEIntersectsTPoseTPoseLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalEIntersectsTPoseTPoseLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalEIntersectsTPoseTPoseLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalEIntersectsTPoseTPoseLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalEIntersectsTPoseTPoseLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalEIntersectsTPoseTPoseLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "TemporalEIntersectsTPoseTPoseLogicalFunction requires 8 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + auto arg6 = std::move(arguments.children[6]); + auto arg7 = std::move(arguments.children[7]); + return TemporalEIntersectsTPoseTPoseLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalETouchesGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalETouchesGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..fc0fbc2ddd --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalETouchesGeometryLogicalFunction.cpp @@ -0,0 +1,131 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalETouchesGeometryLogicalFunction::TemporalETouchesGeometryLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(4); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalETouchesGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalETouchesGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalETouchesGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalETouchesGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, "TemporalETouchesGeometryLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalETouchesGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalETouchesGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalETouchesGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalETouchesGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalETouchesGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalETouchesGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "TemporalETouchesGeometryLogicalFunction requires 4 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + return TemporalETouchesGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalETouchesTCbufferCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalETouchesTCbufferCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..06eaee2b28 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalETouchesTCbufferCbufferLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalETouchesTCbufferCbufferLogicalFunction::TemporalETouchesTCbufferCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction cbufferLit) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(cbufferLit)); +} + +DataType TemporalETouchesTCbufferCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalETouchesTCbufferCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalETouchesTCbufferCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalETouchesTCbufferCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalETouchesTCbufferCbufferLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalETouchesTCbufferCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalETouchesTCbufferCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalETouchesTCbufferCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalETouchesTCbufferCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalETouchesTCbufferCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalETouchesTCbufferCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalETouchesTCbufferCbufferLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalETouchesTCbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalETouchesTCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalETouchesTCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..b9d0dda919 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalETouchesTCbufferLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalETouchesTCbufferLogicalFunction::TemporalETouchesTCbufferLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction radius, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalETouchesTCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalETouchesTCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalETouchesTCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalETouchesTCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalETouchesTCbufferLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalETouchesTCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalETouchesTCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalETouchesTCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalETouchesTCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalETouchesTCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalETouchesTCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalETouchesTCbufferLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalETouchesTCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalETouchesTCbufferTCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalETouchesTCbufferTCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..e123b01fd8 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalETouchesTCbufferTCbufferLogicalFunction.cpp @@ -0,0 +1,143 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalETouchesTCbufferTCbufferLogicalFunction::TemporalETouchesTCbufferTCbufferLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction radiusA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction radiusB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(8); + parameters.push_back(std::move(lonA)); + parameters.push_back(std::move(latA)); + parameters.push_back(std::move(radiusA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(lonB)); + parameters.push_back(std::move(latB)); + parameters.push_back(std::move(radiusB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalETouchesTCbufferTCbufferLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalETouchesTCbufferTCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalETouchesTCbufferTCbufferLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalETouchesTCbufferTCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, "TemporalETouchesTCbufferTCbufferLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalETouchesTCbufferTCbufferLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalETouchesTCbufferTCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalETouchesTCbufferTCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalETouchesTCbufferTCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalETouchesTCbufferTCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalETouchesTCbufferTCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "TemporalETouchesTCbufferTCbufferLogicalFunction requires 8 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + auto arg6 = std::move(arguments.children[6]); + auto arg7 = std::move(arguments.children[7]); + return TemporalETouchesTCbufferTCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalETouchesTGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalETouchesTGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..ad25f0f20c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalETouchesTGeometryLogicalFunction.cpp @@ -0,0 +1,137 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalETouchesTGeometryLogicalFunction::TemporalETouchesTGeometryLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lonA)); + parameters.push_back(std::move(latA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(lonB)); + parameters.push_back(std::move(latB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalETouchesTGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalETouchesTGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalETouchesTGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalETouchesTGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, "TemporalETouchesTGeometryLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalETouchesTGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalETouchesTGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalETouchesTGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalETouchesTGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalETouchesTGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalETouchesTGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "TemporalETouchesTGeometryLogicalFunction requires 6 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + return TemporalETouchesTGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalETouchesTNpointGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalETouchesTNpointGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..09821a8cb3 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalETouchesTNpointGeometryLogicalFunction.cpp @@ -0,0 +1,131 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalETouchesTNpointGeometryLogicalFunction::TemporalETouchesTNpointGeometryLogicalFunction(LogicalFunction rid, + LogicalFunction fraction, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(4); + parameters.push_back(std::move(rid)); + parameters.push_back(std::move(fraction)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalETouchesTNpointGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalETouchesTNpointGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalETouchesTNpointGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalETouchesTNpointGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, "TemporalETouchesTNpointGeometryLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalETouchesTNpointGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalETouchesTNpointGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalETouchesTNpointGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalETouchesTNpointGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalETouchesTNpointGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalETouchesTNpointGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "TemporalETouchesTNpointGeometryLogicalFunction requires 4 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + return TemporalETouchesTNpointGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalETouchesTNpointTNpointLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalETouchesTNpointTNpointLogicalFunction.cpp new file mode 100644 index 0000000000..b3d8b8c0ba --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalETouchesTNpointTNpointLogicalFunction.cpp @@ -0,0 +1,137 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalETouchesTNpointTNpointLogicalFunction::TemporalETouchesTNpointTNpointLogicalFunction(LogicalFunction ridA, + LogicalFunction fractionA, + LogicalFunction tsA, + LogicalFunction ridB, + LogicalFunction fractionB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(6); + parameters.push_back(std::move(ridA)); + parameters.push_back(std::move(fractionA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(ridB)); + parameters.push_back(std::move(fractionB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalETouchesTNpointTNpointLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalETouchesTNpointTNpointLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalETouchesTNpointTNpointLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalETouchesTNpointTNpointLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, "TemporalETouchesTNpointTNpointLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalETouchesTNpointTNpointLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalETouchesTNpointTNpointLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalETouchesTNpointTNpointLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalETouchesTNpointTNpointLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalETouchesTNpointTNpointLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalETouchesTNpointTNpointLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "TemporalETouchesTNpointTNpointLogicalFunction requires 6 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + return TemporalETouchesTNpointTNpointLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalETouchesTPoseGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalETouchesTPoseGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..cf0f71eb87 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalETouchesTPoseGeometryLogicalFunction.cpp @@ -0,0 +1,134 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalETouchesTPoseGeometryLogicalFunction::TemporalETouchesTPoseGeometryLogicalFunction(LogicalFunction x, + LogicalFunction y, + LogicalFunction theta, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(5); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalETouchesTPoseGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalETouchesTPoseGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalETouchesTPoseGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalETouchesTPoseGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, "TemporalETouchesTPoseGeometryLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalETouchesTPoseGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalETouchesTPoseGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalETouchesTPoseGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalETouchesTPoseGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalETouchesTPoseGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalETouchesTPoseGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "TemporalETouchesTPoseGeometryLogicalFunction requires 5 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + return TemporalETouchesTPoseGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalETouchesTPoseTPoseLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalETouchesTPoseTPoseLogicalFunction.cpp new file mode 100644 index 0000000000..9fbc60bb0c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalETouchesTPoseTPoseLogicalFunction.cpp @@ -0,0 +1,143 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalETouchesTPoseTPoseLogicalFunction::TemporalETouchesTPoseTPoseLogicalFunction(LogicalFunction xA, + LogicalFunction yA, + LogicalFunction thetaA, + LogicalFunction tsA, + LogicalFunction xB, + LogicalFunction yB, + LogicalFunction thetaB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(8); + parameters.push_back(std::move(xA)); + parameters.push_back(std::move(yA)); + parameters.push_back(std::move(thetaA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(xB)); + parameters.push_back(std::move(yB)); + parameters.push_back(std::move(thetaB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalETouchesTPoseTPoseLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalETouchesTPoseTPoseLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalETouchesTPoseTPoseLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalETouchesTPoseTPoseLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, "TemporalETouchesTPoseTPoseLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalETouchesTPoseTPoseLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalETouchesTPoseTPoseLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalETouchesTPoseTPoseLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalETouchesTPoseTPoseLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalETouchesTPoseTPoseLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalETouchesTPoseTPoseLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "TemporalETouchesTPoseTPoseLogicalFunction requires 8 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + auto arg6 = std::move(arguments.children[6]); + auto arg7 = std::move(arguments.children[7]); + return TemporalETouchesTPoseTPoseLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalMinusGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalMinusGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..cf8e3098d7 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalMinusGeometryLogicalFunction.cpp @@ -0,0 +1,131 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalMinusGeometryLogicalFunction::TemporalMinusGeometryLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(4); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalMinusGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalMinusGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalMinusGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalMinusGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, "TemporalMinusGeometryLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalMinusGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalMinusGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalMinusGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalMinusGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalMinusGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalMinusGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "TemporalMinusGeometryLogicalFunction requires 4 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + return TemporalMinusGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalNADFloatScalarLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalNADFloatScalarLogicalFunction.cpp new file mode 100644 index 0000000000..31407bf454 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalNADFloatScalarLogicalFunction.cpp @@ -0,0 +1,128 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalNADFloatScalarLogicalFunction::TemporalNADFloatScalarLogicalFunction(LogicalFunction value, + LogicalFunction timestamp, + LogicalFunction scalar) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(scalar)); +} + +DataType TemporalNADFloatScalarLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalNADFloatScalarLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalNADFloatScalarLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalNADFloatScalarLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TemporalNADFloatScalarLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalNADFloatScalarLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalNADFloatScalarLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalNADFloatScalarLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalNADFloatScalarLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalNADFloatScalarLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalNADFloatScalarLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TemporalNADFloatScalarLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TemporalNADFloatScalarLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalNADGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalNADGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..ee72c0f47e --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalNADGeometryLogicalFunction.cpp @@ -0,0 +1,131 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalNADGeometryLogicalFunction::TemporalNADGeometryLogicalFunction(LogicalFunction lon, + LogicalFunction lat, + LogicalFunction timestamp, + LogicalFunction geometry) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(4); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(geometry)); +} + +DataType TemporalNADGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalNADGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalNADGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalNADGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, "TemporalNADGeometryLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalNADGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalNADGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalNADGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalNADGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalNADGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalNADGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "TemporalNADGeometryLogicalFunction requires 4 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + return TemporalNADGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalNADIntScalarLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalNADIntScalarLogicalFunction.cpp new file mode 100644 index 0000000000..b30dfcf072 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalNADIntScalarLogicalFunction.cpp @@ -0,0 +1,128 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalNADIntScalarLogicalFunction::TemporalNADIntScalarLogicalFunction(LogicalFunction value, + LogicalFunction timestamp, + LogicalFunction scalar) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(timestamp)); + parameters.push_back(std::move(scalar)); +} + +DataType TemporalNADIntScalarLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalNADIntScalarLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalNADIntScalarLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalNADIntScalarLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TemporalNADIntScalarLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalNADIntScalarLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalNADIntScalarLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalNADIntScalarLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalNADIntScalarLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalNADIntScalarLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalNADIntScalarLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TemporalNADIntScalarLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TemporalNADIntScalarLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalNADTFloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalNADTFloatLogicalFunction.cpp new file mode 100644 index 0000000000..6c9340c5ec --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalNADTFloatLogicalFunction.cpp @@ -0,0 +1,131 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalNADTFloatLogicalFunction::TemporalNADTFloatLogicalFunction(LogicalFunction valueA, + LogicalFunction tsA, + LogicalFunction valueB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(4); + parameters.push_back(std::move(valueA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(valueB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalNADTFloatLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalNADTFloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalNADTFloatLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalNADTFloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, "TemporalNADTFloatLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalNADTFloatLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalNADTFloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalNADTFloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalNADTFloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalNADTFloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalNADTFloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "TemporalNADTFloatLogicalFunction requires 4 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + return TemporalNADTFloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalNADTGeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalNADTGeometryLogicalFunction.cpp new file mode 100644 index 0000000000..60ca7071f7 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalNADTGeometryLogicalFunction.cpp @@ -0,0 +1,137 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalNADTGeometryLogicalFunction::TemporalNADTGeometryLogicalFunction(LogicalFunction lonA, + LogicalFunction latA, + LogicalFunction tsA, + LogicalFunction lonB, + LogicalFunction latB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lonA)); + parameters.push_back(std::move(latA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(lonB)); + parameters.push_back(std::move(latB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalNADTGeometryLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalNADTGeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalNADTGeometryLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalNADTGeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, "TemporalNADTGeometryLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalNADTGeometryLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalNADTGeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalNADTGeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalNADTGeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalNADTGeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalNADTGeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "TemporalNADTGeometryLogicalFunction requires 6 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + auto arg4 = std::move(arguments.children[4]); + auto arg5 = std::move(arguments.children[5]); + return TemporalNADTGeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalNADTIntLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalNADTIntLogicalFunction.cpp new file mode 100644 index 0000000000..42d47581e6 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalNADTIntLogicalFunction.cpp @@ -0,0 +1,131 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalNADTIntLogicalFunction::TemporalNADTIntLogicalFunction(LogicalFunction valueA, + LogicalFunction tsA, + LogicalFunction valueB, + LogicalFunction tsB) + : dataType(DataTypeProvider::provideDataType(DataType::Type::INT32)) +{ + parameters.reserve(4); + parameters.push_back(std::move(valueA)); + parameters.push_back(std::move(tsA)); + parameters.push_back(std::move(valueB)); + parameters.push_back(std::move(tsB)); +} + +DataType TemporalNADTIntLogicalFunction::getDataType() const +{ + return dataType; +} + +LogicalFunction TemporalNADTIntLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +} + +std::vector TemporalNADTIntLogicalFunction::getChildren() const +{ + return parameters; +} + +LogicalFunction TemporalNADTIntLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, "TemporalNADTIntLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +} + +std::string_view TemporalNADTIntLogicalFunction::getType() const +{ + return NAME; +} + +bool TemporalNADTIntLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + { + return parameters == other->parameters; + } + return false; +} + +std::string TemporalNADTIntLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + { + if (index > 0) + { + args += ", "; + } + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalNADTIntLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + { + newChildren.emplace_back(child.withInferredDataType(schema)); + } + return withChildren(newChildren); +} + +SerializableFunction TemporalNADTIntLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + { + proto.add_children()->CopyFrom(child.serialize()); + } + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalNADTIntLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "TemporalNADTIntLogicalFunction requires 4 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + return TemporalNADTIntLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/CMakeLists.txt b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/CMakeLists.txt index 9cdfcdb2dc..774775b22c 100644 --- a/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/CMakeLists.txt @@ -12,3 +12,26 @@ add_plugin(Var AggregationLogicalFunction nes-logical-operators VarAggregationLogicalFunction.cpp) add_plugin(TemporalSequence AggregationLogicalFunction nes-logical-operators TemporalSequenceAggregationLogicalFunctionV2.cpp) +add_plugin(TemporalLength AggregationLogicalFunction nes-logical-operators TemporalLengthAggregationLogicalFunction.cpp) +add_plugin(PairMeeting AggregationLogicalFunction nes-logical-operators PairMeetingAggregationLogicalFunction.cpp) +add_plugin(CrossDistance AggregationLogicalFunction nes-logical-operators CrossDistanceAggregationLogicalFunction.cpp) +add_plugin(TemporalNumInstants AggregationLogicalFunction nes-logical-operators TemporalNumInstantsAggregationLogicalFunction.cpp) +add_plugin(TemporalNumSequences AggregationLogicalFunction nes-logical-operators TemporalNumSequencesAggregationLogicalFunction.cpp) +add_plugin(TemporalNumTimestamps AggregationLogicalFunction nes-logical-operators TemporalNumTimestampsAggregationLogicalFunction.cpp) +add_plugin(TemporalTFloatStartValue AggregationLogicalFunction nes-logical-operators TemporalTFloatStartValueAggregationLogicalFunction.cpp) +add_plugin(TemporalTFloatEndValue AggregationLogicalFunction nes-logical-operators TemporalTFloatEndValueAggregationLogicalFunction.cpp) +add_plugin(TemporalTFloatMinValue AggregationLogicalFunction nes-logical-operators TemporalTFloatMinValueAggregationLogicalFunction.cpp) +add_plugin(TemporalTFloatMaxValue AggregationLogicalFunction nes-logical-operators TemporalTFloatMaxValueAggregationLogicalFunction.cpp) +add_plugin(TemporalTNumberIntegral AggregationLogicalFunction nes-logical-operators TemporalTNumberIntegralAggregationLogicalFunction.cpp) +add_plugin(TemporalTIntStartValue AggregationLogicalFunction nes-logical-operators TemporalTIntStartValueAggregationLogicalFunction.cpp) +add_plugin(TemporalTIntEndValue AggregationLogicalFunction nes-logical-operators TemporalTIntEndValueAggregationLogicalFunction.cpp) +add_plugin(TemporalTIntMinValue AggregationLogicalFunction nes-logical-operators TemporalTIntMinValueAggregationLogicalFunction.cpp) +add_plugin(TemporalTIntMaxValue AggregationLogicalFunction nes-logical-operators TemporalTIntMaxValueAggregationLogicalFunction.cpp) +add_plugin(TemporalTFloatAvgValue AggregationLogicalFunction nes-logical-operators TemporalTFloatAvgValueAggregationLogicalFunction.cpp) +add_plugin(TemporalTNumberTwAvg AggregationLogicalFunction nes-logical-operators TemporalTNumberTwAvgAggregationLogicalFunction.cpp) +add_plugin(TemporalTIntAvgValue AggregationLogicalFunction nes-logical-operators TemporalTIntAvgValueAggregationLogicalFunction.cpp) +add_plugin(TemporalStartTimestamp AggregationLogicalFunction nes-logical-operators TemporalStartTimestampAggregationLogicalFunction.cpp) +add_plugin(TemporalEndTimestamp AggregationLogicalFunction nes-logical-operators TemporalEndTimestampAggregationLogicalFunction.cpp) +add_plugin(TemporalLowerInc AggregationLogicalFunction nes-logical-operators TemporalLowerIncAggregationLogicalFunction.cpp) +add_plugin(TemporalUpperInc AggregationLogicalFunction nes-logical-operators TemporalUpperIncAggregationLogicalFunction.cpp) +add_plugin(TemporalTPointIsSimple AggregationLogicalFunction nes-logical-operators TemporalTPointIsSimpleAggregationLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/CrossDistanceAggregationLogicalFunction.cpp b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/CrossDistanceAggregationLogicalFunction.cpp new file mode 100644 index 0000000000..b92570d6c3 --- /dev/null +++ b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/CrossDistanceAggregationLogicalFunction.cpp @@ -0,0 +1,157 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace NES +{ + +CrossDistanceAggregationLogicalFunction::CrossDistanceAggregationLogicalFunction( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& vehicleIdField, + const FieldAccessLogicalFunction& asField, + uint64_t vidA, + uint64_t vidB) + : WindowAggregationLogicalFunction( + lonField.getDataType(), + DataTypeProvider::provideDataType(partialAggregateStampType), + DataTypeProvider::provideDataType(finalAggregateStampType), + lonField, + asField) + , lonField(lonField) + , latField(latField) + , timestampField(timestampField) + , vehicleIdField(vehicleIdField) + , vidA(vidA) + , vidB(vidB) +{ +} + +std::shared_ptr +CrossDistanceAggregationLogicalFunction::create( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& vehicleIdField, + uint64_t vidA, + uint64_t vidB) +{ + return std::make_shared( + lonField, latField, timestampField, vehicleIdField, lonField, vidA, vidB); +} + +std::string_view CrossDistanceAggregationLogicalFunction::getName() const noexcept +{ + return NAME; +} + +void CrossDistanceAggregationLogicalFunction::inferStamp(const Schema& schema) +{ + lonField = lonField.withInferredDataType(schema).get(); + latField = latField.withInferredDataType(schema).get(); + timestampField = timestampField.withInferredDataType(schema).get(); + vehicleIdField = vehicleIdField.withInferredDataType(schema).get(); + + onField = lonField; + + if (!lonField.getDataType().isNumeric() || !latField.getDataType().isNumeric() + || !timestampField.getDataType().isNumeric() || !vehicleIdField.getDataType().isNumeric()) + { + throw CannotInferSchema("CrossDistanceAggregationLogicalFunction: lon, lat, timestamp, and vehicle_id fields must be numeric."); + } + + const auto onFieldName = onField.getFieldName(); + const auto asFieldName = asField.getFieldName(); + const auto attributeNameResolver = onFieldName.substr(0, onFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + if (asFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) == std::string::npos) + { + asField = asField.withFieldName(attributeNameResolver + asFieldName).get(); + } + else + { + const auto fieldName = asFieldName.substr(asFieldName.find_last_of(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + asField = asField.withFieldName(attributeNameResolver + fieldName).get(); + } + asField = asField.withDataType(getFinalAggregateStamp()).get(); + inputStamp = onField.getDataType(); +} + +NES::SerializableAggregationFunction CrossDistanceAggregationLogicalFunction::serialize() const +{ + SerializableAggregationFunction saf; + saf.set_type(std::string(NAME)); + + SerializableFunction lonProto; + lonProto.CopyFrom(LogicalFunction(lonField).serialize()); + saf.mutable_on_field()->CopyFrom(lonProto); + + SerializableFunction asProto; + asProto.CopyFrom(LogicalFunction(asField).serialize()); + saf.mutable_as_field()->CopyFrom(asProto); + + SerializableFunction latProto; + latProto.CopyFrom(LogicalFunction(latField).serialize()); + saf.add_extra_fields()->CopyFrom(latProto); + + SerializableFunction tsProto; + tsProto.CopyFrom(LogicalFunction(timestampField).serialize()); + saf.add_extra_fields()->CopyFrom(tsProto); + + SerializableFunction vidProto; + vidProto.CopyFrom(LogicalFunction(vehicleIdField).serialize()); + saf.add_extra_fields()->CopyFrom(vidProto); + + return saf; +} + +AggregationLogicalFunctionRegistryReturnType AggregationLogicalFunctionGeneratedRegistrar::RegisterCrossDistanceAggregationLogicalFunction( + AggregationLogicalFunctionRegistryArguments arguments) +{ + if (arguments.fields.size() == 5) + { + // The Registrar only carries the 5 field args (lon, lat, ts, vid, asField) — the + // SerializableAggregationFunction proto does not yet have slots for the (vidA, + // vidB) constants, so the deserialize path reconstructs with the + // BerlinMOD-scaffold defaults. The parser path always supplies explicit values + // from the SQL constant args. Adding (vidA, vidB) to the proto + extending the + // Registrar args struct would close the round-trip gap; tracked as a follow-up + // alongside the matching PairMeeting Serde follow-up (PR #19). + auto ptr = std::make_shared( + arguments.fields[0], arguments.fields[1], arguments.fields[2], arguments.fields[3], arguments.fields[4], + CrossDistanceAggregationLogicalFunction::DEFAULT_VID_A, + CrossDistanceAggregationLogicalFunction::DEFAULT_VID_B); + return ptr; + } + throw CannotDeserialize( + "CrossDistanceAggregationLogicalFunction requires lon, lat, timestamp, vehicle_id, and alias fields but got {}", + arguments.fields.size()); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/PairMeetingAggregationLogicalFunction.cpp b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/PairMeetingAggregationLogicalFunction.cpp new file mode 100644 index 0000000000..d29b898b13 --- /dev/null +++ b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/PairMeetingAggregationLogicalFunction.cpp @@ -0,0 +1,156 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace NES +{ + +PairMeetingAggregationLogicalFunction::PairMeetingAggregationLogicalFunction( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& vehicleIdField, + const FieldAccessLogicalFunction& asField, + double dMeetMetres) + : WindowAggregationLogicalFunction( + lonField.getDataType(), + DataTypeProvider::provideDataType(partialAggregateStampType), + DataTypeProvider::provideDataType(finalAggregateStampType), + lonField, + asField) + , lonField(lonField) + , latField(latField) + , timestampField(timestampField) + , vehicleIdField(vehicleIdField) + , dMeetMetres(dMeetMetres) +{ +} + +std::shared_ptr +PairMeetingAggregationLogicalFunction::create( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& vehicleIdField, + double dMeetMetres) +{ + return std::make_shared( + lonField, latField, timestampField, vehicleIdField, lonField, dMeetMetres); +} + +std::string_view PairMeetingAggregationLogicalFunction::getName() const noexcept +{ + return NAME; +} + +void PairMeetingAggregationLogicalFunction::inferStamp(const Schema& schema) +{ + lonField = lonField.withInferredDataType(schema).get(); + latField = latField.withInferredDataType(schema).get(); + timestampField = timestampField.withInferredDataType(schema).get(); + vehicleIdField = vehicleIdField.withInferredDataType(schema).get(); + + onField = lonField; + + if (!lonField.getDataType().isNumeric() || !latField.getDataType().isNumeric() + || !timestampField.getDataType().isNumeric() || !vehicleIdField.getDataType().isNumeric()) + { + throw CannotInferSchema("PairMeetingAggregationLogicalFunction: lon, lat, timestamp, and vehicle_id fields must be numeric."); + } + + const auto onFieldName = onField.getFieldName(); + const auto asFieldName = asField.getFieldName(); + const auto attributeNameResolver = onFieldName.substr(0, onFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + if (asFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) == std::string::npos) + { + asField = asField.withFieldName(attributeNameResolver + asFieldName).get(); + } + else + { + const auto fieldName = asFieldName.substr(asFieldName.find_last_of(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + asField = asField.withFieldName(attributeNameResolver + fieldName).get(); + } + asField = asField.withDataType(getFinalAggregateStamp()).get(); + inputStamp = onField.getDataType(); +} + +NES::SerializableAggregationFunction PairMeetingAggregationLogicalFunction::serialize() const +{ + SerializableAggregationFunction saf; + saf.set_type(std::string(NAME)); + + // on_field = lon + SerializableFunction lonProto; + lonProto.CopyFrom(LogicalFunction(lonField).serialize()); + saf.mutable_on_field()->CopyFrom(lonProto); + + // as_field = alias + SerializableFunction asProto; + asProto.CopyFrom(LogicalFunction(asField).serialize()); + saf.mutable_as_field()->CopyFrom(asProto); + + // extra fields = lat, ts, vehicle_id + SerializableFunction latProto; + latProto.CopyFrom(LogicalFunction(latField).serialize()); + saf.add_extra_fields()->CopyFrom(latProto); + + SerializableFunction tsProto; + tsProto.CopyFrom(LogicalFunction(timestampField).serialize()); + saf.add_extra_fields()->CopyFrom(tsProto); + + SerializableFunction vidProto; + vidProto.CopyFrom(LogicalFunction(vehicleIdField).serialize()); + saf.add_extra_fields()->CopyFrom(vidProto); + + return saf; +} + +AggregationLogicalFunctionRegistryReturnType AggregationLogicalFunctionGeneratedRegistrar::RegisterPairMeetingAggregationLogicalFunction( + AggregationLogicalFunctionRegistryArguments arguments) +{ + if (arguments.fields.size() == 5) + { + // The Registrar only carries the 5 field args (lon, lat, ts, vid, asField) — the + // SerializableAggregationFunction proto does not yet have a slot for the dMeet + // constant, so the deserialize path reconstructs with the BerlinMOD-scaffold + // default. The parser path always supplies an explicit dMeet from the SQL + // constant arg. Adding dMeet to the proto + extending the Registrar args struct + // would close the round-trip gap; tracked as a follow-up. + auto ptr = std::make_shared( + arguments.fields[0], arguments.fields[1], arguments.fields[2], arguments.fields[3], arguments.fields[4], + PairMeetingAggregationLogicalFunction::DEFAULT_DMEET_METRES); + return ptr; + } + throw CannotDeserialize( + "PairMeetingAggregationLogicalFunction requires lon, lat, timestamp, vehicle_id, and alias fields but got {}", + arguments.fields.size()); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalEndTimestampAggregationLogicalFunction.cpp b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalEndTimestampAggregationLogicalFunction.cpp new file mode 100644 index 0000000000..2c7284e4cd --- /dev/null +++ b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalEndTimestampAggregationLogicalFunction.cpp @@ -0,0 +1,116 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace NES +{ + +TemporalEndTimestampAggregationLogicalFunction::TemporalEndTimestampAggregationLogicalFunction( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField) + : WindowAggregationLogicalFunction( + lonField.getDataType(), + DataTypeProvider::provideDataType(partialAggregateStampType), + DataTypeProvider::provideDataType(finalAggregateStampType), + lonField, + asField) + , lonField(lonField) + , latField(latField) + , timestampField(timestampField) +{ +} + +std::shared_ptr +TemporalEndTimestampAggregationLogicalFunction::create( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField) +{ + return std::make_shared(lonField, latField, timestampField, lonField); +} + +std::string_view TemporalEndTimestampAggregationLogicalFunction::getName() const noexcept +{ + return NAME; +} + +void TemporalEndTimestampAggregationLogicalFunction::inferStamp(const Schema& schema) +{ + lonField = lonField.withInferredDataType(schema).get(); + latField = latField.withInferredDataType(schema).get(); + timestampField = timestampField.withInferredDataType(schema).get(); + + onField = lonField; + + if (!lonField.getDataType().isNumeric() || !latField.getDataType().isNumeric() || !timestampField.getDataType().isNumeric()) + { + throw CannotInferSchema("TemporalEndTimestampAggregationLogicalFunction: lon, lat, and timestamp fields must be numeric."); + } + + const auto onFieldName = onField.getFieldName(); + const auto asFieldName = asField.getFieldName(); + const auto attributeNameResolver = onFieldName.substr(0, onFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + if (asFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) == std::string::npos) + { + asField = asField.withFieldName(attributeNameResolver + asFieldName).get(); + } + else + { + const auto fieldName = asFieldName.substr(asFieldName.find_last_of(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + asField = asField.withFieldName(attributeNameResolver + fieldName).get(); + } + asField = asField.withDataType(getFinalAggregateStamp()).get(); + inputStamp = onField.getDataType(); +} + +NES::SerializableAggregationFunction TemporalEndTimestampAggregationLogicalFunction::serialize() const +{ + auto saf = TemporalAggregationSerde::serializeTemporalSequence(lonField, latField, timestampField, asField); + saf.set_type(std::string(NAME)); + return saf; +} + +AggregationLogicalFunctionRegistryReturnType AggregationLogicalFunctionGeneratedRegistrar::RegisterTemporalEndTimestampAggregationLogicalFunction( + AggregationLogicalFunctionRegistryArguments arguments) +{ + if (arguments.fields.size() == 4) + { + auto ptr = std::make_shared( + arguments.fields[0], arguments.fields[1], arguments.fields[2], arguments.fields[3]); + return ptr; + } + throw CannotDeserialize( + "TemporalEndTimestampAggregationLogicalFunction requires lon, lat, timestamp, and alias fields but got {}", + arguments.fields.size()); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalLengthAggregationLogicalFunction.cpp b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalLengthAggregationLogicalFunction.cpp new file mode 100644 index 0000000000..ff46bbc173 --- /dev/null +++ b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalLengthAggregationLogicalFunction.cpp @@ -0,0 +1,117 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace NES +{ + +TemporalLengthAggregationLogicalFunction::TemporalLengthAggregationLogicalFunction( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField) + : WindowAggregationLogicalFunction( + lonField.getDataType(), + DataTypeProvider::provideDataType(partialAggregateStampType), + DataTypeProvider::provideDataType(finalAggregateStampType), + lonField, + asField) + , lonField(lonField) + , latField(latField) + , timestampField(timestampField) +{ +} + +std::shared_ptr +TemporalLengthAggregationLogicalFunction::create( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField) +{ + return std::make_shared(lonField, latField, timestampField, lonField); +} + +std::string_view TemporalLengthAggregationLogicalFunction::getName() const noexcept +{ + return NAME; +} + +void TemporalLengthAggregationLogicalFunction::inferStamp(const Schema& schema) +{ + lonField = lonField.withInferredDataType(schema).get(); + latField = latField.withInferredDataType(schema).get(); + timestampField = timestampField.withInferredDataType(schema).get(); + + onField = lonField; + + if (!lonField.getDataType().isNumeric() || !latField.getDataType().isNumeric() || !timestampField.getDataType().isNumeric()) + { + throw CannotInferSchema("TemporalLengthAggregationLogicalFunction: lon, lat, and timestamp fields must be numeric."); + } + + const auto onFieldName = onField.getFieldName(); + const auto asFieldName = asField.getFieldName(); + const auto attributeNameResolver = onFieldName.substr(0, onFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + if (asFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) == std::string::npos) + { + asField = asField.withFieldName(attributeNameResolver + asFieldName).get(); + } + else + { + const auto fieldName = asFieldName.substr(asFieldName.find_last_of(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + asField = asField.withFieldName(attributeNameResolver + fieldName).get(); + } + asField = asField.withDataType(getFinalAggregateStamp()).get(); + inputStamp = onField.getDataType(); +} + +NES::SerializableAggregationFunction TemporalLengthAggregationLogicalFunction::serialize() const +{ + // Same wire shape as TemporalSequence (3 fields + alias); only the type tag differs. + auto saf = TemporalAggregationSerde::serializeTemporalSequence(lonField, latField, timestampField, asField); + saf.set_type(std::string(NAME)); + return saf; +} + +AggregationLogicalFunctionRegistryReturnType AggregationLogicalFunctionGeneratedRegistrar::RegisterTemporalLengthAggregationLogicalFunction( + AggregationLogicalFunctionRegistryArguments arguments) +{ + if (arguments.fields.size() == 4) + { + auto ptr = std::make_shared( + arguments.fields[0], arguments.fields[1], arguments.fields[2], arguments.fields[3]); + return ptr; + } + throw CannotDeserialize( + "TemporalLengthAggregationLogicalFunction requires lon, lat, timestamp, and alias fields but got {}", + arguments.fields.size()); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalLowerIncAggregationLogicalFunction.cpp b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalLowerIncAggregationLogicalFunction.cpp new file mode 100644 index 0000000000..a7d2ae1016 --- /dev/null +++ b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalLowerIncAggregationLogicalFunction.cpp @@ -0,0 +1,116 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace NES +{ + +TemporalLowerIncAggregationLogicalFunction::TemporalLowerIncAggregationLogicalFunction( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField) + : WindowAggregationLogicalFunction( + lonField.getDataType(), + DataTypeProvider::provideDataType(partialAggregateStampType), + DataTypeProvider::provideDataType(finalAggregateStampType), + lonField, + asField) + , lonField(lonField) + , latField(latField) + , timestampField(timestampField) +{ +} + +std::shared_ptr +TemporalLowerIncAggregationLogicalFunction::create( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField) +{ + return std::make_shared(lonField, latField, timestampField, lonField); +} + +std::string_view TemporalLowerIncAggregationLogicalFunction::getName() const noexcept +{ + return NAME; +} + +void TemporalLowerIncAggregationLogicalFunction::inferStamp(const Schema& schema) +{ + lonField = lonField.withInferredDataType(schema).get(); + latField = latField.withInferredDataType(schema).get(); + timestampField = timestampField.withInferredDataType(schema).get(); + + onField = lonField; + + if (!lonField.getDataType().isNumeric() || !latField.getDataType().isNumeric() || !timestampField.getDataType().isNumeric()) + { + throw CannotInferSchema("TemporalLowerIncAggregationLogicalFunction: lon, lat, and timestamp fields must be numeric."); + } + + const auto onFieldName = onField.getFieldName(); + const auto asFieldName = asField.getFieldName(); + const auto attributeNameResolver = onFieldName.substr(0, onFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + if (asFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) == std::string::npos) + { + asField = asField.withFieldName(attributeNameResolver + asFieldName).get(); + } + else + { + const auto fieldName = asFieldName.substr(asFieldName.find_last_of(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + asField = asField.withFieldName(attributeNameResolver + fieldName).get(); + } + asField = asField.withDataType(getFinalAggregateStamp()).get(); + inputStamp = onField.getDataType(); +} + +NES::SerializableAggregationFunction TemporalLowerIncAggregationLogicalFunction::serialize() const +{ + auto saf = TemporalAggregationSerde::serializeTemporalSequence(lonField, latField, timestampField, asField); + saf.set_type(std::string(NAME)); + return saf; +} + +AggregationLogicalFunctionRegistryReturnType AggregationLogicalFunctionGeneratedRegistrar::RegisterTemporalLowerIncAggregationLogicalFunction( + AggregationLogicalFunctionRegistryArguments arguments) +{ + if (arguments.fields.size() == 4) + { + auto ptr = std::make_shared( + arguments.fields[0], arguments.fields[1], arguments.fields[2], arguments.fields[3]); + return ptr; + } + throw CannotDeserialize( + "TemporalLowerIncAggregationLogicalFunction requires lon, lat, timestamp, and alias fields but got {}", + arguments.fields.size()); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalNumInstantsAggregationLogicalFunction.cpp b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalNumInstantsAggregationLogicalFunction.cpp new file mode 100644 index 0000000000..735a6c7cb9 --- /dev/null +++ b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalNumInstantsAggregationLogicalFunction.cpp @@ -0,0 +1,116 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace NES +{ + +TemporalNumInstantsAggregationLogicalFunction::TemporalNumInstantsAggregationLogicalFunction( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField) + : WindowAggregationLogicalFunction( + lonField.getDataType(), + DataTypeProvider::provideDataType(partialAggregateStampType), + DataTypeProvider::provideDataType(finalAggregateStampType), + lonField, + asField) + , lonField(lonField) + , latField(latField) + , timestampField(timestampField) +{ +} + +std::shared_ptr +TemporalNumInstantsAggregationLogicalFunction::create( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField) +{ + return std::make_shared(lonField, latField, timestampField, lonField); +} + +std::string_view TemporalNumInstantsAggregationLogicalFunction::getName() const noexcept +{ + return NAME; +} + +void TemporalNumInstantsAggregationLogicalFunction::inferStamp(const Schema& schema) +{ + lonField = lonField.withInferredDataType(schema).get(); + latField = latField.withInferredDataType(schema).get(); + timestampField = timestampField.withInferredDataType(schema).get(); + + onField = lonField; + + if (!lonField.getDataType().isNumeric() || !latField.getDataType().isNumeric() || !timestampField.getDataType().isNumeric()) + { + throw CannotInferSchema("TemporalNumInstantsAggregationLogicalFunction: lon, lat, and timestamp fields must be numeric."); + } + + const auto onFieldName = onField.getFieldName(); + const auto asFieldName = asField.getFieldName(); + const auto attributeNameResolver = onFieldName.substr(0, onFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + if (asFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) == std::string::npos) + { + asField = asField.withFieldName(attributeNameResolver + asFieldName).get(); + } + else + { + const auto fieldName = asFieldName.substr(asFieldName.find_last_of(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + asField = asField.withFieldName(attributeNameResolver + fieldName).get(); + } + asField = asField.withDataType(getFinalAggregateStamp()).get(); + inputStamp = onField.getDataType(); +} + +NES::SerializableAggregationFunction TemporalNumInstantsAggregationLogicalFunction::serialize() const +{ + auto saf = TemporalAggregationSerde::serializeTemporalSequence(lonField, latField, timestampField, asField); + saf.set_type(std::string(NAME)); + return saf; +} + +AggregationLogicalFunctionRegistryReturnType AggregationLogicalFunctionGeneratedRegistrar::RegisterTemporalNumInstantsAggregationLogicalFunction( + AggregationLogicalFunctionRegistryArguments arguments) +{ + if (arguments.fields.size() == 4) + { + auto ptr = std::make_shared( + arguments.fields[0], arguments.fields[1], arguments.fields[2], arguments.fields[3]); + return ptr; + } + throw CannotDeserialize( + "TemporalNumInstantsAggregationLogicalFunction requires lon, lat, timestamp, and alias fields but got {}", + arguments.fields.size()); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalNumSequencesAggregationLogicalFunction.cpp b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalNumSequencesAggregationLogicalFunction.cpp new file mode 100644 index 0000000000..ebcc060442 --- /dev/null +++ b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalNumSequencesAggregationLogicalFunction.cpp @@ -0,0 +1,116 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace NES +{ + +TemporalNumSequencesAggregationLogicalFunction::TemporalNumSequencesAggregationLogicalFunction( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField) + : WindowAggregationLogicalFunction( + lonField.getDataType(), + DataTypeProvider::provideDataType(partialAggregateStampType), + DataTypeProvider::provideDataType(finalAggregateStampType), + lonField, + asField) + , lonField(lonField) + , latField(latField) + , timestampField(timestampField) +{ +} + +std::shared_ptr +TemporalNumSequencesAggregationLogicalFunction::create( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField) +{ + return std::make_shared(lonField, latField, timestampField, lonField); +} + +std::string_view TemporalNumSequencesAggregationLogicalFunction::getName() const noexcept +{ + return NAME; +} + +void TemporalNumSequencesAggregationLogicalFunction::inferStamp(const Schema& schema) +{ + lonField = lonField.withInferredDataType(schema).get(); + latField = latField.withInferredDataType(schema).get(); + timestampField = timestampField.withInferredDataType(schema).get(); + + onField = lonField; + + if (!lonField.getDataType().isNumeric() || !latField.getDataType().isNumeric() || !timestampField.getDataType().isNumeric()) + { + throw CannotInferSchema("TemporalNumSequencesAggregationLogicalFunction: lon, lat, and timestamp fields must be numeric."); + } + + const auto onFieldName = onField.getFieldName(); + const auto asFieldName = asField.getFieldName(); + const auto attributeNameResolver = onFieldName.substr(0, onFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + if (asFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) == std::string::npos) + { + asField = asField.withFieldName(attributeNameResolver + asFieldName).get(); + } + else + { + const auto fieldName = asFieldName.substr(asFieldName.find_last_of(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + asField = asField.withFieldName(attributeNameResolver + fieldName).get(); + } + asField = asField.withDataType(getFinalAggregateStamp()).get(); + inputStamp = onField.getDataType(); +} + +NES::SerializableAggregationFunction TemporalNumSequencesAggregationLogicalFunction::serialize() const +{ + auto saf = TemporalAggregationSerde::serializeTemporalSequence(lonField, latField, timestampField, asField); + saf.set_type(std::string(NAME)); + return saf; +} + +AggregationLogicalFunctionRegistryReturnType AggregationLogicalFunctionGeneratedRegistrar::RegisterTemporalNumSequencesAggregationLogicalFunction( + AggregationLogicalFunctionRegistryArguments arguments) +{ + if (arguments.fields.size() == 4) + { + auto ptr = std::make_shared( + arguments.fields[0], arguments.fields[1], arguments.fields[2], arguments.fields[3]); + return ptr; + } + throw CannotDeserialize( + "TemporalNumSequencesAggregationLogicalFunction requires lon, lat, timestamp, and alias fields but got {}", + arguments.fields.size()); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalNumTimestampsAggregationLogicalFunction.cpp b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalNumTimestampsAggregationLogicalFunction.cpp new file mode 100644 index 0000000000..81133034b5 --- /dev/null +++ b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalNumTimestampsAggregationLogicalFunction.cpp @@ -0,0 +1,116 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace NES +{ + +TemporalNumTimestampsAggregationLogicalFunction::TemporalNumTimestampsAggregationLogicalFunction( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField) + : WindowAggregationLogicalFunction( + lonField.getDataType(), + DataTypeProvider::provideDataType(partialAggregateStampType), + DataTypeProvider::provideDataType(finalAggregateStampType), + lonField, + asField) + , lonField(lonField) + , latField(latField) + , timestampField(timestampField) +{ +} + +std::shared_ptr +TemporalNumTimestampsAggregationLogicalFunction::create( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField) +{ + return std::make_shared(lonField, latField, timestampField, lonField); +} + +std::string_view TemporalNumTimestampsAggregationLogicalFunction::getName() const noexcept +{ + return NAME; +} + +void TemporalNumTimestampsAggregationLogicalFunction::inferStamp(const Schema& schema) +{ + lonField = lonField.withInferredDataType(schema).get(); + latField = latField.withInferredDataType(schema).get(); + timestampField = timestampField.withInferredDataType(schema).get(); + + onField = lonField; + + if (!lonField.getDataType().isNumeric() || !latField.getDataType().isNumeric() || !timestampField.getDataType().isNumeric()) + { + throw CannotInferSchema("TemporalNumTimestampsAggregationLogicalFunction: lon, lat, and timestamp fields must be numeric."); + } + + const auto onFieldName = onField.getFieldName(); + const auto asFieldName = asField.getFieldName(); + const auto attributeNameResolver = onFieldName.substr(0, onFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + if (asFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) == std::string::npos) + { + asField = asField.withFieldName(attributeNameResolver + asFieldName).get(); + } + else + { + const auto fieldName = asFieldName.substr(asFieldName.find_last_of(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + asField = asField.withFieldName(attributeNameResolver + fieldName).get(); + } + asField = asField.withDataType(getFinalAggregateStamp()).get(); + inputStamp = onField.getDataType(); +} + +NES::SerializableAggregationFunction TemporalNumTimestampsAggregationLogicalFunction::serialize() const +{ + auto saf = TemporalAggregationSerde::serializeTemporalSequence(lonField, latField, timestampField, asField); + saf.set_type(std::string(NAME)); + return saf; +} + +AggregationLogicalFunctionRegistryReturnType AggregationLogicalFunctionGeneratedRegistrar::RegisterTemporalNumTimestampsAggregationLogicalFunction( + AggregationLogicalFunctionRegistryArguments arguments) +{ + if (arguments.fields.size() == 4) + { + auto ptr = std::make_shared( + arguments.fields[0], arguments.fields[1], arguments.fields[2], arguments.fields[3]); + return ptr; + } + throw CannotDeserialize( + "TemporalNumTimestampsAggregationLogicalFunction requires lon, lat, timestamp, and alias fields but got {}", + arguments.fields.size()); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalStartTimestampAggregationLogicalFunction.cpp b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalStartTimestampAggregationLogicalFunction.cpp new file mode 100644 index 0000000000..35ba0bbe90 --- /dev/null +++ b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalStartTimestampAggregationLogicalFunction.cpp @@ -0,0 +1,116 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace NES +{ + +TemporalStartTimestampAggregationLogicalFunction::TemporalStartTimestampAggregationLogicalFunction( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField) + : WindowAggregationLogicalFunction( + lonField.getDataType(), + DataTypeProvider::provideDataType(partialAggregateStampType), + DataTypeProvider::provideDataType(finalAggregateStampType), + lonField, + asField) + , lonField(lonField) + , latField(latField) + , timestampField(timestampField) +{ +} + +std::shared_ptr +TemporalStartTimestampAggregationLogicalFunction::create( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField) +{ + return std::make_shared(lonField, latField, timestampField, lonField); +} + +std::string_view TemporalStartTimestampAggregationLogicalFunction::getName() const noexcept +{ + return NAME; +} + +void TemporalStartTimestampAggregationLogicalFunction::inferStamp(const Schema& schema) +{ + lonField = lonField.withInferredDataType(schema).get(); + latField = latField.withInferredDataType(schema).get(); + timestampField = timestampField.withInferredDataType(schema).get(); + + onField = lonField; + + if (!lonField.getDataType().isNumeric() || !latField.getDataType().isNumeric() || !timestampField.getDataType().isNumeric()) + { + throw CannotInferSchema("TemporalStartTimestampAggregationLogicalFunction: lon, lat, and timestamp fields must be numeric."); + } + + const auto onFieldName = onField.getFieldName(); + const auto asFieldName = asField.getFieldName(); + const auto attributeNameResolver = onFieldName.substr(0, onFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + if (asFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) == std::string::npos) + { + asField = asField.withFieldName(attributeNameResolver + asFieldName).get(); + } + else + { + const auto fieldName = asFieldName.substr(asFieldName.find_last_of(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + asField = asField.withFieldName(attributeNameResolver + fieldName).get(); + } + asField = asField.withDataType(getFinalAggregateStamp()).get(); + inputStamp = onField.getDataType(); +} + +NES::SerializableAggregationFunction TemporalStartTimestampAggregationLogicalFunction::serialize() const +{ + auto saf = TemporalAggregationSerde::serializeTemporalSequence(lonField, latField, timestampField, asField); + saf.set_type(std::string(NAME)); + return saf; +} + +AggregationLogicalFunctionRegistryReturnType AggregationLogicalFunctionGeneratedRegistrar::RegisterTemporalStartTimestampAggregationLogicalFunction( + AggregationLogicalFunctionRegistryArguments arguments) +{ + if (arguments.fields.size() == 4) + { + auto ptr = std::make_shared( + arguments.fields[0], arguments.fields[1], arguments.fields[2], arguments.fields[3]); + return ptr; + } + throw CannotDeserialize( + "TemporalStartTimestampAggregationLogicalFunction requires lon, lat, timestamp, and alias fields but got {}", + arguments.fields.size()); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTFloatAvgValueAggregationLogicalFunction.cpp b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTFloatAvgValueAggregationLogicalFunction.cpp new file mode 100644 index 0000000000..a1cde6e488 --- /dev/null +++ b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTFloatAvgValueAggregationLogicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace NES +{ + +TemporalTFloatAvgValueAggregationLogicalFunction::TemporalTFloatAvgValueAggregationLogicalFunction( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField) + : WindowAggregationLogicalFunction( + valueField.getDataType(), + DataTypeProvider::provideDataType(partialAggregateStampType), + DataTypeProvider::provideDataType(finalAggregateStampType), + valueField, + asField) + , valueField(valueField) + , timestampField(timestampField) +{ +} + +std::shared_ptr +TemporalTFloatAvgValueAggregationLogicalFunction::create( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField) +{ + return std::make_shared(valueField, timestampField, valueField); +} + +std::string_view TemporalTFloatAvgValueAggregationLogicalFunction::getName() const noexcept +{ + return NAME; +} + +void TemporalTFloatAvgValueAggregationLogicalFunction::inferStamp(const Schema& schema) +{ + valueField = valueField.withInferredDataType(schema).get(); + timestampField = timestampField.withInferredDataType(schema).get(); + + onField = valueField; + + if (!valueField.getDataType().isNumeric() || !timestampField.getDataType().isNumeric()) + { + throw CannotInferSchema("TemporalTFloatAvgValueAggregationLogicalFunction: value and timestamp fields must be numeric."); + } + + const auto onFieldName = onField.getFieldName(); + const auto asFieldName = asField.getFieldName(); + const auto attributeNameResolver = onFieldName.substr(0, onFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + if (asFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) == std::string::npos) + { + asField = asField.withFieldName(attributeNameResolver + asFieldName).get(); + } + else + { + const auto fieldName = asFieldName.substr(asFieldName.find_last_of(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + asField = asField.withFieldName(attributeNameResolver + fieldName).get(); + } + asField = asField.withDataType(getFinalAggregateStamp()).get(); + inputStamp = onField.getDataType(); +} + +NES::SerializableAggregationFunction TemporalTFloatAvgValueAggregationLogicalFunction::serialize() const +{ + auto saf = TemporalAggregationSerde::serializeTemporalSequence(valueField, timestampField, valueField, asField); + saf.set_type(std::string(NAME)); + return saf; +} + +AggregationLogicalFunctionRegistryReturnType AggregationLogicalFunctionGeneratedRegistrar::RegisterTemporalTFloatAvgValueAggregationLogicalFunction( + AggregationLogicalFunctionRegistryArguments arguments) +{ + if (arguments.fields.size() == 3) + { + auto ptr = std::make_shared( + arguments.fields[0], arguments.fields[1], arguments.fields[2]); + return ptr; + } + throw CannotDeserialize( + "TemporalTFloatAvgValueAggregationLogicalFunction requires value, timestamp, and alias fields but got {}", + arguments.fields.size()); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTFloatEndValueAggregationLogicalFunction.cpp b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTFloatEndValueAggregationLogicalFunction.cpp new file mode 100644 index 0000000000..60a13746d9 --- /dev/null +++ b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTFloatEndValueAggregationLogicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace NES +{ + +TemporalTFloatEndValueAggregationLogicalFunction::TemporalTFloatEndValueAggregationLogicalFunction( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField) + : WindowAggregationLogicalFunction( + valueField.getDataType(), + DataTypeProvider::provideDataType(partialAggregateStampType), + DataTypeProvider::provideDataType(finalAggregateStampType), + valueField, + asField) + , valueField(valueField) + , timestampField(timestampField) +{ +} + +std::shared_ptr +TemporalTFloatEndValueAggregationLogicalFunction::create( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField) +{ + return std::make_shared(valueField, timestampField, valueField); +} + +std::string_view TemporalTFloatEndValueAggregationLogicalFunction::getName() const noexcept +{ + return NAME; +} + +void TemporalTFloatEndValueAggregationLogicalFunction::inferStamp(const Schema& schema) +{ + valueField = valueField.withInferredDataType(schema).get(); + timestampField = timestampField.withInferredDataType(schema).get(); + + onField = valueField; + + if (!valueField.getDataType().isNumeric() || !timestampField.getDataType().isNumeric()) + { + throw CannotInferSchema("TemporalTFloatEndValueAggregationLogicalFunction: value and timestamp fields must be numeric."); + } + + const auto onFieldName = onField.getFieldName(); + const auto asFieldName = asField.getFieldName(); + const auto attributeNameResolver = onFieldName.substr(0, onFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + if (asFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) == std::string::npos) + { + asField = asField.withFieldName(attributeNameResolver + asFieldName).get(); + } + else + { + const auto fieldName = asFieldName.substr(asFieldName.find_last_of(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + asField = asField.withFieldName(attributeNameResolver + fieldName).get(); + } + asField = asField.withDataType(getFinalAggregateStamp()).get(); + inputStamp = onField.getDataType(); +} + +NES::SerializableAggregationFunction TemporalTFloatEndValueAggregationLogicalFunction::serialize() const +{ + auto saf = TemporalAggregationSerde::serializeTemporalSequence(valueField, timestampField, valueField, asField); + saf.set_type(std::string(NAME)); + return saf; +} + +AggregationLogicalFunctionRegistryReturnType AggregationLogicalFunctionGeneratedRegistrar::RegisterTemporalTFloatEndValueAggregationLogicalFunction( + AggregationLogicalFunctionRegistryArguments arguments) +{ + if (arguments.fields.size() == 3) + { + auto ptr = std::make_shared( + arguments.fields[0], arguments.fields[1], arguments.fields[2]); + return ptr; + } + throw CannotDeserialize( + "TemporalTFloatEndValueAggregationLogicalFunction requires value, timestamp, and alias fields but got {}", + arguments.fields.size()); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTFloatMaxValueAggregationLogicalFunction.cpp b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTFloatMaxValueAggregationLogicalFunction.cpp new file mode 100644 index 0000000000..c0f59a85c8 --- /dev/null +++ b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTFloatMaxValueAggregationLogicalFunction.cpp @@ -0,0 +1,120 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace NES +{ + +TemporalTFloatMaxValueAggregationLogicalFunction::TemporalTFloatMaxValueAggregationLogicalFunction( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField) + : WindowAggregationLogicalFunction( + valueField.getDataType(), + DataTypeProvider::provideDataType(partialAggregateStampType), + DataTypeProvider::provideDataType(finalAggregateStampType), + valueField, + asField) + , valueField(valueField) + , timestampField(timestampField) +{ +} + +std::shared_ptr +TemporalTFloatMaxValueAggregationLogicalFunction::create( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField) +{ + return std::make_shared(valueField, timestampField, valueField); +} + +std::string_view TemporalTFloatMaxValueAggregationLogicalFunction::getName() const noexcept +{ + return NAME; +} + +void TemporalTFloatMaxValueAggregationLogicalFunction::inferStamp(const Schema& schema) +{ + valueField = valueField.withInferredDataType(schema).get(); + timestampField = timestampField.withInferredDataType(schema).get(); + + onField = valueField; + + if (!valueField.getDataType().isNumeric() || !timestampField.getDataType().isNumeric()) + { + throw CannotInferSchema("TemporalTFloatMaxValueAggregationLogicalFunction: value and timestamp fields must be numeric."); + } + + const auto onFieldName = onField.getFieldName(); + const auto asFieldName = asField.getFieldName(); + const auto attributeNameResolver = onFieldName.substr(0, onFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + if (asFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) == std::string::npos) + { + asField = asField.withFieldName(attributeNameResolver + asFieldName).get(); + } + else + { + const auto fieldName = asFieldName.substr(asFieldName.find_last_of(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + asField = asField.withFieldName(attributeNameResolver + fieldName).get(); + } + asField = asField.withDataType(getFinalAggregateStamp()).get(); + inputStamp = onField.getDataType(); +} + +NES::SerializableAggregationFunction TemporalTFloatMaxValueAggregationLogicalFunction::serialize() const +{ + auto saf = TemporalAggregationSerde::serializeTemporalSequence(valueField, timestampField, valueField, asField); + saf.set_type(std::string(NAME)); + return saf; +} + +AggregationLogicalFunctionRegistryReturnType AggregationLogicalFunctionGeneratedRegistrar::RegisterTemporalTFloatMaxValueAggregationLogicalFunction( + AggregationLogicalFunctionRegistryArguments arguments) +{ + // serialize() uses the 4-field TemporalSequence serde with value duplicated: + // parse returns [value, timestamp, value, alias], so alias is fields[3]. + if (arguments.fields.size() == 4) + { + auto ptr = std::make_shared( + arguments.fields[0], arguments.fields[1], arguments.fields[3]); + return ptr; + } + if (arguments.fields.size() == 3) + { + auto ptr = std::make_shared( + arguments.fields[0], arguments.fields[1], arguments.fields[2]); + return ptr; + } + throw CannotDeserialize( + "TemporalTFloatMaxValueAggregationLogicalFunction requires value, timestamp, and alias fields but got {}", + arguments.fields.size()); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTFloatMinValueAggregationLogicalFunction.cpp b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTFloatMinValueAggregationLogicalFunction.cpp new file mode 100644 index 0000000000..b4e88ab38e --- /dev/null +++ b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTFloatMinValueAggregationLogicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace NES +{ + +TemporalTFloatMinValueAggregationLogicalFunction::TemporalTFloatMinValueAggregationLogicalFunction( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField) + : WindowAggregationLogicalFunction( + valueField.getDataType(), + DataTypeProvider::provideDataType(partialAggregateStampType), + DataTypeProvider::provideDataType(finalAggregateStampType), + valueField, + asField) + , valueField(valueField) + , timestampField(timestampField) +{ +} + +std::shared_ptr +TemporalTFloatMinValueAggregationLogicalFunction::create( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField) +{ + return std::make_shared(valueField, timestampField, valueField); +} + +std::string_view TemporalTFloatMinValueAggregationLogicalFunction::getName() const noexcept +{ + return NAME; +} + +void TemporalTFloatMinValueAggregationLogicalFunction::inferStamp(const Schema& schema) +{ + valueField = valueField.withInferredDataType(schema).get(); + timestampField = timestampField.withInferredDataType(schema).get(); + + onField = valueField; + + if (!valueField.getDataType().isNumeric() || !timestampField.getDataType().isNumeric()) + { + throw CannotInferSchema("TemporalTFloatMinValueAggregationLogicalFunction: value and timestamp fields must be numeric."); + } + + const auto onFieldName = onField.getFieldName(); + const auto asFieldName = asField.getFieldName(); + const auto attributeNameResolver = onFieldName.substr(0, onFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + if (asFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) == std::string::npos) + { + asField = asField.withFieldName(attributeNameResolver + asFieldName).get(); + } + else + { + const auto fieldName = asFieldName.substr(asFieldName.find_last_of(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + asField = asField.withFieldName(attributeNameResolver + fieldName).get(); + } + asField = asField.withDataType(getFinalAggregateStamp()).get(); + inputStamp = onField.getDataType(); +} + +NES::SerializableAggregationFunction TemporalTFloatMinValueAggregationLogicalFunction::serialize() const +{ + auto saf = TemporalAggregationSerde::serializeTemporalSequence(valueField, timestampField, valueField, asField); + saf.set_type(std::string(NAME)); + return saf; +} + +AggregationLogicalFunctionRegistryReturnType AggregationLogicalFunctionGeneratedRegistrar::RegisterTemporalTFloatMinValueAggregationLogicalFunction( + AggregationLogicalFunctionRegistryArguments arguments) +{ + if (arguments.fields.size() == 3) + { + auto ptr = std::make_shared( + arguments.fields[0], arguments.fields[1], arguments.fields[2]); + return ptr; + } + throw CannotDeserialize( + "TemporalTFloatMinValueAggregationLogicalFunction requires value, timestamp, and alias fields but got {}", + arguments.fields.size()); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTFloatStartValueAggregationLogicalFunction.cpp b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTFloatStartValueAggregationLogicalFunction.cpp new file mode 100644 index 0000000000..e40ac45a3f --- /dev/null +++ b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTFloatStartValueAggregationLogicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace NES +{ + +TemporalTFloatStartValueAggregationLogicalFunction::TemporalTFloatStartValueAggregationLogicalFunction( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField) + : WindowAggregationLogicalFunction( + valueField.getDataType(), + DataTypeProvider::provideDataType(partialAggregateStampType), + DataTypeProvider::provideDataType(finalAggregateStampType), + valueField, + asField) + , valueField(valueField) + , timestampField(timestampField) +{ +} + +std::shared_ptr +TemporalTFloatStartValueAggregationLogicalFunction::create( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField) +{ + return std::make_shared(valueField, timestampField, valueField); +} + +std::string_view TemporalTFloatStartValueAggregationLogicalFunction::getName() const noexcept +{ + return NAME; +} + +void TemporalTFloatStartValueAggregationLogicalFunction::inferStamp(const Schema& schema) +{ + valueField = valueField.withInferredDataType(schema).get(); + timestampField = timestampField.withInferredDataType(schema).get(); + + onField = valueField; + + if (!valueField.getDataType().isNumeric() || !timestampField.getDataType().isNumeric()) + { + throw CannotInferSchema("TemporalTFloatStartValueAggregationLogicalFunction: value and timestamp fields must be numeric."); + } + + const auto onFieldName = onField.getFieldName(); + const auto asFieldName = asField.getFieldName(); + const auto attributeNameResolver = onFieldName.substr(0, onFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + if (asFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) == std::string::npos) + { + asField = asField.withFieldName(attributeNameResolver + asFieldName).get(); + } + else + { + const auto fieldName = asFieldName.substr(asFieldName.find_last_of(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + asField = asField.withFieldName(attributeNameResolver + fieldName).get(); + } + asField = asField.withDataType(getFinalAggregateStamp()).get(); + inputStamp = onField.getDataType(); +} + +NES::SerializableAggregationFunction TemporalTFloatStartValueAggregationLogicalFunction::serialize() const +{ + auto saf = TemporalAggregationSerde::serializeTemporalSequence(valueField, timestampField, valueField, asField); + saf.set_type(std::string(NAME)); + return saf; +} + +AggregationLogicalFunctionRegistryReturnType AggregationLogicalFunctionGeneratedRegistrar::RegisterTemporalTFloatStartValueAggregationLogicalFunction( + AggregationLogicalFunctionRegistryArguments arguments) +{ + if (arguments.fields.size() == 3) + { + auto ptr = std::make_shared( + arguments.fields[0], arguments.fields[1], arguments.fields[2]); + return ptr; + } + throw CannotDeserialize( + "TemporalTFloatStartValueAggregationLogicalFunction requires value, timestamp, and alias fields but got {}", + arguments.fields.size()); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTIntAvgValueAggregationLogicalFunction.cpp b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTIntAvgValueAggregationLogicalFunction.cpp new file mode 100644 index 0000000000..f3f1bf468a --- /dev/null +++ b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTIntAvgValueAggregationLogicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace NES +{ + +TemporalTIntAvgValueAggregationLogicalFunction::TemporalTIntAvgValueAggregationLogicalFunction( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField) + : WindowAggregationLogicalFunction( + valueField.getDataType(), + DataTypeProvider::provideDataType(partialAggregateStampType), + DataTypeProvider::provideDataType(finalAggregateStampType), + valueField, + asField) + , valueField(valueField) + , timestampField(timestampField) +{ +} + +std::shared_ptr +TemporalTIntAvgValueAggregationLogicalFunction::create( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField) +{ + return std::make_shared(valueField, timestampField, valueField); +} + +std::string_view TemporalTIntAvgValueAggregationLogicalFunction::getName() const noexcept +{ + return NAME; +} + +void TemporalTIntAvgValueAggregationLogicalFunction::inferStamp(const Schema& schema) +{ + valueField = valueField.withInferredDataType(schema).get(); + timestampField = timestampField.withInferredDataType(schema).get(); + + onField = valueField; + + if (!valueField.getDataType().isNumeric() || !timestampField.getDataType().isNumeric()) + { + throw CannotInferSchema("TemporalTIntAvgValueAggregationLogicalFunction: value and timestamp fields must be numeric."); + } + + const auto onFieldName = onField.getFieldName(); + const auto asFieldName = asField.getFieldName(); + const auto attributeNameResolver = onFieldName.substr(0, onFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + if (asFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) == std::string::npos) + { + asField = asField.withFieldName(attributeNameResolver + asFieldName).get(); + } + else + { + const auto fieldName = asFieldName.substr(asFieldName.find_last_of(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + asField = asField.withFieldName(attributeNameResolver + fieldName).get(); + } + asField = asField.withDataType(getFinalAggregateStamp()).get(); + inputStamp = onField.getDataType(); +} + +NES::SerializableAggregationFunction TemporalTIntAvgValueAggregationLogicalFunction::serialize() const +{ + auto saf = TemporalAggregationSerde::serializeTemporalSequence(valueField, timestampField, valueField, asField); + saf.set_type(std::string(NAME)); + return saf; +} + +AggregationLogicalFunctionRegistryReturnType AggregationLogicalFunctionGeneratedRegistrar::RegisterTemporalTIntAvgValueAggregationLogicalFunction( + AggregationLogicalFunctionRegistryArguments arguments) +{ + if (arguments.fields.size() == 3) + { + auto ptr = std::make_shared( + arguments.fields[0], arguments.fields[1], arguments.fields[2]); + return ptr; + } + throw CannotDeserialize( + "TemporalTIntAvgValueAggregationLogicalFunction requires value, timestamp, and alias fields but got {}", + arguments.fields.size()); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTIntEndValueAggregationLogicalFunction.cpp b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTIntEndValueAggregationLogicalFunction.cpp new file mode 100644 index 0000000000..cd3030d281 --- /dev/null +++ b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTIntEndValueAggregationLogicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace NES +{ + +TemporalTIntEndValueAggregationLogicalFunction::TemporalTIntEndValueAggregationLogicalFunction( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField) + : WindowAggregationLogicalFunction( + valueField.getDataType(), + DataTypeProvider::provideDataType(partialAggregateStampType), + DataTypeProvider::provideDataType(finalAggregateStampType), + valueField, + asField) + , valueField(valueField) + , timestampField(timestampField) +{ +} + +std::shared_ptr +TemporalTIntEndValueAggregationLogicalFunction::create( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField) +{ + return std::make_shared(valueField, timestampField, valueField); +} + +std::string_view TemporalTIntEndValueAggregationLogicalFunction::getName() const noexcept +{ + return NAME; +} + +void TemporalTIntEndValueAggregationLogicalFunction::inferStamp(const Schema& schema) +{ + valueField = valueField.withInferredDataType(schema).get(); + timestampField = timestampField.withInferredDataType(schema).get(); + + onField = valueField; + + if (!valueField.getDataType().isNumeric() || !timestampField.getDataType().isNumeric()) + { + throw CannotInferSchema("TemporalTIntEndValueAggregationLogicalFunction: value and timestamp fields must be numeric."); + } + + const auto onFieldName = onField.getFieldName(); + const auto asFieldName = asField.getFieldName(); + const auto attributeNameResolver = onFieldName.substr(0, onFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + if (asFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) == std::string::npos) + { + asField = asField.withFieldName(attributeNameResolver + asFieldName).get(); + } + else + { + const auto fieldName = asFieldName.substr(asFieldName.find_last_of(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + asField = asField.withFieldName(attributeNameResolver + fieldName).get(); + } + asField = asField.withDataType(getFinalAggregateStamp()).get(); + inputStamp = onField.getDataType(); +} + +NES::SerializableAggregationFunction TemporalTIntEndValueAggregationLogicalFunction::serialize() const +{ + auto saf = TemporalAggregationSerde::serializeTemporalSequence(valueField, timestampField, valueField, asField); + saf.set_type(std::string(NAME)); + return saf; +} + +AggregationLogicalFunctionRegistryReturnType AggregationLogicalFunctionGeneratedRegistrar::RegisterTemporalTIntEndValueAggregationLogicalFunction( + AggregationLogicalFunctionRegistryArguments arguments) +{ + if (arguments.fields.size() == 3) + { + auto ptr = std::make_shared( + arguments.fields[0], arguments.fields[1], arguments.fields[2]); + return ptr; + } + throw CannotDeserialize( + "TemporalTIntEndValueAggregationLogicalFunction requires value, timestamp, and alias fields but got {}", + arguments.fields.size()); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTIntMaxValueAggregationLogicalFunction.cpp b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTIntMaxValueAggregationLogicalFunction.cpp new file mode 100644 index 0000000000..177fda5292 --- /dev/null +++ b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTIntMaxValueAggregationLogicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace NES +{ + +TemporalTIntMaxValueAggregationLogicalFunction::TemporalTIntMaxValueAggregationLogicalFunction( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField) + : WindowAggregationLogicalFunction( + valueField.getDataType(), + DataTypeProvider::provideDataType(partialAggregateStampType), + DataTypeProvider::provideDataType(finalAggregateStampType), + valueField, + asField) + , valueField(valueField) + , timestampField(timestampField) +{ +} + +std::shared_ptr +TemporalTIntMaxValueAggregationLogicalFunction::create( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField) +{ + return std::make_shared(valueField, timestampField, valueField); +} + +std::string_view TemporalTIntMaxValueAggregationLogicalFunction::getName() const noexcept +{ + return NAME; +} + +void TemporalTIntMaxValueAggregationLogicalFunction::inferStamp(const Schema& schema) +{ + valueField = valueField.withInferredDataType(schema).get(); + timestampField = timestampField.withInferredDataType(schema).get(); + + onField = valueField; + + if (!valueField.getDataType().isNumeric() || !timestampField.getDataType().isNumeric()) + { + throw CannotInferSchema("TemporalTIntMaxValueAggregationLogicalFunction: value and timestamp fields must be numeric."); + } + + const auto onFieldName = onField.getFieldName(); + const auto asFieldName = asField.getFieldName(); + const auto attributeNameResolver = onFieldName.substr(0, onFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + if (asFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) == std::string::npos) + { + asField = asField.withFieldName(attributeNameResolver + asFieldName).get(); + } + else + { + const auto fieldName = asFieldName.substr(asFieldName.find_last_of(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + asField = asField.withFieldName(attributeNameResolver + fieldName).get(); + } + asField = asField.withDataType(getFinalAggregateStamp()).get(); + inputStamp = onField.getDataType(); +} + +NES::SerializableAggregationFunction TemporalTIntMaxValueAggregationLogicalFunction::serialize() const +{ + auto saf = TemporalAggregationSerde::serializeTemporalSequence(valueField, timestampField, valueField, asField); + saf.set_type(std::string(NAME)); + return saf; +} + +AggregationLogicalFunctionRegistryReturnType AggregationLogicalFunctionGeneratedRegistrar::RegisterTemporalTIntMaxValueAggregationLogicalFunction( + AggregationLogicalFunctionRegistryArguments arguments) +{ + if (arguments.fields.size() == 3) + { + auto ptr = std::make_shared( + arguments.fields[0], arguments.fields[1], arguments.fields[2]); + return ptr; + } + throw CannotDeserialize( + "TemporalTIntMaxValueAggregationLogicalFunction requires value, timestamp, and alias fields but got {}", + arguments.fields.size()); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTIntMinValueAggregationLogicalFunction.cpp b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTIntMinValueAggregationLogicalFunction.cpp new file mode 100644 index 0000000000..5556417e22 --- /dev/null +++ b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTIntMinValueAggregationLogicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace NES +{ + +TemporalTIntMinValueAggregationLogicalFunction::TemporalTIntMinValueAggregationLogicalFunction( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField) + : WindowAggregationLogicalFunction( + valueField.getDataType(), + DataTypeProvider::provideDataType(partialAggregateStampType), + DataTypeProvider::provideDataType(finalAggregateStampType), + valueField, + asField) + , valueField(valueField) + , timestampField(timestampField) +{ +} + +std::shared_ptr +TemporalTIntMinValueAggregationLogicalFunction::create( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField) +{ + return std::make_shared(valueField, timestampField, valueField); +} + +std::string_view TemporalTIntMinValueAggregationLogicalFunction::getName() const noexcept +{ + return NAME; +} + +void TemporalTIntMinValueAggregationLogicalFunction::inferStamp(const Schema& schema) +{ + valueField = valueField.withInferredDataType(schema).get(); + timestampField = timestampField.withInferredDataType(schema).get(); + + onField = valueField; + + if (!valueField.getDataType().isNumeric() || !timestampField.getDataType().isNumeric()) + { + throw CannotInferSchema("TemporalTIntMinValueAggregationLogicalFunction: value and timestamp fields must be numeric."); + } + + const auto onFieldName = onField.getFieldName(); + const auto asFieldName = asField.getFieldName(); + const auto attributeNameResolver = onFieldName.substr(0, onFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + if (asFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) == std::string::npos) + { + asField = asField.withFieldName(attributeNameResolver + asFieldName).get(); + } + else + { + const auto fieldName = asFieldName.substr(asFieldName.find_last_of(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + asField = asField.withFieldName(attributeNameResolver + fieldName).get(); + } + asField = asField.withDataType(getFinalAggregateStamp()).get(); + inputStamp = onField.getDataType(); +} + +NES::SerializableAggregationFunction TemporalTIntMinValueAggregationLogicalFunction::serialize() const +{ + auto saf = TemporalAggregationSerde::serializeTemporalSequence(valueField, timestampField, valueField, asField); + saf.set_type(std::string(NAME)); + return saf; +} + +AggregationLogicalFunctionRegistryReturnType AggregationLogicalFunctionGeneratedRegistrar::RegisterTemporalTIntMinValueAggregationLogicalFunction( + AggregationLogicalFunctionRegistryArguments arguments) +{ + if (arguments.fields.size() == 3) + { + auto ptr = std::make_shared( + arguments.fields[0], arguments.fields[1], arguments.fields[2]); + return ptr; + } + throw CannotDeserialize( + "TemporalTIntMinValueAggregationLogicalFunction requires value, timestamp, and alias fields but got {}", + arguments.fields.size()); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTIntStartValueAggregationLogicalFunction.cpp b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTIntStartValueAggregationLogicalFunction.cpp new file mode 100644 index 0000000000..2103a2e4ca --- /dev/null +++ b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTIntStartValueAggregationLogicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace NES +{ + +TemporalTIntStartValueAggregationLogicalFunction::TemporalTIntStartValueAggregationLogicalFunction( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField) + : WindowAggregationLogicalFunction( + valueField.getDataType(), + DataTypeProvider::provideDataType(partialAggregateStampType), + DataTypeProvider::provideDataType(finalAggregateStampType), + valueField, + asField) + , valueField(valueField) + , timestampField(timestampField) +{ +} + +std::shared_ptr +TemporalTIntStartValueAggregationLogicalFunction::create( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField) +{ + return std::make_shared(valueField, timestampField, valueField); +} + +std::string_view TemporalTIntStartValueAggregationLogicalFunction::getName() const noexcept +{ + return NAME; +} + +void TemporalTIntStartValueAggregationLogicalFunction::inferStamp(const Schema& schema) +{ + valueField = valueField.withInferredDataType(schema).get(); + timestampField = timestampField.withInferredDataType(schema).get(); + + onField = valueField; + + if (!valueField.getDataType().isNumeric() || !timestampField.getDataType().isNumeric()) + { + throw CannotInferSchema("TemporalTIntStartValueAggregationLogicalFunction: value and timestamp fields must be numeric."); + } + + const auto onFieldName = onField.getFieldName(); + const auto asFieldName = asField.getFieldName(); + const auto attributeNameResolver = onFieldName.substr(0, onFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + if (asFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) == std::string::npos) + { + asField = asField.withFieldName(attributeNameResolver + asFieldName).get(); + } + else + { + const auto fieldName = asFieldName.substr(asFieldName.find_last_of(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + asField = asField.withFieldName(attributeNameResolver + fieldName).get(); + } + asField = asField.withDataType(getFinalAggregateStamp()).get(); + inputStamp = onField.getDataType(); +} + +NES::SerializableAggregationFunction TemporalTIntStartValueAggregationLogicalFunction::serialize() const +{ + auto saf = TemporalAggregationSerde::serializeTemporalSequence(valueField, timestampField, valueField, asField); + saf.set_type(std::string(NAME)); + return saf; +} + +AggregationLogicalFunctionRegistryReturnType AggregationLogicalFunctionGeneratedRegistrar::RegisterTemporalTIntStartValueAggregationLogicalFunction( + AggregationLogicalFunctionRegistryArguments arguments) +{ + if (arguments.fields.size() == 3) + { + auto ptr = std::make_shared( + arguments.fields[0], arguments.fields[1], arguments.fields[2]); + return ptr; + } + throw CannotDeserialize( + "TemporalTIntStartValueAggregationLogicalFunction requires value, timestamp, and alias fields but got {}", + arguments.fields.size()); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTNumberIntegralAggregationLogicalFunction.cpp b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTNumberIntegralAggregationLogicalFunction.cpp new file mode 100644 index 0000000000..428d6284f3 --- /dev/null +++ b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTNumberIntegralAggregationLogicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace NES +{ + +TemporalTNumberIntegralAggregationLogicalFunction::TemporalTNumberIntegralAggregationLogicalFunction( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField) + : WindowAggregationLogicalFunction( + valueField.getDataType(), + DataTypeProvider::provideDataType(partialAggregateStampType), + DataTypeProvider::provideDataType(finalAggregateStampType), + valueField, + asField) + , valueField(valueField) + , timestampField(timestampField) +{ +} + +std::shared_ptr +TemporalTNumberIntegralAggregationLogicalFunction::create( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField) +{ + return std::make_shared(valueField, timestampField, valueField); +} + +std::string_view TemporalTNumberIntegralAggregationLogicalFunction::getName() const noexcept +{ + return NAME; +} + +void TemporalTNumberIntegralAggregationLogicalFunction::inferStamp(const Schema& schema) +{ + valueField = valueField.withInferredDataType(schema).get(); + timestampField = timestampField.withInferredDataType(schema).get(); + + onField = valueField; + + if (!valueField.getDataType().isNumeric() || !timestampField.getDataType().isNumeric()) + { + throw CannotInferSchema("TemporalTNumberIntegralAggregationLogicalFunction: value and timestamp fields must be numeric."); + } + + const auto onFieldName = onField.getFieldName(); + const auto asFieldName = asField.getFieldName(); + const auto attributeNameResolver = onFieldName.substr(0, onFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + if (asFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) == std::string::npos) + { + asField = asField.withFieldName(attributeNameResolver + asFieldName).get(); + } + else + { + const auto fieldName = asFieldName.substr(asFieldName.find_last_of(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + asField = asField.withFieldName(attributeNameResolver + fieldName).get(); + } + asField = asField.withDataType(getFinalAggregateStamp()).get(); + inputStamp = onField.getDataType(); +} + +NES::SerializableAggregationFunction TemporalTNumberIntegralAggregationLogicalFunction::serialize() const +{ + auto saf = TemporalAggregationSerde::serializeTemporalSequence(valueField, timestampField, valueField, asField); + saf.set_type(std::string(NAME)); + return saf; +} + +AggregationLogicalFunctionRegistryReturnType AggregationLogicalFunctionGeneratedRegistrar::RegisterTemporalTNumberIntegralAggregationLogicalFunction( + AggregationLogicalFunctionRegistryArguments arguments) +{ + if (arguments.fields.size() == 3) + { + auto ptr = std::make_shared( + arguments.fields[0], arguments.fields[1], arguments.fields[2]); + return ptr; + } + throw CannotDeserialize( + "TemporalTNumberIntegralAggregationLogicalFunction requires value, timestamp, and alias fields but got {}", + arguments.fields.size()); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTNumberTwAvgAggregationLogicalFunction.cpp b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTNumberTwAvgAggregationLogicalFunction.cpp new file mode 100644 index 0000000000..e8848ff768 --- /dev/null +++ b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTNumberTwAvgAggregationLogicalFunction.cpp @@ -0,0 +1,120 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace NES +{ + +TemporalTNumberTwAvgAggregationLogicalFunction::TemporalTNumberTwAvgAggregationLogicalFunction( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField) + : WindowAggregationLogicalFunction( + valueField.getDataType(), + DataTypeProvider::provideDataType(partialAggregateStampType), + DataTypeProvider::provideDataType(finalAggregateStampType), + valueField, + asField) + , valueField(valueField) + , timestampField(timestampField) +{ +} + +std::shared_ptr +TemporalTNumberTwAvgAggregationLogicalFunction::create( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField) +{ + return std::make_shared(valueField, timestampField, valueField); +} + +std::string_view TemporalTNumberTwAvgAggregationLogicalFunction::getName() const noexcept +{ + return NAME; +} + +void TemporalTNumberTwAvgAggregationLogicalFunction::inferStamp(const Schema& schema) +{ + valueField = valueField.withInferredDataType(schema).get(); + timestampField = timestampField.withInferredDataType(schema).get(); + + onField = valueField; + + if (!valueField.getDataType().isNumeric() || !timestampField.getDataType().isNumeric()) + { + throw CannotInferSchema("TemporalTNumberTwAvgAggregationLogicalFunction: value and timestamp fields must be numeric."); + } + + const auto onFieldName = onField.getFieldName(); + const auto asFieldName = asField.getFieldName(); + const auto attributeNameResolver = onFieldName.substr(0, onFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + if (asFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) == std::string::npos) + { + asField = asField.withFieldName(attributeNameResolver + asFieldName).get(); + } + else + { + const auto fieldName = asFieldName.substr(asFieldName.find_last_of(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + asField = asField.withFieldName(attributeNameResolver + fieldName).get(); + } + asField = asField.withDataType(getFinalAggregateStamp()).get(); + inputStamp = onField.getDataType(); +} + +NES::SerializableAggregationFunction TemporalTNumberTwAvgAggregationLogicalFunction::serialize() const +{ + auto saf = TemporalAggregationSerde::serializeTemporalSequence(valueField, timestampField, valueField, asField); + saf.set_type(std::string(NAME)); + return saf; +} + +AggregationLogicalFunctionRegistryReturnType AggregationLogicalFunctionGeneratedRegistrar::RegisterTemporalTNumberTwAvgAggregationLogicalFunction( + AggregationLogicalFunctionRegistryArguments arguments) +{ + // serialize() uses the 4-field TemporalSequence serde with value duplicated: + // parse returns [value, timestamp, value, alias], so alias is fields[3]. + if (arguments.fields.size() == 4) + { + auto ptr = std::make_shared( + arguments.fields[0], arguments.fields[1], arguments.fields[3]); + return ptr; + } + if (arguments.fields.size() == 3) + { + auto ptr = std::make_shared( + arguments.fields[0], arguments.fields[1], arguments.fields[2]); + return ptr; + } + throw CannotDeserialize( + "TemporalTNumberTwAvgAggregationLogicalFunction requires value, timestamp, and alias fields but got {}", + arguments.fields.size()); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTPointIsSimpleAggregationLogicalFunction.cpp b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTPointIsSimpleAggregationLogicalFunction.cpp new file mode 100644 index 0000000000..051a94fd2e --- /dev/null +++ b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalTPointIsSimpleAggregationLogicalFunction.cpp @@ -0,0 +1,116 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace NES +{ + +TemporalTPointIsSimpleAggregationLogicalFunction::TemporalTPointIsSimpleAggregationLogicalFunction( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField) + : WindowAggregationLogicalFunction( + lonField.getDataType(), + DataTypeProvider::provideDataType(partialAggregateStampType), + DataTypeProvider::provideDataType(finalAggregateStampType), + lonField, + asField) + , lonField(lonField) + , latField(latField) + , timestampField(timestampField) +{ +} + +std::shared_ptr +TemporalTPointIsSimpleAggregationLogicalFunction::create( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField) +{ + return std::make_shared(lonField, latField, timestampField, lonField); +} + +std::string_view TemporalTPointIsSimpleAggregationLogicalFunction::getName() const noexcept +{ + return NAME; +} + +void TemporalTPointIsSimpleAggregationLogicalFunction::inferStamp(const Schema& schema) +{ + lonField = lonField.withInferredDataType(schema).get(); + latField = latField.withInferredDataType(schema).get(); + timestampField = timestampField.withInferredDataType(schema).get(); + + onField = lonField; + + if (!lonField.getDataType().isNumeric() || !latField.getDataType().isNumeric() || !timestampField.getDataType().isNumeric()) + { + throw CannotInferSchema("TemporalTPointIsSimpleAggregationLogicalFunction: lon, lat, and timestamp fields must be numeric."); + } + + const auto onFieldName = onField.getFieldName(); + const auto asFieldName = asField.getFieldName(); + const auto attributeNameResolver = onFieldName.substr(0, onFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + if (asFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) == std::string::npos) + { + asField = asField.withFieldName(attributeNameResolver + asFieldName).get(); + } + else + { + const auto fieldName = asFieldName.substr(asFieldName.find_last_of(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + asField = asField.withFieldName(attributeNameResolver + fieldName).get(); + } + asField = asField.withDataType(getFinalAggregateStamp()).get(); + inputStamp = onField.getDataType(); +} + +NES::SerializableAggregationFunction TemporalTPointIsSimpleAggregationLogicalFunction::serialize() const +{ + auto saf = TemporalAggregationSerde::serializeTemporalSequence(lonField, latField, timestampField, asField); + saf.set_type(std::string(NAME)); + return saf; +} + +AggregationLogicalFunctionRegistryReturnType AggregationLogicalFunctionGeneratedRegistrar::RegisterTemporalTPointIsSimpleAggregationLogicalFunction( + AggregationLogicalFunctionRegistryArguments arguments) +{ + if (arguments.fields.size() == 4) + { + auto ptr = std::make_shared( + arguments.fields[0], arguments.fields[1], arguments.fields[2], arguments.fields[3]); + return ptr; + } + throw CannotDeserialize( + "TemporalTPointIsSimpleAggregationLogicalFunction requires lon, lat, timestamp, and alias fields but got {}", + arguments.fields.size()); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalUpperIncAggregationLogicalFunction.cpp b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalUpperIncAggregationLogicalFunction.cpp new file mode 100644 index 0000000000..ef954c21bf --- /dev/null +++ b/nes-logical-operators/src/Operators/Windows/Aggregations/Meos/TemporalUpperIncAggregationLogicalFunction.cpp @@ -0,0 +1,116 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace NES +{ + +TemporalUpperIncAggregationLogicalFunction::TemporalUpperIncAggregationLogicalFunction( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField) + : WindowAggregationLogicalFunction( + lonField.getDataType(), + DataTypeProvider::provideDataType(partialAggregateStampType), + DataTypeProvider::provideDataType(finalAggregateStampType), + lonField, + asField) + , lonField(lonField) + , latField(latField) + , timestampField(timestampField) +{ +} + +std::shared_ptr +TemporalUpperIncAggregationLogicalFunction::create( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField) +{ + return std::make_shared(lonField, latField, timestampField, lonField); +} + +std::string_view TemporalUpperIncAggregationLogicalFunction::getName() const noexcept +{ + return NAME; +} + +void TemporalUpperIncAggregationLogicalFunction::inferStamp(const Schema& schema) +{ + lonField = lonField.withInferredDataType(schema).get(); + latField = latField.withInferredDataType(schema).get(); + timestampField = timestampField.withInferredDataType(schema).get(); + + onField = lonField; + + if (!lonField.getDataType().isNumeric() || !latField.getDataType().isNumeric() || !timestampField.getDataType().isNumeric()) + { + throw CannotInferSchema("TemporalUpperIncAggregationLogicalFunction: lon, lat, and timestamp fields must be numeric."); + } + + const auto onFieldName = onField.getFieldName(); + const auto asFieldName = asField.getFieldName(); + const auto attributeNameResolver = onFieldName.substr(0, onFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + if (asFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) == std::string::npos) + { + asField = asField.withFieldName(attributeNameResolver + asFieldName).get(); + } + else + { + const auto fieldName = asFieldName.substr(asFieldName.find_last_of(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + asField = asField.withFieldName(attributeNameResolver + fieldName).get(); + } + asField = asField.withDataType(getFinalAggregateStamp()).get(); + inputStamp = onField.getDataType(); +} + +NES::SerializableAggregationFunction TemporalUpperIncAggregationLogicalFunction::serialize() const +{ + auto saf = TemporalAggregationSerde::serializeTemporalSequence(lonField, latField, timestampField, asField); + saf.set_type(std::string(NAME)); + return saf; +} + +AggregationLogicalFunctionRegistryReturnType AggregationLogicalFunctionGeneratedRegistrar::RegisterTemporalUpperIncAggregationLogicalFunction( + AggregationLogicalFunctionRegistryArguments arguments) +{ + if (arguments.fields.size() == 4) + { + auto ptr = std::make_shared( + arguments.fields[0], arguments.fields[1], arguments.fields[2], arguments.fields[3]); + return ptr; + } + throw CannotDeserialize( + "TemporalUpperIncAggregationLogicalFunction requires lon, lat, timestamp, and alias fields but got {}", + arguments.fields.size()); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Serialization/FunctionSerializationUtil.cpp b/nes-logical-operators/src/Serialization/FunctionSerializationUtil.cpp index 5d472dd4f3..e8de5c0939 100644 --- a/nes-logical-operators/src/Serialization/FunctionSerializationUtil.cpp +++ b/nes-logical-operators/src/Serialization/FunctionSerializationUtil.cpp @@ -63,8 +63,13 @@ deserializeWindowAggregationFunction(const SerializableAggregationFunction& seri { const auto& type = serializedFunction.type(); - // Special handling for TemporalSequence: extra fields stored inside on_field.config - if (type == std::string("TemporalSequence")) + // Special handling for TemporalSequence-shaped aggregations: extra fields (lat, ts) are + // packed inside on_field.config. These ops override the serialized type to their own NAME + // (e.g. "TemporalNumInstants"), so detecting the packed-config key — not the literal + // "TemporalSequence" type — is what makes the round-trip work for every such aggregation. + if (type == std::string("TemporalSequence") + || serializedFunction.on_field().config().contains( + std::string(TemporalAggregationSerde::TEMPORAL_SEQUENCE_EXTRA_FIELDS_KEY))) { AggregationLogicalFunctionRegistryArguments args; const auto fields = TemporalAggregationSerde::parseTemporalSequence(serializedFunction); diff --git a/nes-physical-operators/include/Aggregation/Function/Meos/CrossDistanceAggregationPhysicalFunction.hpp b/nes-physical-operators/include/Aggregation/Function/Meos/CrossDistanceAggregationPhysicalFunction.hpp new file mode 100644 index 0000000000..5698049b8d --- /dev/null +++ b/nes-physical-operators/include/Aggregation/Function/Meos/CrossDistanceAggregationPhysicalFunction.hpp @@ -0,0 +1,92 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +/** + * @brief Aggregation that emits the BerlinMOD-Q9 cross-distance between two specific + * vehicles per window. + * + * Takes four input fields (lon, lat, timestamp, vehicle_id) plus a per-aggregation + * `(vidA, vidB)` vehicle-pair passed via two SQL integer constant args + * (`CROSS_DISTANCE(lon, lat, ts, vehicle_id, 100, 200)`). The lift step stores per-event + * tuples; the lower step picks the latest known position of each target vehicle within + * the window and emits the spheroidal `geog_distance(POINT, POINT)` between them as a + * FLOAT64. Returns `NaN` when either target vehicle has no observation in the window. + * + * @note `DEFAULT_VID_A` (100) and `DEFAULT_VID_B` (200) preserve the previous + * BerlinMOD-scaffold default; used by the Registrar deserialize path until full Serde + * round-trip for the constant pair is added (currently the proto carries only the 4 + * field + asField args via `SerializableAggregationFunction.extra_fields`). Mirrors the + * Serde caveat from PairMeeting #19. + * + * Closes the MobilityNebula BerlinMOD-Q9 × 3-form partial→full gap; this PR makes the + * target vehicle pair configurable per-query. + */ +class CrossDistanceAggregationPhysicalFunction : public AggregationPhysicalFunction +{ +public: + /// BerlinMOD-scaffold defaults (preserved on the Serde-deserialize path; the parser + /// path always supplies explicit values). + static constexpr uint64_t DEFAULT_VID_A = 100; + static constexpr uint64_t DEFAULT_VID_B = 200; + + CrossDistanceAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction lonFunctionParam, + PhysicalFunction latFunctionParam, + PhysicalFunction timestampFunctionParam, + PhysicalFunction vehicleIdFunctionParam, + uint64_t vidA, + uint64_t vidB, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef); + void lift( + const nautilus::val& aggregationState, + PipelineMemoryProvider& pipelineMemoryProvider, + const Nautilus::Record& record) + override; + void combine( + nautilus::val aggregationState1, + nautilus::val aggregationState2, + PipelineMemoryProvider& pipelineMemoryProvider) override; + Nautilus::Record lower(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + void reset(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + [[nodiscard]] size_t getSizeOfStateInBytes() const override; + ~CrossDistanceAggregationPhysicalFunction() override = default; + void cleanup(nautilus::val aggregationState) override; + +private: + std::shared_ptr bufferRef; + PhysicalFunction lonFunction; + PhysicalFunction latFunction; + PhysicalFunction timestampFunction; + PhysicalFunction vehicleIdFunction; + uint64_t vidA; + uint64_t vidB; +}; + +} diff --git a/nes-physical-operators/include/Aggregation/Function/Meos/PairMeetingAggregationPhysicalFunction.hpp b/nes-physical-operators/include/Aggregation/Function/Meos/PairMeetingAggregationPhysicalFunction.hpp new file mode 100644 index 0000000000..d254bb4646 --- /dev/null +++ b/nes-physical-operators/include/Aggregation/Function/Meos/PairMeetingAggregationPhysicalFunction.hpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +/** + * @brief Cartesian aggregation that emits the BerlinMOD-Q5 pair-meeting answer per window. + * + * Takes four input fields: lon, lat, timestamp, vehicle_id, plus a per-aggregation + * `dMeetMetres` distance threshold passed via the SQL constant arg + * (`PAIR_MEETING(lon, lat, ts, vehicle_id, 200.0)`). The lift step stores per-event + * tuples in a PagedVector. The lower step picks each vehicle's last-known position in the + * window, enumerates vehicle pairs (a < b), and emits pairs whose spheroidal distance is + * at most `dMeetMetres`. Result is a VARSIZED string `"vidA,vidB,ts,dist;..."` — same + * shape pattern as TemporalSequence's BINARY(N) result. + * + * @note `DEFAULT_DMEET_METRES` (200 m) preserves the previous BerlinMOD-scaffold + * default; used by the Registrar deserialize path until full Serde round-trip for the + * dMeet constant is added (currently the proto carries only the 4 field + asField args + * via `SerializableAggregationFunction.extra_fields`). + * + * Closes the MobilityNebula BerlinMOD-Q5 × 3-form partial→full gap; this PR makes the + * meeting-distance configurable per-query. + */ +class PairMeetingAggregationPhysicalFunction : public AggregationPhysicalFunction +{ +public: + /// BerlinMOD-scaffold default (preserved when the SQL omits the constant arg via the + /// Serde-deserialize path; the parser path always supplies an explicit value). + static constexpr double DEFAULT_DMEET_METRES = 200.0; + + PairMeetingAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction lonFunctionParam, + PhysicalFunction latFunctionParam, + PhysicalFunction timestampFunctionParam, + PhysicalFunction vehicleIdFunctionParam, + double dMeetMetres, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef); + void lift( + const nautilus::val& aggregationState, + PipelineMemoryProvider& pipelineMemoryProvider, + const Nautilus::Record& record) + override; + void combine( + nautilus::val aggregationState1, + nautilus::val aggregationState2, + PipelineMemoryProvider& pipelineMemoryProvider) override; + Nautilus::Record lower(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + void reset(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + [[nodiscard]] size_t getSizeOfStateInBytes() const override; + ~PairMeetingAggregationPhysicalFunction() override = default; + void cleanup(nautilus::val aggregationState) override; + +private: + std::shared_ptr bufferRef; + PhysicalFunction lonFunction; + PhysicalFunction latFunction; + PhysicalFunction timestampFunction; + PhysicalFunction vehicleIdFunction; + double dMeetMetres; +}; + +} diff --git a/nes-physical-operators/include/Aggregation/Function/Meos/TemporalEndTimestampAggregationPhysicalFunction.hpp b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalEndTimestampAggregationPhysicalFunction.hpp new file mode 100644 index 0000000000..087688698f --- /dev/null +++ b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalEndTimestampAggregationPhysicalFunction.hpp @@ -0,0 +1,60 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +class TemporalEndTimestampAggregationPhysicalFunction : public AggregationPhysicalFunction +{ +public: + TemporalEndTimestampAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction lonFunctionParam, + PhysicalFunction latFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef); + void lift( + const nautilus::val& aggregationState, + PipelineMemoryProvider& pipelineMemoryProvider, + const Nautilus::Record& record) + override; + void combine( + nautilus::val aggregationState1, + nautilus::val aggregationState2, + PipelineMemoryProvider& pipelineMemoryProvider) override; + Nautilus::Record lower(nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) override; + void reset(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + [[nodiscard]] size_t getSizeOfStateInBytes() const override; + ~TemporalEndTimestampAggregationPhysicalFunction() override = default; + void cleanup(nautilus::val aggregationState) override; + +private: + std::shared_ptr bufferRef; + PhysicalFunction lonFunction; + PhysicalFunction latFunction; + PhysicalFunction timestampFunction; +}; + +} diff --git a/nes-physical-operators/include/Aggregation/Function/Meos/TemporalLengthAggregationPhysicalFunction.hpp b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalLengthAggregationPhysicalFunction.hpp new file mode 100644 index 0000000000..cf73b9e743 --- /dev/null +++ b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalLengthAggregationPhysicalFunction.hpp @@ -0,0 +1,73 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +/** + * @brief Aggregation function that returns the spheroidal length in metres of + * the per-(window, group) trajectory built from the (lon, lat, timestamp) + * tuples lifted into the aggregation state. + * + * Same lift / combine / reset shape as TemporalSequenceAggregationPhysicalFunction; + * the lower step parses the assembled trajectory into a MEOS Temporal object and + * calls MEOS' tpoint_length(Temporal*) to return a single FLOAT64 result. + * + * Used by BerlinMOD-Q6 ("cumulative distance per vehicle") streaming-form + * scaffold: closes the partial→full gap that the prior scaffold documented as + * "PR-B" in docs/berlinmod-streaming-forms.md. + */ +class TemporalLengthAggregationPhysicalFunction : public AggregationPhysicalFunction +{ +public: + TemporalLengthAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction lonFunctionParam, + PhysicalFunction latFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef); + void lift( + const nautilus::val& aggregationState, + PipelineMemoryProvider& pipelineMemoryProvider, + const Nautilus::Record& record) + override; + void combine( + nautilus::val aggregationState1, + nautilus::val aggregationState2, + PipelineMemoryProvider& pipelineMemoryProvider) override; + Nautilus::Record lower(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + void reset(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + [[nodiscard]] size_t getSizeOfStateInBytes() const override; + ~TemporalLengthAggregationPhysicalFunction() override = default; + void cleanup(nautilus::val aggregationState) override; + +private: + std::shared_ptr bufferRef; + PhysicalFunction lonFunction; + PhysicalFunction latFunction; + PhysicalFunction timestampFunction; +}; + +} diff --git a/nes-physical-operators/include/Aggregation/Function/Meos/TemporalLowerIncAggregationPhysicalFunction.hpp b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalLowerIncAggregationPhysicalFunction.hpp new file mode 100644 index 0000000000..8813c3ef2f --- /dev/null +++ b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalLowerIncAggregationPhysicalFunction.hpp @@ -0,0 +1,60 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +class TemporalLowerIncAggregationPhysicalFunction : public AggregationPhysicalFunction +{ +public: + TemporalLowerIncAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction lonFunctionParam, + PhysicalFunction latFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef); + void lift( + const nautilus::val& aggregationState, + PipelineMemoryProvider& pipelineMemoryProvider, + const Nautilus::Record& record) + override; + void combine( + nautilus::val aggregationState1, + nautilus::val aggregationState2, + PipelineMemoryProvider& pipelineMemoryProvider) override; + Nautilus::Record lower(nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) override; + void reset(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + [[nodiscard]] size_t getSizeOfStateInBytes() const override; + ~TemporalLowerIncAggregationPhysicalFunction() override = default; + void cleanup(nautilus::val aggregationState) override; + +private: + std::shared_ptr bufferRef; + PhysicalFunction lonFunction; + PhysicalFunction latFunction; + PhysicalFunction timestampFunction; +}; + +} diff --git a/nes-physical-operators/include/Aggregation/Function/Meos/TemporalNumInstantsAggregationPhysicalFunction.hpp b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalNumInstantsAggregationPhysicalFunction.hpp new file mode 100644 index 0000000000..0a5846a05b --- /dev/null +++ b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalNumInstantsAggregationPhysicalFunction.hpp @@ -0,0 +1,60 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +class TemporalNumInstantsAggregationPhysicalFunction : public AggregationPhysicalFunction +{ +public: + TemporalNumInstantsAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction lonFunctionParam, + PhysicalFunction latFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef); + void lift( + const nautilus::val& aggregationState, + PipelineMemoryProvider& pipelineMemoryProvider, + const Nautilus::Record& record) + override; + void combine( + nautilus::val aggregationState1, + nautilus::val aggregationState2, + PipelineMemoryProvider& pipelineMemoryProvider) override; + Nautilus::Record lower(nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) override; + void reset(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + [[nodiscard]] size_t getSizeOfStateInBytes() const override; + ~TemporalNumInstantsAggregationPhysicalFunction() override = default; + void cleanup(nautilus::val aggregationState) override; + +private: + std::shared_ptr bufferRef; + PhysicalFunction lonFunction; + PhysicalFunction latFunction; + PhysicalFunction timestampFunction; +}; + +} diff --git a/nes-physical-operators/include/Aggregation/Function/Meos/TemporalNumSequencesAggregationPhysicalFunction.hpp b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalNumSequencesAggregationPhysicalFunction.hpp new file mode 100644 index 0000000000..7c16b2768a --- /dev/null +++ b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalNumSequencesAggregationPhysicalFunction.hpp @@ -0,0 +1,60 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +class TemporalNumSequencesAggregationPhysicalFunction : public AggregationPhysicalFunction +{ +public: + TemporalNumSequencesAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction lonFunctionParam, + PhysicalFunction latFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef); + void lift( + const nautilus::val& aggregationState, + PipelineMemoryProvider& pipelineMemoryProvider, + const Nautilus::Record& record) + override; + void combine( + nautilus::val aggregationState1, + nautilus::val aggregationState2, + PipelineMemoryProvider& pipelineMemoryProvider) override; + Nautilus::Record lower(nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) override; + void reset(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + [[nodiscard]] size_t getSizeOfStateInBytes() const override; + ~TemporalNumSequencesAggregationPhysicalFunction() override = default; + void cleanup(nautilus::val aggregationState) override; + +private: + std::shared_ptr bufferRef; + PhysicalFunction lonFunction; + PhysicalFunction latFunction; + PhysicalFunction timestampFunction; +}; + +} diff --git a/nes-physical-operators/include/Aggregation/Function/Meos/TemporalNumTimestampsAggregationPhysicalFunction.hpp b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalNumTimestampsAggregationPhysicalFunction.hpp new file mode 100644 index 0000000000..e1c16f7288 --- /dev/null +++ b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalNumTimestampsAggregationPhysicalFunction.hpp @@ -0,0 +1,60 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +class TemporalNumTimestampsAggregationPhysicalFunction : public AggregationPhysicalFunction +{ +public: + TemporalNumTimestampsAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction lonFunctionParam, + PhysicalFunction latFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef); + void lift( + const nautilus::val& aggregationState, + PipelineMemoryProvider& pipelineMemoryProvider, + const Nautilus::Record& record) + override; + void combine( + nautilus::val aggregationState1, + nautilus::val aggregationState2, + PipelineMemoryProvider& pipelineMemoryProvider) override; + Nautilus::Record lower(nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) override; + void reset(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + [[nodiscard]] size_t getSizeOfStateInBytes() const override; + ~TemporalNumTimestampsAggregationPhysicalFunction() override = default; + void cleanup(nautilus::val aggregationState) override; + +private: + std::shared_ptr bufferRef; + PhysicalFunction lonFunction; + PhysicalFunction latFunction; + PhysicalFunction timestampFunction; +}; + +} diff --git a/nes-physical-operators/include/Aggregation/Function/Meos/TemporalStartTimestampAggregationPhysicalFunction.hpp b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalStartTimestampAggregationPhysicalFunction.hpp new file mode 100644 index 0000000000..7e36deea33 --- /dev/null +++ b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalStartTimestampAggregationPhysicalFunction.hpp @@ -0,0 +1,60 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +class TemporalStartTimestampAggregationPhysicalFunction : public AggregationPhysicalFunction +{ +public: + TemporalStartTimestampAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction lonFunctionParam, + PhysicalFunction latFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef); + void lift( + const nautilus::val& aggregationState, + PipelineMemoryProvider& pipelineMemoryProvider, + const Nautilus::Record& record) + override; + void combine( + nautilus::val aggregationState1, + nautilus::val aggregationState2, + PipelineMemoryProvider& pipelineMemoryProvider) override; + Nautilus::Record lower(nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) override; + void reset(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + [[nodiscard]] size_t getSizeOfStateInBytes() const override; + ~TemporalStartTimestampAggregationPhysicalFunction() override = default; + void cleanup(nautilus::val aggregationState) override; + +private: + std::shared_ptr bufferRef; + PhysicalFunction lonFunction; + PhysicalFunction latFunction; + PhysicalFunction timestampFunction; +}; + +} diff --git a/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTFloatAvgValueAggregationPhysicalFunction.hpp b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTFloatAvgValueAggregationPhysicalFunction.hpp new file mode 100644 index 0000000000..357bfcdff3 --- /dev/null +++ b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTFloatAvgValueAggregationPhysicalFunction.hpp @@ -0,0 +1,58 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +class TemporalTFloatAvgValueAggregationPhysicalFunction : public AggregationPhysicalFunction +{ +public: + TemporalTFloatAvgValueAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction valueFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef); + void lift( + const nautilus::val& aggregationState, + PipelineMemoryProvider& pipelineMemoryProvider, + const Nautilus::Record& record) + override; + void combine( + nautilus::val aggregationState1, + nautilus::val aggregationState2, + PipelineMemoryProvider& pipelineMemoryProvider) override; + Nautilus::Record lower(nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) override; + void reset(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + [[nodiscard]] size_t getSizeOfStateInBytes() const override; + ~TemporalTFloatAvgValueAggregationPhysicalFunction() override = default; + void cleanup(nautilus::val aggregationState) override; + +private: + std::shared_ptr bufferRef; + PhysicalFunction valueFunction; + PhysicalFunction timestampFunction; +}; + +} diff --git a/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTFloatEndValueAggregationPhysicalFunction.hpp b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTFloatEndValueAggregationPhysicalFunction.hpp new file mode 100644 index 0000000000..3a102ebc4d --- /dev/null +++ b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTFloatEndValueAggregationPhysicalFunction.hpp @@ -0,0 +1,58 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +class TemporalTFloatEndValueAggregationPhysicalFunction : public AggregationPhysicalFunction +{ +public: + TemporalTFloatEndValueAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction valueFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef); + void lift( + const nautilus::val& aggregationState, + PipelineMemoryProvider& pipelineMemoryProvider, + const Nautilus::Record& record) + override; + void combine( + nautilus::val aggregationState1, + nautilus::val aggregationState2, + PipelineMemoryProvider& pipelineMemoryProvider) override; + Nautilus::Record lower(nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) override; + void reset(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + [[nodiscard]] size_t getSizeOfStateInBytes() const override; + ~TemporalTFloatEndValueAggregationPhysicalFunction() override = default; + void cleanup(nautilus::val aggregationState) override; + +private: + std::shared_ptr bufferRef; + PhysicalFunction valueFunction; + PhysicalFunction timestampFunction; +}; + +} diff --git a/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTFloatMaxValueAggregationPhysicalFunction.hpp b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTFloatMaxValueAggregationPhysicalFunction.hpp new file mode 100644 index 0000000000..c6b0222d44 --- /dev/null +++ b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTFloatMaxValueAggregationPhysicalFunction.hpp @@ -0,0 +1,58 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +class TemporalTFloatMaxValueAggregationPhysicalFunction : public AggregationPhysicalFunction +{ +public: + TemporalTFloatMaxValueAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction valueFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef); + void lift( + const nautilus::val& aggregationState, + PipelineMemoryProvider& pipelineMemoryProvider, + const Nautilus::Record& record) + override; + void combine( + nautilus::val aggregationState1, + nautilus::val aggregationState2, + PipelineMemoryProvider& pipelineMemoryProvider) override; + Nautilus::Record lower(nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) override; + void reset(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + [[nodiscard]] size_t getSizeOfStateInBytes() const override; + ~TemporalTFloatMaxValueAggregationPhysicalFunction() override = default; + void cleanup(nautilus::val aggregationState) override; + +private: + std::shared_ptr bufferRef; + PhysicalFunction valueFunction; + PhysicalFunction timestampFunction; +}; + +} diff --git a/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTFloatMinValueAggregationPhysicalFunction.hpp b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTFloatMinValueAggregationPhysicalFunction.hpp new file mode 100644 index 0000000000..e99d6626cd --- /dev/null +++ b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTFloatMinValueAggregationPhysicalFunction.hpp @@ -0,0 +1,58 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +class TemporalTFloatMinValueAggregationPhysicalFunction : public AggregationPhysicalFunction +{ +public: + TemporalTFloatMinValueAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction valueFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef); + void lift( + const nautilus::val& aggregationState, + PipelineMemoryProvider& pipelineMemoryProvider, + const Nautilus::Record& record) + override; + void combine( + nautilus::val aggregationState1, + nautilus::val aggregationState2, + PipelineMemoryProvider& pipelineMemoryProvider) override; + Nautilus::Record lower(nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) override; + void reset(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + [[nodiscard]] size_t getSizeOfStateInBytes() const override; + ~TemporalTFloatMinValueAggregationPhysicalFunction() override = default; + void cleanup(nautilus::val aggregationState) override; + +private: + std::shared_ptr bufferRef; + PhysicalFunction valueFunction; + PhysicalFunction timestampFunction; +}; + +} diff --git a/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTFloatStartValueAggregationPhysicalFunction.hpp b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTFloatStartValueAggregationPhysicalFunction.hpp new file mode 100644 index 0000000000..d51c01e89a --- /dev/null +++ b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTFloatStartValueAggregationPhysicalFunction.hpp @@ -0,0 +1,58 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +class TemporalTFloatStartValueAggregationPhysicalFunction : public AggregationPhysicalFunction +{ +public: + TemporalTFloatStartValueAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction valueFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef); + void lift( + const nautilus::val& aggregationState, + PipelineMemoryProvider& pipelineMemoryProvider, + const Nautilus::Record& record) + override; + void combine( + nautilus::val aggregationState1, + nautilus::val aggregationState2, + PipelineMemoryProvider& pipelineMemoryProvider) override; + Nautilus::Record lower(nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) override; + void reset(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + [[nodiscard]] size_t getSizeOfStateInBytes() const override; + ~TemporalTFloatStartValueAggregationPhysicalFunction() override = default; + void cleanup(nautilus::val aggregationState) override; + +private: + std::shared_ptr bufferRef; + PhysicalFunction valueFunction; + PhysicalFunction timestampFunction; +}; + +} diff --git a/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTIntAvgValueAggregationPhysicalFunction.hpp b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTIntAvgValueAggregationPhysicalFunction.hpp new file mode 100644 index 0000000000..2fb133918d --- /dev/null +++ b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTIntAvgValueAggregationPhysicalFunction.hpp @@ -0,0 +1,58 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +class TemporalTIntAvgValueAggregationPhysicalFunction : public AggregationPhysicalFunction +{ +public: + TemporalTIntAvgValueAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction valueFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef); + void lift( + const nautilus::val& aggregationState, + PipelineMemoryProvider& pipelineMemoryProvider, + const Nautilus::Record& record) + override; + void combine( + nautilus::val aggregationState1, + nautilus::val aggregationState2, + PipelineMemoryProvider& pipelineMemoryProvider) override; + Nautilus::Record lower(nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) override; + void reset(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + [[nodiscard]] size_t getSizeOfStateInBytes() const override; + ~TemporalTIntAvgValueAggregationPhysicalFunction() override = default; + void cleanup(nautilus::val aggregationState) override; + +private: + std::shared_ptr bufferRef; + PhysicalFunction valueFunction; + PhysicalFunction timestampFunction; +}; + +} diff --git a/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTIntEndValueAggregationPhysicalFunction.hpp b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTIntEndValueAggregationPhysicalFunction.hpp new file mode 100644 index 0000000000..5ceec8e789 --- /dev/null +++ b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTIntEndValueAggregationPhysicalFunction.hpp @@ -0,0 +1,58 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +class TemporalTIntEndValueAggregationPhysicalFunction : public AggregationPhysicalFunction +{ +public: + TemporalTIntEndValueAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction valueFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef); + void lift( + const nautilus::val& aggregationState, + PipelineMemoryProvider& pipelineMemoryProvider, + const Nautilus::Record& record) + override; + void combine( + nautilus::val aggregationState1, + nautilus::val aggregationState2, + PipelineMemoryProvider& pipelineMemoryProvider) override; + Nautilus::Record lower(nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) override; + void reset(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + [[nodiscard]] size_t getSizeOfStateInBytes() const override; + ~TemporalTIntEndValueAggregationPhysicalFunction() override = default; + void cleanup(nautilus::val aggregationState) override; + +private: + std::shared_ptr bufferRef; + PhysicalFunction valueFunction; + PhysicalFunction timestampFunction; +}; + +} diff --git a/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTIntMaxValueAggregationPhysicalFunction.hpp b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTIntMaxValueAggregationPhysicalFunction.hpp new file mode 100644 index 0000000000..cc3780b870 --- /dev/null +++ b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTIntMaxValueAggregationPhysicalFunction.hpp @@ -0,0 +1,58 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +class TemporalTIntMaxValueAggregationPhysicalFunction : public AggregationPhysicalFunction +{ +public: + TemporalTIntMaxValueAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction valueFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef); + void lift( + const nautilus::val& aggregationState, + PipelineMemoryProvider& pipelineMemoryProvider, + const Nautilus::Record& record) + override; + void combine( + nautilus::val aggregationState1, + nautilus::val aggregationState2, + PipelineMemoryProvider& pipelineMemoryProvider) override; + Nautilus::Record lower(nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) override; + void reset(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + [[nodiscard]] size_t getSizeOfStateInBytes() const override; + ~TemporalTIntMaxValueAggregationPhysicalFunction() override = default; + void cleanup(nautilus::val aggregationState) override; + +private: + std::shared_ptr bufferRef; + PhysicalFunction valueFunction; + PhysicalFunction timestampFunction; +}; + +} diff --git a/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTIntMinValueAggregationPhysicalFunction.hpp b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTIntMinValueAggregationPhysicalFunction.hpp new file mode 100644 index 0000000000..54733b5848 --- /dev/null +++ b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTIntMinValueAggregationPhysicalFunction.hpp @@ -0,0 +1,58 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +class TemporalTIntMinValueAggregationPhysicalFunction : public AggregationPhysicalFunction +{ +public: + TemporalTIntMinValueAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction valueFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef); + void lift( + const nautilus::val& aggregationState, + PipelineMemoryProvider& pipelineMemoryProvider, + const Nautilus::Record& record) + override; + void combine( + nautilus::val aggregationState1, + nautilus::val aggregationState2, + PipelineMemoryProvider& pipelineMemoryProvider) override; + Nautilus::Record lower(nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) override; + void reset(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + [[nodiscard]] size_t getSizeOfStateInBytes() const override; + ~TemporalTIntMinValueAggregationPhysicalFunction() override = default; + void cleanup(nautilus::val aggregationState) override; + +private: + std::shared_ptr bufferRef; + PhysicalFunction valueFunction; + PhysicalFunction timestampFunction; +}; + +} diff --git a/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTIntStartValueAggregationPhysicalFunction.hpp b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTIntStartValueAggregationPhysicalFunction.hpp new file mode 100644 index 0000000000..727921eab0 --- /dev/null +++ b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTIntStartValueAggregationPhysicalFunction.hpp @@ -0,0 +1,58 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +class TemporalTIntStartValueAggregationPhysicalFunction : public AggregationPhysicalFunction +{ +public: + TemporalTIntStartValueAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction valueFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef); + void lift( + const nautilus::val& aggregationState, + PipelineMemoryProvider& pipelineMemoryProvider, + const Nautilus::Record& record) + override; + void combine( + nautilus::val aggregationState1, + nautilus::val aggregationState2, + PipelineMemoryProvider& pipelineMemoryProvider) override; + Nautilus::Record lower(nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) override; + void reset(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + [[nodiscard]] size_t getSizeOfStateInBytes() const override; + ~TemporalTIntStartValueAggregationPhysicalFunction() override = default; + void cleanup(nautilus::val aggregationState) override; + +private: + std::shared_ptr bufferRef; + PhysicalFunction valueFunction; + PhysicalFunction timestampFunction; +}; + +} diff --git a/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTNumberIntegralAggregationPhysicalFunction.hpp b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTNumberIntegralAggregationPhysicalFunction.hpp new file mode 100644 index 0000000000..9b049e7c29 --- /dev/null +++ b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTNumberIntegralAggregationPhysicalFunction.hpp @@ -0,0 +1,58 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +class TemporalTNumberIntegralAggregationPhysicalFunction : public AggregationPhysicalFunction +{ +public: + TemporalTNumberIntegralAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction valueFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef); + void lift( + const nautilus::val& aggregationState, + PipelineMemoryProvider& pipelineMemoryProvider, + const Nautilus::Record& record) + override; + void combine( + nautilus::val aggregationState1, + nautilus::val aggregationState2, + PipelineMemoryProvider& pipelineMemoryProvider) override; + Nautilus::Record lower(nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) override; + void reset(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + [[nodiscard]] size_t getSizeOfStateInBytes() const override; + ~TemporalTNumberIntegralAggregationPhysicalFunction() override = default; + void cleanup(nautilus::val aggregationState) override; + +private: + std::shared_ptr bufferRef; + PhysicalFunction valueFunction; + PhysicalFunction timestampFunction; +}; + +} diff --git a/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTNumberTwAvgAggregationPhysicalFunction.hpp b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTNumberTwAvgAggregationPhysicalFunction.hpp new file mode 100644 index 0000000000..8195a0e071 --- /dev/null +++ b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTNumberTwAvgAggregationPhysicalFunction.hpp @@ -0,0 +1,58 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +class TemporalTNumberTwAvgAggregationPhysicalFunction : public AggregationPhysicalFunction +{ +public: + TemporalTNumberTwAvgAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction valueFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef); + void lift( + const nautilus::val& aggregationState, + PipelineMemoryProvider& pipelineMemoryProvider, + const Nautilus::Record& record) + override; + void combine( + nautilus::val aggregationState1, + nautilus::val aggregationState2, + PipelineMemoryProvider& pipelineMemoryProvider) override; + Nautilus::Record lower(nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) override; + void reset(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + [[nodiscard]] size_t getSizeOfStateInBytes() const override; + ~TemporalTNumberTwAvgAggregationPhysicalFunction() override = default; + void cleanup(nautilus::val aggregationState) override; + +private: + std::shared_ptr bufferRef; + PhysicalFunction valueFunction; + PhysicalFunction timestampFunction; +}; + +} diff --git a/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTPointIsSimpleAggregationPhysicalFunction.hpp b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTPointIsSimpleAggregationPhysicalFunction.hpp new file mode 100644 index 0000000000..dea1b3395c --- /dev/null +++ b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalTPointIsSimpleAggregationPhysicalFunction.hpp @@ -0,0 +1,60 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +class TemporalTPointIsSimpleAggregationPhysicalFunction : public AggregationPhysicalFunction +{ +public: + TemporalTPointIsSimpleAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction lonFunctionParam, + PhysicalFunction latFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef); + void lift( + const nautilus::val& aggregationState, + PipelineMemoryProvider& pipelineMemoryProvider, + const Nautilus::Record& record) + override; + void combine( + nautilus::val aggregationState1, + nautilus::val aggregationState2, + PipelineMemoryProvider& pipelineMemoryProvider) override; + Nautilus::Record lower(nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) override; + void reset(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + [[nodiscard]] size_t getSizeOfStateInBytes() const override; + ~TemporalTPointIsSimpleAggregationPhysicalFunction() override = default; + void cleanup(nautilus::val aggregationState) override; + +private: + std::shared_ptr bufferRef; + PhysicalFunction lonFunction; + PhysicalFunction latFunction; + PhysicalFunction timestampFunction; +}; + +} diff --git a/nes-physical-operators/include/Aggregation/Function/Meos/TemporalUpperIncAggregationPhysicalFunction.hpp b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalUpperIncAggregationPhysicalFunction.hpp new file mode 100644 index 0000000000..18bfaa9963 --- /dev/null +++ b/nes-physical-operators/include/Aggregation/Function/Meos/TemporalUpperIncAggregationPhysicalFunction.hpp @@ -0,0 +1,60 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +class TemporalUpperIncAggregationPhysicalFunction : public AggregationPhysicalFunction +{ +public: + TemporalUpperIncAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction lonFunctionParam, + PhysicalFunction latFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef); + void lift( + const nautilus::val& aggregationState, + PipelineMemoryProvider& pipelineMemoryProvider, + const Nautilus::Record& record) + override; + void combine( + nautilus::val aggregationState1, + nautilus::val aggregationState2, + PipelineMemoryProvider& pipelineMemoryProvider) override; + Nautilus::Record lower(nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) override; + void reset(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + [[nodiscard]] size_t getSizeOfStateInBytes() const override; + ~TemporalUpperIncAggregationPhysicalFunction() override = default; + void cleanup(nautilus::val aggregationState) override; + +private: + std::shared_ptr bufferRef; + PhysicalFunction lonFunction; + PhysicalFunction latFunction; + PhysicalFunction timestampFunction; +}; + +} diff --git a/nes-physical-operators/include/Functions/Meos/TemporalAContainsGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalAContainsGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..3c8ad78eb7 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalAContainsGeometryPhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `acontains_tgeo_geo`. + * + * Per-event always-contains between a single-instant tgeompoint and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalAContainsGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalAContainsGeometryPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalAContainsTCbufferCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalAContainsTCbufferCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..c0d73251a6 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalAContainsTCbufferCbufferPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `acontains_tcbuffer_cbuffer`. + * + * Per-event a-contains between a single-instant tcbuffer and a static Cbuffer literal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalAContainsTCbufferCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalAContainsTCbufferCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction cbufferLitFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalAContainsTCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalAContainsTCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..c36fea169d --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalAContainsTCbufferPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `acontains_tcbuffer_geo`. + * + * Per-event always-contains between a single-instant tcbuffer and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalAContainsTCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalAContainsTCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalAContainsTGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalAContainsTGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..73283d8aac --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalAContainsTGeometryPhysicalFunction.hpp @@ -0,0 +1,46 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `acontains_tgeo_tgeo`. + * + * Per-event always-contains between two single-instant tgeompoints. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalAContainsTGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalAContainsTGeometryPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalAContainsTNpointGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalAContainsTNpointGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..98259c0b92 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalAContainsTNpointGeometryPhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `acontains_tgeo_geo`. + * + * Per-event always-contains between a single-instant tgeompoint resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint and a static geometry (network SRID). + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalAContainsTNpointGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalAContainsTNpointGeometryPhysicalFunction(PhysicalFunction ridFunction, + PhysicalFunction fractionFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalAContainsTNpointTNpointPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalAContainsTNpointTNpointPhysicalFunction.hpp new file mode 100644 index 0000000000..62cdb67c18 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalAContainsTNpointTNpointPhysicalFunction.hpp @@ -0,0 +1,46 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `acontains_tgeo_tgeo`. + * + * Per-event always-contains between two single-instant tgeompoints, each resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalAContainsTNpointTNpointPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalAContainsTNpointTNpointPhysicalFunction(PhysicalFunction ridAFunction, + PhysicalFunction fractionAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction ridBFunction, + PhysicalFunction fractionBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalAContainsTPoseGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalAContainsTPoseGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..6c9256d0bb --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalAContainsTPoseGeometryPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `acontains_tgeo_geo`. + * + * Per-event always-contains between a single-instant tpose (converted to tgeompoint at runtime) and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalAContainsTPoseGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalAContainsTPoseGeometryPhysicalFunction(PhysicalFunction xFunction, + PhysicalFunction yFunction, + PhysicalFunction thetaFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalAContainsTPoseTPosePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalAContainsTPoseTPosePhysicalFunction.hpp new file mode 100644 index 0000000000..55d7c6fe47 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalAContainsTPoseTPosePhysicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `acontains_tgeo_tgeo`. + * + * Per-event always-contains between two single-instant tgeompoints, each lifted from a tpose (x,y,theta,ts) via tpose_to_tpoint composition. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalAContainsTPoseTPosePhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalAContainsTPoseTPosePhysicalFunction(PhysicalFunction xAFunction, + PhysicalFunction yAFunction, + PhysicalFunction thetaAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction xBFunction, + PhysicalFunction yBFunction, + PhysicalFunction thetaBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalACoversTCbufferCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalACoversTCbufferCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..6723719046 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalACoversTCbufferCbufferPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `acovers_tcbuffer_cbuffer`. + * + * Per-event a-covers between a single-instant tcbuffer and a static Cbuffer literal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalACoversTCbufferCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalACoversTCbufferCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction cbufferLitFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalACoversTCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalACoversTCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..2f293663a1 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalACoversTCbufferPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `acovers_tcbuffer_geo`. + * + * Per-event always-covers between a single-instant tcbuffer and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalACoversTCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalACoversTCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalADWithinGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalADWithinGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..1189910171 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalADWithinGeometryPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `adwithin_tgeo_geo`. + * + * Per-event always-distance-within between a single-instant tgeompoint and a static geometry under a static threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalADWithinGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalADWithinGeometryPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction, + PhysicalFunction distFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalADWithinTCbufferCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalADWithinTCbufferCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..49e809ceae --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalADWithinTCbufferCbufferPhysicalFunction.hpp @@ -0,0 +1,46 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `adwithin_tcbuffer_cbuffer`. + * + * Per-event always-distance-within between a single-instant tcbuffer and a static Cbuffer under a fixed threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalADWithinTCbufferCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalADWithinTCbufferCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction cbufferLitFunction, + PhysicalFunction distFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalADWithinTCbufferGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalADWithinTCbufferGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..9e65175b33 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalADWithinTCbufferGeometryPhysicalFunction.hpp @@ -0,0 +1,46 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `adwithin_tcbuffer_geo`. + * + * Per-event always-distance-within between a single-instant tcbuffer and a static geometry under a fixed threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalADWithinTCbufferGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalADWithinTCbufferGeometryPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction, + PhysicalFunction distFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalADWithinTCbufferTCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalADWithinTCbufferTCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..e7cd0ecd50 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalADWithinTCbufferTCbufferPhysicalFunction.hpp @@ -0,0 +1,49 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `adwithin_tcbuffer_tcbuffer`. + * + * Per-event always-distance-within between two single-instant tcbuffers under a fixed threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalADWithinTCbufferTCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalADWithinTCbufferTCbufferPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction radiusAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction radiusBFunction, + PhysicalFunction tsBFunction, + PhysicalFunction distFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalADWithinTGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalADWithinTGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..334760a2e7 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalADWithinTGeometryPhysicalFunction.hpp @@ -0,0 +1,47 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `adwithin_tgeo_tgeo`. + * + * Per-event always-distance-within between two single-instant tgeompoints under a static threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalADWithinTGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalADWithinTGeometryPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction tsBFunction, + PhysicalFunction distFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalADisjointGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalADisjointGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..c49407d389 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalADisjointGeometryPhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `adisjoint_tgeo_geo`. + * + * Per-event always-disjoint between a single-instant tgeompoint and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalADisjointGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalADisjointGeometryPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalADisjointTCbufferCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalADisjointTCbufferCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..e01e72e37e --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalADisjointTCbufferCbufferPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `adisjoint_tcbuffer_cbuffer`. + * + * Per-event a-disjoint between a single-instant tcbuffer and a static Cbuffer literal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalADisjointTCbufferCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalADisjointTCbufferCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction cbufferLitFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalADisjointTCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalADisjointTCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..151c070752 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalADisjointTCbufferPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `adisjoint_tcbuffer_geo`. + * + * Per-event always-disjoint between a single-instant tcbuffer and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalADisjointTCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalADisjointTCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalADisjointTCbufferTCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalADisjointTCbufferTCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..dca7b0321d --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalADisjointTCbufferTCbufferPhysicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `adisjoint_tcbuffer_tcbuffer`. + * + * Per-event always-disjoint between two single-instant tcbuffers. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalADisjointTCbufferTCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalADisjointTCbufferTCbufferPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction radiusAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction radiusBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalADisjointTGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalADisjointTGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..b128b0cd6b --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalADisjointTGeometryPhysicalFunction.hpp @@ -0,0 +1,46 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `adisjoint_tgeo_tgeo`. + * + * Per-event always-disjoint between two single-instant tgeompoints. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalADisjointTGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalADisjointTGeometryPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalADisjointTNpointGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalADisjointTNpointGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..0f13189eb9 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalADisjointTNpointGeometryPhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `adisjoint_tgeo_geo`. + * + * Per-event always-disjoint between a single-instant tgeompoint resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint and a static geometry (network SRID). + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalADisjointTNpointGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalADisjointTNpointGeometryPhysicalFunction(PhysicalFunction ridFunction, + PhysicalFunction fractionFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalADisjointTNpointTNpointPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalADisjointTNpointTNpointPhysicalFunction.hpp new file mode 100644 index 0000000000..55d6a5db3b --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalADisjointTNpointTNpointPhysicalFunction.hpp @@ -0,0 +1,46 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `adisjoint_tgeo_tgeo`. + * + * Per-event always-disjoint between two single-instant tgeompoints, each resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalADisjointTNpointTNpointPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalADisjointTNpointTNpointPhysicalFunction(PhysicalFunction ridAFunction, + PhysicalFunction fractionAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction ridBFunction, + PhysicalFunction fractionBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalADisjointTPoseGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalADisjointTPoseGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..6702225dd8 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalADisjointTPoseGeometryPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `adisjoint_tgeo_geo`. + * + * Per-event always-disjoint between a single-instant tpose (converted to tgeompoint at runtime) and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalADisjointTPoseGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalADisjointTPoseGeometryPhysicalFunction(PhysicalFunction xFunction, + PhysicalFunction yFunction, + PhysicalFunction thetaFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalADisjointTPoseTPosePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalADisjointTPoseTPosePhysicalFunction.hpp new file mode 100644 index 0000000000..e66c3eb13a --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalADisjointTPoseTPosePhysicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `adisjoint_tgeo_tgeo`. + * + * Per-event always-disjoint between two single-instant tgeompoints, each lifted from a tpose (x,y,theta,ts) via tpose_to_tpoint composition. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalADisjointTPoseTPosePhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalADisjointTPoseTPosePhysicalFunction(PhysicalFunction xAFunction, + PhysicalFunction yAFunction, + PhysicalFunction thetaAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction xBFunction, + PhysicalFunction yBFunction, + PhysicalFunction thetaBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalAIntersectsTCbufferCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalAIntersectsTCbufferCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..e88ed285a3 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalAIntersectsTCbufferCbufferPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `aintersects_tcbuffer_cbuffer`. + * + * Per-event a-intersects between a single-instant tcbuffer and a static Cbuffer literal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalAIntersectsTCbufferCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalAIntersectsTCbufferCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction cbufferLitFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalAIntersectsTCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalAIntersectsTCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..60321c7807 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalAIntersectsTCbufferPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `aintersects_tcbuffer_geo`. + * + * Per-event always-intersects between a single-instant tcbuffer and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalAIntersectsTCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalAIntersectsTCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalAIntersectsTCbufferTCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalAIntersectsTCbufferTCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..180ef216a6 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalAIntersectsTCbufferTCbufferPhysicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `aintersects_tcbuffer_tcbuffer`. + * + * Per-event always-intersects between two single-instant tcbuffers. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalAIntersectsTCbufferTCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalAIntersectsTCbufferTCbufferPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction radiusAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction radiusBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalAIntersectsTGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalAIntersectsTGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..d1c06151d3 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalAIntersectsTGeometryPhysicalFunction.hpp @@ -0,0 +1,46 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `aintersects_tgeo_tgeo`. + * + * Per-event always-intersects between two single-instant tgeompoints. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalAIntersectsTGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalAIntersectsTGeometryPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalAIntersectsTNpointGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalAIntersectsTNpointGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..5cf2cdd831 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalAIntersectsTNpointGeometryPhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `aintersects_tgeo_geo`. + * + * Per-event always-intersects between a single-instant tgeompoint resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint and a static geometry (network SRID). + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalAIntersectsTNpointGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalAIntersectsTNpointGeometryPhysicalFunction(PhysicalFunction ridFunction, + PhysicalFunction fractionFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalAIntersectsTNpointTNpointPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalAIntersectsTNpointTNpointPhysicalFunction.hpp new file mode 100644 index 0000000000..5975fe3de9 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalAIntersectsTNpointTNpointPhysicalFunction.hpp @@ -0,0 +1,46 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `aintersects_tgeo_tgeo`. + * + * Per-event always-intersects between two single-instant tgeompoints, each resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalAIntersectsTNpointTNpointPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalAIntersectsTNpointTNpointPhysicalFunction(PhysicalFunction ridAFunction, + PhysicalFunction fractionAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction ridBFunction, + PhysicalFunction fractionBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalAIntersectsTPoseGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalAIntersectsTPoseGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..f785621a64 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalAIntersectsTPoseGeometryPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `aintersects_tgeo_geo`. + * + * Per-event always-intersects between a single-instant tpose (converted to tgeompoint at runtime) and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalAIntersectsTPoseGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalAIntersectsTPoseGeometryPhysicalFunction(PhysicalFunction xFunction, + PhysicalFunction yFunction, + PhysicalFunction thetaFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalAIntersectsTPoseTPosePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalAIntersectsTPoseTPosePhysicalFunction.hpp new file mode 100644 index 0000000000..048b3d5bb6 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalAIntersectsTPoseTPosePhysicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `aintersects_tgeo_tgeo`. + * + * Per-event always-intersects between two single-instant tgeompoints, each lifted from a tpose (x,y,theta,ts) via tpose_to_tpoint composition. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalAIntersectsTPoseTPosePhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalAIntersectsTPoseTPosePhysicalFunction(PhysicalFunction xAFunction, + PhysicalFunction yAFunction, + PhysicalFunction thetaAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction xBFunction, + PhysicalFunction yBFunction, + PhysicalFunction thetaBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalATouchesGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalATouchesGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..24c024a0d2 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalATouchesGeometryPhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `atouches_tgeo_geo`. + * + * Per-event always-touches between a single-instant tgeompoint and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalATouchesGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalATouchesGeometryPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalATouchesTCbufferCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalATouchesTCbufferCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..60321a22f4 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalATouchesTCbufferCbufferPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `atouches_tcbuffer_cbuffer`. + * + * Per-event a-touches between a single-instant tcbuffer and a static Cbuffer literal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalATouchesTCbufferCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalATouchesTCbufferCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction cbufferLitFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalATouchesTCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalATouchesTCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..ed47cbf565 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalATouchesTCbufferPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `atouches_tcbuffer_geo`. + * + * Per-event always-touches between a single-instant tcbuffer and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalATouchesTCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalATouchesTCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalATouchesTCbufferTCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalATouchesTCbufferTCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..33de04ee53 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalATouchesTCbufferTCbufferPhysicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `atouches_tcbuffer_tcbuffer`. + * + * Per-event always-touches between two single-instant tcbuffers. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalATouchesTCbufferTCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalATouchesTCbufferTCbufferPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction radiusAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction radiusBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalATouchesTGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalATouchesTGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..107eb5f6b1 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalATouchesTGeometryPhysicalFunction.hpp @@ -0,0 +1,46 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `atouches_tgeo_tgeo`. + * + * Per-event always-touches between two single-instant tgeompoints. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalATouchesTGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalATouchesTGeometryPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalATouchesTNpointGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalATouchesTNpointGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..ad537884c3 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalATouchesTNpointGeometryPhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `atouches_tgeo_geo`. + * + * Per-event always-touches between a single-instant tgeompoint resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint and a static geometry (network SRID). + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalATouchesTNpointGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalATouchesTNpointGeometryPhysicalFunction(PhysicalFunction ridFunction, + PhysicalFunction fractionFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalATouchesTNpointTNpointPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalATouchesTNpointTNpointPhysicalFunction.hpp new file mode 100644 index 0000000000..10dc34765e --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalATouchesTNpointTNpointPhysicalFunction.hpp @@ -0,0 +1,46 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `atouches_tgeo_tgeo`. + * + * Per-event always-touches between two single-instant tgeompoints, each resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalATouchesTNpointTNpointPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalATouchesTNpointTNpointPhysicalFunction(PhysicalFunction ridAFunction, + PhysicalFunction fractionAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction ridBFunction, + PhysicalFunction fractionBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalATouchesTPoseGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalATouchesTPoseGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..2788d1847f --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalATouchesTPoseGeometryPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `atouches_tgeo_geo`. + * + * Per-event always-touches between a single-instant tpose (converted to tgeompoint at runtime) and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalATouchesTPoseGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalATouchesTPoseGeometryPhysicalFunction(PhysicalFunction xFunction, + PhysicalFunction yFunction, + PhysicalFunction thetaFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalATouchesTPoseTPosePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalATouchesTPoseTPosePhysicalFunction.hpp new file mode 100644 index 0000000000..3da14558eb --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalATouchesTPoseTPosePhysicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `atouches_tgeo_tgeo`. + * + * Per-event always-touches between two single-instant tgeompoints, each lifted from a tpose (x,y,theta,ts) via tpose_to_tpoint composition. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalATouchesTPoseTPosePhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalATouchesTPoseTPosePhysicalFunction(PhysicalFunction xAFunction, + PhysicalFunction yAFunction, + PhysicalFunction thetaAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction xBFunction, + PhysicalFunction yBFunction, + PhysicalFunction thetaBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalAtGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalAtGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..c6f8389a80 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalAtGeometryPhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tgeo_at_geom`. + * + * Per-event spatial restriction: 1 if the single-instant tgeompoint survives clipping by the static geometry, 0 if clipped. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalAtGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalAtGeometryPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEContainsTCbufferCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEContainsTCbufferCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..bdeeceef89 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEContainsTCbufferCbufferPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `econtains_tcbuffer_cbuffer`. + * + * Per-event e-contains between a single-instant tcbuffer and a static Cbuffer literal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEContainsTCbufferCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEContainsTCbufferCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction cbufferLitFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEContainsTCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEContainsTCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..3b30d995d7 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEContainsTCbufferPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `econtains_tcbuffer_geo`. + * + * Per-event ever-contains between a single-instant tcbuffer and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEContainsTCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEContainsTCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEContainsTGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEContainsTGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..6182be5e51 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEContainsTGeometryPhysicalFunction.hpp @@ -0,0 +1,46 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `econtains_tgeo_tgeo`. + * + * Per-event ever-contains between two single-instant tgeompoints built from event fields. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEContainsTGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEContainsTGeometryPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEContainsTNpointGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEContainsTNpointGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..77cb61b374 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEContainsTNpointGeometryPhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `econtains_tgeo_geo`. + * + * Per-event ever-contains between a single-instant tgeompoint resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint and a static geometry (network SRID). + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEContainsTNpointGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEContainsTNpointGeometryPhysicalFunction(PhysicalFunction ridFunction, + PhysicalFunction fractionFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEContainsTNpointTNpointPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEContainsTNpointTNpointPhysicalFunction.hpp new file mode 100644 index 0000000000..480b1a0e0e --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEContainsTNpointTNpointPhysicalFunction.hpp @@ -0,0 +1,46 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `econtains_tgeo_tgeo`. + * + * Per-event ever-contains between two single-instant tgeompoints, each resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEContainsTNpointTNpointPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEContainsTNpointTNpointPhysicalFunction(PhysicalFunction ridAFunction, + PhysicalFunction fractionAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction ridBFunction, + PhysicalFunction fractionBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEContainsTPoseGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEContainsTPoseGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..1431be56ba --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEContainsTPoseGeometryPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `econtains_tgeo_geo`. + * + * Per-event ever-contains between a single-instant tpose (converted to tgeompoint at runtime) and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEContainsTPoseGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEContainsTPoseGeometryPhysicalFunction(PhysicalFunction xFunction, + PhysicalFunction yFunction, + PhysicalFunction thetaFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEContainsTPoseTPosePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEContainsTPoseTPosePhysicalFunction.hpp new file mode 100644 index 0000000000..00e3074da4 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEContainsTPoseTPosePhysicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `econtains_tgeo_tgeo`. + * + * Per-event ever-contains between two single-instant tgeompoints, each lifted from a tpose (x,y,theta,ts) via tpose_to_tpoint composition. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEContainsTPoseTPosePhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEContainsTPoseTPosePhysicalFunction(PhysicalFunction xAFunction, + PhysicalFunction yAFunction, + PhysicalFunction thetaAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction xBFunction, + PhysicalFunction yBFunction, + PhysicalFunction thetaBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalECoversGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalECoversGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..dce5e1f59b --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalECoversGeometryPhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ecovers_tgeo_geo`. + * + * Per-event ever-covers between a single-instant tgeompoint and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalECoversGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalECoversGeometryPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalECoversTCbufferCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalECoversTCbufferCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..5a6a0c8658 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalECoversTCbufferCbufferPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ecovers_tcbuffer_cbuffer`. + * + * Per-event e-covers between a single-instant tcbuffer and a static Cbuffer literal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalECoversTCbufferCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalECoversTCbufferCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction cbufferLitFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalECoversTCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalECoversTCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..2ee94f57bc --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalECoversTCbufferPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ecovers_tcbuffer_geo`. + * + * Per-event ever-covers between a single-instant tcbuffer and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalECoversTCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalECoversTCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalECoversTCbufferTCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalECoversTCbufferTCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..ed25636c8b --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalECoversTCbufferTCbufferPhysicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ecovers_tcbuffer_tcbuffer`. + * + * Per-event ever-covers between two single-instant tcbuffers. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalECoversTCbufferTCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalECoversTCbufferTCbufferPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction radiusAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction radiusBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalECoversTGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalECoversTGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..fdc57d10cc --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalECoversTGeometryPhysicalFunction.hpp @@ -0,0 +1,46 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ecovers_tgeo_tgeo`. + * + * Per-event ever-covers between two single-instant tgeompoints. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalECoversTGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalECoversTGeometryPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalECoversTNpointGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalECoversTNpointGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..897a788789 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalECoversTNpointGeometryPhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ecovers_tgeo_geo`. + * + * Per-event ever-covers between a single-instant tgeompoint resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint and a static geometry (network SRID). + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalECoversTNpointGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalECoversTNpointGeometryPhysicalFunction(PhysicalFunction ridFunction, + PhysicalFunction fractionFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalECoversTNpointTNpointPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalECoversTNpointTNpointPhysicalFunction.hpp new file mode 100644 index 0000000000..f19ad72527 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalECoversTNpointTNpointPhysicalFunction.hpp @@ -0,0 +1,46 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ecovers_tgeo_tgeo`. + * + * Per-event ever-covers between two single-instant tgeompoints, each resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalECoversTNpointTNpointPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalECoversTNpointTNpointPhysicalFunction(PhysicalFunction ridAFunction, + PhysicalFunction fractionAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction ridBFunction, + PhysicalFunction fractionBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalECoversTPoseGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalECoversTPoseGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..926fbe9dd1 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalECoversTPoseGeometryPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ecovers_tgeo_geo`. + * + * Per-event ever-covers between a single-instant tpose (converted to tgeompoint at runtime) and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalECoversTPoseGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalECoversTPoseGeometryPhysicalFunction(PhysicalFunction xFunction, + PhysicalFunction yFunction, + PhysicalFunction thetaFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalECoversTPoseTPosePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalECoversTPoseTPosePhysicalFunction.hpp new file mode 100644 index 0000000000..4222076a64 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalECoversTPoseTPosePhysicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ecovers_tgeo_tgeo`. + * + * Per-event ever-covers between two single-instant tgeompoints, each lifted from a tpose (x,y,theta,ts) via tpose_to_tpoint composition. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalECoversTPoseTPosePhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalECoversTPoseTPosePhysicalFunction(PhysicalFunction xAFunction, + PhysicalFunction yAFunction, + PhysicalFunction thetaAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction xBFunction, + PhysicalFunction yBFunction, + PhysicalFunction thetaBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEDWithinTCbufferCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEDWithinTCbufferCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..9273649046 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEDWithinTCbufferCbufferPhysicalFunction.hpp @@ -0,0 +1,46 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `edwithin_tcbuffer_cbuffer`. + * + * Per-event ever-distance-within between a single-instant tcbuffer and a static Cbuffer under a fixed threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEDWithinTCbufferCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEDWithinTCbufferCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction cbufferLitFunction, + PhysicalFunction distFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEDWithinTCbufferGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEDWithinTCbufferGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..d2af00602c --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEDWithinTCbufferGeometryPhysicalFunction.hpp @@ -0,0 +1,46 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `edwithin_tcbuffer_geo`. + * + * Per-event ever-distance-within between a single-instant tcbuffer and a static geometry under a fixed threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEDWithinTCbufferGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEDWithinTCbufferGeometryPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction, + PhysicalFunction distFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEDWithinTCbufferTCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEDWithinTCbufferTCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..902e387933 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEDWithinTCbufferTCbufferPhysicalFunction.hpp @@ -0,0 +1,49 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `edwithin_tcbuffer_tcbuffer`. + * + * Per-event ever-distance-within between two single-instant tcbuffers under a fixed threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEDWithinTCbufferTCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEDWithinTCbufferTCbufferPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction radiusAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction radiusBFunction, + PhysicalFunction tsBFunction, + PhysicalFunction distFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEDWithinTGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEDWithinTGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..e3e5734f12 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEDWithinTGeometryPhysicalFunction.hpp @@ -0,0 +1,47 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `edwithin_tgeo_tgeo`. + * + * Per-event ever-distance-within between two single-instant tgeompoints under a static threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEDWithinTGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEDWithinTGeometryPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction tsBFunction, + PhysicalFunction distFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEDisjointGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEDisjointGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..3ee871d499 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEDisjointGeometryPhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `edisjoint_tgeo_geo`. + * + * Per-event ever-disjoint between a single-instant tgeompoint built from event fields and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEDisjointGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEDisjointGeometryPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEDisjointTCbufferCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEDisjointTCbufferCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..7d38a0e470 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEDisjointTCbufferCbufferPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `edisjoint_tcbuffer_cbuffer`. + * + * Per-event e-disjoint between a single-instant tcbuffer and a static Cbuffer literal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEDisjointTCbufferCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEDisjointTCbufferCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction cbufferLitFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEDisjointTCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEDisjointTCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..51c75ef7ca --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEDisjointTCbufferPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `edisjoint_tcbuffer_geo`. + * + * Per-event ever-disjoint between a single-instant tcbuffer and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEDisjointTCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEDisjointTCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEDisjointTGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEDisjointTGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..73436d89d6 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEDisjointTGeometryPhysicalFunction.hpp @@ -0,0 +1,46 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `edisjoint_tgeo_tgeo`. + * + * Per-event ever-disjoint between two single-instant tgeompoints. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEDisjointTGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEDisjointTGeometryPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEDisjointTNpointGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEDisjointTNpointGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..8dc7ebce85 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEDisjointTNpointGeometryPhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `edisjoint_tgeo_geo`. + * + * Per-event ever-disjoint between a single-instant tgeompoint resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint and a static geometry (network SRID). + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEDisjointTNpointGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEDisjointTNpointGeometryPhysicalFunction(PhysicalFunction ridFunction, + PhysicalFunction fractionFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEDisjointTNpointTNpointPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEDisjointTNpointTNpointPhysicalFunction.hpp new file mode 100644 index 0000000000..1c1708f7ab --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEDisjointTNpointTNpointPhysicalFunction.hpp @@ -0,0 +1,46 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `edisjoint_tgeo_tgeo`. + * + * Per-event ever-disjoint between two single-instant tgeompoints, each resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEDisjointTNpointTNpointPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEDisjointTNpointTNpointPhysicalFunction(PhysicalFunction ridAFunction, + PhysicalFunction fractionAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction ridBFunction, + PhysicalFunction fractionBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEDisjointTPoseGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEDisjointTPoseGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..90c855d1eb --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEDisjointTPoseGeometryPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `edisjoint_tgeo_geo`. + * + * Per-event ever-disjoint between a single-instant tpose (converted to tgeompoint at runtime) and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEDisjointTPoseGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEDisjointTPoseGeometryPhysicalFunction(PhysicalFunction xFunction, + PhysicalFunction yFunction, + PhysicalFunction thetaFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEDisjointTPoseTPosePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEDisjointTPoseTPosePhysicalFunction.hpp new file mode 100644 index 0000000000..065d0e6461 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEDisjointTPoseTPosePhysicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `edisjoint_tgeo_tgeo`. + * + * Per-event ever-disjoint between two single-instant tgeompoints, each lifted from a tpose (x,y,theta,ts) via tpose_to_tpoint composition. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEDisjointTPoseTPosePhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEDisjointTPoseTPosePhysicalFunction(PhysicalFunction xAFunction, + PhysicalFunction yAFunction, + PhysicalFunction thetaAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction xBFunction, + PhysicalFunction yBFunction, + PhysicalFunction thetaBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEIntersectsGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEIntersectsGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..ba00f089f3 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEIntersectsGeometryPhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `eintersects_tgeo_geo`. + * + * Per-event ever-intersects between a single-instant tgeompoint and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEIntersectsGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEIntersectsGeometryPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEIntersectsTCbufferCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEIntersectsTCbufferCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..ee41643b3e --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEIntersectsTCbufferCbufferPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `eintersects_tcbuffer_cbuffer`. + * + * Per-event e-intersects between a single-instant tcbuffer and a static Cbuffer literal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEIntersectsTCbufferCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEIntersectsTCbufferCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction cbufferLitFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEIntersectsTCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEIntersectsTCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..06b2a4399b --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEIntersectsTCbufferPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `eintersects_tcbuffer_geo`. + * + * Per-event ever-intersects between a single-instant tcbuffer and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEIntersectsTCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEIntersectsTCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEIntersectsTCbufferTCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEIntersectsTCbufferTCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..e6cdb02f7f --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEIntersectsTCbufferTCbufferPhysicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `eintersects_tcbuffer_tcbuffer`. + * + * Per-event ever-intersects between two single-instant tcbuffers. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEIntersectsTCbufferTCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEIntersectsTCbufferTCbufferPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction radiusAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction radiusBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEIntersectsTGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEIntersectsTGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..15709e4761 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEIntersectsTGeometryPhysicalFunction.hpp @@ -0,0 +1,46 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `eintersects_tgeo_tgeo`. + * + * Per-event ever-intersects between two single-instant tgeompoints. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEIntersectsTGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEIntersectsTGeometryPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEIntersectsTNpointGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEIntersectsTNpointGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..b0c9be231e --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEIntersectsTNpointGeometryPhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `eintersects_tgeo_geo`. + * + * Per-event ever-intersects between a single-instant tgeompoint resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint and a static geometry (network SRID). + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEIntersectsTNpointGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEIntersectsTNpointGeometryPhysicalFunction(PhysicalFunction ridFunction, + PhysicalFunction fractionFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEIntersectsTNpointTNpointPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEIntersectsTNpointTNpointPhysicalFunction.hpp new file mode 100644 index 0000000000..a7a00b8140 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEIntersectsTNpointTNpointPhysicalFunction.hpp @@ -0,0 +1,46 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `eintersects_tgeo_tgeo`. + * + * Per-event ever-intersects between two single-instant tgeompoints, each resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEIntersectsTNpointTNpointPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEIntersectsTNpointTNpointPhysicalFunction(PhysicalFunction ridAFunction, + PhysicalFunction fractionAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction ridBFunction, + PhysicalFunction fractionBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEIntersectsTPoseGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEIntersectsTPoseGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..c815791cd4 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEIntersectsTPoseGeometryPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `eintersects_tgeo_geo`. + * + * Per-event ever-intersects between a single-instant tpose (converted to tgeompoint at runtime) and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEIntersectsTPoseGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEIntersectsTPoseGeometryPhysicalFunction(PhysicalFunction xFunction, + PhysicalFunction yFunction, + PhysicalFunction thetaFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalEIntersectsTPoseTPosePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalEIntersectsTPoseTPosePhysicalFunction.hpp new file mode 100644 index 0000000000..e42b0828b8 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalEIntersectsTPoseTPosePhysicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `eintersects_tgeo_tgeo`. + * + * Per-event ever-intersects between two single-instant tgeompoints, each lifted from a tpose (x,y,theta,ts) via tpose_to_tpoint composition. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalEIntersectsTPoseTPosePhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalEIntersectsTPoseTPosePhysicalFunction(PhysicalFunction xAFunction, + PhysicalFunction yAFunction, + PhysicalFunction thetaAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction xBFunction, + PhysicalFunction yBFunction, + PhysicalFunction thetaBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalETouchesGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalETouchesGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..65888d2a61 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalETouchesGeometryPhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `etouches_tgeo_geo`. + * + * Per-event ever-touches between a single-instant tgeompoint and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalETouchesGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalETouchesGeometryPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalETouchesTCbufferCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalETouchesTCbufferCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..2b6ef362b8 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalETouchesTCbufferCbufferPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `etouches_tcbuffer_cbuffer`. + * + * Per-event e-touches between a single-instant tcbuffer and a static Cbuffer literal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalETouchesTCbufferCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalETouchesTCbufferCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction cbufferLitFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalETouchesTCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalETouchesTCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..88649ac984 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalETouchesTCbufferPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `etouches_tcbuffer_geo`. + * + * Per-event ever-touches between a single-instant tcbuffer and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalETouchesTCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalETouchesTCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalETouchesTCbufferTCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalETouchesTCbufferTCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..2cb8da5d40 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalETouchesTCbufferTCbufferPhysicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `etouches_tcbuffer_tcbuffer`. + * + * Per-event ever-touches between two single-instant tcbuffers. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalETouchesTCbufferTCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalETouchesTCbufferTCbufferPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction radiusAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction radiusBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalETouchesTGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalETouchesTGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..40ca50ec4e --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalETouchesTGeometryPhysicalFunction.hpp @@ -0,0 +1,46 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `etouches_tgeo_tgeo`. + * + * Per-event ever-touches between two single-instant tgeompoints. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalETouchesTGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalETouchesTGeometryPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalETouchesTNpointGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalETouchesTNpointGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..5f7bd8e9c0 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalETouchesTNpointGeometryPhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `etouches_tgeo_geo`. + * + * Per-event ever-touches between a single-instant tgeompoint resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint and a static geometry (network SRID). + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalETouchesTNpointGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalETouchesTNpointGeometryPhysicalFunction(PhysicalFunction ridFunction, + PhysicalFunction fractionFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalETouchesTNpointTNpointPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalETouchesTNpointTNpointPhysicalFunction.hpp new file mode 100644 index 0000000000..9bd2369f50 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalETouchesTNpointTNpointPhysicalFunction.hpp @@ -0,0 +1,46 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `etouches_tgeo_tgeo`. + * + * Per-event ever-touches between two single-instant tgeompoints, each resolved from a tnpoint (rid,fraction,ts) via tnpoint_to_tgeompoint. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalETouchesTNpointTNpointPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalETouchesTNpointTNpointPhysicalFunction(PhysicalFunction ridAFunction, + PhysicalFunction fractionAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction ridBFunction, + PhysicalFunction fractionBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalETouchesTPoseGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalETouchesTPoseGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..1568db775a --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalETouchesTPoseGeometryPhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `etouches_tgeo_geo`. + * + * Per-event ever-touches between a single-instant tpose (converted to tgeompoint at runtime) and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalETouchesTPoseGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalETouchesTPoseGeometryPhysicalFunction(PhysicalFunction xFunction, + PhysicalFunction yFunction, + PhysicalFunction thetaFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalETouchesTPoseTPosePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalETouchesTPoseTPosePhysicalFunction.hpp new file mode 100644 index 0000000000..69f44bec62 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalETouchesTPoseTPosePhysicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `etouches_tgeo_tgeo`. + * + * Per-event ever-touches between two single-instant tgeompoints, each lifted from a tpose (x,y,theta,ts) via tpose_to_tpoint composition. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalETouchesTPoseTPosePhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalETouchesTPoseTPosePhysicalFunction(PhysicalFunction xAFunction, + PhysicalFunction yAFunction, + PhysicalFunction thetaAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction xBFunction, + PhysicalFunction yBFunction, + PhysicalFunction thetaBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalMinusGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalMinusGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..804a902946 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalMinusGeometryPhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tgeo_minus_geom`. + * + * Per-event spatial subtraction: 1 if the single-instant tgeompoint survives subtraction of the static geometry, 0 if removed. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalMinusGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalMinusGeometryPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalNADFloatScalarPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalNADFloatScalarPhysicalFunction.hpp new file mode 100644 index 0000000000..b2dab0f15d --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalNADFloatScalarPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `nad_tfloat_float`. + * + * Per-event nearest-approach distance between a single-instant tfloat and a scalar double. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalNADFloatScalarPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalNADFloatScalarPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction timestampFunction, + PhysicalFunction scalarFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalNADGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalNADGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..9df4f8a948 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalNADGeometryPhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `nad_tgeo_geo`. + * + * Per-event nearest-approach distance between a single-instant tgeompoint and a static geometry. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalNADGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalNADGeometryPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalNADIntScalarPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalNADIntScalarPhysicalFunction.hpp new file mode 100644 index 0000000000..cbf6fb5494 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalNADIntScalarPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `nad_tint_int`. + * + * Per-event nearest-approach distance between a single-instant tint and a scalar int. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalNADIntScalarPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalNADIntScalarPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction timestampFunction, + PhysicalFunction scalarFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalNADTFloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalNADTFloatPhysicalFunction.hpp new file mode 100644 index 0000000000..bfb14c6178 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalNADTFloatPhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `nad_tfloat_tfloat`. + * + * Per-event nearest-approach distance between two single-instant tfloats. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalNADTFloatPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalNADTFloatPhysicalFunction(PhysicalFunction valueAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction valueBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalNADTGeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalNADTGeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..7d743b4bda --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalNADTGeometryPhysicalFunction.hpp @@ -0,0 +1,46 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `nad_tgeo_tgeo`. + * + * Per-event nearest-approach distance between two single-instant tgeompoints. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalNADTGeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalNADTGeometryPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalNADTIntPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalNADTIntPhysicalFunction.hpp new file mode 100644 index 0000000000..9c711bc4c6 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalNADTIntPhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `nad_tint_tint`. + * + * Per-event nearest-approach distance between two single-instant tints. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalNADTIntPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalNADTIntPhysicalFunction(PhysicalFunction valueAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction valueBFunction, + PhysicalFunction tsBFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Aggregation/Function/Meos/CMakeLists.txt b/nes-physical-operators/src/Aggregation/Function/Meos/CMakeLists.txt index c34e12f47e..c0c635da86 100644 --- a/nes-physical-operators/src/Aggregation/Function/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Aggregation/Function/Meos/CMakeLists.txt @@ -11,4 +11,27 @@ # limitations under the License. add_plugin(TemporalSequence AggregationPhysicalFunction nes-physical-operators TemporalSequenceAggregationPhysicalFunction.cpp) +add_plugin(TemporalLength AggregationPhysicalFunction nes-physical-operators TemporalLengthAggregationPhysicalFunction.cpp) +add_plugin(PairMeeting AggregationPhysicalFunction nes-physical-operators PairMeetingAggregationPhysicalFunction.cpp) +add_plugin(CrossDistance AggregationPhysicalFunction nes-physical-operators CrossDistanceAggregationPhysicalFunction.cpp) add_plugin(Var AggregationPhysicalFunction nes-physical-operators VarAggregationFunction.cpp) +add_plugin(TemporalNumInstants AggregationPhysicalFunction nes-physical-operators TemporalNumInstantsAggregationPhysicalFunction.cpp) +add_plugin(TemporalNumSequences AggregationPhysicalFunction nes-physical-operators TemporalNumSequencesAggregationPhysicalFunction.cpp) +add_plugin(TemporalNumTimestamps AggregationPhysicalFunction nes-physical-operators TemporalNumTimestampsAggregationPhysicalFunction.cpp) +add_plugin(TemporalTFloatStartValue AggregationPhysicalFunction nes-physical-operators TemporalTFloatStartValueAggregationPhysicalFunction.cpp) +add_plugin(TemporalTFloatEndValue AggregationPhysicalFunction nes-physical-operators TemporalTFloatEndValueAggregationPhysicalFunction.cpp) +add_plugin(TemporalTFloatMinValue AggregationPhysicalFunction nes-physical-operators TemporalTFloatMinValueAggregationPhysicalFunction.cpp) +add_plugin(TemporalTFloatMaxValue AggregationPhysicalFunction nes-physical-operators TemporalTFloatMaxValueAggregationPhysicalFunction.cpp) +add_plugin(TemporalTNumberIntegral AggregationPhysicalFunction nes-physical-operators TemporalTNumberIntegralAggregationPhysicalFunction.cpp) +add_plugin(TemporalTIntStartValue AggregationPhysicalFunction nes-physical-operators TemporalTIntStartValueAggregationPhysicalFunction.cpp) +add_plugin(TemporalTIntEndValue AggregationPhysicalFunction nes-physical-operators TemporalTIntEndValueAggregationPhysicalFunction.cpp) +add_plugin(TemporalTIntMinValue AggregationPhysicalFunction nes-physical-operators TemporalTIntMinValueAggregationPhysicalFunction.cpp) +add_plugin(TemporalTIntMaxValue AggregationPhysicalFunction nes-physical-operators TemporalTIntMaxValueAggregationPhysicalFunction.cpp) +add_plugin(TemporalTFloatAvgValue AggregationPhysicalFunction nes-physical-operators TemporalTFloatAvgValueAggregationPhysicalFunction.cpp) +add_plugin(TemporalTNumberTwAvg AggregationPhysicalFunction nes-physical-operators TemporalTNumberTwAvgAggregationPhysicalFunction.cpp) +add_plugin(TemporalTIntAvgValue AggregationPhysicalFunction nes-physical-operators TemporalTIntAvgValueAggregationPhysicalFunction.cpp) +add_plugin(TemporalStartTimestamp AggregationPhysicalFunction nes-physical-operators TemporalStartTimestampAggregationPhysicalFunction.cpp) +add_plugin(TemporalEndTimestamp AggregationPhysicalFunction nes-physical-operators TemporalEndTimestampAggregationPhysicalFunction.cpp) +add_plugin(TemporalLowerInc AggregationPhysicalFunction nes-physical-operators TemporalLowerIncAggregationPhysicalFunction.cpp) +add_plugin(TemporalUpperInc AggregationPhysicalFunction nes-physical-operators TemporalUpperIncAggregationPhysicalFunction.cpp) +add_plugin(TemporalTPointIsSimple AggregationPhysicalFunction nes-physical-operators TemporalTPointIsSimpleAggregationPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Aggregation/Function/Meos/CrossDistanceAggregationPhysicalFunction.cpp b/nes-physical-operators/src/Aggregation/Function/Meos/CrossDistanceAggregationPhysicalFunction.cpp new file mode 100644 index 0000000000..5ea4a126a9 --- /dev/null +++ b/nes-physical-operators/src/Aggregation/Function/Meos/CrossDistanceAggregationPhysicalFunction.cpp @@ -0,0 +1,286 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +extern "C" { +#include +#include +} + +namespace NES +{ + +constexpr static std::string_view LonFieldName = "lon"; +constexpr static std::string_view LatFieldName = "lat"; +constexpr static std::string_view TimestampFieldName = "timestamp"; +constexpr static std::string_view VehicleIdFieldName = "vehicle_id"; + +static std::mutex cross_distance_mutex; + +CrossDistanceAggregationPhysicalFunction::CrossDistanceAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction lonFunctionParam, + PhysicalFunction latFunctionParam, + PhysicalFunction timestampFunctionParam, + PhysicalFunction vehicleIdFunctionParam, + uint64_t vidA, + uint64_t vidB, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef) + : AggregationPhysicalFunction(std::move(inputType), std::move(resultType), lonFunctionParam, std::move(resultFieldIdentifier)) + , bufferRef(std::move(bufferRef)) + , lonFunction(std::move(lonFunctionParam)) + , latFunction(std::move(latFunctionParam)) + , timestampFunction(std::move(timestampFunctionParam)) + , vehicleIdFunction(std::move(vehicleIdFunctionParam)) + , vidA(vidA) + , vidB(vidB) +{ +} + +void CrossDistanceAggregationPhysicalFunction::lift( + const nautilus::val& aggregationState, PipelineMemoryProvider& pipelineMemoryProvider, const Nautilus::Record& record) +{ + const auto pagedVectorPtr = static_cast>(aggregationState); + + auto lonValue = lonFunction.execute(record, pipelineMemoryProvider.arena); + auto latValue = latFunction.execute(record, pipelineMemoryProvider.arena); + auto timestampValue = timestampFunction.execute(record, pipelineMemoryProvider.arena); + auto vehicleIdValue = vehicleIdFunction.execute(record, pipelineMemoryProvider.arena); + + Record aggregateStateRecord({ + {std::string(LonFieldName), lonValue}, + {std::string(LatFieldName), latValue}, + {std::string(TimestampFieldName), timestampValue}, + {std::string(VehicleIdFieldName), vehicleIdValue} + }); + + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + pagedVectorRef.writeRecord(aggregateStateRecord, pipelineMemoryProvider.bufferProvider); +} + +void CrossDistanceAggregationPhysicalFunction::combine( + const nautilus::val aggregationState1, + const nautilus::val aggregationState2, + PipelineMemoryProvider&) +{ + const auto memArea1 = static_cast>(aggregationState1); + const auto memArea2 = static_cast>(aggregationState2); + + nautilus::invoke( + +[](Nautilus::Interface::PagedVector* vector1, const Nautilus::Interface::PagedVector* vector2) -> void + { vector1->copyFrom(*vector2); }, + memArea1, + memArea2); +} + +Nautilus::Record CrossDistanceAggregationPhysicalFunction::lower( + const nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) +{ + MEOS::Meos::ensureMeosInitialized(); + + const auto pagedVectorPtr = static_cast>(aggregationState); + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + const auto allFieldNames = bufferRef->getMemoryLayout()->getSchema().getFieldNames(); + const auto numberOfEntries = invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) + { + return pagedVector->getTotalNumberOfEntries(); + }, + pagedVectorPtr); + + if (numberOfEntries == nautilus::val(0)) { + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, nautilus::val(std::numeric_limits::quiet_NaN())); + return resultRecord; + } + + // Allocate a 6-double scratch buffer on the heap (we cannot put std::optional<…> structures + // through the nautilus invoke ABI). Layout: [lonA, latA, tsA, lonB, latB, tsB]. + // Sentinel ts = -1 means "not yet observed". + auto scratchPtr = nautilus::invoke( + +[]() -> double* + { + double* scratch = (double*)malloc(sizeof(double) * 6); + // Bit-cast tsA, tsB sentinels by writing -1 as the int64 reinterpret of the double. + // We just set them to NaN markers and treat NaN as "not observed". + scratch[0] = std::numeric_limits::quiet_NaN(); + scratch[1] = std::numeric_limits::quiet_NaN(); + scratch[2] = std::numeric_limits::quiet_NaN(); + scratch[3] = std::numeric_limits::quiet_NaN(); + scratch[4] = std::numeric_limits::quiet_NaN(); + scratch[5] = std::numeric_limits::quiet_NaN(); + return scratch; + }); + + const auto endIt = pagedVectorRef.end(allFieldNames); + for (auto candidateIt = pagedVectorRef.begin(allFieldNames); candidateIt != endIt; ++candidateIt) + { + const auto itemRecord = *candidateIt; + + const auto lonValue = itemRecord.read(std::string(LonFieldName)); + const auto latValue = itemRecord.read(std::string(LatFieldName)); + const auto timestampValue = itemRecord.read(std::string(TimestampFieldName)); + const auto vehicleIdValue = itemRecord.read(std::string(VehicleIdFieldName)); + + auto lon = lonValue.cast>(); + auto lat = latValue.cast>(); + auto timestamp = timestampValue.cast>(); + auto vehicleId = vehicleIdValue.cast>(); + + // Overwrite-on-match — final value is the latest event for each target VID in iter order. + // vidA / vidB are passed through to the captureless lambda alongside the state + // pointer (Nautilus invoke ABI forbids closures); same pattern as + // PairMeetingAggregationPhysicalFunction's dMeet threading in PR #19. + nautilus::invoke( + +[](double* scratch, double lonVal, double latVal, int64_t tsVal, uint64_t vid, + uint64_t vidAArg, uint64_t vidBArg) -> void + { + if (vid == vidAArg) { + scratch[0] = lonVal; + scratch[1] = latVal; + scratch[2] = static_cast(tsVal); + } else if (vid == vidBArg) { + scratch[3] = lonVal; + scratch[4] = latVal; + scratch[5] = static_cast(tsVal); + } + }, + scratchPtr, lon, lat, timestamp, vehicleId, + nautilus::val(vidA), nautilus::val(vidB)); + } + + auto distanceMetres = nautilus::invoke( + +[](double* scratch) -> double + { + // If either target vehicle has no observation in the window, return NaN. + if (std::isnan(scratch[2]) || std::isnan(scratch[5])) { + free(scratch); + return std::numeric_limits::quiet_NaN(); + } + + std::lock_guard lock(cross_distance_mutex); + + char wktA[80]; + char wktB[80]; + snprintf(wktA, sizeof(wktA), "SRID=4326;Point(%.7f %.7f)", scratch[0], scratch[1]); + snprintf(wktB, sizeof(wktB), "SRID=4326;Point(%.7f %.7f)", scratch[3], scratch[4]); + free(scratch); + + GSERIALIZED* gA = geom_in(wktA, -1); + GSERIALIZED* gB = geom_in(wktB, -1); + if (gA == nullptr || gB == nullptr) { + if (gA) free(gA); + if (gB) free(gB); + return std::numeric_limits::quiet_NaN(); + } + GSERIALIZED* ggA = geom_to_geog(gA); + GSERIALIZED* ggB = geom_to_geog(gB); + + // For the spheroidal distance, dwithin probes only give boolean output; we want a + // numeric value. The PROJ/MEOS shared object exposes `geog_distance` for this; here + // we instead drive the MEOS NAD over single-instant tgeompoints which goes through + // the same geog_distance path internally. + char tgeoA[120]; + char tgeoB[120]; + snprintf(tgeoA, sizeof(tgeoA), "Point(%.7f %.7f)@2000-01-01 00:00:00", scratch[0], scratch[1]); + snprintf(tgeoB, sizeof(tgeoB), "Point(%.7f %.7f)@2000-01-01 00:00:00", scratch[3], scratch[4]); + Temporal* tA = (Temporal*)MEOS::Meos::parseTemporalPoint(std::string(tgeoA)); + Temporal* tB = (Temporal*)MEOS::Meos::parseTemporalPoint(std::string(tgeoB)); + double distance = std::numeric_limits::quiet_NaN(); + if (tA != nullptr && tB != nullptr) { + distance = nad_tgeo_tgeo(tA, tB); + } + if (tA != nullptr) MEOS::Meos::freeTemporalObject(tA); + if (tB != nullptr) MEOS::Meos::freeTemporalObject(tB); + free(ggA); + free(ggB); + free(gA); + free(gB); + return distance; + }, + scratchPtr); + + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, distanceMetres); + return resultRecord; +} + +void CrossDistanceAggregationPhysicalFunction::reset(const nautilus::val aggregationState, PipelineMemoryProvider&) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + new (pagedVector) Nautilus::Interface::PagedVector(); + }, + aggregationState); +} + +size_t CrossDistanceAggregationPhysicalFunction::getSizeOfStateInBytes() const +{ + return sizeof(Nautilus::Interface::PagedVector); +} + +void CrossDistanceAggregationPhysicalFunction::cleanup(nautilus::val aggregationState) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast( + pagedVectorMemArea); + pagedVector->~PagedVector(); + }, + aggregationState); +} + + +AggregationPhysicalFunctionRegistryReturnType AggregationPhysicalFunctionGeneratedRegistrar::RegisterCrossDistanceAggregationPhysicalFunction( + AggregationPhysicalFunctionRegistryArguments) +{ + throw std::runtime_error("CROSS_DISTANCE aggregation cannot be created through the registry. " + "It requires four field functions (longitude, latitude, timestamp, vehicle_id)"); +} + +} diff --git a/nes-physical-operators/src/Aggregation/Function/Meos/PairMeetingAggregationPhysicalFunction.cpp b/nes-physical-operators/src/Aggregation/Function/Meos/PairMeetingAggregationPhysicalFunction.cpp new file mode 100644 index 0000000000..5f50dd33ed --- /dev/null +++ b/nes-physical-operators/src/Aggregation/Function/Meos/PairMeetingAggregationPhysicalFunction.cpp @@ -0,0 +1,312 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +extern "C" { +#include +#include +} + +namespace NES +{ + +constexpr static std::string_view LonFieldName = "lon"; +constexpr static std::string_view LatFieldName = "lat"; +constexpr static std::string_view TimestampFieldName = "timestamp"; +constexpr static std::string_view VehicleIdFieldName = "vehicle_id"; + +static std::mutex pair_meeting_mutex; + +PairMeetingAggregationPhysicalFunction::PairMeetingAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction lonFunctionParam, + PhysicalFunction latFunctionParam, + PhysicalFunction timestampFunctionParam, + PhysicalFunction vehicleIdFunctionParam, + double dMeetMetres, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef) + : AggregationPhysicalFunction(std::move(inputType), std::move(resultType), lonFunctionParam, std::move(resultFieldIdentifier)) + , bufferRef(std::move(bufferRef)) + , lonFunction(std::move(lonFunctionParam)) + , latFunction(std::move(latFunctionParam)) + , timestampFunction(std::move(timestampFunctionParam)) + , vehicleIdFunction(std::move(vehicleIdFunctionParam)) + , dMeetMetres(dMeetMetres) +{ +} + +void PairMeetingAggregationPhysicalFunction::lift( + const nautilus::val& aggregationState, PipelineMemoryProvider& pipelineMemoryProvider, const Nautilus::Record& record) +{ + const auto pagedVectorPtr = static_cast>(aggregationState); + + auto lonValue = lonFunction.execute(record, pipelineMemoryProvider.arena); + auto latValue = latFunction.execute(record, pipelineMemoryProvider.arena); + auto timestampValue = timestampFunction.execute(record, pipelineMemoryProvider.arena); + auto vehicleIdValue = vehicleIdFunction.execute(record, pipelineMemoryProvider.arena); + + Record aggregateStateRecord({ + {std::string(LonFieldName), lonValue}, + {std::string(LatFieldName), latValue}, + {std::string(TimestampFieldName), timestampValue}, + {std::string(VehicleIdFieldName), vehicleIdValue} + }); + + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + pagedVectorRef.writeRecord(aggregateStateRecord, pipelineMemoryProvider.bufferProvider); +} + +void PairMeetingAggregationPhysicalFunction::combine( + const nautilus::val aggregationState1, + const nautilus::val aggregationState2, + PipelineMemoryProvider&) +{ + const auto memArea1 = static_cast>(aggregationState1); + const auto memArea2 = static_cast>(aggregationState2); + + nautilus::invoke( + +[](Nautilus::Interface::PagedVector* vector1, const Nautilus::Interface::PagedVector* vector2) -> void + { vector1->copyFrom(*vector2); }, + memArea1, + memArea2); +} + +Nautilus::Record PairMeetingAggregationPhysicalFunction::lower( + const nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) +{ + MEOS::Meos::ensureMeosInitialized(); + + const auto pagedVectorPtr = static_cast>(aggregationState); + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + const auto allFieldNames = bufferRef->getMemoryLayout()->getSchema().getFieldNames(); + const auto numberOfEntries = invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) + { + return pagedVector->getTotalNumberOfEntries(); + }, + pagedVectorPtr); + + // Allocate an empty result buffer up-front; the lower step will fill it during the + // single pass over the PagedVector entries. + auto pairsBuffer = nautilus::invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) -> char* + { + // Worst case: every vehicle pair could meet. Pre-allocate ~80 bytes per emitted + // pair (BerlinMOD vehicle counts at the scaffold scale never exceed double digits + // per window, so this is a safe upper bound). + size_t bufferSize = pagedVector->getTotalNumberOfEntries() * 80 + 64; + char* buffer = (char*)malloc(bufferSize); + memset(buffer, 0, bufferSize); + return buffer; + }, + pagedVectorPtr); + + if (numberOfEntries == nautilus::val(0)) { + // Empty window — emit empty string + auto emptyLen = nautilus::val(0); + auto variableSized = pipelineMemoryProvider.arena.allocateVariableSizedData(emptyLen); + nautilus::invoke(+[](char* buffer) -> void { free(buffer); }, pairsBuffer); + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, variableSized); + return resultRecord; + } + + // Walk every entry; the lambda maintains a per-vehicle latest-position map. + // (Nautilus invoke ABI requires that all state be passed through pointer args; we + // model the map as a plain std::unordered_map> allocated + // via new and threaded as a void* through the invoke calls.) + auto vehicleMapPtr = nautilus::invoke( + +[]() -> void* + { + return new std::unordered_map>(); + }); + + const auto endIt = pagedVectorRef.end(allFieldNames); + for (auto candidateIt = pagedVectorRef.begin(allFieldNames); candidateIt != endIt; ++candidateIt) + { + const auto itemRecord = *candidateIt; + + const auto lonValue = itemRecord.read(std::string(LonFieldName)); + const auto latValue = itemRecord.read(std::string(LatFieldName)); + const auto timestampValue = itemRecord.read(std::string(TimestampFieldName)); + const auto vehicleIdValue = itemRecord.read(std::string(VehicleIdFieldName)); + + auto lon = lonValue.cast>(); + auto lat = latValue.cast>(); + auto timestamp = timestampValue.cast>(); + auto vehicleId = vehicleIdValue.cast>(); + + nautilus::invoke( + +[](void* mapPtr, double lonVal, double latVal, int64_t tsVal, uint64_t vid) -> void + { + auto* map = static_cast>*>(mapPtr); + // Overwrite-on-insert => map ends up holding the LATEST event per vehicle + // (since the PagedVector iteration preserves insertion order). + (*map)[vid] = std::make_tuple(lonVal, latVal, tsVal); + }, + vehicleMapPtr, lon, lat, timestamp, vehicleId); + } + + // Now enumerate pairs and check geog_dwithin(a, b, dMeet). + // dMeet is passed in via the captureless lambda's arg list (Nautilus invoke ABI + // forbids closures; we thread the threshold through alongside the state pointers). + nautilus::invoke( + +[](void* mapPtr, char* outBuffer, double dMeet) -> void + { + std::lock_guard lock(pair_meeting_mutex); + auto* map = static_cast>*>(mapPtr); + + // Stable iteration order + std::vector vids; + vids.reserve(map->size()); + for (const auto& kv : *map) + { + vids.push_back(kv.first); + } + std::sort(vids.begin(), vids.end()); + + bool first = true; + for (size_t i = 0; i + 1 < vids.size(); ++i) + { + for (size_t j = i + 1; j < vids.size(); ++j) + { + const auto& [lonA, latA, tsA] = (*map)[vids[i]]; + const auto& [lonB, latB, tsB] = (*map)[vids[j]]; + + char wktA[80]; + char wktB[80]; + snprintf(wktA, sizeof(wktA), "SRID=4326;Point(%.7f %.7f)", lonA, latA); + snprintf(wktB, sizeof(wktB), "SRID=4326;Point(%.7f %.7f)", lonB, latB); + GSERIALIZED* gA = geom_in(wktA, -1); + GSERIALIZED* gB = geom_in(wktB, -1); + if (gA == nullptr || gB == nullptr) { + if (gA) free(gA); + if (gB) free(gB); + continue; + } + GSERIALIZED* ggA = geom_to_geog(gA); + GSERIALIZED* ggB = geom_to_geog(gB); + bool meets = geog_dwithin(ggA, ggB, dMeet, true); + if (meets) { + // Use the later of the two timestamps as the meeting time + int64_t tsMax = (tsA > tsB) ? tsA : tsB; + // Approximate distance via geog distance (not exposed in meos_geo here yet); + // emit (vidA, vidB, ts, "≤dMeet") triple + char buf[128]; + snprintf(buf, sizeof(buf), "%s%lu,%lu,%lld,<=%.1f", + first ? "" : ";", + (unsigned long)vids[i], (unsigned long)vids[j], + (long long)tsMax, + dMeet); + strcat(outBuffer, buf); + first = false; + } + free(ggA); + free(ggB); + free(gA); + free(gB); + } + } + delete map; + }, + vehicleMapPtr, pairsBuffer, nautilus::val(dMeetMetres)); + + // Allocate VARSIZED output sized to the assembled string + auto strLen = nautilus::invoke( + +[](const char* buffer) -> size_t { return strlen(buffer); }, + pairsBuffer); + + auto variableSized = pipelineMemoryProvider.arena.allocateVariableSizedData(strLen); + nautilus::invoke( + +[](int8_t* dest, const char* src, size_t len) -> void + { + if (len > 0) memcpy(dest, src, len); + free((void*)src); + }, + variableSized.getContent(), pairsBuffer, strLen); + + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, variableSized); + return resultRecord; +} + +void PairMeetingAggregationPhysicalFunction::reset(const nautilus::val aggregationState, PipelineMemoryProvider&) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + new (pagedVector) Nautilus::Interface::PagedVector(); + }, + aggregationState); +} + +size_t PairMeetingAggregationPhysicalFunction::getSizeOfStateInBytes() const +{ + return sizeof(Nautilus::Interface::PagedVector); +} + +void PairMeetingAggregationPhysicalFunction::cleanup(nautilus::val aggregationState) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast( + pagedVectorMemArea); + pagedVector->~PagedVector(); + }, + aggregationState); +} + + +AggregationPhysicalFunctionRegistryReturnType AggregationPhysicalFunctionGeneratedRegistrar::RegisterPairMeetingAggregationPhysicalFunction( + AggregationPhysicalFunctionRegistryArguments) +{ + throw std::runtime_error("PAIR_MEETING aggregation cannot be created through the registry. " + "It requires four field functions (longitude, latitude, timestamp, vehicle_id)"); +} + +} diff --git a/nes-physical-operators/src/Aggregation/Function/Meos/TemporalEndTimestampAggregationPhysicalFunction.cpp b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalEndTimestampAggregationPhysicalFunction.cpp new file mode 100644 index 0000000000..8d4d7c589a --- /dev/null +++ b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalEndTimestampAggregationPhysicalFunction.cpp @@ -0,0 +1,260 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +extern "C" { +#include +#include +} + +namespace NES +{ + +constexpr static std::string_view LonFieldName = "lon"; +constexpr static std::string_view LatFieldName = "lat"; +constexpr static std::string_view TimestampFieldName = "timestamp"; + +static std::mutex meos_temporalendtimestamp_mutex; + + +TemporalEndTimestampAggregationPhysicalFunction::TemporalEndTimestampAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction lonFunctionParam, + PhysicalFunction latFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef) + : AggregationPhysicalFunction(std::move(inputType), std::move(resultType), lonFunctionParam, std::move(resultFieldIdentifier)) + , bufferRef(std::move(bufferRef)) + , lonFunction(std::move(lonFunctionParam)) + , latFunction(std::move(latFunctionParam)) + , timestampFunction(std::move(timestampFunctionParam)) +{ +} + +void TemporalEndTimestampAggregationPhysicalFunction::lift( + const nautilus::val& aggregationState, PipelineMemoryProvider& pipelineMemoryProvider, const Nautilus::Record& record) +{ + const auto pagedVectorPtr = static_cast>(aggregationState); + + auto lonValue = lonFunction.execute(record, pipelineMemoryProvider.arena); + auto latValue = latFunction.execute(record, pipelineMemoryProvider.arena); + auto timestampValue = timestampFunction.execute(record, pipelineMemoryProvider.arena); + + Record aggregateStateRecord({ + {std::string(LonFieldName), lonValue}, + {std::string(LatFieldName), latValue}, + {std::string(TimestampFieldName), timestampValue} + }); + + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + pagedVectorRef.writeRecord(aggregateStateRecord, pipelineMemoryProvider.bufferProvider); +} + +void TemporalEndTimestampAggregationPhysicalFunction::combine( + const nautilus::val aggregationState1, + const nautilus::val aggregationState2, + PipelineMemoryProvider&) +{ + const auto memArea1 = static_cast>(aggregationState1); + const auto memArea2 = static_cast>(aggregationState2); + + nautilus::invoke( + +[](Nautilus::Interface::PagedVector* vector1, const Nautilus::Interface::PagedVector* vector2) -> void + { vector1->copyFrom(*vector2); }, + memArea1, + memArea2); +} + +Nautilus::Record TemporalEndTimestampAggregationPhysicalFunction::lower( + const nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) +{ + MEOS::Meos::ensureMeosInitialized(); + + const auto pagedVectorPtr = static_cast>(aggregationState); + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + const auto allFieldNames = bufferRef->getMemoryLayout()->getSchema().getFieldNames(); + const auto numberOfEntries = invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) + { + return pagedVector->getTotalNumberOfEntries(); + }, + pagedVectorPtr); + + if (numberOfEntries == nautilus::val(0)) { + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, nautilus::val(0)); + return resultRecord; + } + + auto trajectoryStr = nautilus::invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) -> char* + { + size_t bufferSize = pagedVector->getTotalNumberOfEntries() * 150 + 50; + char* buffer = (char*)malloc(bufferSize); + memset(buffer, 0, bufferSize); + strcpy(buffer, "{"); + return buffer; + }, + pagedVectorPtr); + + auto pointCounter = nautilus::val(0); + + const auto endIt = pagedVectorRef.end(allFieldNames); + for (auto candidateIt = pagedVectorRef.begin(allFieldNames); candidateIt != endIt; ++candidateIt) + { + const auto itemRecord = *candidateIt; + + const auto lonValue = itemRecord.read(std::string(LonFieldName)); + const auto latValue = itemRecord.read(std::string(LatFieldName)); + const auto timestampValue = itemRecord.read(std::string(TimestampFieldName)); + + auto lon = lonValue.cast>(); + auto lat = latValue.cast>(); + auto timestamp = timestampValue.cast>(); + + trajectoryStr = nautilus::invoke( + +[](char* buffer, double lonVal, double latVal, int64_t tsVal, int64_t counter) -> char* + { + if (counter > 0) { + strcat(buffer, ", "); + } + + long long adjustedTime; + if (tsVal > 1000000000000LL) { + adjustedTime = tsVal / 1000; + } else { + adjustedTime = tsVal; + } + + std::string timestampString = MEOS::Meos::convertSecondsToTimestamp(adjustedTime); + const char* timestampStr = timestampString.c_str(); + + char pointStr[120]; + sprintf(pointStr, "Point(%.6f %.6f)@%s", lonVal, latVal, timestampStr); + strcat(buffer, pointStr); + return buffer; + }, + trajectoryStr, + lon, + lat, + timestamp, + pointCounter); + + pointCounter = pointCounter + nautilus::val(1); + } + + trajectoryStr = nautilus::invoke( + +[](char* buffer) -> char* + { + strcat(buffer, "}"); + return buffer; + }, + trajectoryStr); + + auto resultValue = nautilus::invoke( + +[](const char* trajStr) -> int64_t + { + if (!trajStr || strlen(trajStr) == 0) { + free((void*)trajStr); + return (int64_t)0; + } + + std::lock_guard lock(meos_temporalendtimestamp_mutex); + + std::string trajString(trajStr); + void* temp = MEOS::Meos::parseTemporalPoint(trajString); + if (!temp) { + free((void*)trajStr); + return (int64_t)0; + } + + int64_t value = temporal_end_timestamptz(static_cast(temp)); + + MEOS::Meos::freeTemporalObject(temp); + free((void*)trajStr); + return value; + }, + trajectoryStr); + + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, resultValue); + return resultRecord; +} + +void TemporalEndTimestampAggregationPhysicalFunction::reset(const nautilus::val aggregationState, PipelineMemoryProvider&) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + new (pagedVector) Nautilus::Interface::PagedVector(); + }, + aggregationState); +} + +size_t TemporalEndTimestampAggregationPhysicalFunction::getSizeOfStateInBytes() const +{ + return sizeof(Nautilus::Interface::PagedVector); +} + +void TemporalEndTimestampAggregationPhysicalFunction::cleanup(nautilus::val aggregationState) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + pagedVector->~PagedVector(); + }, + aggregationState); +} + + +AggregationPhysicalFunctionRegistryReturnType AggregationPhysicalFunctionGeneratedRegistrar::RegisterTemporalEndTimestampAggregationPhysicalFunction( + AggregationPhysicalFunctionRegistryArguments) +{ + throw std::runtime_error("TemporalEndTimestamp aggregation cannot be created through the registry. " + "It requires three field functions (longitude, latitude, timestamp)"); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Aggregation/Function/Meos/TemporalLengthAggregationPhysicalFunction.cpp b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalLengthAggregationPhysicalFunction.cpp new file mode 100644 index 0000000000..68be90ee6b --- /dev/null +++ b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalLengthAggregationPhysicalFunction.cpp @@ -0,0 +1,271 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +// MEOS wrapper header + geo extension symbols for tpoint_length +#include +extern "C" { +#include +#include +} + +namespace NES +{ + +constexpr static std::string_view LonFieldName = "lon"; +constexpr static std::string_view LatFieldName = "lat"; +constexpr static std::string_view TimestampFieldName = "timestamp"; + +// Mutex for thread-safe MEOS operations +static std::mutex meos_length_mutex; + + +TemporalLengthAggregationPhysicalFunction::TemporalLengthAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction lonFunctionParam, + PhysicalFunction latFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef) + : AggregationPhysicalFunction(std::move(inputType), std::move(resultType), lonFunctionParam, std::move(resultFieldIdentifier)) + , bufferRef(std::move(bufferRef)) + , lonFunction(std::move(lonFunctionParam)) + , latFunction(std::move(latFunctionParam)) + , timestampFunction(std::move(timestampFunctionParam)) +{ +} + +void TemporalLengthAggregationPhysicalFunction::lift( + const nautilus::val& aggregationState, PipelineMemoryProvider& pipelineMemoryProvider, const Nautilus::Record& record) +{ + const auto pagedVectorPtr = static_cast>(aggregationState); + + auto lonValue = lonFunction.execute(record, pipelineMemoryProvider.arena); + auto latValue = latFunction.execute(record, pipelineMemoryProvider.arena); + auto timestampValue = timestampFunction.execute(record, pipelineMemoryProvider.arena); + + Record aggregateStateRecord({ + {std::string(LonFieldName), lonValue}, + {std::string(LatFieldName), latValue}, + {std::string(TimestampFieldName), timestampValue} + }); + + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + pagedVectorRef.writeRecord(aggregateStateRecord, pipelineMemoryProvider.bufferProvider); +} + +void TemporalLengthAggregationPhysicalFunction::combine( + const nautilus::val aggregationState1, + const nautilus::val aggregationState2, + PipelineMemoryProvider&) +{ + const auto memArea1 = static_cast>(aggregationState1); + const auto memArea2 = static_cast>(aggregationState2); + + nautilus::invoke( + +[](Nautilus::Interface::PagedVector* vector1, const Nautilus::Interface::PagedVector* vector2) -> void + { vector1->copyFrom(*vector2); }, + memArea1, + memArea2); +} + +Nautilus::Record TemporalLengthAggregationPhysicalFunction::lower( + const nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) +{ + MEOS::Meos::ensureMeosInitialized(); + + const auto pagedVectorPtr = static_cast>(aggregationState); + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + const auto allFieldNames = bufferRef->getMemoryLayout()->getSchema().getFieldNames(); + const auto numberOfEntries = invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) + { + return pagedVector->getTotalNumberOfEntries(); + }, + pagedVectorPtr); + + // Handle empty PagedVector case — zero-length trajectory + if (numberOfEntries == nautilus::val(0)) { + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, nautilus::val(0.0)); + return resultRecord; + } + + // Build the trajectory string in the same MEOS instant-set format that + // TemporalSequenceAggregationPhysicalFunction uses: {Point(lon lat)@ts, ...} + auto trajectoryStr = nautilus::invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) -> char* + { + size_t bufferSize = pagedVector->getTotalNumberOfEntries() * 150 + 50; + char* buffer = (char*)malloc(bufferSize); + memset(buffer, 0, bufferSize); + strcpy(buffer, "{"); + return buffer; + }, + pagedVectorPtr); + + auto pointCounter = nautilus::val(0); + + const auto endIt = pagedVectorRef.end(allFieldNames); + for (auto candidateIt = pagedVectorRef.begin(allFieldNames); candidateIt != endIt; ++candidateIt) + { + const auto itemRecord = *candidateIt; + + const auto lonValue = itemRecord.read(std::string(LonFieldName)); + const auto latValue = itemRecord.read(std::string(LatFieldName)); + const auto timestampValue = itemRecord.read(std::string(TimestampFieldName)); + + auto lon = lonValue.cast>(); + auto lat = latValue.cast>(); + auto timestamp = timestampValue.cast>(); + + trajectoryStr = nautilus::invoke( + +[](char* buffer, double lonVal, double latVal, int64_t tsVal, int64_t counter) -> char* + { + if (counter > 0) { + strcat(buffer, ", "); + } + + long long adjustedTime; + if (tsVal > 1000000000000LL) { + adjustedTime = tsVal / 1000; + } else { + adjustedTime = tsVal; + } + + std::string timestampString = MEOS::Meos::convertSecondsToTimestamp(adjustedTime); + const char* timestampStr = timestampString.c_str(); + + char pointStr[120]; + sprintf(pointStr, "Point(%.6f %.6f)@%s", lonVal, latVal, timestampStr); + strcat(buffer, pointStr); + return buffer; + }, + trajectoryStr, + lon, + lat, + timestamp, + pointCounter); + + pointCounter = pointCounter + nautilus::val(1); + } + + trajectoryStr = nautilus::invoke( + +[](char* buffer) -> char* + { + strcat(buffer, "}"); + return buffer; + }, + trajectoryStr); + + // Parse the assembled trajectory into a MEOS Temporal object, call + // tpoint_length on it, and free both the C string and the Temporal. + auto totalLength = nautilus::invoke( + +[](const char* trajStr) -> double + { + if (!trajStr || strlen(trajStr) == 0) { + free((void*)trajStr); + return 0.0; + } + + std::lock_guard lock(meos_length_mutex); + + std::string trajString(trajStr); + void* temp = MEOS::Meos::parseTemporalPoint(trajString); + if (!temp) { + free((void*)trajStr); + return 0.0; + } + + // tpoint_length is the MEOS C symbol from meos_geo.h. It returns the + // spheroidal length in the SRID's distance unit (metres for the + // BerlinMOD WGS84 trajectories that the scaffold streams). + double length = tpoint_length(static_cast(temp)); + + MEOS::Meos::freeTemporalObject(temp); + free((void*)trajStr); + return length; + }, + trajectoryStr); + + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, totalLength); + return resultRecord; +} + +void TemporalLengthAggregationPhysicalFunction::reset(const nautilus::val aggregationState, PipelineMemoryProvider&) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + new (pagedVector) Nautilus::Interface::PagedVector(); + }, + aggregationState); +} + +size_t TemporalLengthAggregationPhysicalFunction::getSizeOfStateInBytes() const +{ + return sizeof(Nautilus::Interface::PagedVector); +} + +void TemporalLengthAggregationPhysicalFunction::cleanup(nautilus::val aggregationState) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast( + pagedVectorMemArea); + pagedVector->~PagedVector(); + }, + aggregationState); +} + + +AggregationPhysicalFunctionRegistryReturnType AggregationPhysicalFunctionGeneratedRegistrar::RegisterTemporalLengthAggregationPhysicalFunction( + AggregationPhysicalFunctionRegistryArguments) +{ + throw std::runtime_error("TEMPORAL_LENGTH aggregation cannot be created through the registry. " + "It requires three field functions (longitude, latitude, timestamp)"); +} + +} diff --git a/nes-physical-operators/src/Aggregation/Function/Meos/TemporalLowerIncAggregationPhysicalFunction.cpp b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalLowerIncAggregationPhysicalFunction.cpp new file mode 100644 index 0000000000..1ccc9f2731 --- /dev/null +++ b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalLowerIncAggregationPhysicalFunction.cpp @@ -0,0 +1,260 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +extern "C" { +#include +#include +} + +namespace NES +{ + +constexpr static std::string_view LonFieldName = "lon"; +constexpr static std::string_view LatFieldName = "lat"; +constexpr static std::string_view TimestampFieldName = "timestamp"; + +static std::mutex meos_temporallowerinc_mutex; + + +TemporalLowerIncAggregationPhysicalFunction::TemporalLowerIncAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction lonFunctionParam, + PhysicalFunction latFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef) + : AggregationPhysicalFunction(std::move(inputType), std::move(resultType), lonFunctionParam, std::move(resultFieldIdentifier)) + , bufferRef(std::move(bufferRef)) + , lonFunction(std::move(lonFunctionParam)) + , latFunction(std::move(latFunctionParam)) + , timestampFunction(std::move(timestampFunctionParam)) +{ +} + +void TemporalLowerIncAggregationPhysicalFunction::lift( + const nautilus::val& aggregationState, PipelineMemoryProvider& pipelineMemoryProvider, const Nautilus::Record& record) +{ + const auto pagedVectorPtr = static_cast>(aggregationState); + + auto lonValue = lonFunction.execute(record, pipelineMemoryProvider.arena); + auto latValue = latFunction.execute(record, pipelineMemoryProvider.arena); + auto timestampValue = timestampFunction.execute(record, pipelineMemoryProvider.arena); + + Record aggregateStateRecord({ + {std::string(LonFieldName), lonValue}, + {std::string(LatFieldName), latValue}, + {std::string(TimestampFieldName), timestampValue} + }); + + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + pagedVectorRef.writeRecord(aggregateStateRecord, pipelineMemoryProvider.bufferProvider); +} + +void TemporalLowerIncAggregationPhysicalFunction::combine( + const nautilus::val aggregationState1, + const nautilus::val aggregationState2, + PipelineMemoryProvider&) +{ + const auto memArea1 = static_cast>(aggregationState1); + const auto memArea2 = static_cast>(aggregationState2); + + nautilus::invoke( + +[](Nautilus::Interface::PagedVector* vector1, const Nautilus::Interface::PagedVector* vector2) -> void + { vector1->copyFrom(*vector2); }, + memArea1, + memArea2); +} + +Nautilus::Record TemporalLowerIncAggregationPhysicalFunction::lower( + const nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) +{ + MEOS::Meos::ensureMeosInitialized(); + + const auto pagedVectorPtr = static_cast>(aggregationState); + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + const auto allFieldNames = bufferRef->getMemoryLayout()->getSchema().getFieldNames(); + const auto numberOfEntries = invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) + { + return pagedVector->getTotalNumberOfEntries(); + }, + pagedVectorPtr); + + if (numberOfEntries == nautilus::val(0)) { + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, nautilus::val(0)); + return resultRecord; + } + + auto trajectoryStr = nautilus::invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) -> char* + { + size_t bufferSize = pagedVector->getTotalNumberOfEntries() * 150 + 50; + char* buffer = (char*)malloc(bufferSize); + memset(buffer, 0, bufferSize); + strcpy(buffer, "{"); + return buffer; + }, + pagedVectorPtr); + + auto pointCounter = nautilus::val(0); + + const auto endIt = pagedVectorRef.end(allFieldNames); + for (auto candidateIt = pagedVectorRef.begin(allFieldNames); candidateIt != endIt; ++candidateIt) + { + const auto itemRecord = *candidateIt; + + const auto lonValue = itemRecord.read(std::string(LonFieldName)); + const auto latValue = itemRecord.read(std::string(LatFieldName)); + const auto timestampValue = itemRecord.read(std::string(TimestampFieldName)); + + auto lon = lonValue.cast>(); + auto lat = latValue.cast>(); + auto timestamp = timestampValue.cast>(); + + trajectoryStr = nautilus::invoke( + +[](char* buffer, double lonVal, double latVal, int64_t tsVal, int64_t counter) -> char* + { + if (counter > 0) { + strcat(buffer, ", "); + } + + long long adjustedTime; + if (tsVal > 1000000000000LL) { + adjustedTime = tsVal / 1000; + } else { + adjustedTime = tsVal; + } + + std::string timestampString = MEOS::Meos::convertSecondsToTimestamp(adjustedTime); + const char* timestampStr = timestampString.c_str(); + + char pointStr[120]; + sprintf(pointStr, "Point(%.6f %.6f)@%s", lonVal, latVal, timestampStr); + strcat(buffer, pointStr); + return buffer; + }, + trajectoryStr, + lon, + lat, + timestamp, + pointCounter); + + pointCounter = pointCounter + nautilus::val(1); + } + + trajectoryStr = nautilus::invoke( + +[](char* buffer) -> char* + { + strcat(buffer, "}"); + return buffer; + }, + trajectoryStr); + + auto resultValue = nautilus::invoke( + +[](const char* trajStr) -> bool + { + if (!trajStr || strlen(trajStr) == 0) { + free((void*)trajStr); + return (bool)0; + } + + std::lock_guard lock(meos_temporallowerinc_mutex); + + std::string trajString(trajStr); + void* temp = MEOS::Meos::parseTemporalPoint(trajString); + if (!temp) { + free((void*)trajStr); + return (bool)0; + } + + bool value = temporal_lower_inc(static_cast(temp)); + + MEOS::Meos::freeTemporalObject(temp); + free((void*)trajStr); + return value; + }, + trajectoryStr); + + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, resultValue); + return resultRecord; +} + +void TemporalLowerIncAggregationPhysicalFunction::reset(const nautilus::val aggregationState, PipelineMemoryProvider&) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + new (pagedVector) Nautilus::Interface::PagedVector(); + }, + aggregationState); +} + +size_t TemporalLowerIncAggregationPhysicalFunction::getSizeOfStateInBytes() const +{ + return sizeof(Nautilus::Interface::PagedVector); +} + +void TemporalLowerIncAggregationPhysicalFunction::cleanup(nautilus::val aggregationState) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + pagedVector->~PagedVector(); + }, + aggregationState); +} + + +AggregationPhysicalFunctionRegistryReturnType AggregationPhysicalFunctionGeneratedRegistrar::RegisterTemporalLowerIncAggregationPhysicalFunction( + AggregationPhysicalFunctionRegistryArguments) +{ + throw std::runtime_error("TemporalLowerInc aggregation cannot be created through the registry. " + "It requires three field functions (longitude, latitude, timestamp)"); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Aggregation/Function/Meos/TemporalNumInstantsAggregationPhysicalFunction.cpp b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalNumInstantsAggregationPhysicalFunction.cpp new file mode 100644 index 0000000000..e5d4afd8e7 --- /dev/null +++ b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalNumInstantsAggregationPhysicalFunction.cpp @@ -0,0 +1,260 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +extern "C" { +#include +#include +} + +namespace NES +{ + +constexpr static std::string_view LonFieldName = "lon"; +constexpr static std::string_view LatFieldName = "lat"; +constexpr static std::string_view TimestampFieldName = "timestamp"; + +static std::mutex meos_temporalnuminstants_mutex; + + +TemporalNumInstantsAggregationPhysicalFunction::TemporalNumInstantsAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction lonFunctionParam, + PhysicalFunction latFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef) + : AggregationPhysicalFunction(std::move(inputType), std::move(resultType), lonFunctionParam, std::move(resultFieldIdentifier)) + , bufferRef(std::move(bufferRef)) + , lonFunction(std::move(lonFunctionParam)) + , latFunction(std::move(latFunctionParam)) + , timestampFunction(std::move(timestampFunctionParam)) +{ +} + +void TemporalNumInstantsAggregationPhysicalFunction::lift( + const nautilus::val& aggregationState, PipelineMemoryProvider& pipelineMemoryProvider, const Nautilus::Record& record) +{ + const auto pagedVectorPtr = static_cast>(aggregationState); + + auto lonValue = lonFunction.execute(record, pipelineMemoryProvider.arena); + auto latValue = latFunction.execute(record, pipelineMemoryProvider.arena); + auto timestampValue = timestampFunction.execute(record, pipelineMemoryProvider.arena); + + Record aggregateStateRecord({ + {std::string(LonFieldName), lonValue}, + {std::string(LatFieldName), latValue}, + {std::string(TimestampFieldName), timestampValue} + }); + + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + pagedVectorRef.writeRecord(aggregateStateRecord, pipelineMemoryProvider.bufferProvider); +} + +void TemporalNumInstantsAggregationPhysicalFunction::combine( + const nautilus::val aggregationState1, + const nautilus::val aggregationState2, + PipelineMemoryProvider&) +{ + const auto memArea1 = static_cast>(aggregationState1); + const auto memArea2 = static_cast>(aggregationState2); + + nautilus::invoke( + +[](Nautilus::Interface::PagedVector* vector1, const Nautilus::Interface::PagedVector* vector2) -> void + { vector1->copyFrom(*vector2); }, + memArea1, + memArea2); +} + +Nautilus::Record TemporalNumInstantsAggregationPhysicalFunction::lower( + const nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) +{ + MEOS::Meos::ensureMeosInitialized(); + + const auto pagedVectorPtr = static_cast>(aggregationState); + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + const auto allFieldNames = bufferRef->getMemoryLayout()->getSchema().getFieldNames(); + const auto numberOfEntries = invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) + { + return pagedVector->getTotalNumberOfEntries(); + }, + pagedVectorPtr); + + if (numberOfEntries == nautilus::val(0)) { + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, nautilus::val(0)); + return resultRecord; + } + + auto trajectoryStr = nautilus::invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) -> char* + { + size_t bufferSize = pagedVector->getTotalNumberOfEntries() * 150 + 50; + char* buffer = (char*)malloc(bufferSize); + memset(buffer, 0, bufferSize); + strcpy(buffer, "{"); + return buffer; + }, + pagedVectorPtr); + + auto pointCounter = nautilus::val(0); + + const auto endIt = pagedVectorRef.end(allFieldNames); + for (auto candidateIt = pagedVectorRef.begin(allFieldNames); candidateIt != endIt; ++candidateIt) + { + const auto itemRecord = *candidateIt; + + const auto lonValue = itemRecord.read(std::string(LonFieldName)); + const auto latValue = itemRecord.read(std::string(LatFieldName)); + const auto timestampValue = itemRecord.read(std::string(TimestampFieldName)); + + auto lon = lonValue.cast>(); + auto lat = latValue.cast>(); + auto timestamp = timestampValue.cast>(); + + trajectoryStr = nautilus::invoke( + +[](char* buffer, double lonVal, double latVal, int64_t tsVal, int64_t counter) -> char* + { + if (counter > 0) { + strcat(buffer, ", "); + } + + long long adjustedTime; + if (tsVal > 1000000000000LL) { + adjustedTime = tsVal / 1000; + } else { + adjustedTime = tsVal; + } + + std::string timestampString = MEOS::Meos::convertSecondsToTimestamp(adjustedTime); + const char* timestampStr = timestampString.c_str(); + + char pointStr[120]; + sprintf(pointStr, "Point(%.6f %.6f)@%s", lonVal, latVal, timestampStr); + strcat(buffer, pointStr); + return buffer; + }, + trajectoryStr, + lon, + lat, + timestamp, + pointCounter); + + pointCounter = pointCounter + nautilus::val(1); + } + + trajectoryStr = nautilus::invoke( + +[](char* buffer) -> char* + { + strcat(buffer, "}"); + return buffer; + }, + trajectoryStr); + + auto resultValue = nautilus::invoke( + +[](const char* trajStr) -> int + { + if (!trajStr || strlen(trajStr) == 0) { + free((void*)trajStr); + return (int)0; + } + + std::lock_guard lock(meos_temporalnuminstants_mutex); + + std::string trajString(trajStr); + void* temp = MEOS::Meos::parseTemporalPoint(trajString); + if (!temp) { + free((void*)trajStr); + return (int)0; + } + + int value = temporal_num_instants(static_cast(temp)); + + MEOS::Meos::freeTemporalObject(temp); + free((void*)trajStr); + return value; + }, + trajectoryStr); + + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, resultValue); + return resultRecord; +} + +void TemporalNumInstantsAggregationPhysicalFunction::reset(const nautilus::val aggregationState, PipelineMemoryProvider&) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + new (pagedVector) Nautilus::Interface::PagedVector(); + }, + aggregationState); +} + +size_t TemporalNumInstantsAggregationPhysicalFunction::getSizeOfStateInBytes() const +{ + return sizeof(Nautilus::Interface::PagedVector); +} + +void TemporalNumInstantsAggregationPhysicalFunction::cleanup(nautilus::val aggregationState) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + pagedVector->~PagedVector(); + }, + aggregationState); +} + + +AggregationPhysicalFunctionRegistryReturnType AggregationPhysicalFunctionGeneratedRegistrar::RegisterTemporalNumInstantsAggregationPhysicalFunction( + AggregationPhysicalFunctionRegistryArguments) +{ + throw std::runtime_error("TemporalNumInstants aggregation cannot be created through the registry. " + "It requires three field functions (longitude, latitude, timestamp)"); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Aggregation/Function/Meos/TemporalNumSequencesAggregationPhysicalFunction.cpp b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalNumSequencesAggregationPhysicalFunction.cpp new file mode 100644 index 0000000000..895c9f5810 --- /dev/null +++ b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalNumSequencesAggregationPhysicalFunction.cpp @@ -0,0 +1,260 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +extern "C" { +#include +#include +} + +namespace NES +{ + +constexpr static std::string_view LonFieldName = "lon"; +constexpr static std::string_view LatFieldName = "lat"; +constexpr static std::string_view TimestampFieldName = "timestamp"; + +static std::mutex meos_temporalnumsequences_mutex; + + +TemporalNumSequencesAggregationPhysicalFunction::TemporalNumSequencesAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction lonFunctionParam, + PhysicalFunction latFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef) + : AggregationPhysicalFunction(std::move(inputType), std::move(resultType), lonFunctionParam, std::move(resultFieldIdentifier)) + , bufferRef(std::move(bufferRef)) + , lonFunction(std::move(lonFunctionParam)) + , latFunction(std::move(latFunctionParam)) + , timestampFunction(std::move(timestampFunctionParam)) +{ +} + +void TemporalNumSequencesAggregationPhysicalFunction::lift( + const nautilus::val& aggregationState, PipelineMemoryProvider& pipelineMemoryProvider, const Nautilus::Record& record) +{ + const auto pagedVectorPtr = static_cast>(aggregationState); + + auto lonValue = lonFunction.execute(record, pipelineMemoryProvider.arena); + auto latValue = latFunction.execute(record, pipelineMemoryProvider.arena); + auto timestampValue = timestampFunction.execute(record, pipelineMemoryProvider.arena); + + Record aggregateStateRecord({ + {std::string(LonFieldName), lonValue}, + {std::string(LatFieldName), latValue}, + {std::string(TimestampFieldName), timestampValue} + }); + + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + pagedVectorRef.writeRecord(aggregateStateRecord, pipelineMemoryProvider.bufferProvider); +} + +void TemporalNumSequencesAggregationPhysicalFunction::combine( + const nautilus::val aggregationState1, + const nautilus::val aggregationState2, + PipelineMemoryProvider&) +{ + const auto memArea1 = static_cast>(aggregationState1); + const auto memArea2 = static_cast>(aggregationState2); + + nautilus::invoke( + +[](Nautilus::Interface::PagedVector* vector1, const Nautilus::Interface::PagedVector* vector2) -> void + { vector1->copyFrom(*vector2); }, + memArea1, + memArea2); +} + +Nautilus::Record TemporalNumSequencesAggregationPhysicalFunction::lower( + const nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) +{ + MEOS::Meos::ensureMeosInitialized(); + + const auto pagedVectorPtr = static_cast>(aggregationState); + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + const auto allFieldNames = bufferRef->getMemoryLayout()->getSchema().getFieldNames(); + const auto numberOfEntries = invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) + { + return pagedVector->getTotalNumberOfEntries(); + }, + pagedVectorPtr); + + if (numberOfEntries == nautilus::val(0)) { + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, nautilus::val(0)); + return resultRecord; + } + + auto trajectoryStr = nautilus::invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) -> char* + { + size_t bufferSize = pagedVector->getTotalNumberOfEntries() * 150 + 50; + char* buffer = (char*)malloc(bufferSize); + memset(buffer, 0, bufferSize); + strcpy(buffer, "{"); + return buffer; + }, + pagedVectorPtr); + + auto pointCounter = nautilus::val(0); + + const auto endIt = pagedVectorRef.end(allFieldNames); + for (auto candidateIt = pagedVectorRef.begin(allFieldNames); candidateIt != endIt; ++candidateIt) + { + const auto itemRecord = *candidateIt; + + const auto lonValue = itemRecord.read(std::string(LonFieldName)); + const auto latValue = itemRecord.read(std::string(LatFieldName)); + const auto timestampValue = itemRecord.read(std::string(TimestampFieldName)); + + auto lon = lonValue.cast>(); + auto lat = latValue.cast>(); + auto timestamp = timestampValue.cast>(); + + trajectoryStr = nautilus::invoke( + +[](char* buffer, double lonVal, double latVal, int64_t tsVal, int64_t counter) -> char* + { + if (counter > 0) { + strcat(buffer, ", "); + } + + long long adjustedTime; + if (tsVal > 1000000000000LL) { + adjustedTime = tsVal / 1000; + } else { + adjustedTime = tsVal; + } + + std::string timestampString = MEOS::Meos::convertSecondsToTimestamp(adjustedTime); + const char* timestampStr = timestampString.c_str(); + + char pointStr[120]; + sprintf(pointStr, "Point(%.6f %.6f)@%s", lonVal, latVal, timestampStr); + strcat(buffer, pointStr); + return buffer; + }, + trajectoryStr, + lon, + lat, + timestamp, + pointCounter); + + pointCounter = pointCounter + nautilus::val(1); + } + + trajectoryStr = nautilus::invoke( + +[](char* buffer) -> char* + { + strcat(buffer, "}"); + return buffer; + }, + trajectoryStr); + + auto resultValue = nautilus::invoke( + +[](const char* trajStr) -> int + { + if (!trajStr || strlen(trajStr) == 0) { + free((void*)trajStr); + return (int)0; + } + + std::lock_guard lock(meos_temporalnumsequences_mutex); + + std::string trajString(trajStr); + void* temp = MEOS::Meos::parseTemporalPoint(trajString); + if (!temp) { + free((void*)trajStr); + return (int)0; + } + + int value = temporal_num_sequences(static_cast(temp)); + + MEOS::Meos::freeTemporalObject(temp); + free((void*)trajStr); + return value; + }, + trajectoryStr); + + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, resultValue); + return resultRecord; +} + +void TemporalNumSequencesAggregationPhysicalFunction::reset(const nautilus::val aggregationState, PipelineMemoryProvider&) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + new (pagedVector) Nautilus::Interface::PagedVector(); + }, + aggregationState); +} + +size_t TemporalNumSequencesAggregationPhysicalFunction::getSizeOfStateInBytes() const +{ + return sizeof(Nautilus::Interface::PagedVector); +} + +void TemporalNumSequencesAggregationPhysicalFunction::cleanup(nautilus::val aggregationState) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + pagedVector->~PagedVector(); + }, + aggregationState); +} + + +AggregationPhysicalFunctionRegistryReturnType AggregationPhysicalFunctionGeneratedRegistrar::RegisterTemporalNumSequencesAggregationPhysicalFunction( + AggregationPhysicalFunctionRegistryArguments) +{ + throw std::runtime_error("TemporalNumSequences aggregation cannot be created through the registry. " + "It requires three field functions (longitude, latitude, timestamp)"); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Aggregation/Function/Meos/TemporalNumTimestampsAggregationPhysicalFunction.cpp b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalNumTimestampsAggregationPhysicalFunction.cpp new file mode 100644 index 0000000000..2e30896f45 --- /dev/null +++ b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalNumTimestampsAggregationPhysicalFunction.cpp @@ -0,0 +1,260 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +extern "C" { +#include +#include +} + +namespace NES +{ + +constexpr static std::string_view LonFieldName = "lon"; +constexpr static std::string_view LatFieldName = "lat"; +constexpr static std::string_view TimestampFieldName = "timestamp"; + +static std::mutex meos_temporalnumtimestamps_mutex; + + +TemporalNumTimestampsAggregationPhysicalFunction::TemporalNumTimestampsAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction lonFunctionParam, + PhysicalFunction latFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef) + : AggregationPhysicalFunction(std::move(inputType), std::move(resultType), lonFunctionParam, std::move(resultFieldIdentifier)) + , bufferRef(std::move(bufferRef)) + , lonFunction(std::move(lonFunctionParam)) + , latFunction(std::move(latFunctionParam)) + , timestampFunction(std::move(timestampFunctionParam)) +{ +} + +void TemporalNumTimestampsAggregationPhysicalFunction::lift( + const nautilus::val& aggregationState, PipelineMemoryProvider& pipelineMemoryProvider, const Nautilus::Record& record) +{ + const auto pagedVectorPtr = static_cast>(aggregationState); + + auto lonValue = lonFunction.execute(record, pipelineMemoryProvider.arena); + auto latValue = latFunction.execute(record, pipelineMemoryProvider.arena); + auto timestampValue = timestampFunction.execute(record, pipelineMemoryProvider.arena); + + Record aggregateStateRecord({ + {std::string(LonFieldName), lonValue}, + {std::string(LatFieldName), latValue}, + {std::string(TimestampFieldName), timestampValue} + }); + + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + pagedVectorRef.writeRecord(aggregateStateRecord, pipelineMemoryProvider.bufferProvider); +} + +void TemporalNumTimestampsAggregationPhysicalFunction::combine( + const nautilus::val aggregationState1, + const nautilus::val aggregationState2, + PipelineMemoryProvider&) +{ + const auto memArea1 = static_cast>(aggregationState1); + const auto memArea2 = static_cast>(aggregationState2); + + nautilus::invoke( + +[](Nautilus::Interface::PagedVector* vector1, const Nautilus::Interface::PagedVector* vector2) -> void + { vector1->copyFrom(*vector2); }, + memArea1, + memArea2); +} + +Nautilus::Record TemporalNumTimestampsAggregationPhysicalFunction::lower( + const nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) +{ + MEOS::Meos::ensureMeosInitialized(); + + const auto pagedVectorPtr = static_cast>(aggregationState); + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + const auto allFieldNames = bufferRef->getMemoryLayout()->getSchema().getFieldNames(); + const auto numberOfEntries = invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) + { + return pagedVector->getTotalNumberOfEntries(); + }, + pagedVectorPtr); + + if (numberOfEntries == nautilus::val(0)) { + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, nautilus::val(0)); + return resultRecord; + } + + auto trajectoryStr = nautilus::invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) -> char* + { + size_t bufferSize = pagedVector->getTotalNumberOfEntries() * 150 + 50; + char* buffer = (char*)malloc(bufferSize); + memset(buffer, 0, bufferSize); + strcpy(buffer, "{"); + return buffer; + }, + pagedVectorPtr); + + auto pointCounter = nautilus::val(0); + + const auto endIt = pagedVectorRef.end(allFieldNames); + for (auto candidateIt = pagedVectorRef.begin(allFieldNames); candidateIt != endIt; ++candidateIt) + { + const auto itemRecord = *candidateIt; + + const auto lonValue = itemRecord.read(std::string(LonFieldName)); + const auto latValue = itemRecord.read(std::string(LatFieldName)); + const auto timestampValue = itemRecord.read(std::string(TimestampFieldName)); + + auto lon = lonValue.cast>(); + auto lat = latValue.cast>(); + auto timestamp = timestampValue.cast>(); + + trajectoryStr = nautilus::invoke( + +[](char* buffer, double lonVal, double latVal, int64_t tsVal, int64_t counter) -> char* + { + if (counter > 0) { + strcat(buffer, ", "); + } + + long long adjustedTime; + if (tsVal > 1000000000000LL) { + adjustedTime = tsVal / 1000; + } else { + adjustedTime = tsVal; + } + + std::string timestampString = MEOS::Meos::convertSecondsToTimestamp(adjustedTime); + const char* timestampStr = timestampString.c_str(); + + char pointStr[120]; + sprintf(pointStr, "Point(%.6f %.6f)@%s", lonVal, latVal, timestampStr); + strcat(buffer, pointStr); + return buffer; + }, + trajectoryStr, + lon, + lat, + timestamp, + pointCounter); + + pointCounter = pointCounter + nautilus::val(1); + } + + trajectoryStr = nautilus::invoke( + +[](char* buffer) -> char* + { + strcat(buffer, "}"); + return buffer; + }, + trajectoryStr); + + auto resultValue = nautilus::invoke( + +[](const char* trajStr) -> int + { + if (!trajStr || strlen(trajStr) == 0) { + free((void*)trajStr); + return (int)0; + } + + std::lock_guard lock(meos_temporalnumtimestamps_mutex); + + std::string trajString(trajStr); + void* temp = MEOS::Meos::parseTemporalPoint(trajString); + if (!temp) { + free((void*)trajStr); + return (int)0; + } + + int value = temporal_num_timestamps(static_cast(temp)); + + MEOS::Meos::freeTemporalObject(temp); + free((void*)trajStr); + return value; + }, + trajectoryStr); + + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, resultValue); + return resultRecord; +} + +void TemporalNumTimestampsAggregationPhysicalFunction::reset(const nautilus::val aggregationState, PipelineMemoryProvider&) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + new (pagedVector) Nautilus::Interface::PagedVector(); + }, + aggregationState); +} + +size_t TemporalNumTimestampsAggregationPhysicalFunction::getSizeOfStateInBytes() const +{ + return sizeof(Nautilus::Interface::PagedVector); +} + +void TemporalNumTimestampsAggregationPhysicalFunction::cleanup(nautilus::val aggregationState) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + pagedVector->~PagedVector(); + }, + aggregationState); +} + + +AggregationPhysicalFunctionRegistryReturnType AggregationPhysicalFunctionGeneratedRegistrar::RegisterTemporalNumTimestampsAggregationPhysicalFunction( + AggregationPhysicalFunctionRegistryArguments) +{ + throw std::runtime_error("TemporalNumTimestamps aggregation cannot be created through the registry. " + "It requires three field functions (longitude, latitude, timestamp)"); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Aggregation/Function/Meos/TemporalStartTimestampAggregationPhysicalFunction.cpp b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalStartTimestampAggregationPhysicalFunction.cpp new file mode 100644 index 0000000000..5676e0c832 --- /dev/null +++ b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalStartTimestampAggregationPhysicalFunction.cpp @@ -0,0 +1,260 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +extern "C" { +#include +#include +} + +namespace NES +{ + +constexpr static std::string_view LonFieldName = "lon"; +constexpr static std::string_view LatFieldName = "lat"; +constexpr static std::string_view TimestampFieldName = "timestamp"; + +static std::mutex meos_temporalstarttimestamp_mutex; + + +TemporalStartTimestampAggregationPhysicalFunction::TemporalStartTimestampAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction lonFunctionParam, + PhysicalFunction latFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef) + : AggregationPhysicalFunction(std::move(inputType), std::move(resultType), lonFunctionParam, std::move(resultFieldIdentifier)) + , bufferRef(std::move(bufferRef)) + , lonFunction(std::move(lonFunctionParam)) + , latFunction(std::move(latFunctionParam)) + , timestampFunction(std::move(timestampFunctionParam)) +{ +} + +void TemporalStartTimestampAggregationPhysicalFunction::lift( + const nautilus::val& aggregationState, PipelineMemoryProvider& pipelineMemoryProvider, const Nautilus::Record& record) +{ + const auto pagedVectorPtr = static_cast>(aggregationState); + + auto lonValue = lonFunction.execute(record, pipelineMemoryProvider.arena); + auto latValue = latFunction.execute(record, pipelineMemoryProvider.arena); + auto timestampValue = timestampFunction.execute(record, pipelineMemoryProvider.arena); + + Record aggregateStateRecord({ + {std::string(LonFieldName), lonValue}, + {std::string(LatFieldName), latValue}, + {std::string(TimestampFieldName), timestampValue} + }); + + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + pagedVectorRef.writeRecord(aggregateStateRecord, pipelineMemoryProvider.bufferProvider); +} + +void TemporalStartTimestampAggregationPhysicalFunction::combine( + const nautilus::val aggregationState1, + const nautilus::val aggregationState2, + PipelineMemoryProvider&) +{ + const auto memArea1 = static_cast>(aggregationState1); + const auto memArea2 = static_cast>(aggregationState2); + + nautilus::invoke( + +[](Nautilus::Interface::PagedVector* vector1, const Nautilus::Interface::PagedVector* vector2) -> void + { vector1->copyFrom(*vector2); }, + memArea1, + memArea2); +} + +Nautilus::Record TemporalStartTimestampAggregationPhysicalFunction::lower( + const nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) +{ + MEOS::Meos::ensureMeosInitialized(); + + const auto pagedVectorPtr = static_cast>(aggregationState); + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + const auto allFieldNames = bufferRef->getMemoryLayout()->getSchema().getFieldNames(); + const auto numberOfEntries = invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) + { + return pagedVector->getTotalNumberOfEntries(); + }, + pagedVectorPtr); + + if (numberOfEntries == nautilus::val(0)) { + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, nautilus::val(0)); + return resultRecord; + } + + auto trajectoryStr = nautilus::invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) -> char* + { + size_t bufferSize = pagedVector->getTotalNumberOfEntries() * 150 + 50; + char* buffer = (char*)malloc(bufferSize); + memset(buffer, 0, bufferSize); + strcpy(buffer, "{"); + return buffer; + }, + pagedVectorPtr); + + auto pointCounter = nautilus::val(0); + + const auto endIt = pagedVectorRef.end(allFieldNames); + for (auto candidateIt = pagedVectorRef.begin(allFieldNames); candidateIt != endIt; ++candidateIt) + { + const auto itemRecord = *candidateIt; + + const auto lonValue = itemRecord.read(std::string(LonFieldName)); + const auto latValue = itemRecord.read(std::string(LatFieldName)); + const auto timestampValue = itemRecord.read(std::string(TimestampFieldName)); + + auto lon = lonValue.cast>(); + auto lat = latValue.cast>(); + auto timestamp = timestampValue.cast>(); + + trajectoryStr = nautilus::invoke( + +[](char* buffer, double lonVal, double latVal, int64_t tsVal, int64_t counter) -> char* + { + if (counter > 0) { + strcat(buffer, ", "); + } + + long long adjustedTime; + if (tsVal > 1000000000000LL) { + adjustedTime = tsVal / 1000; + } else { + adjustedTime = tsVal; + } + + std::string timestampString = MEOS::Meos::convertSecondsToTimestamp(adjustedTime); + const char* timestampStr = timestampString.c_str(); + + char pointStr[120]; + sprintf(pointStr, "Point(%.6f %.6f)@%s", lonVal, latVal, timestampStr); + strcat(buffer, pointStr); + return buffer; + }, + trajectoryStr, + lon, + lat, + timestamp, + pointCounter); + + pointCounter = pointCounter + nautilus::val(1); + } + + trajectoryStr = nautilus::invoke( + +[](char* buffer) -> char* + { + strcat(buffer, "}"); + return buffer; + }, + trajectoryStr); + + auto resultValue = nautilus::invoke( + +[](const char* trajStr) -> int64_t + { + if (!trajStr || strlen(trajStr) == 0) { + free((void*)trajStr); + return (int64_t)0; + } + + std::lock_guard lock(meos_temporalstarttimestamp_mutex); + + std::string trajString(trajStr); + void* temp = MEOS::Meos::parseTemporalPoint(trajString); + if (!temp) { + free((void*)trajStr); + return (int64_t)0; + } + + int64_t value = temporal_start_timestamptz(static_cast(temp)); + + MEOS::Meos::freeTemporalObject(temp); + free((void*)trajStr); + return value; + }, + trajectoryStr); + + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, resultValue); + return resultRecord; +} + +void TemporalStartTimestampAggregationPhysicalFunction::reset(const nautilus::val aggregationState, PipelineMemoryProvider&) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + new (pagedVector) Nautilus::Interface::PagedVector(); + }, + aggregationState); +} + +size_t TemporalStartTimestampAggregationPhysicalFunction::getSizeOfStateInBytes() const +{ + return sizeof(Nautilus::Interface::PagedVector); +} + +void TemporalStartTimestampAggregationPhysicalFunction::cleanup(nautilus::val aggregationState) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + pagedVector->~PagedVector(); + }, + aggregationState); +} + + +AggregationPhysicalFunctionRegistryReturnType AggregationPhysicalFunctionGeneratedRegistrar::RegisterTemporalStartTimestampAggregationPhysicalFunction( + AggregationPhysicalFunctionRegistryArguments) +{ + throw std::runtime_error("TemporalStartTimestamp aggregation cannot be created through the registry. " + "It requires three field functions (longitude, latitude, timestamp)"); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTFloatAvgValueAggregationPhysicalFunction.cpp b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTFloatAvgValueAggregationPhysicalFunction.cpp new file mode 100644 index 0000000000..a2e84162fd --- /dev/null +++ b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTFloatAvgValueAggregationPhysicalFunction.cpp @@ -0,0 +1,253 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +extern "C" { +#include +} + +namespace NES +{ + +constexpr static std::string_view ValueFieldName = "value"; +constexpr static std::string_view TimestampFieldName = "timestamp"; + +static std::mutex meos_temporaltfloatavgvalue_mutex; + + +TemporalTFloatAvgValueAggregationPhysicalFunction::TemporalTFloatAvgValueAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction valueFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef) + : AggregationPhysicalFunction(std::move(inputType), std::move(resultType), valueFunctionParam, std::move(resultFieldIdentifier)) + , bufferRef(std::move(bufferRef)) + , valueFunction(std::move(valueFunctionParam)) + , timestampFunction(std::move(timestampFunctionParam)) +{ +} + +void TemporalTFloatAvgValueAggregationPhysicalFunction::lift( + const nautilus::val& aggregationState, PipelineMemoryProvider& pipelineMemoryProvider, const Nautilus::Record& record) +{ + const auto pagedVectorPtr = static_cast>(aggregationState); + + auto valueValue = valueFunction.execute(record, pipelineMemoryProvider.arena); + auto timestampValue = timestampFunction.execute(record, pipelineMemoryProvider.arena); + + Record aggregateStateRecord({ + {std::string(ValueFieldName), valueValue}, + {std::string(TimestampFieldName), timestampValue} + }); + + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + pagedVectorRef.writeRecord(aggregateStateRecord, pipelineMemoryProvider.bufferProvider); +} + +void TemporalTFloatAvgValueAggregationPhysicalFunction::combine( + const nautilus::val aggregationState1, + const nautilus::val aggregationState2, + PipelineMemoryProvider&) +{ + const auto memArea1 = static_cast>(aggregationState1); + const auto memArea2 = static_cast>(aggregationState2); + + nautilus::invoke( + +[](Nautilus::Interface::PagedVector* vector1, const Nautilus::Interface::PagedVector* vector2) -> void + { vector1->copyFrom(*vector2); }, + memArea1, + memArea2); +} + +Nautilus::Record TemporalTFloatAvgValueAggregationPhysicalFunction::lower( + const nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) +{ + MEOS::Meos::ensureMeosInitialized(); + + const auto pagedVectorPtr = static_cast>(aggregationState); + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + const auto allFieldNames = bufferRef->getMemoryLayout()->getSchema().getFieldNames(); + const auto numberOfEntries = invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) + { + return pagedVector->getTotalNumberOfEntries(); + }, + pagedVectorPtr); + + if (numberOfEntries == nautilus::val(0)) { + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, nautilus::val(0)); + return resultRecord; + } + + auto sequenceStr = nautilus::invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) -> char* + { + size_t bufferSize = pagedVector->getTotalNumberOfEntries() * 80 + 50; + char* buffer = (char*)malloc(bufferSize); + memset(buffer, 0, bufferSize); + strcpy(buffer, "{"); + return buffer; + }, + pagedVectorPtr); + + auto pointCounter = nautilus::val(0); + + const auto endIt = pagedVectorRef.end(allFieldNames); + for (auto candidateIt = pagedVectorRef.begin(allFieldNames); candidateIt != endIt; ++candidateIt) + { + const auto itemRecord = *candidateIt; + + const auto valueRaw = itemRecord.read(std::string(ValueFieldName)); + const auto timestampRaw = itemRecord.read(std::string(TimestampFieldName)); + + auto value = valueRaw.cast>(); + auto timestamp = timestampRaw.cast>(); + + sequenceStr = nautilus::invoke( + +[](char* buffer, double valueVal, int64_t tsVal, int64_t counter) -> char* + { + if (counter > 0) { + strcat(buffer, ", "); + } + + long long adjustedTime; + if (tsVal > 1000000000000LL) { + adjustedTime = tsVal / 1000; + } else { + adjustedTime = tsVal; + } + + std::string timestampString = MEOS::Meos::convertSecondsToTimestamp(adjustedTime); + const char* timestampStr = timestampString.c_str(); + + char itemStr[80]; + sprintf(itemStr, "%.6f@%s", valueVal, timestampStr); + strcat(buffer, itemStr); + return buffer; + }, + sequenceStr, + value, + timestamp, + pointCounter); + + pointCounter = pointCounter + nautilus::val(1); + } + + sequenceStr = nautilus::invoke( + +[](char* buffer) -> char* + { + strcat(buffer, "}"); + return buffer; + }, + sequenceStr); + + auto resultValue = nautilus::invoke( + +[](const char* seqStr) -> double + { + if (!seqStr || strlen(seqStr) == 0) { + free((void*)seqStr); + return (double)0; + } + + std::lock_guard lock(meos_temporaltfloatavgvalue_mutex); + + Temporal* temp = tfloat_in(seqStr); + if (!temp) { + free((void*)seqStr); + return (double)0; + } + + /* tfloat_avg_value is declared in meos.h but not defined in libmeos; + use the generic tnumber_avg_value (tfloat is a tnumber), matching + the TInt sibling op. */ + double value = tnumber_avg_value(temp); + + free(temp); + free((void*)seqStr); + return value; + }, + sequenceStr); + + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, resultValue); + return resultRecord; +} + +void TemporalTFloatAvgValueAggregationPhysicalFunction::reset(const nautilus::val aggregationState, PipelineMemoryProvider&) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + new (pagedVector) Nautilus::Interface::PagedVector(); + }, + aggregationState); +} + +size_t TemporalTFloatAvgValueAggregationPhysicalFunction::getSizeOfStateInBytes() const +{ + return sizeof(Nautilus::Interface::PagedVector); +} + +void TemporalTFloatAvgValueAggregationPhysicalFunction::cleanup(nautilus::val aggregationState) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + pagedVector->~PagedVector(); + }, + aggregationState); +} + + +AggregationPhysicalFunctionRegistryReturnType AggregationPhysicalFunctionGeneratedRegistrar::RegisterTemporalTFloatAvgValueAggregationPhysicalFunction( + AggregationPhysicalFunctionRegistryArguments) +{ + throw std::runtime_error("TemporalTFloatAvgValue aggregation cannot be created through the registry. " + "It requires two field functions (value, timestamp)"); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTFloatEndValueAggregationPhysicalFunction.cpp b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTFloatEndValueAggregationPhysicalFunction.cpp new file mode 100644 index 0000000000..65de784a9e --- /dev/null +++ b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTFloatEndValueAggregationPhysicalFunction.cpp @@ -0,0 +1,250 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +extern "C" { +#include +} + +namespace NES +{ + +constexpr static std::string_view ValueFieldName = "value"; +constexpr static std::string_view TimestampFieldName = "timestamp"; + +static std::mutex meos_temporaltfloatendvalue_mutex; + + +TemporalTFloatEndValueAggregationPhysicalFunction::TemporalTFloatEndValueAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction valueFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef) + : AggregationPhysicalFunction(std::move(inputType), std::move(resultType), valueFunctionParam, std::move(resultFieldIdentifier)) + , bufferRef(std::move(bufferRef)) + , valueFunction(std::move(valueFunctionParam)) + , timestampFunction(std::move(timestampFunctionParam)) +{ +} + +void TemporalTFloatEndValueAggregationPhysicalFunction::lift( + const nautilus::val& aggregationState, PipelineMemoryProvider& pipelineMemoryProvider, const Nautilus::Record& record) +{ + const auto pagedVectorPtr = static_cast>(aggregationState); + + auto valueValue = valueFunction.execute(record, pipelineMemoryProvider.arena); + auto timestampValue = timestampFunction.execute(record, pipelineMemoryProvider.arena); + + Record aggregateStateRecord({ + {std::string(ValueFieldName), valueValue}, + {std::string(TimestampFieldName), timestampValue} + }); + + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + pagedVectorRef.writeRecord(aggregateStateRecord, pipelineMemoryProvider.bufferProvider); +} + +void TemporalTFloatEndValueAggregationPhysicalFunction::combine( + const nautilus::val aggregationState1, + const nautilus::val aggregationState2, + PipelineMemoryProvider&) +{ + const auto memArea1 = static_cast>(aggregationState1); + const auto memArea2 = static_cast>(aggregationState2); + + nautilus::invoke( + +[](Nautilus::Interface::PagedVector* vector1, const Nautilus::Interface::PagedVector* vector2) -> void + { vector1->copyFrom(*vector2); }, + memArea1, + memArea2); +} + +Nautilus::Record TemporalTFloatEndValueAggregationPhysicalFunction::lower( + const nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) +{ + MEOS::Meos::ensureMeosInitialized(); + + const auto pagedVectorPtr = static_cast>(aggregationState); + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + const auto allFieldNames = bufferRef->getMemoryLayout()->getSchema().getFieldNames(); + const auto numberOfEntries = invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) + { + return pagedVector->getTotalNumberOfEntries(); + }, + pagedVectorPtr); + + if (numberOfEntries == nautilus::val(0)) { + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, nautilus::val(0)); + return resultRecord; + } + + auto sequenceStr = nautilus::invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) -> char* + { + size_t bufferSize = pagedVector->getTotalNumberOfEntries() * 80 + 50; + char* buffer = (char*)malloc(bufferSize); + memset(buffer, 0, bufferSize); + strcpy(buffer, "{"); + return buffer; + }, + pagedVectorPtr); + + auto pointCounter = nautilus::val(0); + + const auto endIt = pagedVectorRef.end(allFieldNames); + for (auto candidateIt = pagedVectorRef.begin(allFieldNames); candidateIt != endIt; ++candidateIt) + { + const auto itemRecord = *candidateIt; + + const auto valueRaw = itemRecord.read(std::string(ValueFieldName)); + const auto timestampRaw = itemRecord.read(std::string(TimestampFieldName)); + + auto value = valueRaw.cast>(); + auto timestamp = timestampRaw.cast>(); + + sequenceStr = nautilus::invoke( + +[](char* buffer, double valueVal, int64_t tsVal, int64_t counter) -> char* + { + if (counter > 0) { + strcat(buffer, ", "); + } + + long long adjustedTime; + if (tsVal > 1000000000000LL) { + adjustedTime = tsVal / 1000; + } else { + adjustedTime = tsVal; + } + + std::string timestampString = MEOS::Meos::convertSecondsToTimestamp(adjustedTime); + const char* timestampStr = timestampString.c_str(); + + char itemStr[80]; + sprintf(itemStr, "%.6f@%s", valueVal, timestampStr); + strcat(buffer, itemStr); + return buffer; + }, + sequenceStr, + value, + timestamp, + pointCounter); + + pointCounter = pointCounter + nautilus::val(1); + } + + sequenceStr = nautilus::invoke( + +[](char* buffer) -> char* + { + strcat(buffer, "}"); + return buffer; + }, + sequenceStr); + + auto resultValue = nautilus::invoke( + +[](const char* seqStr) -> double + { + if (!seqStr || strlen(seqStr) == 0) { + free((void*)seqStr); + return (double)0; + } + + std::lock_guard lock(meos_temporaltfloatendvalue_mutex); + + Temporal* temp = tfloat_in(seqStr); + if (!temp) { + free((void*)seqStr); + return (double)0; + } + + double value = tfloat_end_value(temp); + + free(temp); + free((void*)seqStr); + return value; + }, + sequenceStr); + + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, resultValue); + return resultRecord; +} + +void TemporalTFloatEndValueAggregationPhysicalFunction::reset(const nautilus::val aggregationState, PipelineMemoryProvider&) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + new (pagedVector) Nautilus::Interface::PagedVector(); + }, + aggregationState); +} + +size_t TemporalTFloatEndValueAggregationPhysicalFunction::getSizeOfStateInBytes() const +{ + return sizeof(Nautilus::Interface::PagedVector); +} + +void TemporalTFloatEndValueAggregationPhysicalFunction::cleanup(nautilus::val aggregationState) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + pagedVector->~PagedVector(); + }, + aggregationState); +} + + +AggregationPhysicalFunctionRegistryReturnType AggregationPhysicalFunctionGeneratedRegistrar::RegisterTemporalTFloatEndValueAggregationPhysicalFunction( + AggregationPhysicalFunctionRegistryArguments) +{ + throw std::runtime_error("TemporalTFloatEndValue aggregation cannot be created through the registry. " + "It requires two field functions (value, timestamp)"); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTFloatMaxValueAggregationPhysicalFunction.cpp b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTFloatMaxValueAggregationPhysicalFunction.cpp new file mode 100644 index 0000000000..c9fb3b8b6c --- /dev/null +++ b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTFloatMaxValueAggregationPhysicalFunction.cpp @@ -0,0 +1,250 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +extern "C" { +#include +} + +namespace NES +{ + +constexpr static std::string_view ValueFieldName = "value"; +constexpr static std::string_view TimestampFieldName = "timestamp"; + +static std::mutex meos_temporaltfloatmaxvalue_mutex; + + +TemporalTFloatMaxValueAggregationPhysicalFunction::TemporalTFloatMaxValueAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction valueFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef) + : AggregationPhysicalFunction(std::move(inputType), std::move(resultType), valueFunctionParam, std::move(resultFieldIdentifier)) + , bufferRef(std::move(bufferRef)) + , valueFunction(std::move(valueFunctionParam)) + , timestampFunction(std::move(timestampFunctionParam)) +{ +} + +void TemporalTFloatMaxValueAggregationPhysicalFunction::lift( + const nautilus::val& aggregationState, PipelineMemoryProvider& pipelineMemoryProvider, const Nautilus::Record& record) +{ + const auto pagedVectorPtr = static_cast>(aggregationState); + + auto valueValue = valueFunction.execute(record, pipelineMemoryProvider.arena); + auto timestampValue = timestampFunction.execute(record, pipelineMemoryProvider.arena); + + Record aggregateStateRecord({ + {std::string(ValueFieldName), valueValue}, + {std::string(TimestampFieldName), timestampValue} + }); + + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + pagedVectorRef.writeRecord(aggregateStateRecord, pipelineMemoryProvider.bufferProvider); +} + +void TemporalTFloatMaxValueAggregationPhysicalFunction::combine( + const nautilus::val aggregationState1, + const nautilus::val aggregationState2, + PipelineMemoryProvider&) +{ + const auto memArea1 = static_cast>(aggregationState1); + const auto memArea2 = static_cast>(aggregationState2); + + nautilus::invoke( + +[](Nautilus::Interface::PagedVector* vector1, const Nautilus::Interface::PagedVector* vector2) -> void + { vector1->copyFrom(*vector2); }, + memArea1, + memArea2); +} + +Nautilus::Record TemporalTFloatMaxValueAggregationPhysicalFunction::lower( + const nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) +{ + MEOS::Meos::ensureMeosInitialized(); + + const auto pagedVectorPtr = static_cast>(aggregationState); + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + const auto allFieldNames = bufferRef->getMemoryLayout()->getSchema().getFieldNames(); + const auto numberOfEntries = invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) + { + return pagedVector->getTotalNumberOfEntries(); + }, + pagedVectorPtr); + + if (numberOfEntries == nautilus::val(0)) { + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, nautilus::val(0)); + return resultRecord; + } + + auto sequenceStr = nautilus::invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) -> char* + { + size_t bufferSize = pagedVector->getTotalNumberOfEntries() * 80 + 50; + char* buffer = (char*)malloc(bufferSize); + memset(buffer, 0, bufferSize); + strcpy(buffer, "{"); + return buffer; + }, + pagedVectorPtr); + + auto pointCounter = nautilus::val(0); + + const auto endIt = pagedVectorRef.end(allFieldNames); + for (auto candidateIt = pagedVectorRef.begin(allFieldNames); candidateIt != endIt; ++candidateIt) + { + const auto itemRecord = *candidateIt; + + const auto valueRaw = itemRecord.read(std::string(ValueFieldName)); + const auto timestampRaw = itemRecord.read(std::string(TimestampFieldName)); + + auto value = valueRaw.cast>(); + auto timestamp = timestampRaw.cast>(); + + sequenceStr = nautilus::invoke( + +[](char* buffer, double valueVal, int64_t tsVal, int64_t counter) -> char* + { + if (counter > 0) { + strcat(buffer, ", "); + } + + long long adjustedTime; + if (tsVal > 1000000000000LL) { + adjustedTime = tsVal / 1000; + } else { + adjustedTime = tsVal; + } + + std::string timestampString = MEOS::Meos::convertSecondsToTimestamp(adjustedTime); + const char* timestampStr = timestampString.c_str(); + + char itemStr[80]; + sprintf(itemStr, "%.6f@%s", valueVal, timestampStr); + strcat(buffer, itemStr); + return buffer; + }, + sequenceStr, + value, + timestamp, + pointCounter); + + pointCounter = pointCounter + nautilus::val(1); + } + + sequenceStr = nautilus::invoke( + +[](char* buffer) -> char* + { + strcat(buffer, "}"); + return buffer; + }, + sequenceStr); + + auto resultValue = nautilus::invoke( + +[](const char* seqStr) -> double + { + if (!seqStr || strlen(seqStr) == 0) { + free((void*)seqStr); + return (double)0; + } + + std::lock_guard lock(meos_temporaltfloatmaxvalue_mutex); + + Temporal* temp = tfloat_in(seqStr); + if (!temp) { + free((void*)seqStr); + return (double)0; + } + + double value = tfloat_max_value(temp); + + free(temp); + free((void*)seqStr); + return value; + }, + sequenceStr); + + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, resultValue); + return resultRecord; +} + +void TemporalTFloatMaxValueAggregationPhysicalFunction::reset(const nautilus::val aggregationState, PipelineMemoryProvider&) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + new (pagedVector) Nautilus::Interface::PagedVector(); + }, + aggregationState); +} + +size_t TemporalTFloatMaxValueAggregationPhysicalFunction::getSizeOfStateInBytes() const +{ + return sizeof(Nautilus::Interface::PagedVector); +} + +void TemporalTFloatMaxValueAggregationPhysicalFunction::cleanup(nautilus::val aggregationState) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + pagedVector->~PagedVector(); + }, + aggregationState); +} + + +AggregationPhysicalFunctionRegistryReturnType AggregationPhysicalFunctionGeneratedRegistrar::RegisterTemporalTFloatMaxValueAggregationPhysicalFunction( + AggregationPhysicalFunctionRegistryArguments) +{ + throw std::runtime_error("TemporalTFloatMaxValue aggregation cannot be created through the registry. " + "It requires two field functions (value, timestamp)"); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTFloatMinValueAggregationPhysicalFunction.cpp b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTFloatMinValueAggregationPhysicalFunction.cpp new file mode 100644 index 0000000000..304e4a22cf --- /dev/null +++ b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTFloatMinValueAggregationPhysicalFunction.cpp @@ -0,0 +1,250 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +extern "C" { +#include +} + +namespace NES +{ + +constexpr static std::string_view ValueFieldName = "value"; +constexpr static std::string_view TimestampFieldName = "timestamp"; + +static std::mutex meos_temporaltfloatminvalue_mutex; + + +TemporalTFloatMinValueAggregationPhysicalFunction::TemporalTFloatMinValueAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction valueFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef) + : AggregationPhysicalFunction(std::move(inputType), std::move(resultType), valueFunctionParam, std::move(resultFieldIdentifier)) + , bufferRef(std::move(bufferRef)) + , valueFunction(std::move(valueFunctionParam)) + , timestampFunction(std::move(timestampFunctionParam)) +{ +} + +void TemporalTFloatMinValueAggregationPhysicalFunction::lift( + const nautilus::val& aggregationState, PipelineMemoryProvider& pipelineMemoryProvider, const Nautilus::Record& record) +{ + const auto pagedVectorPtr = static_cast>(aggregationState); + + auto valueValue = valueFunction.execute(record, pipelineMemoryProvider.arena); + auto timestampValue = timestampFunction.execute(record, pipelineMemoryProvider.arena); + + Record aggregateStateRecord({ + {std::string(ValueFieldName), valueValue}, + {std::string(TimestampFieldName), timestampValue} + }); + + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + pagedVectorRef.writeRecord(aggregateStateRecord, pipelineMemoryProvider.bufferProvider); +} + +void TemporalTFloatMinValueAggregationPhysicalFunction::combine( + const nautilus::val aggregationState1, + const nautilus::val aggregationState2, + PipelineMemoryProvider&) +{ + const auto memArea1 = static_cast>(aggregationState1); + const auto memArea2 = static_cast>(aggregationState2); + + nautilus::invoke( + +[](Nautilus::Interface::PagedVector* vector1, const Nautilus::Interface::PagedVector* vector2) -> void + { vector1->copyFrom(*vector2); }, + memArea1, + memArea2); +} + +Nautilus::Record TemporalTFloatMinValueAggregationPhysicalFunction::lower( + const nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) +{ + MEOS::Meos::ensureMeosInitialized(); + + const auto pagedVectorPtr = static_cast>(aggregationState); + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + const auto allFieldNames = bufferRef->getMemoryLayout()->getSchema().getFieldNames(); + const auto numberOfEntries = invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) + { + return pagedVector->getTotalNumberOfEntries(); + }, + pagedVectorPtr); + + if (numberOfEntries == nautilus::val(0)) { + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, nautilus::val(0)); + return resultRecord; + } + + auto sequenceStr = nautilus::invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) -> char* + { + size_t bufferSize = pagedVector->getTotalNumberOfEntries() * 80 + 50; + char* buffer = (char*)malloc(bufferSize); + memset(buffer, 0, bufferSize); + strcpy(buffer, "{"); + return buffer; + }, + pagedVectorPtr); + + auto pointCounter = nautilus::val(0); + + const auto endIt = pagedVectorRef.end(allFieldNames); + for (auto candidateIt = pagedVectorRef.begin(allFieldNames); candidateIt != endIt; ++candidateIt) + { + const auto itemRecord = *candidateIt; + + const auto valueRaw = itemRecord.read(std::string(ValueFieldName)); + const auto timestampRaw = itemRecord.read(std::string(TimestampFieldName)); + + auto value = valueRaw.cast>(); + auto timestamp = timestampRaw.cast>(); + + sequenceStr = nautilus::invoke( + +[](char* buffer, double valueVal, int64_t tsVal, int64_t counter) -> char* + { + if (counter > 0) { + strcat(buffer, ", "); + } + + long long adjustedTime; + if (tsVal > 1000000000000LL) { + adjustedTime = tsVal / 1000; + } else { + adjustedTime = tsVal; + } + + std::string timestampString = MEOS::Meos::convertSecondsToTimestamp(adjustedTime); + const char* timestampStr = timestampString.c_str(); + + char itemStr[80]; + sprintf(itemStr, "%.6f@%s", valueVal, timestampStr); + strcat(buffer, itemStr); + return buffer; + }, + sequenceStr, + value, + timestamp, + pointCounter); + + pointCounter = pointCounter + nautilus::val(1); + } + + sequenceStr = nautilus::invoke( + +[](char* buffer) -> char* + { + strcat(buffer, "}"); + return buffer; + }, + sequenceStr); + + auto resultValue = nautilus::invoke( + +[](const char* seqStr) -> double + { + if (!seqStr || strlen(seqStr) == 0) { + free((void*)seqStr); + return (double)0; + } + + std::lock_guard lock(meos_temporaltfloatminvalue_mutex); + + Temporal* temp = tfloat_in(seqStr); + if (!temp) { + free((void*)seqStr); + return (double)0; + } + + double value = tfloat_min_value(temp); + + free(temp); + free((void*)seqStr); + return value; + }, + sequenceStr); + + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, resultValue); + return resultRecord; +} + +void TemporalTFloatMinValueAggregationPhysicalFunction::reset(const nautilus::val aggregationState, PipelineMemoryProvider&) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + new (pagedVector) Nautilus::Interface::PagedVector(); + }, + aggregationState); +} + +size_t TemporalTFloatMinValueAggregationPhysicalFunction::getSizeOfStateInBytes() const +{ + return sizeof(Nautilus::Interface::PagedVector); +} + +void TemporalTFloatMinValueAggregationPhysicalFunction::cleanup(nautilus::val aggregationState) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + pagedVector->~PagedVector(); + }, + aggregationState); +} + + +AggregationPhysicalFunctionRegistryReturnType AggregationPhysicalFunctionGeneratedRegistrar::RegisterTemporalTFloatMinValueAggregationPhysicalFunction( + AggregationPhysicalFunctionRegistryArguments) +{ + throw std::runtime_error("TemporalTFloatMinValue aggregation cannot be created through the registry. " + "It requires two field functions (value, timestamp)"); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTFloatStartValueAggregationPhysicalFunction.cpp b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTFloatStartValueAggregationPhysicalFunction.cpp new file mode 100644 index 0000000000..de5e3acca4 --- /dev/null +++ b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTFloatStartValueAggregationPhysicalFunction.cpp @@ -0,0 +1,250 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +extern "C" { +#include +} + +namespace NES +{ + +constexpr static std::string_view ValueFieldName = "value"; +constexpr static std::string_view TimestampFieldName = "timestamp"; + +static std::mutex meos_temporaltfloatstartvalue_mutex; + + +TemporalTFloatStartValueAggregationPhysicalFunction::TemporalTFloatStartValueAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction valueFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef) + : AggregationPhysicalFunction(std::move(inputType), std::move(resultType), valueFunctionParam, std::move(resultFieldIdentifier)) + , bufferRef(std::move(bufferRef)) + , valueFunction(std::move(valueFunctionParam)) + , timestampFunction(std::move(timestampFunctionParam)) +{ +} + +void TemporalTFloatStartValueAggregationPhysicalFunction::lift( + const nautilus::val& aggregationState, PipelineMemoryProvider& pipelineMemoryProvider, const Nautilus::Record& record) +{ + const auto pagedVectorPtr = static_cast>(aggregationState); + + auto valueValue = valueFunction.execute(record, pipelineMemoryProvider.arena); + auto timestampValue = timestampFunction.execute(record, pipelineMemoryProvider.arena); + + Record aggregateStateRecord({ + {std::string(ValueFieldName), valueValue}, + {std::string(TimestampFieldName), timestampValue} + }); + + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + pagedVectorRef.writeRecord(aggregateStateRecord, pipelineMemoryProvider.bufferProvider); +} + +void TemporalTFloatStartValueAggregationPhysicalFunction::combine( + const nautilus::val aggregationState1, + const nautilus::val aggregationState2, + PipelineMemoryProvider&) +{ + const auto memArea1 = static_cast>(aggregationState1); + const auto memArea2 = static_cast>(aggregationState2); + + nautilus::invoke( + +[](Nautilus::Interface::PagedVector* vector1, const Nautilus::Interface::PagedVector* vector2) -> void + { vector1->copyFrom(*vector2); }, + memArea1, + memArea2); +} + +Nautilus::Record TemporalTFloatStartValueAggregationPhysicalFunction::lower( + const nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) +{ + MEOS::Meos::ensureMeosInitialized(); + + const auto pagedVectorPtr = static_cast>(aggregationState); + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + const auto allFieldNames = bufferRef->getMemoryLayout()->getSchema().getFieldNames(); + const auto numberOfEntries = invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) + { + return pagedVector->getTotalNumberOfEntries(); + }, + pagedVectorPtr); + + if (numberOfEntries == nautilus::val(0)) { + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, nautilus::val(0)); + return resultRecord; + } + + auto sequenceStr = nautilus::invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) -> char* + { + size_t bufferSize = pagedVector->getTotalNumberOfEntries() * 80 + 50; + char* buffer = (char*)malloc(bufferSize); + memset(buffer, 0, bufferSize); + strcpy(buffer, "{"); + return buffer; + }, + pagedVectorPtr); + + auto pointCounter = nautilus::val(0); + + const auto endIt = pagedVectorRef.end(allFieldNames); + for (auto candidateIt = pagedVectorRef.begin(allFieldNames); candidateIt != endIt; ++candidateIt) + { + const auto itemRecord = *candidateIt; + + const auto valueRaw = itemRecord.read(std::string(ValueFieldName)); + const auto timestampRaw = itemRecord.read(std::string(TimestampFieldName)); + + auto value = valueRaw.cast>(); + auto timestamp = timestampRaw.cast>(); + + sequenceStr = nautilus::invoke( + +[](char* buffer, double valueVal, int64_t tsVal, int64_t counter) -> char* + { + if (counter > 0) { + strcat(buffer, ", "); + } + + long long adjustedTime; + if (tsVal > 1000000000000LL) { + adjustedTime = tsVal / 1000; + } else { + adjustedTime = tsVal; + } + + std::string timestampString = MEOS::Meos::convertSecondsToTimestamp(adjustedTime); + const char* timestampStr = timestampString.c_str(); + + char itemStr[80]; + sprintf(itemStr, "%.6f@%s", valueVal, timestampStr); + strcat(buffer, itemStr); + return buffer; + }, + sequenceStr, + value, + timestamp, + pointCounter); + + pointCounter = pointCounter + nautilus::val(1); + } + + sequenceStr = nautilus::invoke( + +[](char* buffer) -> char* + { + strcat(buffer, "}"); + return buffer; + }, + sequenceStr); + + auto resultValue = nautilus::invoke( + +[](const char* seqStr) -> double + { + if (!seqStr || strlen(seqStr) == 0) { + free((void*)seqStr); + return (double)0; + } + + std::lock_guard lock(meos_temporaltfloatstartvalue_mutex); + + Temporal* temp = tfloat_in(seqStr); + if (!temp) { + free((void*)seqStr); + return (double)0; + } + + double value = tfloat_start_value(temp); + + free(temp); + free((void*)seqStr); + return value; + }, + sequenceStr); + + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, resultValue); + return resultRecord; +} + +void TemporalTFloatStartValueAggregationPhysicalFunction::reset(const nautilus::val aggregationState, PipelineMemoryProvider&) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + new (pagedVector) Nautilus::Interface::PagedVector(); + }, + aggregationState); +} + +size_t TemporalTFloatStartValueAggregationPhysicalFunction::getSizeOfStateInBytes() const +{ + return sizeof(Nautilus::Interface::PagedVector); +} + +void TemporalTFloatStartValueAggregationPhysicalFunction::cleanup(nautilus::val aggregationState) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + pagedVector->~PagedVector(); + }, + aggregationState); +} + + +AggregationPhysicalFunctionRegistryReturnType AggregationPhysicalFunctionGeneratedRegistrar::RegisterTemporalTFloatStartValueAggregationPhysicalFunction( + AggregationPhysicalFunctionRegistryArguments) +{ + throw std::runtime_error("TemporalTFloatStartValue aggregation cannot be created through the registry. " + "It requires two field functions (value, timestamp)"); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTIntAvgValueAggregationPhysicalFunction.cpp b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTIntAvgValueAggregationPhysicalFunction.cpp new file mode 100644 index 0000000000..0c9bcaf38d --- /dev/null +++ b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTIntAvgValueAggregationPhysicalFunction.cpp @@ -0,0 +1,250 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +extern "C" { +#include +} + +namespace NES +{ + +constexpr static std::string_view ValueFieldName = "value"; +constexpr static std::string_view TimestampFieldName = "timestamp"; + +static std::mutex meos_temporaltintavgvalue_mutex; + + +TemporalTIntAvgValueAggregationPhysicalFunction::TemporalTIntAvgValueAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction valueFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef) + : AggregationPhysicalFunction(std::move(inputType), std::move(resultType), valueFunctionParam, std::move(resultFieldIdentifier)) + , bufferRef(std::move(bufferRef)) + , valueFunction(std::move(valueFunctionParam)) + , timestampFunction(std::move(timestampFunctionParam)) +{ +} + +void TemporalTIntAvgValueAggregationPhysicalFunction::lift( + const nautilus::val& aggregationState, PipelineMemoryProvider& pipelineMemoryProvider, const Nautilus::Record& record) +{ + const auto pagedVectorPtr = static_cast>(aggregationState); + + auto valueValue = valueFunction.execute(record, pipelineMemoryProvider.arena); + auto timestampValue = timestampFunction.execute(record, pipelineMemoryProvider.arena); + + Record aggregateStateRecord({ + {std::string(ValueFieldName), valueValue}, + {std::string(TimestampFieldName), timestampValue} + }); + + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + pagedVectorRef.writeRecord(aggregateStateRecord, pipelineMemoryProvider.bufferProvider); +} + +void TemporalTIntAvgValueAggregationPhysicalFunction::combine( + const nautilus::val aggregationState1, + const nautilus::val aggregationState2, + PipelineMemoryProvider&) +{ + const auto memArea1 = static_cast>(aggregationState1); + const auto memArea2 = static_cast>(aggregationState2); + + nautilus::invoke( + +[](Nautilus::Interface::PagedVector* vector1, const Nautilus::Interface::PagedVector* vector2) -> void + { vector1->copyFrom(*vector2); }, + memArea1, + memArea2); +} + +Nautilus::Record TemporalTIntAvgValueAggregationPhysicalFunction::lower( + const nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) +{ + MEOS::Meos::ensureMeosInitialized(); + + const auto pagedVectorPtr = static_cast>(aggregationState); + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + const auto allFieldNames = bufferRef->getMemoryLayout()->getSchema().getFieldNames(); + const auto numberOfEntries = invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) + { + return pagedVector->getTotalNumberOfEntries(); + }, + pagedVectorPtr); + + if (numberOfEntries == nautilus::val(0)) { + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, nautilus::val(0)); + return resultRecord; + } + + auto sequenceStr = nautilus::invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) -> char* + { + size_t bufferSize = pagedVector->getTotalNumberOfEntries() * 80 + 50; + char* buffer = (char*)malloc(bufferSize); + memset(buffer, 0, bufferSize); + strcpy(buffer, "{"); + return buffer; + }, + pagedVectorPtr); + + auto pointCounter = nautilus::val(0); + + const auto endIt = pagedVectorRef.end(allFieldNames); + for (auto candidateIt = pagedVectorRef.begin(allFieldNames); candidateIt != endIt; ++candidateIt) + { + const auto itemRecord = *candidateIt; + + const auto valueRaw = itemRecord.read(std::string(ValueFieldName)); + const auto timestampRaw = itemRecord.read(std::string(TimestampFieldName)); + + auto value = valueRaw.cast>(); + auto timestamp = timestampRaw.cast>(); + + sequenceStr = nautilus::invoke( + +[](char* buffer, int32_t valueVal, int64_t tsVal, int64_t counter) -> char* + { + if (counter > 0) { + strcat(buffer, ", "); + } + + long long adjustedTime; + if (tsVal > 1000000000000LL) { + adjustedTime = tsVal / 1000; + } else { + adjustedTime = tsVal; + } + + std::string timestampString = MEOS::Meos::convertSecondsToTimestamp(adjustedTime); + const char* timestampStr = timestampString.c_str(); + + char itemStr[80]; + sprintf(itemStr, "%d@%s", valueVal, timestampStr); + strcat(buffer, itemStr); + return buffer; + }, + sequenceStr, + value, + timestamp, + pointCounter); + + pointCounter = pointCounter + nautilus::val(1); + } + + sequenceStr = nautilus::invoke( + +[](char* buffer) -> char* + { + strcat(buffer, "}"); + return buffer; + }, + sequenceStr); + + auto resultValue = nautilus::invoke( + +[](const char* seqStr) -> double + { + if (!seqStr || strlen(seqStr) == 0) { + free((void*)seqStr); + return (double)0; + } + + std::lock_guard lock(meos_temporaltintavgvalue_mutex); + + Temporal* temp = tint_in(seqStr); + if (!temp) { + free((void*)seqStr); + return (double)0; + } + + double value = tnumber_avg_value(temp); + + free(temp); + free((void*)seqStr); + return value; + }, + sequenceStr); + + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, resultValue); + return resultRecord; +} + +void TemporalTIntAvgValueAggregationPhysicalFunction::reset(const nautilus::val aggregationState, PipelineMemoryProvider&) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + new (pagedVector) Nautilus::Interface::PagedVector(); + }, + aggregationState); +} + +size_t TemporalTIntAvgValueAggregationPhysicalFunction::getSizeOfStateInBytes() const +{ + return sizeof(Nautilus::Interface::PagedVector); +} + +void TemporalTIntAvgValueAggregationPhysicalFunction::cleanup(nautilus::val aggregationState) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + pagedVector->~PagedVector(); + }, + aggregationState); +} + + +AggregationPhysicalFunctionRegistryReturnType AggregationPhysicalFunctionGeneratedRegistrar::RegisterTemporalTIntAvgValueAggregationPhysicalFunction( + AggregationPhysicalFunctionRegistryArguments) +{ + throw std::runtime_error("TemporalTIntAvgValue aggregation cannot be created through the registry. " + "It requires two field functions (value, timestamp)"); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTIntEndValueAggregationPhysicalFunction.cpp b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTIntEndValueAggregationPhysicalFunction.cpp new file mode 100644 index 0000000000..c8a8c388b1 --- /dev/null +++ b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTIntEndValueAggregationPhysicalFunction.cpp @@ -0,0 +1,250 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +extern "C" { +#include +} + +namespace NES +{ + +constexpr static std::string_view ValueFieldName = "value"; +constexpr static std::string_view TimestampFieldName = "timestamp"; + +static std::mutex meos_temporaltintendvalue_mutex; + + +TemporalTIntEndValueAggregationPhysicalFunction::TemporalTIntEndValueAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction valueFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef) + : AggregationPhysicalFunction(std::move(inputType), std::move(resultType), valueFunctionParam, std::move(resultFieldIdentifier)) + , bufferRef(std::move(bufferRef)) + , valueFunction(std::move(valueFunctionParam)) + , timestampFunction(std::move(timestampFunctionParam)) +{ +} + +void TemporalTIntEndValueAggregationPhysicalFunction::lift( + const nautilus::val& aggregationState, PipelineMemoryProvider& pipelineMemoryProvider, const Nautilus::Record& record) +{ + const auto pagedVectorPtr = static_cast>(aggregationState); + + auto valueValue = valueFunction.execute(record, pipelineMemoryProvider.arena); + auto timestampValue = timestampFunction.execute(record, pipelineMemoryProvider.arena); + + Record aggregateStateRecord({ + {std::string(ValueFieldName), valueValue}, + {std::string(TimestampFieldName), timestampValue} + }); + + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + pagedVectorRef.writeRecord(aggregateStateRecord, pipelineMemoryProvider.bufferProvider); +} + +void TemporalTIntEndValueAggregationPhysicalFunction::combine( + const nautilus::val aggregationState1, + const nautilus::val aggregationState2, + PipelineMemoryProvider&) +{ + const auto memArea1 = static_cast>(aggregationState1); + const auto memArea2 = static_cast>(aggregationState2); + + nautilus::invoke( + +[](Nautilus::Interface::PagedVector* vector1, const Nautilus::Interface::PagedVector* vector2) -> void + { vector1->copyFrom(*vector2); }, + memArea1, + memArea2); +} + +Nautilus::Record TemporalTIntEndValueAggregationPhysicalFunction::lower( + const nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) +{ + MEOS::Meos::ensureMeosInitialized(); + + const auto pagedVectorPtr = static_cast>(aggregationState); + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + const auto allFieldNames = bufferRef->getMemoryLayout()->getSchema().getFieldNames(); + const auto numberOfEntries = invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) + { + return pagedVector->getTotalNumberOfEntries(); + }, + pagedVectorPtr); + + if (numberOfEntries == nautilus::val(0)) { + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, nautilus::val(0)); + return resultRecord; + } + + auto sequenceStr = nautilus::invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) -> char* + { + size_t bufferSize = pagedVector->getTotalNumberOfEntries() * 80 + 50; + char* buffer = (char*)malloc(bufferSize); + memset(buffer, 0, bufferSize); + strcpy(buffer, "{"); + return buffer; + }, + pagedVectorPtr); + + auto pointCounter = nautilus::val(0); + + const auto endIt = pagedVectorRef.end(allFieldNames); + for (auto candidateIt = pagedVectorRef.begin(allFieldNames); candidateIt != endIt; ++candidateIt) + { + const auto itemRecord = *candidateIt; + + const auto valueRaw = itemRecord.read(std::string(ValueFieldName)); + const auto timestampRaw = itemRecord.read(std::string(TimestampFieldName)); + + auto value = valueRaw.cast>(); + auto timestamp = timestampRaw.cast>(); + + sequenceStr = nautilus::invoke( + +[](char* buffer, int32_t valueVal, int64_t tsVal, int64_t counter) -> char* + { + if (counter > 0) { + strcat(buffer, ", "); + } + + long long adjustedTime; + if (tsVal > 1000000000000LL) { + adjustedTime = tsVal / 1000; + } else { + adjustedTime = tsVal; + } + + std::string timestampString = MEOS::Meos::convertSecondsToTimestamp(adjustedTime); + const char* timestampStr = timestampString.c_str(); + + char itemStr[80]; + sprintf(itemStr, "%d@%s", valueVal, timestampStr); + strcat(buffer, itemStr); + return buffer; + }, + sequenceStr, + value, + timestamp, + pointCounter); + + pointCounter = pointCounter + nautilus::val(1); + } + + sequenceStr = nautilus::invoke( + +[](char* buffer) -> char* + { + strcat(buffer, "}"); + return buffer; + }, + sequenceStr); + + auto resultValue = nautilus::invoke( + +[](const char* seqStr) -> int + { + if (!seqStr || strlen(seqStr) == 0) { + free((void*)seqStr); + return (int)0; + } + + std::lock_guard lock(meos_temporaltintendvalue_mutex); + + Temporal* temp = tint_in(seqStr); + if (!temp) { + free((void*)seqStr); + return (int)0; + } + + int value = tint_end_value(temp); + + free(temp); + free((void*)seqStr); + return value; + }, + sequenceStr); + + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, resultValue); + return resultRecord; +} + +void TemporalTIntEndValueAggregationPhysicalFunction::reset(const nautilus::val aggregationState, PipelineMemoryProvider&) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + new (pagedVector) Nautilus::Interface::PagedVector(); + }, + aggregationState); +} + +size_t TemporalTIntEndValueAggregationPhysicalFunction::getSizeOfStateInBytes() const +{ + return sizeof(Nautilus::Interface::PagedVector); +} + +void TemporalTIntEndValueAggregationPhysicalFunction::cleanup(nautilus::val aggregationState) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + pagedVector->~PagedVector(); + }, + aggregationState); +} + + +AggregationPhysicalFunctionRegistryReturnType AggregationPhysicalFunctionGeneratedRegistrar::RegisterTemporalTIntEndValueAggregationPhysicalFunction( + AggregationPhysicalFunctionRegistryArguments) +{ + throw std::runtime_error("TemporalTIntEndValue aggregation cannot be created through the registry. " + "It requires two field functions (value, timestamp)"); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTIntMaxValueAggregationPhysicalFunction.cpp b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTIntMaxValueAggregationPhysicalFunction.cpp new file mode 100644 index 0000000000..60071775aa --- /dev/null +++ b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTIntMaxValueAggregationPhysicalFunction.cpp @@ -0,0 +1,250 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +extern "C" { +#include +} + +namespace NES +{ + +constexpr static std::string_view ValueFieldName = "value"; +constexpr static std::string_view TimestampFieldName = "timestamp"; + +static std::mutex meos_temporaltintmaxvalue_mutex; + + +TemporalTIntMaxValueAggregationPhysicalFunction::TemporalTIntMaxValueAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction valueFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef) + : AggregationPhysicalFunction(std::move(inputType), std::move(resultType), valueFunctionParam, std::move(resultFieldIdentifier)) + , bufferRef(std::move(bufferRef)) + , valueFunction(std::move(valueFunctionParam)) + , timestampFunction(std::move(timestampFunctionParam)) +{ +} + +void TemporalTIntMaxValueAggregationPhysicalFunction::lift( + const nautilus::val& aggregationState, PipelineMemoryProvider& pipelineMemoryProvider, const Nautilus::Record& record) +{ + const auto pagedVectorPtr = static_cast>(aggregationState); + + auto valueValue = valueFunction.execute(record, pipelineMemoryProvider.arena); + auto timestampValue = timestampFunction.execute(record, pipelineMemoryProvider.arena); + + Record aggregateStateRecord({ + {std::string(ValueFieldName), valueValue}, + {std::string(TimestampFieldName), timestampValue} + }); + + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + pagedVectorRef.writeRecord(aggregateStateRecord, pipelineMemoryProvider.bufferProvider); +} + +void TemporalTIntMaxValueAggregationPhysicalFunction::combine( + const nautilus::val aggregationState1, + const nautilus::val aggregationState2, + PipelineMemoryProvider&) +{ + const auto memArea1 = static_cast>(aggregationState1); + const auto memArea2 = static_cast>(aggregationState2); + + nautilus::invoke( + +[](Nautilus::Interface::PagedVector* vector1, const Nautilus::Interface::PagedVector* vector2) -> void + { vector1->copyFrom(*vector2); }, + memArea1, + memArea2); +} + +Nautilus::Record TemporalTIntMaxValueAggregationPhysicalFunction::lower( + const nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) +{ + MEOS::Meos::ensureMeosInitialized(); + + const auto pagedVectorPtr = static_cast>(aggregationState); + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + const auto allFieldNames = bufferRef->getMemoryLayout()->getSchema().getFieldNames(); + const auto numberOfEntries = invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) + { + return pagedVector->getTotalNumberOfEntries(); + }, + pagedVectorPtr); + + if (numberOfEntries == nautilus::val(0)) { + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, nautilus::val(0)); + return resultRecord; + } + + auto sequenceStr = nautilus::invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) -> char* + { + size_t bufferSize = pagedVector->getTotalNumberOfEntries() * 80 + 50; + char* buffer = (char*)malloc(bufferSize); + memset(buffer, 0, bufferSize); + strcpy(buffer, "{"); + return buffer; + }, + pagedVectorPtr); + + auto pointCounter = nautilus::val(0); + + const auto endIt = pagedVectorRef.end(allFieldNames); + for (auto candidateIt = pagedVectorRef.begin(allFieldNames); candidateIt != endIt; ++candidateIt) + { + const auto itemRecord = *candidateIt; + + const auto valueRaw = itemRecord.read(std::string(ValueFieldName)); + const auto timestampRaw = itemRecord.read(std::string(TimestampFieldName)); + + auto value = valueRaw.cast>(); + auto timestamp = timestampRaw.cast>(); + + sequenceStr = nautilus::invoke( + +[](char* buffer, int32_t valueVal, int64_t tsVal, int64_t counter) -> char* + { + if (counter > 0) { + strcat(buffer, ", "); + } + + long long adjustedTime; + if (tsVal > 1000000000000LL) { + adjustedTime = tsVal / 1000; + } else { + adjustedTime = tsVal; + } + + std::string timestampString = MEOS::Meos::convertSecondsToTimestamp(adjustedTime); + const char* timestampStr = timestampString.c_str(); + + char itemStr[80]; + sprintf(itemStr, "%d@%s", valueVal, timestampStr); + strcat(buffer, itemStr); + return buffer; + }, + sequenceStr, + value, + timestamp, + pointCounter); + + pointCounter = pointCounter + nautilus::val(1); + } + + sequenceStr = nautilus::invoke( + +[](char* buffer) -> char* + { + strcat(buffer, "}"); + return buffer; + }, + sequenceStr); + + auto resultValue = nautilus::invoke( + +[](const char* seqStr) -> int + { + if (!seqStr || strlen(seqStr) == 0) { + free((void*)seqStr); + return (int)0; + } + + std::lock_guard lock(meos_temporaltintmaxvalue_mutex); + + Temporal* temp = tint_in(seqStr); + if (!temp) { + free((void*)seqStr); + return (int)0; + } + + int value = tint_max_value(temp); + + free(temp); + free((void*)seqStr); + return value; + }, + sequenceStr); + + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, resultValue); + return resultRecord; +} + +void TemporalTIntMaxValueAggregationPhysicalFunction::reset(const nautilus::val aggregationState, PipelineMemoryProvider&) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + new (pagedVector) Nautilus::Interface::PagedVector(); + }, + aggregationState); +} + +size_t TemporalTIntMaxValueAggregationPhysicalFunction::getSizeOfStateInBytes() const +{ + return sizeof(Nautilus::Interface::PagedVector); +} + +void TemporalTIntMaxValueAggregationPhysicalFunction::cleanup(nautilus::val aggregationState) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + pagedVector->~PagedVector(); + }, + aggregationState); +} + + +AggregationPhysicalFunctionRegistryReturnType AggregationPhysicalFunctionGeneratedRegistrar::RegisterTemporalTIntMaxValueAggregationPhysicalFunction( + AggregationPhysicalFunctionRegistryArguments) +{ + throw std::runtime_error("TemporalTIntMaxValue aggregation cannot be created through the registry. " + "It requires two field functions (value, timestamp)"); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTIntMinValueAggregationPhysicalFunction.cpp b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTIntMinValueAggregationPhysicalFunction.cpp new file mode 100644 index 0000000000..90287903cc --- /dev/null +++ b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTIntMinValueAggregationPhysicalFunction.cpp @@ -0,0 +1,250 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +extern "C" { +#include +} + +namespace NES +{ + +constexpr static std::string_view ValueFieldName = "value"; +constexpr static std::string_view TimestampFieldName = "timestamp"; + +static std::mutex meos_temporaltintminvalue_mutex; + + +TemporalTIntMinValueAggregationPhysicalFunction::TemporalTIntMinValueAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction valueFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef) + : AggregationPhysicalFunction(std::move(inputType), std::move(resultType), valueFunctionParam, std::move(resultFieldIdentifier)) + , bufferRef(std::move(bufferRef)) + , valueFunction(std::move(valueFunctionParam)) + , timestampFunction(std::move(timestampFunctionParam)) +{ +} + +void TemporalTIntMinValueAggregationPhysicalFunction::lift( + const nautilus::val& aggregationState, PipelineMemoryProvider& pipelineMemoryProvider, const Nautilus::Record& record) +{ + const auto pagedVectorPtr = static_cast>(aggregationState); + + auto valueValue = valueFunction.execute(record, pipelineMemoryProvider.arena); + auto timestampValue = timestampFunction.execute(record, pipelineMemoryProvider.arena); + + Record aggregateStateRecord({ + {std::string(ValueFieldName), valueValue}, + {std::string(TimestampFieldName), timestampValue} + }); + + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + pagedVectorRef.writeRecord(aggregateStateRecord, pipelineMemoryProvider.bufferProvider); +} + +void TemporalTIntMinValueAggregationPhysicalFunction::combine( + const nautilus::val aggregationState1, + const nautilus::val aggregationState2, + PipelineMemoryProvider&) +{ + const auto memArea1 = static_cast>(aggregationState1); + const auto memArea2 = static_cast>(aggregationState2); + + nautilus::invoke( + +[](Nautilus::Interface::PagedVector* vector1, const Nautilus::Interface::PagedVector* vector2) -> void + { vector1->copyFrom(*vector2); }, + memArea1, + memArea2); +} + +Nautilus::Record TemporalTIntMinValueAggregationPhysicalFunction::lower( + const nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) +{ + MEOS::Meos::ensureMeosInitialized(); + + const auto pagedVectorPtr = static_cast>(aggregationState); + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + const auto allFieldNames = bufferRef->getMemoryLayout()->getSchema().getFieldNames(); + const auto numberOfEntries = invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) + { + return pagedVector->getTotalNumberOfEntries(); + }, + pagedVectorPtr); + + if (numberOfEntries == nautilus::val(0)) { + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, nautilus::val(0)); + return resultRecord; + } + + auto sequenceStr = nautilus::invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) -> char* + { + size_t bufferSize = pagedVector->getTotalNumberOfEntries() * 80 + 50; + char* buffer = (char*)malloc(bufferSize); + memset(buffer, 0, bufferSize); + strcpy(buffer, "{"); + return buffer; + }, + pagedVectorPtr); + + auto pointCounter = nautilus::val(0); + + const auto endIt = pagedVectorRef.end(allFieldNames); + for (auto candidateIt = pagedVectorRef.begin(allFieldNames); candidateIt != endIt; ++candidateIt) + { + const auto itemRecord = *candidateIt; + + const auto valueRaw = itemRecord.read(std::string(ValueFieldName)); + const auto timestampRaw = itemRecord.read(std::string(TimestampFieldName)); + + auto value = valueRaw.cast>(); + auto timestamp = timestampRaw.cast>(); + + sequenceStr = nautilus::invoke( + +[](char* buffer, int32_t valueVal, int64_t tsVal, int64_t counter) -> char* + { + if (counter > 0) { + strcat(buffer, ", "); + } + + long long adjustedTime; + if (tsVal > 1000000000000LL) { + adjustedTime = tsVal / 1000; + } else { + adjustedTime = tsVal; + } + + std::string timestampString = MEOS::Meos::convertSecondsToTimestamp(adjustedTime); + const char* timestampStr = timestampString.c_str(); + + char itemStr[80]; + sprintf(itemStr, "%d@%s", valueVal, timestampStr); + strcat(buffer, itemStr); + return buffer; + }, + sequenceStr, + value, + timestamp, + pointCounter); + + pointCounter = pointCounter + nautilus::val(1); + } + + sequenceStr = nautilus::invoke( + +[](char* buffer) -> char* + { + strcat(buffer, "}"); + return buffer; + }, + sequenceStr); + + auto resultValue = nautilus::invoke( + +[](const char* seqStr) -> int + { + if (!seqStr || strlen(seqStr) == 0) { + free((void*)seqStr); + return (int)0; + } + + std::lock_guard lock(meos_temporaltintminvalue_mutex); + + Temporal* temp = tint_in(seqStr); + if (!temp) { + free((void*)seqStr); + return (int)0; + } + + int value = tint_min_value(temp); + + free(temp); + free((void*)seqStr); + return value; + }, + sequenceStr); + + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, resultValue); + return resultRecord; +} + +void TemporalTIntMinValueAggregationPhysicalFunction::reset(const nautilus::val aggregationState, PipelineMemoryProvider&) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + new (pagedVector) Nautilus::Interface::PagedVector(); + }, + aggregationState); +} + +size_t TemporalTIntMinValueAggregationPhysicalFunction::getSizeOfStateInBytes() const +{ + return sizeof(Nautilus::Interface::PagedVector); +} + +void TemporalTIntMinValueAggregationPhysicalFunction::cleanup(nautilus::val aggregationState) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + pagedVector->~PagedVector(); + }, + aggregationState); +} + + +AggregationPhysicalFunctionRegistryReturnType AggregationPhysicalFunctionGeneratedRegistrar::RegisterTemporalTIntMinValueAggregationPhysicalFunction( + AggregationPhysicalFunctionRegistryArguments) +{ + throw std::runtime_error("TemporalTIntMinValue aggregation cannot be created through the registry. " + "It requires two field functions (value, timestamp)"); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTIntStartValueAggregationPhysicalFunction.cpp b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTIntStartValueAggregationPhysicalFunction.cpp new file mode 100644 index 0000000000..d6b1aeda38 --- /dev/null +++ b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTIntStartValueAggregationPhysicalFunction.cpp @@ -0,0 +1,250 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +extern "C" { +#include +} + +namespace NES +{ + +constexpr static std::string_view ValueFieldName = "value"; +constexpr static std::string_view TimestampFieldName = "timestamp"; + +static std::mutex meos_temporaltintstartvalue_mutex; + + +TemporalTIntStartValueAggregationPhysicalFunction::TemporalTIntStartValueAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction valueFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef) + : AggregationPhysicalFunction(std::move(inputType), std::move(resultType), valueFunctionParam, std::move(resultFieldIdentifier)) + , bufferRef(std::move(bufferRef)) + , valueFunction(std::move(valueFunctionParam)) + , timestampFunction(std::move(timestampFunctionParam)) +{ +} + +void TemporalTIntStartValueAggregationPhysicalFunction::lift( + const nautilus::val& aggregationState, PipelineMemoryProvider& pipelineMemoryProvider, const Nautilus::Record& record) +{ + const auto pagedVectorPtr = static_cast>(aggregationState); + + auto valueValue = valueFunction.execute(record, pipelineMemoryProvider.arena); + auto timestampValue = timestampFunction.execute(record, pipelineMemoryProvider.arena); + + Record aggregateStateRecord({ + {std::string(ValueFieldName), valueValue}, + {std::string(TimestampFieldName), timestampValue} + }); + + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + pagedVectorRef.writeRecord(aggregateStateRecord, pipelineMemoryProvider.bufferProvider); +} + +void TemporalTIntStartValueAggregationPhysicalFunction::combine( + const nautilus::val aggregationState1, + const nautilus::val aggregationState2, + PipelineMemoryProvider&) +{ + const auto memArea1 = static_cast>(aggregationState1); + const auto memArea2 = static_cast>(aggregationState2); + + nautilus::invoke( + +[](Nautilus::Interface::PagedVector* vector1, const Nautilus::Interface::PagedVector* vector2) -> void + { vector1->copyFrom(*vector2); }, + memArea1, + memArea2); +} + +Nautilus::Record TemporalTIntStartValueAggregationPhysicalFunction::lower( + const nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) +{ + MEOS::Meos::ensureMeosInitialized(); + + const auto pagedVectorPtr = static_cast>(aggregationState); + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + const auto allFieldNames = bufferRef->getMemoryLayout()->getSchema().getFieldNames(); + const auto numberOfEntries = invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) + { + return pagedVector->getTotalNumberOfEntries(); + }, + pagedVectorPtr); + + if (numberOfEntries == nautilus::val(0)) { + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, nautilus::val(0)); + return resultRecord; + } + + auto sequenceStr = nautilus::invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) -> char* + { + size_t bufferSize = pagedVector->getTotalNumberOfEntries() * 80 + 50; + char* buffer = (char*)malloc(bufferSize); + memset(buffer, 0, bufferSize); + strcpy(buffer, "{"); + return buffer; + }, + pagedVectorPtr); + + auto pointCounter = nautilus::val(0); + + const auto endIt = pagedVectorRef.end(allFieldNames); + for (auto candidateIt = pagedVectorRef.begin(allFieldNames); candidateIt != endIt; ++candidateIt) + { + const auto itemRecord = *candidateIt; + + const auto valueRaw = itemRecord.read(std::string(ValueFieldName)); + const auto timestampRaw = itemRecord.read(std::string(TimestampFieldName)); + + auto value = valueRaw.cast>(); + auto timestamp = timestampRaw.cast>(); + + sequenceStr = nautilus::invoke( + +[](char* buffer, int32_t valueVal, int64_t tsVal, int64_t counter) -> char* + { + if (counter > 0) { + strcat(buffer, ", "); + } + + long long adjustedTime; + if (tsVal > 1000000000000LL) { + adjustedTime = tsVal / 1000; + } else { + adjustedTime = tsVal; + } + + std::string timestampString = MEOS::Meos::convertSecondsToTimestamp(adjustedTime); + const char* timestampStr = timestampString.c_str(); + + char itemStr[80]; + sprintf(itemStr, "%d@%s", valueVal, timestampStr); + strcat(buffer, itemStr); + return buffer; + }, + sequenceStr, + value, + timestamp, + pointCounter); + + pointCounter = pointCounter + nautilus::val(1); + } + + sequenceStr = nautilus::invoke( + +[](char* buffer) -> char* + { + strcat(buffer, "}"); + return buffer; + }, + sequenceStr); + + auto resultValue = nautilus::invoke( + +[](const char* seqStr) -> int + { + if (!seqStr || strlen(seqStr) == 0) { + free((void*)seqStr); + return (int)0; + } + + std::lock_guard lock(meos_temporaltintstartvalue_mutex); + + Temporal* temp = tint_in(seqStr); + if (!temp) { + free((void*)seqStr); + return (int)0; + } + + int value = tint_start_value(temp); + + free(temp); + free((void*)seqStr); + return value; + }, + sequenceStr); + + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, resultValue); + return resultRecord; +} + +void TemporalTIntStartValueAggregationPhysicalFunction::reset(const nautilus::val aggregationState, PipelineMemoryProvider&) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + new (pagedVector) Nautilus::Interface::PagedVector(); + }, + aggregationState); +} + +size_t TemporalTIntStartValueAggregationPhysicalFunction::getSizeOfStateInBytes() const +{ + return sizeof(Nautilus::Interface::PagedVector); +} + +void TemporalTIntStartValueAggregationPhysicalFunction::cleanup(nautilus::val aggregationState) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + pagedVector->~PagedVector(); + }, + aggregationState); +} + + +AggregationPhysicalFunctionRegistryReturnType AggregationPhysicalFunctionGeneratedRegistrar::RegisterTemporalTIntStartValueAggregationPhysicalFunction( + AggregationPhysicalFunctionRegistryArguments) +{ + throw std::runtime_error("TemporalTIntStartValue aggregation cannot be created through the registry. " + "It requires two field functions (value, timestamp)"); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTNumberIntegralAggregationPhysicalFunction.cpp b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTNumberIntegralAggregationPhysicalFunction.cpp new file mode 100644 index 0000000000..6a409c85f7 --- /dev/null +++ b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTNumberIntegralAggregationPhysicalFunction.cpp @@ -0,0 +1,250 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +extern "C" { +#include +} + +namespace NES +{ + +constexpr static std::string_view ValueFieldName = "value"; +constexpr static std::string_view TimestampFieldName = "timestamp"; + +static std::mutex meos_temporaltnumberintegral_mutex; + + +TemporalTNumberIntegralAggregationPhysicalFunction::TemporalTNumberIntegralAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction valueFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef) + : AggregationPhysicalFunction(std::move(inputType), std::move(resultType), valueFunctionParam, std::move(resultFieldIdentifier)) + , bufferRef(std::move(bufferRef)) + , valueFunction(std::move(valueFunctionParam)) + , timestampFunction(std::move(timestampFunctionParam)) +{ +} + +void TemporalTNumberIntegralAggregationPhysicalFunction::lift( + const nautilus::val& aggregationState, PipelineMemoryProvider& pipelineMemoryProvider, const Nautilus::Record& record) +{ + const auto pagedVectorPtr = static_cast>(aggregationState); + + auto valueValue = valueFunction.execute(record, pipelineMemoryProvider.arena); + auto timestampValue = timestampFunction.execute(record, pipelineMemoryProvider.arena); + + Record aggregateStateRecord({ + {std::string(ValueFieldName), valueValue}, + {std::string(TimestampFieldName), timestampValue} + }); + + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + pagedVectorRef.writeRecord(aggregateStateRecord, pipelineMemoryProvider.bufferProvider); +} + +void TemporalTNumberIntegralAggregationPhysicalFunction::combine( + const nautilus::val aggregationState1, + const nautilus::val aggregationState2, + PipelineMemoryProvider&) +{ + const auto memArea1 = static_cast>(aggregationState1); + const auto memArea2 = static_cast>(aggregationState2); + + nautilus::invoke( + +[](Nautilus::Interface::PagedVector* vector1, const Nautilus::Interface::PagedVector* vector2) -> void + { vector1->copyFrom(*vector2); }, + memArea1, + memArea2); +} + +Nautilus::Record TemporalTNumberIntegralAggregationPhysicalFunction::lower( + const nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) +{ + MEOS::Meos::ensureMeosInitialized(); + + const auto pagedVectorPtr = static_cast>(aggregationState); + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + const auto allFieldNames = bufferRef->getMemoryLayout()->getSchema().getFieldNames(); + const auto numberOfEntries = invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) + { + return pagedVector->getTotalNumberOfEntries(); + }, + pagedVectorPtr); + + if (numberOfEntries == nautilus::val(0)) { + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, nautilus::val(0)); + return resultRecord; + } + + auto sequenceStr = nautilus::invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) -> char* + { + size_t bufferSize = pagedVector->getTotalNumberOfEntries() * 80 + 50; + char* buffer = (char*)malloc(bufferSize); + memset(buffer, 0, bufferSize); + strcpy(buffer, "{"); + return buffer; + }, + pagedVectorPtr); + + auto pointCounter = nautilus::val(0); + + const auto endIt = pagedVectorRef.end(allFieldNames); + for (auto candidateIt = pagedVectorRef.begin(allFieldNames); candidateIt != endIt; ++candidateIt) + { + const auto itemRecord = *candidateIt; + + const auto valueRaw = itemRecord.read(std::string(ValueFieldName)); + const auto timestampRaw = itemRecord.read(std::string(TimestampFieldName)); + + auto value = valueRaw.cast>(); + auto timestamp = timestampRaw.cast>(); + + sequenceStr = nautilus::invoke( + +[](char* buffer, double valueVal, int64_t tsVal, int64_t counter) -> char* + { + if (counter > 0) { + strcat(buffer, ", "); + } + + long long adjustedTime; + if (tsVal > 1000000000000LL) { + adjustedTime = tsVal / 1000; + } else { + adjustedTime = tsVal; + } + + std::string timestampString = MEOS::Meos::convertSecondsToTimestamp(adjustedTime); + const char* timestampStr = timestampString.c_str(); + + char itemStr[80]; + sprintf(itemStr, "%.6f@%s", valueVal, timestampStr); + strcat(buffer, itemStr); + return buffer; + }, + sequenceStr, + value, + timestamp, + pointCounter); + + pointCounter = pointCounter + nautilus::val(1); + } + + sequenceStr = nautilus::invoke( + +[](char* buffer) -> char* + { + strcat(buffer, "}"); + return buffer; + }, + sequenceStr); + + auto resultValue = nautilus::invoke( + +[](const char* seqStr) -> double + { + if (!seqStr || strlen(seqStr) == 0) { + free((void*)seqStr); + return (double)0; + } + + std::lock_guard lock(meos_temporaltnumberintegral_mutex); + + Temporal* temp = tfloat_in(seqStr); + if (!temp) { + free((void*)seqStr); + return (double)0; + } + + double value = tnumber_integral(temp); + + free(temp); + free((void*)seqStr); + return value; + }, + sequenceStr); + + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, resultValue); + return resultRecord; +} + +void TemporalTNumberIntegralAggregationPhysicalFunction::reset(const nautilus::val aggregationState, PipelineMemoryProvider&) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + new (pagedVector) Nautilus::Interface::PagedVector(); + }, + aggregationState); +} + +size_t TemporalTNumberIntegralAggregationPhysicalFunction::getSizeOfStateInBytes() const +{ + return sizeof(Nautilus::Interface::PagedVector); +} + +void TemporalTNumberIntegralAggregationPhysicalFunction::cleanup(nautilus::val aggregationState) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + pagedVector->~PagedVector(); + }, + aggregationState); +} + + +AggregationPhysicalFunctionRegistryReturnType AggregationPhysicalFunctionGeneratedRegistrar::RegisterTemporalTNumberIntegralAggregationPhysicalFunction( + AggregationPhysicalFunctionRegistryArguments) +{ + throw std::runtime_error("TemporalTNumberIntegral aggregation cannot be created through the registry. " + "It requires two field functions (value, timestamp)"); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTNumberTwAvgAggregationPhysicalFunction.cpp b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTNumberTwAvgAggregationPhysicalFunction.cpp new file mode 100644 index 0000000000..603dad68d9 --- /dev/null +++ b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTNumberTwAvgAggregationPhysicalFunction.cpp @@ -0,0 +1,250 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +extern "C" { +#include +} + +namespace NES +{ + +constexpr static std::string_view ValueFieldName = "value"; +constexpr static std::string_view TimestampFieldName = "timestamp"; + +static std::mutex meos_temporaltnumbertwavg_mutex; + + +TemporalTNumberTwAvgAggregationPhysicalFunction::TemporalTNumberTwAvgAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction valueFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef) + : AggregationPhysicalFunction(std::move(inputType), std::move(resultType), valueFunctionParam, std::move(resultFieldIdentifier)) + , bufferRef(std::move(bufferRef)) + , valueFunction(std::move(valueFunctionParam)) + , timestampFunction(std::move(timestampFunctionParam)) +{ +} + +void TemporalTNumberTwAvgAggregationPhysicalFunction::lift( + const nautilus::val& aggregationState, PipelineMemoryProvider& pipelineMemoryProvider, const Nautilus::Record& record) +{ + const auto pagedVectorPtr = static_cast>(aggregationState); + + auto valueValue = valueFunction.execute(record, pipelineMemoryProvider.arena); + auto timestampValue = timestampFunction.execute(record, pipelineMemoryProvider.arena); + + Record aggregateStateRecord({ + {std::string(ValueFieldName), valueValue}, + {std::string(TimestampFieldName), timestampValue} + }); + + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + pagedVectorRef.writeRecord(aggregateStateRecord, pipelineMemoryProvider.bufferProvider); +} + +void TemporalTNumberTwAvgAggregationPhysicalFunction::combine( + const nautilus::val aggregationState1, + const nautilus::val aggregationState2, + PipelineMemoryProvider&) +{ + const auto memArea1 = static_cast>(aggregationState1); + const auto memArea2 = static_cast>(aggregationState2); + + nautilus::invoke( + +[](Nautilus::Interface::PagedVector* vector1, const Nautilus::Interface::PagedVector* vector2) -> void + { vector1->copyFrom(*vector2); }, + memArea1, + memArea2); +} + +Nautilus::Record TemporalTNumberTwAvgAggregationPhysicalFunction::lower( + const nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) +{ + MEOS::Meos::ensureMeosInitialized(); + + const auto pagedVectorPtr = static_cast>(aggregationState); + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + const auto allFieldNames = bufferRef->getMemoryLayout()->getSchema().getFieldNames(); + const auto numberOfEntries = invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) + { + return pagedVector->getTotalNumberOfEntries(); + }, + pagedVectorPtr); + + if (numberOfEntries == nautilus::val(0)) { + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, nautilus::val(0)); + return resultRecord; + } + + auto sequenceStr = nautilus::invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) -> char* + { + size_t bufferSize = pagedVector->getTotalNumberOfEntries() * 80 + 50; + char* buffer = (char*)malloc(bufferSize); + memset(buffer, 0, bufferSize); + strcpy(buffer, "{"); + return buffer; + }, + pagedVectorPtr); + + auto pointCounter = nautilus::val(0); + + const auto endIt = pagedVectorRef.end(allFieldNames); + for (auto candidateIt = pagedVectorRef.begin(allFieldNames); candidateIt != endIt; ++candidateIt) + { + const auto itemRecord = *candidateIt; + + const auto valueRaw = itemRecord.read(std::string(ValueFieldName)); + const auto timestampRaw = itemRecord.read(std::string(TimestampFieldName)); + + auto value = valueRaw.cast>(); + auto timestamp = timestampRaw.cast>(); + + sequenceStr = nautilus::invoke( + +[](char* buffer, double valueVal, int64_t tsVal, int64_t counter) -> char* + { + if (counter > 0) { + strcat(buffer, ", "); + } + + long long adjustedTime; + if (tsVal > 1000000000000LL) { + adjustedTime = tsVal / 1000; + } else { + adjustedTime = tsVal; + } + + std::string timestampString = MEOS::Meos::convertSecondsToTimestamp(adjustedTime); + const char* timestampStr = timestampString.c_str(); + + char itemStr[80]; + sprintf(itemStr, "%.6f@%s", valueVal, timestampStr); + strcat(buffer, itemStr); + return buffer; + }, + sequenceStr, + value, + timestamp, + pointCounter); + + pointCounter = pointCounter + nautilus::val(1); + } + + sequenceStr = nautilus::invoke( + +[](char* buffer) -> char* + { + strcat(buffer, "}"); + return buffer; + }, + sequenceStr); + + auto resultValue = nautilus::invoke( + +[](const char* seqStr) -> double + { + if (!seqStr || strlen(seqStr) == 0) { + free((void*)seqStr); + return (double)0; + } + + std::lock_guard lock(meos_temporaltnumbertwavg_mutex); + + Temporal* temp = tfloat_in(seqStr); + if (!temp) { + free((void*)seqStr); + return (double)0; + } + + double value = tnumber_twavg(temp); + + free(temp); + free((void*)seqStr); + return value; + }, + sequenceStr); + + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, resultValue); + return resultRecord; +} + +void TemporalTNumberTwAvgAggregationPhysicalFunction::reset(const nautilus::val aggregationState, PipelineMemoryProvider&) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + new (pagedVector) Nautilus::Interface::PagedVector(); + }, + aggregationState); +} + +size_t TemporalTNumberTwAvgAggregationPhysicalFunction::getSizeOfStateInBytes() const +{ + return sizeof(Nautilus::Interface::PagedVector); +} + +void TemporalTNumberTwAvgAggregationPhysicalFunction::cleanup(nautilus::val aggregationState) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + pagedVector->~PagedVector(); + }, + aggregationState); +} + + +AggregationPhysicalFunctionRegistryReturnType AggregationPhysicalFunctionGeneratedRegistrar::RegisterTemporalTNumberTwAvgAggregationPhysicalFunction( + AggregationPhysicalFunctionRegistryArguments) +{ + throw std::runtime_error("TemporalTNumberTwAvg aggregation cannot be created through the registry. " + "It requires two field functions (value, timestamp)"); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTPointIsSimpleAggregationPhysicalFunction.cpp b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTPointIsSimpleAggregationPhysicalFunction.cpp new file mode 100644 index 0000000000..e83703a864 --- /dev/null +++ b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalTPointIsSimpleAggregationPhysicalFunction.cpp @@ -0,0 +1,260 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +extern "C" { +#include +#include +} + +namespace NES +{ + +constexpr static std::string_view LonFieldName = "lon"; +constexpr static std::string_view LatFieldName = "lat"; +constexpr static std::string_view TimestampFieldName = "timestamp"; + +static std::mutex meos_temporaltpointissimple_mutex; + + +TemporalTPointIsSimpleAggregationPhysicalFunction::TemporalTPointIsSimpleAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction lonFunctionParam, + PhysicalFunction latFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef) + : AggregationPhysicalFunction(std::move(inputType), std::move(resultType), lonFunctionParam, std::move(resultFieldIdentifier)) + , bufferRef(std::move(bufferRef)) + , lonFunction(std::move(lonFunctionParam)) + , latFunction(std::move(latFunctionParam)) + , timestampFunction(std::move(timestampFunctionParam)) +{ +} + +void TemporalTPointIsSimpleAggregationPhysicalFunction::lift( + const nautilus::val& aggregationState, PipelineMemoryProvider& pipelineMemoryProvider, const Nautilus::Record& record) +{ + const auto pagedVectorPtr = static_cast>(aggregationState); + + auto lonValue = lonFunction.execute(record, pipelineMemoryProvider.arena); + auto latValue = latFunction.execute(record, pipelineMemoryProvider.arena); + auto timestampValue = timestampFunction.execute(record, pipelineMemoryProvider.arena); + + Record aggregateStateRecord({ + {std::string(LonFieldName), lonValue}, + {std::string(LatFieldName), latValue}, + {std::string(TimestampFieldName), timestampValue} + }); + + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + pagedVectorRef.writeRecord(aggregateStateRecord, pipelineMemoryProvider.bufferProvider); +} + +void TemporalTPointIsSimpleAggregationPhysicalFunction::combine( + const nautilus::val aggregationState1, + const nautilus::val aggregationState2, + PipelineMemoryProvider&) +{ + const auto memArea1 = static_cast>(aggregationState1); + const auto memArea2 = static_cast>(aggregationState2); + + nautilus::invoke( + +[](Nautilus::Interface::PagedVector* vector1, const Nautilus::Interface::PagedVector* vector2) -> void + { vector1->copyFrom(*vector2); }, + memArea1, + memArea2); +} + +Nautilus::Record TemporalTPointIsSimpleAggregationPhysicalFunction::lower( + const nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) +{ + MEOS::Meos::ensureMeosInitialized(); + + const auto pagedVectorPtr = static_cast>(aggregationState); + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + const auto allFieldNames = bufferRef->getMemoryLayout()->getSchema().getFieldNames(); + const auto numberOfEntries = invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) + { + return pagedVector->getTotalNumberOfEntries(); + }, + pagedVectorPtr); + + if (numberOfEntries == nautilus::val(0)) { + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, nautilus::val(0)); + return resultRecord; + } + + auto trajectoryStr = nautilus::invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) -> char* + { + size_t bufferSize = pagedVector->getTotalNumberOfEntries() * 150 + 50; + char* buffer = (char*)malloc(bufferSize); + memset(buffer, 0, bufferSize); + strcpy(buffer, "{"); + return buffer; + }, + pagedVectorPtr); + + auto pointCounter = nautilus::val(0); + + const auto endIt = pagedVectorRef.end(allFieldNames); + for (auto candidateIt = pagedVectorRef.begin(allFieldNames); candidateIt != endIt; ++candidateIt) + { + const auto itemRecord = *candidateIt; + + const auto lonValue = itemRecord.read(std::string(LonFieldName)); + const auto latValue = itemRecord.read(std::string(LatFieldName)); + const auto timestampValue = itemRecord.read(std::string(TimestampFieldName)); + + auto lon = lonValue.cast>(); + auto lat = latValue.cast>(); + auto timestamp = timestampValue.cast>(); + + trajectoryStr = nautilus::invoke( + +[](char* buffer, double lonVal, double latVal, int64_t tsVal, int64_t counter) -> char* + { + if (counter > 0) { + strcat(buffer, ", "); + } + + long long adjustedTime; + if (tsVal > 1000000000000LL) { + adjustedTime = tsVal / 1000; + } else { + adjustedTime = tsVal; + } + + std::string timestampString = MEOS::Meos::convertSecondsToTimestamp(adjustedTime); + const char* timestampStr = timestampString.c_str(); + + char pointStr[120]; + sprintf(pointStr, "Point(%.6f %.6f)@%s", lonVal, latVal, timestampStr); + strcat(buffer, pointStr); + return buffer; + }, + trajectoryStr, + lon, + lat, + timestamp, + pointCounter); + + pointCounter = pointCounter + nautilus::val(1); + } + + trajectoryStr = nautilus::invoke( + +[](char* buffer) -> char* + { + strcat(buffer, "}"); + return buffer; + }, + trajectoryStr); + + auto resultValue = nautilus::invoke( + +[](const char* trajStr) -> bool + { + if (!trajStr || strlen(trajStr) == 0) { + free((void*)trajStr); + return (bool)0; + } + + std::lock_guard lock(meos_temporaltpointissimple_mutex); + + std::string trajString(trajStr); + void* temp = MEOS::Meos::parseTemporalPoint(trajString); + if (!temp) { + free((void*)trajStr); + return (bool)0; + } + + bool value = tpoint_is_simple(static_cast(temp)); + + MEOS::Meos::freeTemporalObject(temp); + free((void*)trajStr); + return value; + }, + trajectoryStr); + + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, resultValue); + return resultRecord; +} + +void TemporalTPointIsSimpleAggregationPhysicalFunction::reset(const nautilus::val aggregationState, PipelineMemoryProvider&) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + new (pagedVector) Nautilus::Interface::PagedVector(); + }, + aggregationState); +} + +size_t TemporalTPointIsSimpleAggregationPhysicalFunction::getSizeOfStateInBytes() const +{ + return sizeof(Nautilus::Interface::PagedVector); +} + +void TemporalTPointIsSimpleAggregationPhysicalFunction::cleanup(nautilus::val aggregationState) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + pagedVector->~PagedVector(); + }, + aggregationState); +} + + +AggregationPhysicalFunctionRegistryReturnType AggregationPhysicalFunctionGeneratedRegistrar::RegisterTemporalTPointIsSimpleAggregationPhysicalFunction( + AggregationPhysicalFunctionRegistryArguments) +{ + throw std::runtime_error("TemporalTPointIsSimple aggregation cannot be created through the registry. " + "It requires three field functions (longitude, latitude, timestamp)"); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Aggregation/Function/Meos/TemporalUpperIncAggregationPhysicalFunction.cpp b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalUpperIncAggregationPhysicalFunction.cpp new file mode 100644 index 0000000000..a8198aae08 --- /dev/null +++ b/nes-physical-operators/src/Aggregation/Function/Meos/TemporalUpperIncAggregationPhysicalFunction.cpp @@ -0,0 +1,260 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +extern "C" { +#include +#include +} + +namespace NES +{ + +constexpr static std::string_view LonFieldName = "lon"; +constexpr static std::string_view LatFieldName = "lat"; +constexpr static std::string_view TimestampFieldName = "timestamp"; + +static std::mutex meos_temporalupperinc_mutex; + + +TemporalUpperIncAggregationPhysicalFunction::TemporalUpperIncAggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction lonFunctionParam, + PhysicalFunction latFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef) + : AggregationPhysicalFunction(std::move(inputType), std::move(resultType), lonFunctionParam, std::move(resultFieldIdentifier)) + , bufferRef(std::move(bufferRef)) + , lonFunction(std::move(lonFunctionParam)) + , latFunction(std::move(latFunctionParam)) + , timestampFunction(std::move(timestampFunctionParam)) +{ +} + +void TemporalUpperIncAggregationPhysicalFunction::lift( + const nautilus::val& aggregationState, PipelineMemoryProvider& pipelineMemoryProvider, const Nautilus::Record& record) +{ + const auto pagedVectorPtr = static_cast>(aggregationState); + + auto lonValue = lonFunction.execute(record, pipelineMemoryProvider.arena); + auto latValue = latFunction.execute(record, pipelineMemoryProvider.arena); + auto timestampValue = timestampFunction.execute(record, pipelineMemoryProvider.arena); + + Record aggregateStateRecord({ + {std::string(LonFieldName), lonValue}, + {std::string(LatFieldName), latValue}, + {std::string(TimestampFieldName), timestampValue} + }); + + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + pagedVectorRef.writeRecord(aggregateStateRecord, pipelineMemoryProvider.bufferProvider); +} + +void TemporalUpperIncAggregationPhysicalFunction::combine( + const nautilus::val aggregationState1, + const nautilus::val aggregationState2, + PipelineMemoryProvider&) +{ + const auto memArea1 = static_cast>(aggregationState1); + const auto memArea2 = static_cast>(aggregationState2); + + nautilus::invoke( + +[](Nautilus::Interface::PagedVector* vector1, const Nautilus::Interface::PagedVector* vector2) -> void + { vector1->copyFrom(*vector2); }, + memArea1, + memArea2); +} + +Nautilus::Record TemporalUpperIncAggregationPhysicalFunction::lower( + const nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) +{ + MEOS::Meos::ensureMeosInitialized(); + + const auto pagedVectorPtr = static_cast>(aggregationState); + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + const auto allFieldNames = bufferRef->getMemoryLayout()->getSchema().getFieldNames(); + const auto numberOfEntries = invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) + { + return pagedVector->getTotalNumberOfEntries(); + }, + pagedVectorPtr); + + if (numberOfEntries == nautilus::val(0)) { + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, nautilus::val(0)); + return resultRecord; + } + + auto trajectoryStr = nautilus::invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) -> char* + { + size_t bufferSize = pagedVector->getTotalNumberOfEntries() * 150 + 50; + char* buffer = (char*)malloc(bufferSize); + memset(buffer, 0, bufferSize); + strcpy(buffer, "{"); + return buffer; + }, + pagedVectorPtr); + + auto pointCounter = nautilus::val(0); + + const auto endIt = pagedVectorRef.end(allFieldNames); + for (auto candidateIt = pagedVectorRef.begin(allFieldNames); candidateIt != endIt; ++candidateIt) + { + const auto itemRecord = *candidateIt; + + const auto lonValue = itemRecord.read(std::string(LonFieldName)); + const auto latValue = itemRecord.read(std::string(LatFieldName)); + const auto timestampValue = itemRecord.read(std::string(TimestampFieldName)); + + auto lon = lonValue.cast>(); + auto lat = latValue.cast>(); + auto timestamp = timestampValue.cast>(); + + trajectoryStr = nautilus::invoke( + +[](char* buffer, double lonVal, double latVal, int64_t tsVal, int64_t counter) -> char* + { + if (counter > 0) { + strcat(buffer, ", "); + } + + long long adjustedTime; + if (tsVal > 1000000000000LL) { + adjustedTime = tsVal / 1000; + } else { + adjustedTime = tsVal; + } + + std::string timestampString = MEOS::Meos::convertSecondsToTimestamp(adjustedTime); + const char* timestampStr = timestampString.c_str(); + + char pointStr[120]; + sprintf(pointStr, "Point(%.6f %.6f)@%s", lonVal, latVal, timestampStr); + strcat(buffer, pointStr); + return buffer; + }, + trajectoryStr, + lon, + lat, + timestamp, + pointCounter); + + pointCounter = pointCounter + nautilus::val(1); + } + + trajectoryStr = nautilus::invoke( + +[](char* buffer) -> char* + { + strcat(buffer, "}"); + return buffer; + }, + trajectoryStr); + + auto resultValue = nautilus::invoke( + +[](const char* trajStr) -> bool + { + if (!trajStr || strlen(trajStr) == 0) { + free((void*)trajStr); + return (bool)0; + } + + std::lock_guard lock(meos_temporalupperinc_mutex); + + std::string trajString(trajStr); + void* temp = MEOS::Meos::parseTemporalPoint(trajString); + if (!temp) { + free((void*)trajStr); + return (bool)0; + } + + bool value = temporal_upper_inc(static_cast(temp)); + + MEOS::Meos::freeTemporalObject(temp); + free((void*)trajStr); + return value; + }, + trajectoryStr); + + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, resultValue); + return resultRecord; +} + +void TemporalUpperIncAggregationPhysicalFunction::reset(const nautilus::val aggregationState, PipelineMemoryProvider&) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + new (pagedVector) Nautilus::Interface::PagedVector(); + }, + aggregationState); +} + +size_t TemporalUpperIncAggregationPhysicalFunction::getSizeOfStateInBytes() const +{ + return sizeof(Nautilus::Interface::PagedVector); +} + +void TemporalUpperIncAggregationPhysicalFunction::cleanup(nautilus::val aggregationState) +{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + { + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + pagedVector->~PagedVector(); + }, + aggregationState); +} + + +AggregationPhysicalFunctionRegistryReturnType AggregationPhysicalFunctionGeneratedRegistrar::RegisterTemporalUpperIncAggregationPhysicalFunction( + AggregationPhysicalFunctionRegistryArguments) +{ + throw std::runtime_error("TemporalUpperInc aggregation cannot be created through the registry. " + "It requires three field functions (longitude, latitude, timestamp)"); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 516cdce4c3..1201563d56 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -16,3 +16,98 @@ add_plugin(TemporalAIntersectsGeometry PhysicalFunction nes-physical-operators T add_plugin(TemporalEContainsGeometry PhysicalFunction nes-physical-operators TemporalEContainsGeometryPhysicalFunction.cpp) add_plugin(TemporalEDWithinGeometry PhysicalFunction nes-physical-operators TemporalEDWithinGeometryPhysicalFunction.cpp) add_plugin(TemporalAtStBox PhysicalFunction nes-physical-operators TemporalAtStBoxPhysicalFunction.cpp) +add_plugin(TemporalEDisjointGeometry PhysicalFunction nes-physical-operators TemporalEDisjointGeometryPhysicalFunction.cpp) +add_plugin(TemporalATouchesGeometry PhysicalFunction nes-physical-operators TemporalATouchesGeometryPhysicalFunction.cpp) +add_plugin(TemporalECoversGeometry PhysicalFunction nes-physical-operators TemporalECoversGeometryPhysicalFunction.cpp) +add_plugin(TemporalAContainsGeometry PhysicalFunction nes-physical-operators TemporalAContainsGeometryPhysicalFunction.cpp) +add_plugin(TemporalETouchesGeometry PhysicalFunction nes-physical-operators TemporalETouchesGeometryPhysicalFunction.cpp) +add_plugin(TemporalADisjointGeometry PhysicalFunction nes-physical-operators TemporalADisjointGeometryPhysicalFunction.cpp) +add_plugin(TemporalEIntersectsGeometry PhysicalFunction nes-physical-operators TemporalEIntersectsGeometryPhysicalFunction.cpp) +add_plugin(TemporalEContainsTGeometry PhysicalFunction nes-physical-operators TemporalEContainsTGeometryPhysicalFunction.cpp) +add_plugin(TemporalECoversTGeometry PhysicalFunction nes-physical-operators TemporalECoversTGeometryPhysicalFunction.cpp) +add_plugin(TemporalEDisjointTGeometry PhysicalFunction nes-physical-operators TemporalEDisjointTGeometryPhysicalFunction.cpp) +add_plugin(TemporalEIntersectsTGeometry PhysicalFunction nes-physical-operators TemporalEIntersectsTGeometryPhysicalFunction.cpp) +add_plugin(TemporalETouchesTGeometry PhysicalFunction nes-physical-operators TemporalETouchesTGeometryPhysicalFunction.cpp) +add_plugin(TemporalAContainsTGeometry PhysicalFunction nes-physical-operators TemporalAContainsTGeometryPhysicalFunction.cpp) +add_plugin(TemporalADisjointTGeometry PhysicalFunction nes-physical-operators TemporalADisjointTGeometryPhysicalFunction.cpp) +add_plugin(TemporalAIntersectsTGeometry PhysicalFunction nes-physical-operators TemporalAIntersectsTGeometryPhysicalFunction.cpp) +add_plugin(TemporalATouchesTGeometry PhysicalFunction nes-physical-operators TemporalATouchesTGeometryPhysicalFunction.cpp) +add_plugin(TemporalNADGeometry PhysicalFunction nes-physical-operators TemporalNADGeometryPhysicalFunction.cpp) +add_plugin(TemporalNADTGeometry PhysicalFunction nes-physical-operators TemporalNADTGeometryPhysicalFunction.cpp) +add_plugin(TemporalEDWithinTGeometry PhysicalFunction nes-physical-operators TemporalEDWithinTGeometryPhysicalFunction.cpp) +add_plugin(TemporalADWithinGeometry PhysicalFunction nes-physical-operators TemporalADWithinGeometryPhysicalFunction.cpp) +add_plugin(TemporalADWithinTGeometry PhysicalFunction nes-physical-operators TemporalADWithinTGeometryPhysicalFunction.cpp) +add_plugin(TemporalNADFloatScalar PhysicalFunction nes-physical-operators TemporalNADFloatScalarPhysicalFunction.cpp) +add_plugin(TemporalNADIntScalar PhysicalFunction nes-physical-operators TemporalNADIntScalarPhysicalFunction.cpp) +add_plugin(TemporalNADTFloat PhysicalFunction nes-physical-operators TemporalNADTFloatPhysicalFunction.cpp) +add_plugin(TemporalNADTInt PhysicalFunction nes-physical-operators TemporalNADTIntPhysicalFunction.cpp) +add_plugin(TemporalAtGeometry PhysicalFunction nes-physical-operators TemporalAtGeometryPhysicalFunction.cpp) +add_plugin(TemporalMinusGeometry PhysicalFunction nes-physical-operators TemporalMinusGeometryPhysicalFunction.cpp) +add_plugin(TemporalEContainsTCbuffer PhysicalFunction nes-physical-operators TemporalEContainsTCbufferPhysicalFunction.cpp) +add_plugin(TemporalECoversTCbuffer PhysicalFunction nes-physical-operators TemporalECoversTCbufferPhysicalFunction.cpp) +add_plugin(TemporalEDisjointTCbuffer PhysicalFunction nes-physical-operators TemporalEDisjointTCbufferPhysicalFunction.cpp) +add_plugin(TemporalEIntersectsTCbuffer PhysicalFunction nes-physical-operators TemporalEIntersectsTCbufferPhysicalFunction.cpp) +add_plugin(TemporalETouchesTCbuffer PhysicalFunction nes-physical-operators TemporalETouchesTCbufferPhysicalFunction.cpp) +add_plugin(TemporalAContainsTCbuffer PhysicalFunction nes-physical-operators TemporalAContainsTCbufferPhysicalFunction.cpp) +add_plugin(TemporalACoversTCbuffer PhysicalFunction nes-physical-operators TemporalACoversTCbufferPhysicalFunction.cpp) +add_plugin(TemporalADisjointTCbuffer PhysicalFunction nes-physical-operators TemporalADisjointTCbufferPhysicalFunction.cpp) +add_plugin(TemporalAIntersectsTCbuffer PhysicalFunction nes-physical-operators TemporalAIntersectsTCbufferPhysicalFunction.cpp) +add_plugin(TemporalATouchesTCbuffer PhysicalFunction nes-physical-operators TemporalATouchesTCbufferPhysicalFunction.cpp) +add_plugin(TemporalEContainsTCbufferCbuffer PhysicalFunction nes-physical-operators TemporalEContainsTCbufferCbufferPhysicalFunction.cpp) +add_plugin(TemporalECoversTCbufferCbuffer PhysicalFunction nes-physical-operators TemporalECoversTCbufferCbufferPhysicalFunction.cpp) +add_plugin(TemporalEDisjointTCbufferCbuffer PhysicalFunction nes-physical-operators TemporalEDisjointTCbufferCbufferPhysicalFunction.cpp) +add_plugin(TemporalEIntersectsTCbufferCbuffer PhysicalFunction nes-physical-operators TemporalEIntersectsTCbufferCbufferPhysicalFunction.cpp) +add_plugin(TemporalETouchesTCbufferCbuffer PhysicalFunction nes-physical-operators TemporalETouchesTCbufferCbufferPhysicalFunction.cpp) +add_plugin(TemporalAContainsTCbufferCbuffer PhysicalFunction nes-physical-operators TemporalAContainsTCbufferCbufferPhysicalFunction.cpp) +add_plugin(TemporalACoversTCbufferCbuffer PhysicalFunction nes-physical-operators TemporalACoversTCbufferCbufferPhysicalFunction.cpp) +add_plugin(TemporalADisjointTCbufferCbuffer PhysicalFunction nes-physical-operators TemporalADisjointTCbufferCbufferPhysicalFunction.cpp) +add_plugin(TemporalAIntersectsTCbufferCbuffer PhysicalFunction nes-physical-operators TemporalAIntersectsTCbufferCbufferPhysicalFunction.cpp) +add_plugin(TemporalATouchesTCbufferCbuffer PhysicalFunction nes-physical-operators TemporalATouchesTCbufferCbufferPhysicalFunction.cpp) +add_plugin(TemporalADisjointTCbufferTCbuffer PhysicalFunction nes-physical-operators TemporalADisjointTCbufferTCbufferPhysicalFunction.cpp) +add_plugin(TemporalAIntersectsTCbufferTCbuffer PhysicalFunction nes-physical-operators TemporalAIntersectsTCbufferTCbufferPhysicalFunction.cpp) +add_plugin(TemporalATouchesTCbufferTCbuffer PhysicalFunction nes-physical-operators TemporalATouchesTCbufferTCbufferPhysicalFunction.cpp) +add_plugin(TemporalECoversTCbufferTCbuffer PhysicalFunction nes-physical-operators TemporalECoversTCbufferTCbufferPhysicalFunction.cpp) +add_plugin(TemporalEIntersectsTCbufferTCbuffer PhysicalFunction nes-physical-operators TemporalEIntersectsTCbufferTCbufferPhysicalFunction.cpp) +add_plugin(TemporalETouchesTCbufferTCbuffer PhysicalFunction nes-physical-operators TemporalETouchesTCbufferTCbufferPhysicalFunction.cpp) +add_plugin(TemporalEDWithinTCbufferGeometry PhysicalFunction nes-physical-operators TemporalEDWithinTCbufferGeometryPhysicalFunction.cpp) +add_plugin(TemporalADWithinTCbufferGeometry PhysicalFunction nes-physical-operators TemporalADWithinTCbufferGeometryPhysicalFunction.cpp) +add_plugin(TemporalEDWithinTCbufferCbuffer PhysicalFunction nes-physical-operators TemporalEDWithinTCbufferCbufferPhysicalFunction.cpp) +add_plugin(TemporalADWithinTCbufferCbuffer PhysicalFunction nes-physical-operators TemporalADWithinTCbufferCbufferPhysicalFunction.cpp) +add_plugin(TemporalEDWithinTCbufferTCbuffer PhysicalFunction nes-physical-operators TemporalEDWithinTCbufferTCbufferPhysicalFunction.cpp) +add_plugin(TemporalADWithinTCbufferTCbuffer PhysicalFunction nes-physical-operators TemporalADWithinTCbufferTCbufferPhysicalFunction.cpp) +add_plugin(TemporalEContainsTPoseGeometry PhysicalFunction nes-physical-operators TemporalEContainsTPoseGeometryPhysicalFunction.cpp) +add_plugin(TemporalECoversTPoseGeometry PhysicalFunction nes-physical-operators TemporalECoversTPoseGeometryPhysicalFunction.cpp) +add_plugin(TemporalEDisjointTPoseGeometry PhysicalFunction nes-physical-operators TemporalEDisjointTPoseGeometryPhysicalFunction.cpp) +add_plugin(TemporalEIntersectsTPoseGeometry PhysicalFunction nes-physical-operators TemporalEIntersectsTPoseGeometryPhysicalFunction.cpp) +add_plugin(TemporalETouchesTPoseGeometry PhysicalFunction nes-physical-operators TemporalETouchesTPoseGeometryPhysicalFunction.cpp) +add_plugin(TemporalAContainsTPoseGeometry PhysicalFunction nes-physical-operators TemporalAContainsTPoseGeometryPhysicalFunction.cpp) +add_plugin(TemporalADisjointTPoseGeometry PhysicalFunction nes-physical-operators TemporalADisjointTPoseGeometryPhysicalFunction.cpp) +add_plugin(TemporalAIntersectsTPoseGeometry PhysicalFunction nes-physical-operators TemporalAIntersectsTPoseGeometryPhysicalFunction.cpp) +add_plugin(TemporalATouchesTPoseGeometry PhysicalFunction nes-physical-operators TemporalATouchesTPoseGeometryPhysicalFunction.cpp) +add_plugin(TemporalEContainsTPoseTPose PhysicalFunction nes-physical-operators TemporalEContainsTPoseTPosePhysicalFunction.cpp) +add_plugin(TemporalECoversTPoseTPose PhysicalFunction nes-physical-operators TemporalECoversTPoseTPosePhysicalFunction.cpp) +add_plugin(TemporalEDisjointTPoseTPose PhysicalFunction nes-physical-operators TemporalEDisjointTPoseTPosePhysicalFunction.cpp) +add_plugin(TemporalEIntersectsTPoseTPose PhysicalFunction nes-physical-operators TemporalEIntersectsTPoseTPosePhysicalFunction.cpp) +add_plugin(TemporalETouchesTPoseTPose PhysicalFunction nes-physical-operators TemporalETouchesTPoseTPosePhysicalFunction.cpp) +add_plugin(TemporalAContainsTPoseTPose PhysicalFunction nes-physical-operators TemporalAContainsTPoseTPosePhysicalFunction.cpp) +add_plugin(TemporalADisjointTPoseTPose PhysicalFunction nes-physical-operators TemporalADisjointTPoseTPosePhysicalFunction.cpp) +add_plugin(TemporalAIntersectsTPoseTPose PhysicalFunction nes-physical-operators TemporalAIntersectsTPoseTPosePhysicalFunction.cpp) +add_plugin(TemporalATouchesTPoseTPose PhysicalFunction nes-physical-operators TemporalATouchesTPoseTPosePhysicalFunction.cpp) +add_plugin(TemporalEContainsTNpointGeometry PhysicalFunction nes-physical-operators TemporalEContainsTNpointGeometryPhysicalFunction.cpp) +add_plugin(TemporalEContainsTNpointTNpoint PhysicalFunction nes-physical-operators TemporalEContainsTNpointTNpointPhysicalFunction.cpp) +add_plugin(TemporalECoversTNpointGeometry PhysicalFunction nes-physical-operators TemporalECoversTNpointGeometryPhysicalFunction.cpp) +add_plugin(TemporalECoversTNpointTNpoint PhysicalFunction nes-physical-operators TemporalECoversTNpointTNpointPhysicalFunction.cpp) +add_plugin(TemporalEDisjointTNpointGeometry PhysicalFunction nes-physical-operators TemporalEDisjointTNpointGeometryPhysicalFunction.cpp) +add_plugin(TemporalEDisjointTNpointTNpoint PhysicalFunction nes-physical-operators TemporalEDisjointTNpointTNpointPhysicalFunction.cpp) +add_plugin(TemporalEIntersectsTNpointGeometry PhysicalFunction nes-physical-operators TemporalEIntersectsTNpointGeometryPhysicalFunction.cpp) +add_plugin(TemporalEIntersectsTNpointTNpoint PhysicalFunction nes-physical-operators TemporalEIntersectsTNpointTNpointPhysicalFunction.cpp) +add_plugin(TemporalETouchesTNpointGeometry PhysicalFunction nes-physical-operators TemporalETouchesTNpointGeometryPhysicalFunction.cpp) +add_plugin(TemporalETouchesTNpointTNpoint PhysicalFunction nes-physical-operators TemporalETouchesTNpointTNpointPhysicalFunction.cpp) +add_plugin(TemporalAContainsTNpointGeometry PhysicalFunction nes-physical-operators TemporalAContainsTNpointGeometryPhysicalFunction.cpp) +add_plugin(TemporalAContainsTNpointTNpoint PhysicalFunction nes-physical-operators TemporalAContainsTNpointTNpointPhysicalFunction.cpp) +add_plugin(TemporalADisjointTNpointGeometry PhysicalFunction nes-physical-operators TemporalADisjointTNpointGeometryPhysicalFunction.cpp) +add_plugin(TemporalADisjointTNpointTNpoint PhysicalFunction nes-physical-operators TemporalADisjointTNpointTNpointPhysicalFunction.cpp) +add_plugin(TemporalAIntersectsTNpointGeometry PhysicalFunction nes-physical-operators TemporalAIntersectsTNpointGeometryPhysicalFunction.cpp) +add_plugin(TemporalAIntersectsTNpointTNpoint PhysicalFunction nes-physical-operators TemporalAIntersectsTNpointTNpointPhysicalFunction.cpp) +add_plugin(TemporalATouchesTNpointGeometry PhysicalFunction nes-physical-operators TemporalATouchesTNpointGeometryPhysicalFunction.cpp) +add_plugin(TemporalATouchesTNpointTNpoint PhysicalFunction nes-physical-operators TemporalATouchesTNpointTNpointPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/TemporalAContainsGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalAContainsGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..46dd387913 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalAContainsGeometryPhysicalFunction.cpp @@ -0,0 +1,124 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalAContainsGeometryPhysicalFunction::TemporalAContainsGeometryPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(4); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalAContainsGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto timestamp = parameterValues[2].cast>(); + auto geometry = parameterValues[3].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + uint64_t timestampValue, + const char* geometryPtr, + uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) { + return 0; + } + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string temporalGeometryWkt = fmt::format("SRID=4326;Point({} {})@{}", lonValue, latValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (temporalGeometryWkt.empty() || staticGeometryWkt.empty()) + return 0; + + MEOS::Meos::TemporalGeometry temporalGeometry(temporalGeometryWkt); + if (!temporalGeometry.getGeometry()) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) return 0; + + // MEOS spatial-relation call — same shape as TemporalEDWithin's + // edwithin_tgeo_geo, but specific MEOS function per generated operator. + // Real MEOS spatial-rel signature: int fn(const Temporal *, const GSERIALIZED *) + // (no `atstart` flag — that's specific to geog_dwithin / edwithin's 3-arg variant). + return acontains_tgeo_geo(temporalGeometry.getGeometry(), + staticGeometry.getGeometry()); + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalAContainsGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "TemporalAContainsGeometryPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + return TemporalAContainsGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalAContainsTCbufferCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalAContainsTCbufferCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..35ce6a2897 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalAContainsTCbufferCbufferPhysicalFunction.cpp @@ -0,0 +1,126 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalAContainsTCbufferCbufferPhysicalFunction::TemporalAContainsTCbufferCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction cbufferLitFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(radiusFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(cbufferLitFunction)); +} + +VarVal TemporalAContainsTCbufferCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto cbufLit = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + double radiusValue, + uint64_t timestampValue, + const char* cbufLitPtr, + uint32_t cbufLitSize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({} {}),{})@{}", + lonValue, latValue, radiusValue, timestampString); + std::string cbufferLiteral(cbufLitPtr, cbufLitSize); + + while (!cbufferLiteral.empty() && (cbufferLiteral.front() == '\'' || cbufferLiteral.front() == '"')) + cbufferLiteral.erase(cbufferLiteral.begin()); + while (!cbufferLiteral.empty() && (cbufferLiteral.back() == '\'' || cbufferLiteral.back() == '"')) + cbufferLiteral.pop_back(); + + if (tcbufferWkt.empty() || cbufferLiteral.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + Cbuffer* cb = cbuffer_in(cbufferLiteral.c_str()); + if (!cb) { free(tcbuffer); return 0; } + + int r = acontains_tcbuffer_cbuffer(tcbuffer, cb); + free(tcbuffer); + free(cb); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, radius, timestamp, cbufLit.getContent(), cbufLit.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalAContainsTCbufferCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalAContainsTCbufferCbufferPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalAContainsTCbufferCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalAContainsTCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalAContainsTCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..a3b52dfb06 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalAContainsTCbufferPhysicalFunction.cpp @@ -0,0 +1,125 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalAContainsTCbufferPhysicalFunction::TemporalAContainsTCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(radiusFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalAContainsTCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto geometry = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + double radiusValue, + uint64_t timestampValue, + const char* geometryPtr, + uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({} {}),{})@{}", + lonValue, latValue, radiusValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tcbufferWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tcbuffer); return 0; } + + int r = acontains_tcbuffer_geo(tcbuffer, staticGeometry.getGeometry()); + free(tcbuffer); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, radius, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalAContainsTCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalAContainsTCbufferPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalAContainsTCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalAContainsTGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalAContainsTGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..b1f3aaa9da --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalAContainsTGeometryPhysicalFunction.cpp @@ -0,0 +1,117 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalAContainsTGeometryPhysicalFunction::TemporalAContainsTGeometryPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(6); + parameterFunctions.push_back(std::move(lonAFunction)); + parameterFunctions.push_back(std::move(latAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(lonBFunction)); + parameterFunctions.push_back(std::move(latBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalAContainsTGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lonA = parameterValues[0].cast>(); + auto latA = parameterValues[1].cast>(); + auto tsA = parameterValues[2].cast>(); + auto lonB = parameterValues[3].cast>(); + auto latB = parameterValues[4].cast>(); + auto tsB = parameterValues[5].cast>(); + + const auto result = nautilus::invoke( + +[](double lonAValue, double latAValue, uint64_t tsAValue, + double lonBValue, double latBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonAValue >= -180.0 && lonAValue <= 180.0 && latAValue >= -90.0 && latAValue <= 90.0)) return 0; + if (!(lonBValue >= -180.0 && lonBValue <= 180.0 && latBValue >= -90.0 && latBValue <= 90.0)) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string temporalGeometryAWkt = fmt::format("SRID=4326;Point({} {})@{}", lonAValue, latAValue, tsAString); + std::string temporalGeometryBWkt = fmt::format("SRID=4326;Point({} {})@{}", lonBValue, latBValue, tsBString); + + MEOS::Meos::TemporalGeometry temporalGeometryA(temporalGeometryAWkt); + if (!temporalGeometryA.getGeometry()) return 0; + MEOS::Meos::TemporalGeometry temporalGeometryB(temporalGeometryBWkt); + if (!temporalGeometryB.getGeometry()) return 0; + + // MEOS *_tgeo_tgeo spatial-relation: int fn(const Temporal*, const Temporal*). + return acontains_tgeo_tgeo(temporalGeometryA.getGeometry(), + temporalGeometryB.getGeometry()); + } + catch (const std::exception&) + { + return 0; + } + }, + lonA, latA, tsA, lonB, latB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalAContainsTGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "TemporalAContainsTGeometryPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + return TemporalAContainsTGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalAContainsTNpointGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalAContainsTNpointGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..9117a27506 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalAContainsTNpointGeometryPhysicalFunction.cpp @@ -0,0 +1,118 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalAContainsTNpointGeometryPhysicalFunction::TemporalAContainsTNpointGeometryPhysicalFunction(PhysicalFunction ridFunction, + PhysicalFunction fractionFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(4); + parameterFunctions.push_back(std::move(ridFunction)); + parameterFunctions.push_back(std::move(fractionFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalAContainsTNpointGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto rid = parameterValues[0].cast>(); + auto fraction = parameterValues[1].cast>(); + auto timestamp = parameterValues[2].cast>(); + auto geometry = parameterValues[3].cast(); + + const auto result = nautilus::invoke( + +[](uint64_t ridValue, double fractionValue, uint64_t timestampValue, + const char* geometryPtr, uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tnpointWkt = fmt::format("NPoint({}, {})@{}", ridValue, fractionValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tnpointWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tnpoint = tnpoint_in(tnpointWkt.c_str()); + if (!tnpoint) return 0; + Temporal* tgeo = tnpoint_to_tgeompoint(tnpoint); + if (!tgeo) { free(tnpoint); return 0; } + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tgeo); free(tnpoint); return 0; } + + int r = acontains_tgeo_geo(tgeo, staticGeometry.getGeometry()); + free(tgeo); + free(tnpoint); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + rid, fraction, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalAContainsTNpointGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "TemporalAContainsTNpointGeometryPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + return TemporalAContainsTNpointGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalAContainsTNpointTNpointPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalAContainsTNpointTNpointPhysicalFunction.cpp new file mode 100644 index 0000000000..e347e885d8 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalAContainsTNpointTNpointPhysicalFunction.cpp @@ -0,0 +1,126 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalAContainsTNpointTNpointPhysicalFunction::TemporalAContainsTNpointTNpointPhysicalFunction(PhysicalFunction ridAFunction, + PhysicalFunction fractionAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction ridBFunction, + PhysicalFunction fractionBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(6); + parameterFunctions.push_back(std::move(ridAFunction)); + parameterFunctions.push_back(std::move(fractionAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(ridBFunction)); + parameterFunctions.push_back(std::move(fractionBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalAContainsTNpointTNpointPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto ridA = parameterValues[0].cast>(); + auto fractionA = parameterValues[1].cast>(); + auto tsA = parameterValues[2].cast>(); + auto ridB = parameterValues[3].cast>(); + auto fractionB = parameterValues[4].cast>(); + auto tsB = parameterValues[5].cast>(); + + const auto result = nautilus::invoke( + +[](uint64_t ridAValue, double fractionAValue, uint64_t tsAValue, + uint64_t ridBValue, double fractionBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string tnpointAWkt = fmt::format("NPoint({}, {})@{}", ridAValue, fractionAValue, tsAString); + std::string tnpointBWkt = fmt::format("NPoint({}, {})@{}", ridBValue, fractionBValue, tsBString); + + if (tnpointAWkt.empty() || tnpointBWkt.empty()) return 0; + + Temporal* tnpointA = tnpoint_in(tnpointAWkt.c_str()); + if (!tnpointA) return 0; + Temporal* tgeoA = tnpoint_to_tgeompoint(tnpointA); + if (!tgeoA) { free(tnpointA); return 0; } + Temporal* tnpointB = tnpoint_in(tnpointBWkt.c_str()); + if (!tnpointB) { free(tgeoA); free(tnpointA); return 0; } + Temporal* tgeoB = tnpoint_to_tgeompoint(tnpointB); + if (!tgeoB) { free(tnpointB); free(tgeoA); free(tnpointA); return 0; } + + int r = acontains_tgeo_tgeo(tgeoA, tgeoB); + free(tgeoB); + free(tnpointB); + free(tgeoA); + free(tnpointA); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + ridA, fractionA, tsA, ridB, fractionB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalAContainsTNpointTNpointPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "TemporalAContainsTNpointTNpointPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + return TemporalAContainsTNpointTNpointPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalAContainsTPoseGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalAContainsTPoseGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..6cfcceb550 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalAContainsTPoseGeometryPhysicalFunction.cpp @@ -0,0 +1,124 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalAContainsTPoseGeometryPhysicalFunction::TemporalAContainsTPoseGeometryPhysicalFunction(PhysicalFunction xFunction, + PhysicalFunction yFunction, + PhysicalFunction thetaFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(xFunction)); + parameterFunctions.push_back(std::move(yFunction)); + parameterFunctions.push_back(std::move(thetaFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalAContainsTPoseGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto x = parameterValues[0].cast>(); + auto y = parameterValues[1].cast>(); + auto theta = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto geometry = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double xValue, double yValue, double thetaValue, uint64_t timestampValue, + const char* geometryPtr, uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(xValue >= -180.0 && xValue <= 180.0 && yValue >= -90.0 && yValue <= 90.0)) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tposeWkt = fmt::format("Pose(Point({} {}), {})@{}", + xValue, yValue, thetaValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tposeWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tpose = tpose_in(tposeWkt.c_str()); + if (!tpose) return 0; + Temporal* tgeo = tpose_to_tpoint(tpose); + if (!tgeo) { free(tpose); return 0; } + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tgeo); free(tpose); return 0; } + + int r = acontains_tgeo_geo(tgeo, staticGeometry.getGeometry()); + free(tgeo); + free(tpose); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + x, y, theta, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalAContainsTPoseGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalAContainsTPoseGeometryPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalAContainsTPoseGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalAContainsTPoseTPosePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalAContainsTPoseTPosePhysicalFunction.cpp new file mode 100644 index 0000000000..4c41e64de6 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalAContainsTPoseTPosePhysicalFunction.cpp @@ -0,0 +1,136 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalAContainsTPoseTPosePhysicalFunction::TemporalAContainsTPoseTPosePhysicalFunction(PhysicalFunction xAFunction, + PhysicalFunction yAFunction, + PhysicalFunction thetaAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction xBFunction, + PhysicalFunction yBFunction, + PhysicalFunction thetaBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(8); + parameterFunctions.push_back(std::move(xAFunction)); + parameterFunctions.push_back(std::move(yAFunction)); + parameterFunctions.push_back(std::move(thetaAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(xBFunction)); + parameterFunctions.push_back(std::move(yBFunction)); + parameterFunctions.push_back(std::move(thetaBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalAContainsTPoseTPosePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto xA = parameterValues[0].cast>(); + auto yA = parameterValues[1].cast>(); + auto thetaA = parameterValues[2].cast>(); + auto tsA = parameterValues[3].cast>(); + auto xB = parameterValues[4].cast>(); + auto yB = parameterValues[5].cast>(); + auto thetaB = parameterValues[6].cast>(); + auto tsB = parameterValues[7].cast>(); + + const auto result = nautilus::invoke( + +[](double xAValue, double yAValue, double thetaAValue, uint64_t tsAValue, + double xBValue, double yBValue, double thetaBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(xAValue >= -180.0 && xAValue <= 180.0 && yAValue >= -90.0 && yAValue <= 90.0)) return 0; + if (!(xBValue >= -180.0 && xBValue <= 180.0 && yBValue >= -90.0 && yBValue <= 90.0)) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string tposeAWkt = fmt::format("Pose(Point({} {}), {})@{}", xAValue, yAValue, thetaAValue, tsAString); + std::string tposeBWkt = fmt::format("Pose(Point({} {}), {})@{}", xBValue, yBValue, thetaBValue, tsBString); + + if (tposeAWkt.empty() || tposeBWkt.empty()) return 0; + + Temporal* tposeA = tpose_in(tposeAWkt.c_str()); + if (!tposeA) return 0; + Temporal* tgeoA = tpose_to_tpoint(tposeA); + if (!tgeoA) { free(tposeA); return 0; } + Temporal* tposeB = tpose_in(tposeBWkt.c_str()); + if (!tposeB) { free(tgeoA); free(tposeA); return 0; } + Temporal* tgeoB = tpose_to_tpoint(tposeB); + if (!tgeoB) { free(tposeB); free(tgeoA); free(tposeA); return 0; } + + int r = acontains_tgeo_tgeo(tgeoA, tgeoB); + free(tgeoB); + free(tposeB); + free(tgeoA); + free(tposeA); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + xA, yA, thetaA, tsA, xB, yB, thetaB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalAContainsTPoseTPosePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "TemporalAContainsTPoseTPosePhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + auto arg6 = std::move(arguments.childFunctions[6]); + auto arg7 = std::move(arguments.childFunctions[7]); + return TemporalAContainsTPoseTPosePhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalACoversTCbufferCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalACoversTCbufferCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..46ba72cfb8 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalACoversTCbufferCbufferPhysicalFunction.cpp @@ -0,0 +1,126 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalACoversTCbufferCbufferPhysicalFunction::TemporalACoversTCbufferCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction cbufferLitFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(radiusFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(cbufferLitFunction)); +} + +VarVal TemporalACoversTCbufferCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto cbufLit = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + double radiusValue, + uint64_t timestampValue, + const char* cbufLitPtr, + uint32_t cbufLitSize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({} {}),{})@{}", + lonValue, latValue, radiusValue, timestampString); + std::string cbufferLiteral(cbufLitPtr, cbufLitSize); + + while (!cbufferLiteral.empty() && (cbufferLiteral.front() == '\'' || cbufferLiteral.front() == '"')) + cbufferLiteral.erase(cbufferLiteral.begin()); + while (!cbufferLiteral.empty() && (cbufferLiteral.back() == '\'' || cbufferLiteral.back() == '"')) + cbufferLiteral.pop_back(); + + if (tcbufferWkt.empty() || cbufferLiteral.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + Cbuffer* cb = cbuffer_in(cbufferLiteral.c_str()); + if (!cb) { free(tcbuffer); return 0; } + + int r = acovers_tcbuffer_cbuffer(tcbuffer, cb); + free(tcbuffer); + free(cb); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, radius, timestamp, cbufLit.getContent(), cbufLit.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalACoversTCbufferCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalACoversTCbufferCbufferPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalACoversTCbufferCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalACoversTCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalACoversTCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..2c4bc0dfd3 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalACoversTCbufferPhysicalFunction.cpp @@ -0,0 +1,125 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalACoversTCbufferPhysicalFunction::TemporalACoversTCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(radiusFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalACoversTCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto geometry = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + double radiusValue, + uint64_t timestampValue, + const char* geometryPtr, + uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({} {}),{})@{}", + lonValue, latValue, radiusValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tcbufferWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tcbuffer); return 0; } + + int r = acovers_tcbuffer_geo(tcbuffer, staticGeometry.getGeometry()); + free(tcbuffer); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, radius, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalACoversTCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalACoversTCbufferPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalACoversTCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalADWithinGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalADWithinGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..c7b624cae2 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalADWithinGeometryPhysicalFunction.cpp @@ -0,0 +1,125 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalADWithinGeometryPhysicalFunction::TemporalADWithinGeometryPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction, + PhysicalFunction distFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); + parameterFunctions.push_back(std::move(distFunction)); +} + +VarVal TemporalADWithinGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto timestamp = parameterValues[2].cast>(); + auto geometry = parameterValues[3].cast(); + auto dist = parameterValues[4].cast>(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + uint64_t timestampValue, + const char* geometryPtr, + uint32_t geometrySize, + double distValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string temporalGeometryWkt = fmt::format("SRID=4326;Point({} {})@{}", lonValue, latValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (temporalGeometryWkt.empty() || staticGeometryWkt.empty()) return 0; + + MEOS::Meos::TemporalGeometry temporalGeometry(temporalGeometryWkt); + if (!temporalGeometry.getGeometry()) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) return 0; + + // MEOS *_tgeo_geo with trailing distance arg + // — int fn(const Temporal*, const GSERIALIZED*, double). + return adwithin_tgeo_geo(temporalGeometry.getGeometry(), + staticGeometry.getGeometry(), + distValue); + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, timestamp, geometry.getContent(), geometry.getContentSize(), dist); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalADWithinGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalADWithinGeometryPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalADWithinGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalADWithinTCbufferCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalADWithinTCbufferCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..b8acf099e0 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalADWithinTCbufferCbufferPhysicalFunction.cpp @@ -0,0 +1,126 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalADWithinTCbufferCbufferPhysicalFunction::TemporalADWithinTCbufferCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction cbufferLitFunction, + PhysicalFunction distFunction) +{ + parameterFunctions.reserve(6); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(radiusFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(cbufferLitFunction)); + parameterFunctions.push_back(std::move(distFunction)); +} + +VarVal TemporalADWithinTCbufferCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto cbufLit = parameterValues[4].cast(); + auto dist = parameterValues[5].cast>(); + + const auto result = nautilus::invoke( + +[](double lonValue, double latValue, double radiusValue, uint64_t timestampValue, + const char* cbufLitPtr, uint32_t cbufLitSize, double distValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({} {}),{})@{}", + lonValue, latValue, radiusValue, timestampString); + std::string cbufferLiteral(cbufLitPtr, cbufLitSize); + + while (!cbufferLiteral.empty() && (cbufferLiteral.front() == '\'' || cbufferLiteral.front() == '"')) + cbufferLiteral.erase(cbufferLiteral.begin()); + while (!cbufferLiteral.empty() && (cbufferLiteral.back() == '\'' || cbufferLiteral.back() == '"')) + cbufferLiteral.pop_back(); + + if (tcbufferWkt.empty() || cbufferLiteral.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + Cbuffer* cb = cbuffer_in(cbufferLiteral.c_str()); + if (!cb) { free(tcbuffer); return 0; } + + int r = adwithin_tcbuffer_cbuffer(tcbuffer, cb, distValue); + free(tcbuffer); + free(cb); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, radius, timestamp, cbufLit.getContent(), cbufLit.getContentSize(), dist); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalADWithinTCbufferCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "TemporalADWithinTCbufferCbufferPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + return TemporalADWithinTCbufferCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalADWithinTCbufferGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalADWithinTCbufferGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..38778bc42b --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalADWithinTCbufferGeometryPhysicalFunction.cpp @@ -0,0 +1,125 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalADWithinTCbufferGeometryPhysicalFunction::TemporalADWithinTCbufferGeometryPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction, + PhysicalFunction distFunction) +{ + parameterFunctions.reserve(6); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(radiusFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); + parameterFunctions.push_back(std::move(distFunction)); +} + +VarVal TemporalADWithinTCbufferGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto geometry = parameterValues[4].cast(); + auto dist = parameterValues[5].cast>(); + + const auto result = nautilus::invoke( + +[](double lonValue, double latValue, double radiusValue, uint64_t timestampValue, + const char* geometryPtr, uint32_t geometrySize, double distValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({} {}),{})@{}", + lonValue, latValue, radiusValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tcbufferWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tcbuffer); return 0; } + + int r = adwithin_tcbuffer_geo(tcbuffer, staticGeometry.getGeometry(), distValue); + free(tcbuffer); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, radius, timestamp, geometry.getContent(), geometry.getContentSize(), dist); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalADWithinTCbufferGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "TemporalADWithinTCbufferGeometryPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + return TemporalADWithinTCbufferGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalADWithinTCbufferTCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalADWithinTCbufferTCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..c309e7452d --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalADWithinTCbufferTCbufferPhysicalFunction.cpp @@ -0,0 +1,132 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalADWithinTCbufferTCbufferPhysicalFunction::TemporalADWithinTCbufferTCbufferPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction radiusAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction radiusBFunction, + PhysicalFunction tsBFunction, + PhysicalFunction distFunction) +{ + parameterFunctions.reserve(9); + parameterFunctions.push_back(std::move(lonAFunction)); + parameterFunctions.push_back(std::move(latAFunction)); + parameterFunctions.push_back(std::move(radiusAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(lonBFunction)); + parameterFunctions.push_back(std::move(latBFunction)); + parameterFunctions.push_back(std::move(radiusBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); + parameterFunctions.push_back(std::move(distFunction)); +} + +VarVal TemporalADWithinTCbufferTCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lonA = parameterValues[0].cast>(); + auto latA = parameterValues[1].cast>(); + auto radiusA = parameterValues[2].cast>(); + auto tsA = parameterValues[3].cast>(); + auto lonB = parameterValues[4].cast>(); + auto latB = parameterValues[5].cast>(); + auto radiusB = parameterValues[6].cast>(); + auto tsB = parameterValues[7].cast>(); + auto dist = parameterValues[8].cast>(); + + const auto result = nautilus::invoke( + +[](double lonAValue, double latAValue, double radiusAValue, uint64_t tsAValue, + double lonBValue, double latBValue, double radiusBValue, uint64_t tsBValue, + double distValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonAValue >= -180.0 && lonAValue <= 180.0 && latAValue >= -90.0 && latAValue <= 90.0)) return 0; + if (!(lonBValue >= -180.0 && lonBValue <= 180.0 && latBValue >= -90.0 && latBValue <= 90.0)) return 0; + if (radiusAValue < 0.0 || radiusBValue < 0.0) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string wktA = fmt::format("Cbuffer(Point({} {}),{})@{}", lonAValue, latAValue, radiusAValue, tsAString); + std::string wktB = fmt::format("Cbuffer(Point({} {}),{})@{}", lonBValue, latBValue, radiusBValue, tsBString); + + Temporal* tA = tcbuffer_in(wktA.c_str()); + if (!tA) return 0; + Temporal* tB = tcbuffer_in(wktB.c_str()); + if (!tB) { free(tA); return 0; } + + int r = adwithin_tcbuffer_tcbuffer(tA, tB, distValue); + free(tA); + free(tB); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB, dist); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalADWithinTCbufferTCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 9, + "TemporalADWithinTCbufferTCbufferPhysicalFunction requires 9 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + auto arg6 = std::move(arguments.childFunctions[6]); + auto arg7 = std::move(arguments.childFunctions[7]); + auto arg8 = std::move(arguments.childFunctions[8]); + return TemporalADWithinTCbufferTCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7), std::move(arg8)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalADWithinTGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalADWithinTGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..7a77d53a0a --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalADWithinTGeometryPhysicalFunction.cpp @@ -0,0 +1,124 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalADWithinTGeometryPhysicalFunction::TemporalADWithinTGeometryPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction tsBFunction, + PhysicalFunction distFunction) +{ + parameterFunctions.reserve(7); + parameterFunctions.push_back(std::move(lonAFunction)); + parameterFunctions.push_back(std::move(latAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(lonBFunction)); + parameterFunctions.push_back(std::move(latBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); + parameterFunctions.push_back(std::move(distFunction)); +} + +VarVal TemporalADWithinTGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lonA = parameterValues[0].cast>(); + auto latA = parameterValues[1].cast>(); + auto tsA = parameterValues[2].cast>(); + auto lonB = parameterValues[3].cast>(); + auto latB = parameterValues[4].cast>(); + auto tsB = parameterValues[5].cast>(); + auto dist = parameterValues[6].cast>(); + + const auto result = nautilus::invoke( + +[](double lonAValue, double latAValue, uint64_t tsAValue, + double lonBValue, double latBValue, uint64_t tsBValue, + double distValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonAValue >= -180.0 && lonAValue <= 180.0 && latAValue >= -90.0 && latAValue <= 90.0)) return 0; + if (!(lonBValue >= -180.0 && lonBValue <= 180.0 && latBValue >= -90.0 && latBValue <= 90.0)) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string temporalGeometryAWkt = fmt::format("SRID=4326;Point({} {})@{}", lonAValue, latAValue, tsAString); + std::string temporalGeometryBWkt = fmt::format("SRID=4326;Point({} {})@{}", lonBValue, latBValue, tsBString); + + MEOS::Meos::TemporalGeometry temporalGeometryA(temporalGeometryAWkt); + if (!temporalGeometryA.getGeometry()) return 0; + MEOS::Meos::TemporalGeometry temporalGeometryB(temporalGeometryBWkt); + if (!temporalGeometryB.getGeometry()) return 0; + + // MEOS *_tgeo_tgeo with trailing distance arg + // — int fn(const Temporal*, const Temporal*, double). + return adwithin_tgeo_tgeo(temporalGeometryA.getGeometry(), + temporalGeometryB.getGeometry(), + distValue); + } + catch (const std::exception&) + { + return 0; + } + }, + lonA, latA, tsA, lonB, latB, tsB, dist); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalADWithinTGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "TemporalADWithinTGeometryPhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + auto arg6 = std::move(arguments.childFunctions[6]); + return TemporalADWithinTGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalADisjointGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalADisjointGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..98880a767c --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalADisjointGeometryPhysicalFunction.cpp @@ -0,0 +1,124 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalADisjointGeometryPhysicalFunction::TemporalADisjointGeometryPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(4); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalADisjointGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto timestamp = parameterValues[2].cast>(); + auto geometry = parameterValues[3].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + uint64_t timestampValue, + const char* geometryPtr, + uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) { + return 0; + } + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string temporalGeometryWkt = fmt::format("SRID=4326;Point({} {})@{}", lonValue, latValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (temporalGeometryWkt.empty() || staticGeometryWkt.empty()) + return 0; + + MEOS::Meos::TemporalGeometry temporalGeometry(temporalGeometryWkt); + if (!temporalGeometry.getGeometry()) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) return 0; + + // MEOS spatial-relation call — same shape as TemporalEDWithin's + // edwithin_tgeo_geo, but specific MEOS function per generated operator. + // Real MEOS spatial-rel signature: int fn(const Temporal *, const GSERIALIZED *) + // (no `atstart` flag — that's specific to geog_dwithin / edwithin's 3-arg variant). + return adisjoint_tgeo_geo(temporalGeometry.getGeometry(), + staticGeometry.getGeometry()); + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalADisjointGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "TemporalADisjointGeometryPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + return TemporalADisjointGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalADisjointTCbufferCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalADisjointTCbufferCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..734e1b0b42 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalADisjointTCbufferCbufferPhysicalFunction.cpp @@ -0,0 +1,126 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalADisjointTCbufferCbufferPhysicalFunction::TemporalADisjointTCbufferCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction cbufferLitFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(radiusFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(cbufferLitFunction)); +} + +VarVal TemporalADisjointTCbufferCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto cbufLit = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + double radiusValue, + uint64_t timestampValue, + const char* cbufLitPtr, + uint32_t cbufLitSize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({} {}),{})@{}", + lonValue, latValue, radiusValue, timestampString); + std::string cbufferLiteral(cbufLitPtr, cbufLitSize); + + while (!cbufferLiteral.empty() && (cbufferLiteral.front() == '\'' || cbufferLiteral.front() == '"')) + cbufferLiteral.erase(cbufferLiteral.begin()); + while (!cbufferLiteral.empty() && (cbufferLiteral.back() == '\'' || cbufferLiteral.back() == '"')) + cbufferLiteral.pop_back(); + + if (tcbufferWkt.empty() || cbufferLiteral.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + Cbuffer* cb = cbuffer_in(cbufferLiteral.c_str()); + if (!cb) { free(tcbuffer); return 0; } + + int r = adisjoint_tcbuffer_cbuffer(tcbuffer, cb); + free(tcbuffer); + free(cb); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, radius, timestamp, cbufLit.getContent(), cbufLit.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalADisjointTCbufferCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalADisjointTCbufferCbufferPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalADisjointTCbufferCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalADisjointTCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalADisjointTCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..24aab94588 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalADisjointTCbufferPhysicalFunction.cpp @@ -0,0 +1,125 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalADisjointTCbufferPhysicalFunction::TemporalADisjointTCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(radiusFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalADisjointTCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto geometry = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + double radiusValue, + uint64_t timestampValue, + const char* geometryPtr, + uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({} {}),{})@{}", + lonValue, latValue, radiusValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tcbufferWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tcbuffer); return 0; } + + int r = adisjoint_tcbuffer_geo(tcbuffer, staticGeometry.getGeometry()); + free(tcbuffer); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, radius, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalADisjointTCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalADisjointTCbufferPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalADisjointTCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalADisjointTCbufferTCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalADisjointTCbufferTCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..7c51d596d4 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalADisjointTCbufferTCbufferPhysicalFunction.cpp @@ -0,0 +1,127 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalADisjointTCbufferTCbufferPhysicalFunction::TemporalADisjointTCbufferTCbufferPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction radiusAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction radiusBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(8); + parameterFunctions.push_back(std::move(lonAFunction)); + parameterFunctions.push_back(std::move(latAFunction)); + parameterFunctions.push_back(std::move(radiusAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(lonBFunction)); + parameterFunctions.push_back(std::move(latBFunction)); + parameterFunctions.push_back(std::move(radiusBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalADisjointTCbufferTCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lonA = parameterValues[0].cast>(); + auto latA = parameterValues[1].cast>(); + auto radiusA = parameterValues[2].cast>(); + auto tsA = parameterValues[3].cast>(); + auto lonB = parameterValues[4].cast>(); + auto latB = parameterValues[5].cast>(); + auto radiusB = parameterValues[6].cast>(); + auto tsB = parameterValues[7].cast>(); + + const auto result = nautilus::invoke( + +[](double lonAValue, double latAValue, double radiusAValue, uint64_t tsAValue, + double lonBValue, double latBValue, double radiusBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonAValue >= -180.0 && lonAValue <= 180.0 && latAValue >= -90.0 && latAValue <= 90.0)) return 0; + if (!(lonBValue >= -180.0 && lonBValue <= 180.0 && latBValue >= -90.0 && latBValue <= 90.0)) return 0; + if (radiusAValue < 0.0 || radiusBValue < 0.0) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string wktA = fmt::format("Cbuffer(Point({} {}),{})@{}", lonAValue, latAValue, radiusAValue, tsAString); + std::string wktB = fmt::format("Cbuffer(Point({} {}),{})@{}", lonBValue, latBValue, radiusBValue, tsBString); + + Temporal* tA = tcbuffer_in(wktA.c_str()); + if (!tA) return 0; + Temporal* tB = tcbuffer_in(wktB.c_str()); + if (!tB) { free(tA); return 0; } + + int r = adisjoint_tcbuffer_tcbuffer(tA, tB); + free(tA); + free(tB); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalADisjointTCbufferTCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "TemporalADisjointTCbufferTCbufferPhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + auto arg6 = std::move(arguments.childFunctions[6]); + auto arg7 = std::move(arguments.childFunctions[7]); + return TemporalADisjointTCbufferTCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalADisjointTGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalADisjointTGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..78da042055 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalADisjointTGeometryPhysicalFunction.cpp @@ -0,0 +1,117 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalADisjointTGeometryPhysicalFunction::TemporalADisjointTGeometryPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(6); + parameterFunctions.push_back(std::move(lonAFunction)); + parameterFunctions.push_back(std::move(latAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(lonBFunction)); + parameterFunctions.push_back(std::move(latBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalADisjointTGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lonA = parameterValues[0].cast>(); + auto latA = parameterValues[1].cast>(); + auto tsA = parameterValues[2].cast>(); + auto lonB = parameterValues[3].cast>(); + auto latB = parameterValues[4].cast>(); + auto tsB = parameterValues[5].cast>(); + + const auto result = nautilus::invoke( + +[](double lonAValue, double latAValue, uint64_t tsAValue, + double lonBValue, double latBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonAValue >= -180.0 && lonAValue <= 180.0 && latAValue >= -90.0 && latAValue <= 90.0)) return 0; + if (!(lonBValue >= -180.0 && lonBValue <= 180.0 && latBValue >= -90.0 && latBValue <= 90.0)) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string temporalGeometryAWkt = fmt::format("SRID=4326;Point({} {})@{}", lonAValue, latAValue, tsAString); + std::string temporalGeometryBWkt = fmt::format("SRID=4326;Point({} {})@{}", lonBValue, latBValue, tsBString); + + MEOS::Meos::TemporalGeometry temporalGeometryA(temporalGeometryAWkt); + if (!temporalGeometryA.getGeometry()) return 0; + MEOS::Meos::TemporalGeometry temporalGeometryB(temporalGeometryBWkt); + if (!temporalGeometryB.getGeometry()) return 0; + + // MEOS *_tgeo_tgeo spatial-relation: int fn(const Temporal*, const Temporal*). + return adisjoint_tgeo_tgeo(temporalGeometryA.getGeometry(), + temporalGeometryB.getGeometry()); + } + catch (const std::exception&) + { + return 0; + } + }, + lonA, latA, tsA, lonB, latB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalADisjointTGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "TemporalADisjointTGeometryPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + return TemporalADisjointTGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalADisjointTNpointGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalADisjointTNpointGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..dff22a4085 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalADisjointTNpointGeometryPhysicalFunction.cpp @@ -0,0 +1,118 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalADisjointTNpointGeometryPhysicalFunction::TemporalADisjointTNpointGeometryPhysicalFunction(PhysicalFunction ridFunction, + PhysicalFunction fractionFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(4); + parameterFunctions.push_back(std::move(ridFunction)); + parameterFunctions.push_back(std::move(fractionFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalADisjointTNpointGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto rid = parameterValues[0].cast>(); + auto fraction = parameterValues[1].cast>(); + auto timestamp = parameterValues[2].cast>(); + auto geometry = parameterValues[3].cast(); + + const auto result = nautilus::invoke( + +[](uint64_t ridValue, double fractionValue, uint64_t timestampValue, + const char* geometryPtr, uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tnpointWkt = fmt::format("NPoint({}, {})@{}", ridValue, fractionValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tnpointWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tnpoint = tnpoint_in(tnpointWkt.c_str()); + if (!tnpoint) return 0; + Temporal* tgeo = tnpoint_to_tgeompoint(tnpoint); + if (!tgeo) { free(tnpoint); return 0; } + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tgeo); free(tnpoint); return 0; } + + int r = adisjoint_tgeo_geo(tgeo, staticGeometry.getGeometry()); + free(tgeo); + free(tnpoint); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + rid, fraction, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalADisjointTNpointGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "TemporalADisjointTNpointGeometryPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + return TemporalADisjointTNpointGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalADisjointTNpointTNpointPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalADisjointTNpointTNpointPhysicalFunction.cpp new file mode 100644 index 0000000000..8a07cc2dfb --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalADisjointTNpointTNpointPhysicalFunction.cpp @@ -0,0 +1,126 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalADisjointTNpointTNpointPhysicalFunction::TemporalADisjointTNpointTNpointPhysicalFunction(PhysicalFunction ridAFunction, + PhysicalFunction fractionAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction ridBFunction, + PhysicalFunction fractionBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(6); + parameterFunctions.push_back(std::move(ridAFunction)); + parameterFunctions.push_back(std::move(fractionAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(ridBFunction)); + parameterFunctions.push_back(std::move(fractionBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalADisjointTNpointTNpointPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto ridA = parameterValues[0].cast>(); + auto fractionA = parameterValues[1].cast>(); + auto tsA = parameterValues[2].cast>(); + auto ridB = parameterValues[3].cast>(); + auto fractionB = parameterValues[4].cast>(); + auto tsB = parameterValues[5].cast>(); + + const auto result = nautilus::invoke( + +[](uint64_t ridAValue, double fractionAValue, uint64_t tsAValue, + uint64_t ridBValue, double fractionBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string tnpointAWkt = fmt::format("NPoint({}, {})@{}", ridAValue, fractionAValue, tsAString); + std::string tnpointBWkt = fmt::format("NPoint({}, {})@{}", ridBValue, fractionBValue, tsBString); + + if (tnpointAWkt.empty() || tnpointBWkt.empty()) return 0; + + Temporal* tnpointA = tnpoint_in(tnpointAWkt.c_str()); + if (!tnpointA) return 0; + Temporal* tgeoA = tnpoint_to_tgeompoint(tnpointA); + if (!tgeoA) { free(tnpointA); return 0; } + Temporal* tnpointB = tnpoint_in(tnpointBWkt.c_str()); + if (!tnpointB) { free(tgeoA); free(tnpointA); return 0; } + Temporal* tgeoB = tnpoint_to_tgeompoint(tnpointB); + if (!tgeoB) { free(tnpointB); free(tgeoA); free(tnpointA); return 0; } + + int r = adisjoint_tgeo_tgeo(tgeoA, tgeoB); + free(tgeoB); + free(tnpointB); + free(tgeoA); + free(tnpointA); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + ridA, fractionA, tsA, ridB, fractionB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalADisjointTNpointTNpointPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "TemporalADisjointTNpointTNpointPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + return TemporalADisjointTNpointTNpointPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalADisjointTPoseGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalADisjointTPoseGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..c83756ca94 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalADisjointTPoseGeometryPhysicalFunction.cpp @@ -0,0 +1,124 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalADisjointTPoseGeometryPhysicalFunction::TemporalADisjointTPoseGeometryPhysicalFunction(PhysicalFunction xFunction, + PhysicalFunction yFunction, + PhysicalFunction thetaFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(xFunction)); + parameterFunctions.push_back(std::move(yFunction)); + parameterFunctions.push_back(std::move(thetaFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalADisjointTPoseGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto x = parameterValues[0].cast>(); + auto y = parameterValues[1].cast>(); + auto theta = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto geometry = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double xValue, double yValue, double thetaValue, uint64_t timestampValue, + const char* geometryPtr, uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(xValue >= -180.0 && xValue <= 180.0 && yValue >= -90.0 && yValue <= 90.0)) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tposeWkt = fmt::format("Pose(Point({} {}), {})@{}", + xValue, yValue, thetaValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tposeWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tpose = tpose_in(tposeWkt.c_str()); + if (!tpose) return 0; + Temporal* tgeo = tpose_to_tpoint(tpose); + if (!tgeo) { free(tpose); return 0; } + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tgeo); free(tpose); return 0; } + + int r = adisjoint_tgeo_geo(tgeo, staticGeometry.getGeometry()); + free(tgeo); + free(tpose); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + x, y, theta, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalADisjointTPoseGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalADisjointTPoseGeometryPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalADisjointTPoseGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalADisjointTPoseTPosePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalADisjointTPoseTPosePhysicalFunction.cpp new file mode 100644 index 0000000000..4c762fbfc1 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalADisjointTPoseTPosePhysicalFunction.cpp @@ -0,0 +1,136 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalADisjointTPoseTPosePhysicalFunction::TemporalADisjointTPoseTPosePhysicalFunction(PhysicalFunction xAFunction, + PhysicalFunction yAFunction, + PhysicalFunction thetaAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction xBFunction, + PhysicalFunction yBFunction, + PhysicalFunction thetaBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(8); + parameterFunctions.push_back(std::move(xAFunction)); + parameterFunctions.push_back(std::move(yAFunction)); + parameterFunctions.push_back(std::move(thetaAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(xBFunction)); + parameterFunctions.push_back(std::move(yBFunction)); + parameterFunctions.push_back(std::move(thetaBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalADisjointTPoseTPosePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto xA = parameterValues[0].cast>(); + auto yA = parameterValues[1].cast>(); + auto thetaA = parameterValues[2].cast>(); + auto tsA = parameterValues[3].cast>(); + auto xB = parameterValues[4].cast>(); + auto yB = parameterValues[5].cast>(); + auto thetaB = parameterValues[6].cast>(); + auto tsB = parameterValues[7].cast>(); + + const auto result = nautilus::invoke( + +[](double xAValue, double yAValue, double thetaAValue, uint64_t tsAValue, + double xBValue, double yBValue, double thetaBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(xAValue >= -180.0 && xAValue <= 180.0 && yAValue >= -90.0 && yAValue <= 90.0)) return 0; + if (!(xBValue >= -180.0 && xBValue <= 180.0 && yBValue >= -90.0 && yBValue <= 90.0)) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string tposeAWkt = fmt::format("Pose(Point({} {}), {})@{}", xAValue, yAValue, thetaAValue, tsAString); + std::string tposeBWkt = fmt::format("Pose(Point({} {}), {})@{}", xBValue, yBValue, thetaBValue, tsBString); + + if (tposeAWkt.empty() || tposeBWkt.empty()) return 0; + + Temporal* tposeA = tpose_in(tposeAWkt.c_str()); + if (!tposeA) return 0; + Temporal* tgeoA = tpose_to_tpoint(tposeA); + if (!tgeoA) { free(tposeA); return 0; } + Temporal* tposeB = tpose_in(tposeBWkt.c_str()); + if (!tposeB) { free(tgeoA); free(tposeA); return 0; } + Temporal* tgeoB = tpose_to_tpoint(tposeB); + if (!tgeoB) { free(tposeB); free(tgeoA); free(tposeA); return 0; } + + int r = adisjoint_tgeo_tgeo(tgeoA, tgeoB); + free(tgeoB); + free(tposeB); + free(tgeoA); + free(tposeA); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + xA, yA, thetaA, tsA, xB, yB, thetaB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalADisjointTPoseTPosePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "TemporalADisjointTPoseTPosePhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + auto arg6 = std::move(arguments.childFunctions[6]); + auto arg7 = std::move(arguments.childFunctions[7]); + return TemporalADisjointTPoseTPosePhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalAIntersectsTCbufferCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalAIntersectsTCbufferCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..e18e1653ff --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalAIntersectsTCbufferCbufferPhysicalFunction.cpp @@ -0,0 +1,126 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalAIntersectsTCbufferCbufferPhysicalFunction::TemporalAIntersectsTCbufferCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction cbufferLitFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(radiusFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(cbufferLitFunction)); +} + +VarVal TemporalAIntersectsTCbufferCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto cbufLit = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + double radiusValue, + uint64_t timestampValue, + const char* cbufLitPtr, + uint32_t cbufLitSize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({} {}),{})@{}", + lonValue, latValue, radiusValue, timestampString); + std::string cbufferLiteral(cbufLitPtr, cbufLitSize); + + while (!cbufferLiteral.empty() && (cbufferLiteral.front() == '\'' || cbufferLiteral.front() == '"')) + cbufferLiteral.erase(cbufferLiteral.begin()); + while (!cbufferLiteral.empty() && (cbufferLiteral.back() == '\'' || cbufferLiteral.back() == '"')) + cbufferLiteral.pop_back(); + + if (tcbufferWkt.empty() || cbufferLiteral.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + Cbuffer* cb = cbuffer_in(cbufferLiteral.c_str()); + if (!cb) { free(tcbuffer); return 0; } + + int r = aintersects_tcbuffer_cbuffer(tcbuffer, cb); + free(tcbuffer); + free(cb); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, radius, timestamp, cbufLit.getContent(), cbufLit.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalAIntersectsTCbufferCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalAIntersectsTCbufferCbufferPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalAIntersectsTCbufferCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalAIntersectsTCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalAIntersectsTCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..30b9298f61 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalAIntersectsTCbufferPhysicalFunction.cpp @@ -0,0 +1,125 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalAIntersectsTCbufferPhysicalFunction::TemporalAIntersectsTCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(radiusFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalAIntersectsTCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto geometry = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + double radiusValue, + uint64_t timestampValue, + const char* geometryPtr, + uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({} {}),{})@{}", + lonValue, latValue, radiusValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tcbufferWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tcbuffer); return 0; } + + int r = aintersects_tcbuffer_geo(tcbuffer, staticGeometry.getGeometry()); + free(tcbuffer); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, radius, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalAIntersectsTCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalAIntersectsTCbufferPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalAIntersectsTCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalAIntersectsTCbufferTCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalAIntersectsTCbufferTCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..3ca3c6478b --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalAIntersectsTCbufferTCbufferPhysicalFunction.cpp @@ -0,0 +1,127 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalAIntersectsTCbufferTCbufferPhysicalFunction::TemporalAIntersectsTCbufferTCbufferPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction radiusAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction radiusBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(8); + parameterFunctions.push_back(std::move(lonAFunction)); + parameterFunctions.push_back(std::move(latAFunction)); + parameterFunctions.push_back(std::move(radiusAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(lonBFunction)); + parameterFunctions.push_back(std::move(latBFunction)); + parameterFunctions.push_back(std::move(radiusBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalAIntersectsTCbufferTCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lonA = parameterValues[0].cast>(); + auto latA = parameterValues[1].cast>(); + auto radiusA = parameterValues[2].cast>(); + auto tsA = parameterValues[3].cast>(); + auto lonB = parameterValues[4].cast>(); + auto latB = parameterValues[5].cast>(); + auto radiusB = parameterValues[6].cast>(); + auto tsB = parameterValues[7].cast>(); + + const auto result = nautilus::invoke( + +[](double lonAValue, double latAValue, double radiusAValue, uint64_t tsAValue, + double lonBValue, double latBValue, double radiusBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonAValue >= -180.0 && lonAValue <= 180.0 && latAValue >= -90.0 && latAValue <= 90.0)) return 0; + if (!(lonBValue >= -180.0 && lonBValue <= 180.0 && latBValue >= -90.0 && latBValue <= 90.0)) return 0; + if (radiusAValue < 0.0 || radiusBValue < 0.0) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string wktA = fmt::format("Cbuffer(Point({} {}),{})@{}", lonAValue, latAValue, radiusAValue, tsAString); + std::string wktB = fmt::format("Cbuffer(Point({} {}),{})@{}", lonBValue, latBValue, radiusBValue, tsBString); + + Temporal* tA = tcbuffer_in(wktA.c_str()); + if (!tA) return 0; + Temporal* tB = tcbuffer_in(wktB.c_str()); + if (!tB) { free(tA); return 0; } + + int r = aintersects_tcbuffer_tcbuffer(tA, tB); + free(tA); + free(tB); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalAIntersectsTCbufferTCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "TemporalAIntersectsTCbufferTCbufferPhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + auto arg6 = std::move(arguments.childFunctions[6]); + auto arg7 = std::move(arguments.childFunctions[7]); + return TemporalAIntersectsTCbufferTCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalAIntersectsTGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalAIntersectsTGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..7a958dccf9 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalAIntersectsTGeometryPhysicalFunction.cpp @@ -0,0 +1,117 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalAIntersectsTGeometryPhysicalFunction::TemporalAIntersectsTGeometryPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(6); + parameterFunctions.push_back(std::move(lonAFunction)); + parameterFunctions.push_back(std::move(latAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(lonBFunction)); + parameterFunctions.push_back(std::move(latBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalAIntersectsTGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lonA = parameterValues[0].cast>(); + auto latA = parameterValues[1].cast>(); + auto tsA = parameterValues[2].cast>(); + auto lonB = parameterValues[3].cast>(); + auto latB = parameterValues[4].cast>(); + auto tsB = parameterValues[5].cast>(); + + const auto result = nautilus::invoke( + +[](double lonAValue, double latAValue, uint64_t tsAValue, + double lonBValue, double latBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonAValue >= -180.0 && lonAValue <= 180.0 && latAValue >= -90.0 && latAValue <= 90.0)) return 0; + if (!(lonBValue >= -180.0 && lonBValue <= 180.0 && latBValue >= -90.0 && latBValue <= 90.0)) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string temporalGeometryAWkt = fmt::format("SRID=4326;Point({} {})@{}", lonAValue, latAValue, tsAString); + std::string temporalGeometryBWkt = fmt::format("SRID=4326;Point({} {})@{}", lonBValue, latBValue, tsBString); + + MEOS::Meos::TemporalGeometry temporalGeometryA(temporalGeometryAWkt); + if (!temporalGeometryA.getGeometry()) return 0; + MEOS::Meos::TemporalGeometry temporalGeometryB(temporalGeometryBWkt); + if (!temporalGeometryB.getGeometry()) return 0; + + // MEOS *_tgeo_tgeo spatial-relation: int fn(const Temporal*, const Temporal*). + return aintersects_tgeo_tgeo(temporalGeometryA.getGeometry(), + temporalGeometryB.getGeometry()); + } + catch (const std::exception&) + { + return 0; + } + }, + lonA, latA, tsA, lonB, latB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalAIntersectsTGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "TemporalAIntersectsTGeometryPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + return TemporalAIntersectsTGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalAIntersectsTNpointGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalAIntersectsTNpointGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..a50638053f --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalAIntersectsTNpointGeometryPhysicalFunction.cpp @@ -0,0 +1,118 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalAIntersectsTNpointGeometryPhysicalFunction::TemporalAIntersectsTNpointGeometryPhysicalFunction(PhysicalFunction ridFunction, + PhysicalFunction fractionFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(4); + parameterFunctions.push_back(std::move(ridFunction)); + parameterFunctions.push_back(std::move(fractionFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalAIntersectsTNpointGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto rid = parameterValues[0].cast>(); + auto fraction = parameterValues[1].cast>(); + auto timestamp = parameterValues[2].cast>(); + auto geometry = parameterValues[3].cast(); + + const auto result = nautilus::invoke( + +[](uint64_t ridValue, double fractionValue, uint64_t timestampValue, + const char* geometryPtr, uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tnpointWkt = fmt::format("NPoint({}, {})@{}", ridValue, fractionValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tnpointWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tnpoint = tnpoint_in(tnpointWkt.c_str()); + if (!tnpoint) return 0; + Temporal* tgeo = tnpoint_to_tgeompoint(tnpoint); + if (!tgeo) { free(tnpoint); return 0; } + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tgeo); free(tnpoint); return 0; } + + int r = aintersects_tgeo_geo(tgeo, staticGeometry.getGeometry()); + free(tgeo); + free(tnpoint); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + rid, fraction, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalAIntersectsTNpointGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "TemporalAIntersectsTNpointGeometryPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + return TemporalAIntersectsTNpointGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalAIntersectsTNpointTNpointPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalAIntersectsTNpointTNpointPhysicalFunction.cpp new file mode 100644 index 0000000000..daa80b7093 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalAIntersectsTNpointTNpointPhysicalFunction.cpp @@ -0,0 +1,126 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalAIntersectsTNpointTNpointPhysicalFunction::TemporalAIntersectsTNpointTNpointPhysicalFunction(PhysicalFunction ridAFunction, + PhysicalFunction fractionAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction ridBFunction, + PhysicalFunction fractionBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(6); + parameterFunctions.push_back(std::move(ridAFunction)); + parameterFunctions.push_back(std::move(fractionAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(ridBFunction)); + parameterFunctions.push_back(std::move(fractionBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalAIntersectsTNpointTNpointPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto ridA = parameterValues[0].cast>(); + auto fractionA = parameterValues[1].cast>(); + auto tsA = parameterValues[2].cast>(); + auto ridB = parameterValues[3].cast>(); + auto fractionB = parameterValues[4].cast>(); + auto tsB = parameterValues[5].cast>(); + + const auto result = nautilus::invoke( + +[](uint64_t ridAValue, double fractionAValue, uint64_t tsAValue, + uint64_t ridBValue, double fractionBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string tnpointAWkt = fmt::format("NPoint({}, {})@{}", ridAValue, fractionAValue, tsAString); + std::string tnpointBWkt = fmt::format("NPoint({}, {})@{}", ridBValue, fractionBValue, tsBString); + + if (tnpointAWkt.empty() || tnpointBWkt.empty()) return 0; + + Temporal* tnpointA = tnpoint_in(tnpointAWkt.c_str()); + if (!tnpointA) return 0; + Temporal* tgeoA = tnpoint_to_tgeompoint(tnpointA); + if (!tgeoA) { free(tnpointA); return 0; } + Temporal* tnpointB = tnpoint_in(tnpointBWkt.c_str()); + if (!tnpointB) { free(tgeoA); free(tnpointA); return 0; } + Temporal* tgeoB = tnpoint_to_tgeompoint(tnpointB); + if (!tgeoB) { free(tnpointB); free(tgeoA); free(tnpointA); return 0; } + + int r = aintersects_tgeo_tgeo(tgeoA, tgeoB); + free(tgeoB); + free(tnpointB); + free(tgeoA); + free(tnpointA); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + ridA, fractionA, tsA, ridB, fractionB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalAIntersectsTNpointTNpointPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "TemporalAIntersectsTNpointTNpointPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + return TemporalAIntersectsTNpointTNpointPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalAIntersectsTPoseGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalAIntersectsTPoseGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..98370112a6 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalAIntersectsTPoseGeometryPhysicalFunction.cpp @@ -0,0 +1,124 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalAIntersectsTPoseGeometryPhysicalFunction::TemporalAIntersectsTPoseGeometryPhysicalFunction(PhysicalFunction xFunction, + PhysicalFunction yFunction, + PhysicalFunction thetaFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(xFunction)); + parameterFunctions.push_back(std::move(yFunction)); + parameterFunctions.push_back(std::move(thetaFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalAIntersectsTPoseGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto x = parameterValues[0].cast>(); + auto y = parameterValues[1].cast>(); + auto theta = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto geometry = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double xValue, double yValue, double thetaValue, uint64_t timestampValue, + const char* geometryPtr, uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(xValue >= -180.0 && xValue <= 180.0 && yValue >= -90.0 && yValue <= 90.0)) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tposeWkt = fmt::format("Pose(Point({} {}), {})@{}", + xValue, yValue, thetaValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tposeWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tpose = tpose_in(tposeWkt.c_str()); + if (!tpose) return 0; + Temporal* tgeo = tpose_to_tpoint(tpose); + if (!tgeo) { free(tpose); return 0; } + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tgeo); free(tpose); return 0; } + + int r = aintersects_tgeo_geo(tgeo, staticGeometry.getGeometry()); + free(tgeo); + free(tpose); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + x, y, theta, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalAIntersectsTPoseGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalAIntersectsTPoseGeometryPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalAIntersectsTPoseGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalAIntersectsTPoseTPosePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalAIntersectsTPoseTPosePhysicalFunction.cpp new file mode 100644 index 0000000000..f583c92e19 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalAIntersectsTPoseTPosePhysicalFunction.cpp @@ -0,0 +1,136 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalAIntersectsTPoseTPosePhysicalFunction::TemporalAIntersectsTPoseTPosePhysicalFunction(PhysicalFunction xAFunction, + PhysicalFunction yAFunction, + PhysicalFunction thetaAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction xBFunction, + PhysicalFunction yBFunction, + PhysicalFunction thetaBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(8); + parameterFunctions.push_back(std::move(xAFunction)); + parameterFunctions.push_back(std::move(yAFunction)); + parameterFunctions.push_back(std::move(thetaAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(xBFunction)); + parameterFunctions.push_back(std::move(yBFunction)); + parameterFunctions.push_back(std::move(thetaBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalAIntersectsTPoseTPosePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto xA = parameterValues[0].cast>(); + auto yA = parameterValues[1].cast>(); + auto thetaA = parameterValues[2].cast>(); + auto tsA = parameterValues[3].cast>(); + auto xB = parameterValues[4].cast>(); + auto yB = parameterValues[5].cast>(); + auto thetaB = parameterValues[6].cast>(); + auto tsB = parameterValues[7].cast>(); + + const auto result = nautilus::invoke( + +[](double xAValue, double yAValue, double thetaAValue, uint64_t tsAValue, + double xBValue, double yBValue, double thetaBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(xAValue >= -180.0 && xAValue <= 180.0 && yAValue >= -90.0 && yAValue <= 90.0)) return 0; + if (!(xBValue >= -180.0 && xBValue <= 180.0 && yBValue >= -90.0 && yBValue <= 90.0)) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string tposeAWkt = fmt::format("Pose(Point({} {}), {})@{}", xAValue, yAValue, thetaAValue, tsAString); + std::string tposeBWkt = fmt::format("Pose(Point({} {}), {})@{}", xBValue, yBValue, thetaBValue, tsBString); + + if (tposeAWkt.empty() || tposeBWkt.empty()) return 0; + + Temporal* tposeA = tpose_in(tposeAWkt.c_str()); + if (!tposeA) return 0; + Temporal* tgeoA = tpose_to_tpoint(tposeA); + if (!tgeoA) { free(tposeA); return 0; } + Temporal* tposeB = tpose_in(tposeBWkt.c_str()); + if (!tposeB) { free(tgeoA); free(tposeA); return 0; } + Temporal* tgeoB = tpose_to_tpoint(tposeB); + if (!tgeoB) { free(tposeB); free(tgeoA); free(tposeA); return 0; } + + int r = aintersects_tgeo_tgeo(tgeoA, tgeoB); + free(tgeoB); + free(tposeB); + free(tgeoA); + free(tposeA); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + xA, yA, thetaA, tsA, xB, yB, thetaB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalAIntersectsTPoseTPosePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "TemporalAIntersectsTPoseTPosePhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + auto arg6 = std::move(arguments.childFunctions[6]); + auto arg7 = std::move(arguments.childFunctions[7]); + return TemporalAIntersectsTPoseTPosePhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalATouchesGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalATouchesGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..5f52041227 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalATouchesGeometryPhysicalFunction.cpp @@ -0,0 +1,124 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalATouchesGeometryPhysicalFunction::TemporalATouchesGeometryPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(4); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalATouchesGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto timestamp = parameterValues[2].cast>(); + auto geometry = parameterValues[3].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + uint64_t timestampValue, + const char* geometryPtr, + uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) { + return 0; + } + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string temporalGeometryWkt = fmt::format("SRID=4326;Point({} {})@{}", lonValue, latValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (temporalGeometryWkt.empty() || staticGeometryWkt.empty()) + return 0; + + MEOS::Meos::TemporalGeometry temporalGeometry(temporalGeometryWkt); + if (!temporalGeometry.getGeometry()) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) return 0; + + // MEOS spatial-relation call — same shape as TemporalEDWithin's + // edwithin_tgeo_geo, but specific MEOS function per generated operator. + // Real MEOS spatial-rel signature: int fn(const Temporal *, const GSERIALIZED *) + // (no `atstart` flag — that's specific to geog_dwithin / edwithin's 3-arg variant). + return atouches_tgeo_geo(temporalGeometry.getGeometry(), + staticGeometry.getGeometry()); + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalATouchesGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "TemporalATouchesGeometryPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + return TemporalATouchesGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalATouchesTCbufferCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalATouchesTCbufferCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..40827fa6dc --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalATouchesTCbufferCbufferPhysicalFunction.cpp @@ -0,0 +1,126 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalATouchesTCbufferCbufferPhysicalFunction::TemporalATouchesTCbufferCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction cbufferLitFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(radiusFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(cbufferLitFunction)); +} + +VarVal TemporalATouchesTCbufferCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto cbufLit = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + double radiusValue, + uint64_t timestampValue, + const char* cbufLitPtr, + uint32_t cbufLitSize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({} {}),{})@{}", + lonValue, latValue, radiusValue, timestampString); + std::string cbufferLiteral(cbufLitPtr, cbufLitSize); + + while (!cbufferLiteral.empty() && (cbufferLiteral.front() == '\'' || cbufferLiteral.front() == '"')) + cbufferLiteral.erase(cbufferLiteral.begin()); + while (!cbufferLiteral.empty() && (cbufferLiteral.back() == '\'' || cbufferLiteral.back() == '"')) + cbufferLiteral.pop_back(); + + if (tcbufferWkt.empty() || cbufferLiteral.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + Cbuffer* cb = cbuffer_in(cbufferLiteral.c_str()); + if (!cb) { free(tcbuffer); return 0; } + + int r = atouches_tcbuffer_cbuffer(tcbuffer, cb); + free(tcbuffer); + free(cb); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, radius, timestamp, cbufLit.getContent(), cbufLit.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalATouchesTCbufferCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalATouchesTCbufferCbufferPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalATouchesTCbufferCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalATouchesTCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalATouchesTCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..8fea0f9319 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalATouchesTCbufferPhysicalFunction.cpp @@ -0,0 +1,125 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalATouchesTCbufferPhysicalFunction::TemporalATouchesTCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(radiusFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalATouchesTCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto geometry = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + double radiusValue, + uint64_t timestampValue, + const char* geometryPtr, + uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({} {}),{})@{}", + lonValue, latValue, radiusValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tcbufferWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tcbuffer); return 0; } + + int r = atouches_tcbuffer_geo(tcbuffer, staticGeometry.getGeometry()); + free(tcbuffer); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, radius, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalATouchesTCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalATouchesTCbufferPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalATouchesTCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalATouchesTCbufferTCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalATouchesTCbufferTCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..db67648002 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalATouchesTCbufferTCbufferPhysicalFunction.cpp @@ -0,0 +1,127 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalATouchesTCbufferTCbufferPhysicalFunction::TemporalATouchesTCbufferTCbufferPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction radiusAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction radiusBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(8); + parameterFunctions.push_back(std::move(lonAFunction)); + parameterFunctions.push_back(std::move(latAFunction)); + parameterFunctions.push_back(std::move(radiusAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(lonBFunction)); + parameterFunctions.push_back(std::move(latBFunction)); + parameterFunctions.push_back(std::move(radiusBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalATouchesTCbufferTCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lonA = parameterValues[0].cast>(); + auto latA = parameterValues[1].cast>(); + auto radiusA = parameterValues[2].cast>(); + auto tsA = parameterValues[3].cast>(); + auto lonB = parameterValues[4].cast>(); + auto latB = parameterValues[5].cast>(); + auto radiusB = parameterValues[6].cast>(); + auto tsB = parameterValues[7].cast>(); + + const auto result = nautilus::invoke( + +[](double lonAValue, double latAValue, double radiusAValue, uint64_t tsAValue, + double lonBValue, double latBValue, double radiusBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonAValue >= -180.0 && lonAValue <= 180.0 && latAValue >= -90.0 && latAValue <= 90.0)) return 0; + if (!(lonBValue >= -180.0 && lonBValue <= 180.0 && latBValue >= -90.0 && latBValue <= 90.0)) return 0; + if (radiusAValue < 0.0 || radiusBValue < 0.0) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string wktA = fmt::format("Cbuffer(Point({} {}),{})@{}", lonAValue, latAValue, radiusAValue, tsAString); + std::string wktB = fmt::format("Cbuffer(Point({} {}),{})@{}", lonBValue, latBValue, radiusBValue, tsBString); + + Temporal* tA = tcbuffer_in(wktA.c_str()); + if (!tA) return 0; + Temporal* tB = tcbuffer_in(wktB.c_str()); + if (!tB) { free(tA); return 0; } + + int r = atouches_tcbuffer_tcbuffer(tA, tB); + free(tA); + free(tB); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalATouchesTCbufferTCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "TemporalATouchesTCbufferTCbufferPhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + auto arg6 = std::move(arguments.childFunctions[6]); + auto arg7 = std::move(arguments.childFunctions[7]); + return TemporalATouchesTCbufferTCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalATouchesTGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalATouchesTGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..5befc70bec --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalATouchesTGeometryPhysicalFunction.cpp @@ -0,0 +1,117 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalATouchesTGeometryPhysicalFunction::TemporalATouchesTGeometryPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(6); + parameterFunctions.push_back(std::move(lonAFunction)); + parameterFunctions.push_back(std::move(latAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(lonBFunction)); + parameterFunctions.push_back(std::move(latBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalATouchesTGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lonA = parameterValues[0].cast>(); + auto latA = parameterValues[1].cast>(); + auto tsA = parameterValues[2].cast>(); + auto lonB = parameterValues[3].cast>(); + auto latB = parameterValues[4].cast>(); + auto tsB = parameterValues[5].cast>(); + + const auto result = nautilus::invoke( + +[](double lonAValue, double latAValue, uint64_t tsAValue, + double lonBValue, double latBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonAValue >= -180.0 && lonAValue <= 180.0 && latAValue >= -90.0 && latAValue <= 90.0)) return 0; + if (!(lonBValue >= -180.0 && lonBValue <= 180.0 && latBValue >= -90.0 && latBValue <= 90.0)) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string temporalGeometryAWkt = fmt::format("SRID=4326;Point({} {})@{}", lonAValue, latAValue, tsAString); + std::string temporalGeometryBWkt = fmt::format("SRID=4326;Point({} {})@{}", lonBValue, latBValue, tsBString); + + MEOS::Meos::TemporalGeometry temporalGeometryA(temporalGeometryAWkt); + if (!temporalGeometryA.getGeometry()) return 0; + MEOS::Meos::TemporalGeometry temporalGeometryB(temporalGeometryBWkt); + if (!temporalGeometryB.getGeometry()) return 0; + + // MEOS *_tgeo_tgeo spatial-relation: int fn(const Temporal*, const Temporal*). + return atouches_tgeo_tgeo(temporalGeometryA.getGeometry(), + temporalGeometryB.getGeometry()); + } + catch (const std::exception&) + { + return 0; + } + }, + lonA, latA, tsA, lonB, latB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalATouchesTGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "TemporalATouchesTGeometryPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + return TemporalATouchesTGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalATouchesTNpointGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalATouchesTNpointGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..83b47a5f65 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalATouchesTNpointGeometryPhysicalFunction.cpp @@ -0,0 +1,118 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalATouchesTNpointGeometryPhysicalFunction::TemporalATouchesTNpointGeometryPhysicalFunction(PhysicalFunction ridFunction, + PhysicalFunction fractionFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(4); + parameterFunctions.push_back(std::move(ridFunction)); + parameterFunctions.push_back(std::move(fractionFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalATouchesTNpointGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto rid = parameterValues[0].cast>(); + auto fraction = parameterValues[1].cast>(); + auto timestamp = parameterValues[2].cast>(); + auto geometry = parameterValues[3].cast(); + + const auto result = nautilus::invoke( + +[](uint64_t ridValue, double fractionValue, uint64_t timestampValue, + const char* geometryPtr, uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tnpointWkt = fmt::format("NPoint({}, {})@{}", ridValue, fractionValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tnpointWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tnpoint = tnpoint_in(tnpointWkt.c_str()); + if (!tnpoint) return 0; + Temporal* tgeo = tnpoint_to_tgeompoint(tnpoint); + if (!tgeo) { free(tnpoint); return 0; } + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tgeo); free(tnpoint); return 0; } + + int r = atouches_tgeo_geo(tgeo, staticGeometry.getGeometry()); + free(tgeo); + free(tnpoint); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + rid, fraction, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalATouchesTNpointGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "TemporalATouchesTNpointGeometryPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + return TemporalATouchesTNpointGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalATouchesTNpointTNpointPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalATouchesTNpointTNpointPhysicalFunction.cpp new file mode 100644 index 0000000000..9efb004284 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalATouchesTNpointTNpointPhysicalFunction.cpp @@ -0,0 +1,126 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalATouchesTNpointTNpointPhysicalFunction::TemporalATouchesTNpointTNpointPhysicalFunction(PhysicalFunction ridAFunction, + PhysicalFunction fractionAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction ridBFunction, + PhysicalFunction fractionBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(6); + parameterFunctions.push_back(std::move(ridAFunction)); + parameterFunctions.push_back(std::move(fractionAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(ridBFunction)); + parameterFunctions.push_back(std::move(fractionBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalATouchesTNpointTNpointPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto ridA = parameterValues[0].cast>(); + auto fractionA = parameterValues[1].cast>(); + auto tsA = parameterValues[2].cast>(); + auto ridB = parameterValues[3].cast>(); + auto fractionB = parameterValues[4].cast>(); + auto tsB = parameterValues[5].cast>(); + + const auto result = nautilus::invoke( + +[](uint64_t ridAValue, double fractionAValue, uint64_t tsAValue, + uint64_t ridBValue, double fractionBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string tnpointAWkt = fmt::format("NPoint({}, {})@{}", ridAValue, fractionAValue, tsAString); + std::string tnpointBWkt = fmt::format("NPoint({}, {})@{}", ridBValue, fractionBValue, tsBString); + + if (tnpointAWkt.empty() || tnpointBWkt.empty()) return 0; + + Temporal* tnpointA = tnpoint_in(tnpointAWkt.c_str()); + if (!tnpointA) return 0; + Temporal* tgeoA = tnpoint_to_tgeompoint(tnpointA); + if (!tgeoA) { free(tnpointA); return 0; } + Temporal* tnpointB = tnpoint_in(tnpointBWkt.c_str()); + if (!tnpointB) { free(tgeoA); free(tnpointA); return 0; } + Temporal* tgeoB = tnpoint_to_tgeompoint(tnpointB); + if (!tgeoB) { free(tnpointB); free(tgeoA); free(tnpointA); return 0; } + + int r = atouches_tgeo_tgeo(tgeoA, tgeoB); + free(tgeoB); + free(tnpointB); + free(tgeoA); + free(tnpointA); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + ridA, fractionA, tsA, ridB, fractionB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalATouchesTNpointTNpointPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "TemporalATouchesTNpointTNpointPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + return TemporalATouchesTNpointTNpointPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalATouchesTPoseGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalATouchesTPoseGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..b8b52bd58d --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalATouchesTPoseGeometryPhysicalFunction.cpp @@ -0,0 +1,124 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalATouchesTPoseGeometryPhysicalFunction::TemporalATouchesTPoseGeometryPhysicalFunction(PhysicalFunction xFunction, + PhysicalFunction yFunction, + PhysicalFunction thetaFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(xFunction)); + parameterFunctions.push_back(std::move(yFunction)); + parameterFunctions.push_back(std::move(thetaFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalATouchesTPoseGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto x = parameterValues[0].cast>(); + auto y = parameterValues[1].cast>(); + auto theta = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto geometry = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double xValue, double yValue, double thetaValue, uint64_t timestampValue, + const char* geometryPtr, uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(xValue >= -180.0 && xValue <= 180.0 && yValue >= -90.0 && yValue <= 90.0)) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tposeWkt = fmt::format("Pose(Point({} {}), {})@{}", + xValue, yValue, thetaValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tposeWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tpose = tpose_in(tposeWkt.c_str()); + if (!tpose) return 0; + Temporal* tgeo = tpose_to_tpoint(tpose); + if (!tgeo) { free(tpose); return 0; } + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tgeo); free(tpose); return 0; } + + int r = atouches_tgeo_geo(tgeo, staticGeometry.getGeometry()); + free(tgeo); + free(tpose); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + x, y, theta, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalATouchesTPoseGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalATouchesTPoseGeometryPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalATouchesTPoseGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalATouchesTPoseTPosePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalATouchesTPoseTPosePhysicalFunction.cpp new file mode 100644 index 0000000000..65767e2a08 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalATouchesTPoseTPosePhysicalFunction.cpp @@ -0,0 +1,136 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalATouchesTPoseTPosePhysicalFunction::TemporalATouchesTPoseTPosePhysicalFunction(PhysicalFunction xAFunction, + PhysicalFunction yAFunction, + PhysicalFunction thetaAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction xBFunction, + PhysicalFunction yBFunction, + PhysicalFunction thetaBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(8); + parameterFunctions.push_back(std::move(xAFunction)); + parameterFunctions.push_back(std::move(yAFunction)); + parameterFunctions.push_back(std::move(thetaAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(xBFunction)); + parameterFunctions.push_back(std::move(yBFunction)); + parameterFunctions.push_back(std::move(thetaBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalATouchesTPoseTPosePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto xA = parameterValues[0].cast>(); + auto yA = parameterValues[1].cast>(); + auto thetaA = parameterValues[2].cast>(); + auto tsA = parameterValues[3].cast>(); + auto xB = parameterValues[4].cast>(); + auto yB = parameterValues[5].cast>(); + auto thetaB = parameterValues[6].cast>(); + auto tsB = parameterValues[7].cast>(); + + const auto result = nautilus::invoke( + +[](double xAValue, double yAValue, double thetaAValue, uint64_t tsAValue, + double xBValue, double yBValue, double thetaBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(xAValue >= -180.0 && xAValue <= 180.0 && yAValue >= -90.0 && yAValue <= 90.0)) return 0; + if (!(xBValue >= -180.0 && xBValue <= 180.0 && yBValue >= -90.0 && yBValue <= 90.0)) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string tposeAWkt = fmt::format("Pose(Point({} {}), {})@{}", xAValue, yAValue, thetaAValue, tsAString); + std::string tposeBWkt = fmt::format("Pose(Point({} {}), {})@{}", xBValue, yBValue, thetaBValue, tsBString); + + if (tposeAWkt.empty() || tposeBWkt.empty()) return 0; + + Temporal* tposeA = tpose_in(tposeAWkt.c_str()); + if (!tposeA) return 0; + Temporal* tgeoA = tpose_to_tpoint(tposeA); + if (!tgeoA) { free(tposeA); return 0; } + Temporal* tposeB = tpose_in(tposeBWkt.c_str()); + if (!tposeB) { free(tgeoA); free(tposeA); return 0; } + Temporal* tgeoB = tpose_to_tpoint(tposeB); + if (!tgeoB) { free(tposeB); free(tgeoA); free(tposeA); return 0; } + + int r = atouches_tgeo_tgeo(tgeoA, tgeoB); + free(tgeoB); + free(tposeB); + free(tgeoA); + free(tposeA); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + xA, yA, thetaA, tsA, xB, yB, thetaB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalATouchesTPoseTPosePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "TemporalATouchesTPoseTPosePhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + auto arg6 = std::move(arguments.childFunctions[6]); + auto arg7 = std::move(arguments.childFunctions[7]); + return TemporalATouchesTPoseTPosePhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalAtGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalAtGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..ab946b1f10 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalAtGeometryPhysicalFunction.cpp @@ -0,0 +1,124 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalAtGeometryPhysicalFunction::TemporalAtGeometryPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(4); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalAtGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto timestamp = parameterValues[2].cast>(); + auto geometry = parameterValues[3].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + uint64_t timestampValue, + const char* geometryPtr, + uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string temporalGeometryWkt = fmt::format("SRID=4326;Point({} {})@{}", lonValue, latValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (temporalGeometryWkt.empty() || staticGeometryWkt.empty()) return 0; + + MEOS::Meos::TemporalGeometry temporalGeometry(temporalGeometryWkt); + if (!temporalGeometry.getGeometry()) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) return 0; + + // MEOS restriction call — returns Temporal* (non-null if the + // input survived the restriction, null if clipped/empty). + // For per-event single-instant inputs this collapses to a + // filter predicate: 1 if the point survives, 0 if clipped. + Temporal* clipped = tgeo_at_geom(temporalGeometry.getGeometry(), + staticGeometry.getGeometry()); + if (clipped == nullptr) return 0; + free(clipped); + return 1; + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalAtGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "TemporalAtGeometryPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + return TemporalAtGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEContainsTCbufferCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEContainsTCbufferCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..4354a43847 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEContainsTCbufferCbufferPhysicalFunction.cpp @@ -0,0 +1,126 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalEContainsTCbufferCbufferPhysicalFunction::TemporalEContainsTCbufferCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction cbufferLitFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(radiusFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(cbufferLitFunction)); +} + +VarVal TemporalEContainsTCbufferCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto cbufLit = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + double radiusValue, + uint64_t timestampValue, + const char* cbufLitPtr, + uint32_t cbufLitSize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({} {}),{})@{}", + lonValue, latValue, radiusValue, timestampString); + std::string cbufferLiteral(cbufLitPtr, cbufLitSize); + + while (!cbufferLiteral.empty() && (cbufferLiteral.front() == '\'' || cbufferLiteral.front() == '"')) + cbufferLiteral.erase(cbufferLiteral.begin()); + while (!cbufferLiteral.empty() && (cbufferLiteral.back() == '\'' || cbufferLiteral.back() == '"')) + cbufferLiteral.pop_back(); + + if (tcbufferWkt.empty() || cbufferLiteral.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + Cbuffer* cb = cbuffer_in(cbufferLiteral.c_str()); + if (!cb) { free(tcbuffer); return 0; } + + int r = econtains_tcbuffer_cbuffer(tcbuffer, cb); + free(tcbuffer); + free(cb); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, radius, timestamp, cbufLit.getContent(), cbufLit.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEContainsTCbufferCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalEContainsTCbufferCbufferPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalEContainsTCbufferCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEContainsTCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEContainsTCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..59f23fcf45 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEContainsTCbufferPhysicalFunction.cpp @@ -0,0 +1,125 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalEContainsTCbufferPhysicalFunction::TemporalEContainsTCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(radiusFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalEContainsTCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto geometry = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + double radiusValue, + uint64_t timestampValue, + const char* geometryPtr, + uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({} {}),{})@{}", + lonValue, latValue, radiusValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tcbufferWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tcbuffer); return 0; } + + int r = econtains_tcbuffer_geo(tcbuffer, staticGeometry.getGeometry()); + free(tcbuffer); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, radius, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEContainsTCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalEContainsTCbufferPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalEContainsTCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEContainsTGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEContainsTGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..05b5b13dd4 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEContainsTGeometryPhysicalFunction.cpp @@ -0,0 +1,117 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalEContainsTGeometryPhysicalFunction::TemporalEContainsTGeometryPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(6); + parameterFunctions.push_back(std::move(lonAFunction)); + parameterFunctions.push_back(std::move(latAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(lonBFunction)); + parameterFunctions.push_back(std::move(latBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalEContainsTGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lonA = parameterValues[0].cast>(); + auto latA = parameterValues[1].cast>(); + auto tsA = parameterValues[2].cast>(); + auto lonB = parameterValues[3].cast>(); + auto latB = parameterValues[4].cast>(); + auto tsB = parameterValues[5].cast>(); + + const auto result = nautilus::invoke( + +[](double lonAValue, double latAValue, uint64_t tsAValue, + double lonBValue, double latBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonAValue >= -180.0 && lonAValue <= 180.0 && latAValue >= -90.0 && latAValue <= 90.0)) return 0; + if (!(lonBValue >= -180.0 && lonBValue <= 180.0 && latBValue >= -90.0 && latBValue <= 90.0)) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string temporalGeometryAWkt = fmt::format("SRID=4326;Point({} {})@{}", lonAValue, latAValue, tsAString); + std::string temporalGeometryBWkt = fmt::format("SRID=4326;Point({} {})@{}", lonBValue, latBValue, tsBString); + + MEOS::Meos::TemporalGeometry temporalGeometryA(temporalGeometryAWkt); + if (!temporalGeometryA.getGeometry()) return 0; + MEOS::Meos::TemporalGeometry temporalGeometryB(temporalGeometryBWkt); + if (!temporalGeometryB.getGeometry()) return 0; + + // MEOS *_tgeo_tgeo spatial-relation: int fn(const Temporal*, const Temporal*). + return econtains_tgeo_tgeo(temporalGeometryA.getGeometry(), + temporalGeometryB.getGeometry()); + } + catch (const std::exception&) + { + return 0; + } + }, + lonA, latA, tsA, lonB, latB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEContainsTGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "TemporalEContainsTGeometryPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + return TemporalEContainsTGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEContainsTNpointGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEContainsTNpointGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..e895fbcd94 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEContainsTNpointGeometryPhysicalFunction.cpp @@ -0,0 +1,118 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalEContainsTNpointGeometryPhysicalFunction::TemporalEContainsTNpointGeometryPhysicalFunction(PhysicalFunction ridFunction, + PhysicalFunction fractionFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(4); + parameterFunctions.push_back(std::move(ridFunction)); + parameterFunctions.push_back(std::move(fractionFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalEContainsTNpointGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto rid = parameterValues[0].cast>(); + auto fraction = parameterValues[1].cast>(); + auto timestamp = parameterValues[2].cast>(); + auto geometry = parameterValues[3].cast(); + + const auto result = nautilus::invoke( + +[](uint64_t ridValue, double fractionValue, uint64_t timestampValue, + const char* geometryPtr, uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tnpointWkt = fmt::format("NPoint({}, {})@{}", ridValue, fractionValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tnpointWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tnpoint = tnpoint_in(tnpointWkt.c_str()); + if (!tnpoint) return 0; + Temporal* tgeo = tnpoint_to_tgeompoint(tnpoint); + if (!tgeo) { free(tnpoint); return 0; } + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tgeo); free(tnpoint); return 0; } + + int r = econtains_tgeo_geo(tgeo, staticGeometry.getGeometry()); + free(tgeo); + free(tnpoint); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + rid, fraction, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEContainsTNpointGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "TemporalEContainsTNpointGeometryPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + return TemporalEContainsTNpointGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEContainsTNpointTNpointPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEContainsTNpointTNpointPhysicalFunction.cpp new file mode 100644 index 0000000000..b435a68713 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEContainsTNpointTNpointPhysicalFunction.cpp @@ -0,0 +1,126 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalEContainsTNpointTNpointPhysicalFunction::TemporalEContainsTNpointTNpointPhysicalFunction(PhysicalFunction ridAFunction, + PhysicalFunction fractionAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction ridBFunction, + PhysicalFunction fractionBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(6); + parameterFunctions.push_back(std::move(ridAFunction)); + parameterFunctions.push_back(std::move(fractionAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(ridBFunction)); + parameterFunctions.push_back(std::move(fractionBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalEContainsTNpointTNpointPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto ridA = parameterValues[0].cast>(); + auto fractionA = parameterValues[1].cast>(); + auto tsA = parameterValues[2].cast>(); + auto ridB = parameterValues[3].cast>(); + auto fractionB = parameterValues[4].cast>(); + auto tsB = parameterValues[5].cast>(); + + const auto result = nautilus::invoke( + +[](uint64_t ridAValue, double fractionAValue, uint64_t tsAValue, + uint64_t ridBValue, double fractionBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string tnpointAWkt = fmt::format("NPoint({}, {})@{}", ridAValue, fractionAValue, tsAString); + std::string tnpointBWkt = fmt::format("NPoint({}, {})@{}", ridBValue, fractionBValue, tsBString); + + if (tnpointAWkt.empty() || tnpointBWkt.empty()) return 0; + + Temporal* tnpointA = tnpoint_in(tnpointAWkt.c_str()); + if (!tnpointA) return 0; + Temporal* tgeoA = tnpoint_to_tgeompoint(tnpointA); + if (!tgeoA) { free(tnpointA); return 0; } + Temporal* tnpointB = tnpoint_in(tnpointBWkt.c_str()); + if (!tnpointB) { free(tgeoA); free(tnpointA); return 0; } + Temporal* tgeoB = tnpoint_to_tgeompoint(tnpointB); + if (!tgeoB) { free(tnpointB); free(tgeoA); free(tnpointA); return 0; } + + int r = econtains_tgeo_tgeo(tgeoA, tgeoB); + free(tgeoB); + free(tnpointB); + free(tgeoA); + free(tnpointA); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + ridA, fractionA, tsA, ridB, fractionB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEContainsTNpointTNpointPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "TemporalEContainsTNpointTNpointPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + return TemporalEContainsTNpointTNpointPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEContainsTPoseGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEContainsTPoseGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..3ac62f1c41 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEContainsTPoseGeometryPhysicalFunction.cpp @@ -0,0 +1,124 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalEContainsTPoseGeometryPhysicalFunction::TemporalEContainsTPoseGeometryPhysicalFunction(PhysicalFunction xFunction, + PhysicalFunction yFunction, + PhysicalFunction thetaFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(xFunction)); + parameterFunctions.push_back(std::move(yFunction)); + parameterFunctions.push_back(std::move(thetaFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalEContainsTPoseGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto x = parameterValues[0].cast>(); + auto y = parameterValues[1].cast>(); + auto theta = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto geometry = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double xValue, double yValue, double thetaValue, uint64_t timestampValue, + const char* geometryPtr, uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(xValue >= -180.0 && xValue <= 180.0 && yValue >= -90.0 && yValue <= 90.0)) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tposeWkt = fmt::format("Pose(Point({} {}), {})@{}", + xValue, yValue, thetaValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tposeWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tpose = tpose_in(tposeWkt.c_str()); + if (!tpose) return 0; + Temporal* tgeo = tpose_to_tpoint(tpose); + if (!tgeo) { free(tpose); return 0; } + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tgeo); free(tpose); return 0; } + + int r = econtains_tgeo_geo(tgeo, staticGeometry.getGeometry()); + free(tgeo); + free(tpose); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + x, y, theta, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEContainsTPoseGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalEContainsTPoseGeometryPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalEContainsTPoseGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEContainsTPoseTPosePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEContainsTPoseTPosePhysicalFunction.cpp new file mode 100644 index 0000000000..aea0df7fc9 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEContainsTPoseTPosePhysicalFunction.cpp @@ -0,0 +1,136 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalEContainsTPoseTPosePhysicalFunction::TemporalEContainsTPoseTPosePhysicalFunction(PhysicalFunction xAFunction, + PhysicalFunction yAFunction, + PhysicalFunction thetaAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction xBFunction, + PhysicalFunction yBFunction, + PhysicalFunction thetaBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(8); + parameterFunctions.push_back(std::move(xAFunction)); + parameterFunctions.push_back(std::move(yAFunction)); + parameterFunctions.push_back(std::move(thetaAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(xBFunction)); + parameterFunctions.push_back(std::move(yBFunction)); + parameterFunctions.push_back(std::move(thetaBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalEContainsTPoseTPosePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto xA = parameterValues[0].cast>(); + auto yA = parameterValues[1].cast>(); + auto thetaA = parameterValues[2].cast>(); + auto tsA = parameterValues[3].cast>(); + auto xB = parameterValues[4].cast>(); + auto yB = parameterValues[5].cast>(); + auto thetaB = parameterValues[6].cast>(); + auto tsB = parameterValues[7].cast>(); + + const auto result = nautilus::invoke( + +[](double xAValue, double yAValue, double thetaAValue, uint64_t tsAValue, + double xBValue, double yBValue, double thetaBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(xAValue >= -180.0 && xAValue <= 180.0 && yAValue >= -90.0 && yAValue <= 90.0)) return 0; + if (!(xBValue >= -180.0 && xBValue <= 180.0 && yBValue >= -90.0 && yBValue <= 90.0)) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string tposeAWkt = fmt::format("Pose(Point({} {}), {})@{}", xAValue, yAValue, thetaAValue, tsAString); + std::string tposeBWkt = fmt::format("Pose(Point({} {}), {})@{}", xBValue, yBValue, thetaBValue, tsBString); + + if (tposeAWkt.empty() || tposeBWkt.empty()) return 0; + + Temporal* tposeA = tpose_in(tposeAWkt.c_str()); + if (!tposeA) return 0; + Temporal* tgeoA = tpose_to_tpoint(tposeA); + if (!tgeoA) { free(tposeA); return 0; } + Temporal* tposeB = tpose_in(tposeBWkt.c_str()); + if (!tposeB) { free(tgeoA); free(tposeA); return 0; } + Temporal* tgeoB = tpose_to_tpoint(tposeB); + if (!tgeoB) { free(tposeB); free(tgeoA); free(tposeA); return 0; } + + int r = econtains_tgeo_tgeo(tgeoA, tgeoB); + free(tgeoB); + free(tposeB); + free(tgeoA); + free(tposeA); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + xA, yA, thetaA, tsA, xB, yB, thetaB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEContainsTPoseTPosePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "TemporalEContainsTPoseTPosePhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + auto arg6 = std::move(arguments.childFunctions[6]); + auto arg7 = std::move(arguments.childFunctions[7]); + return TemporalEContainsTPoseTPosePhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalECoversGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalECoversGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..58cd90da42 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalECoversGeometryPhysicalFunction.cpp @@ -0,0 +1,124 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalECoversGeometryPhysicalFunction::TemporalECoversGeometryPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(4); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalECoversGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto timestamp = parameterValues[2].cast>(); + auto geometry = parameterValues[3].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + uint64_t timestampValue, + const char* geometryPtr, + uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) { + return 0; + } + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string temporalGeometryWkt = fmt::format("SRID=4326;Point({} {})@{}", lonValue, latValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (temporalGeometryWkt.empty() || staticGeometryWkt.empty()) + return 0; + + MEOS::Meos::TemporalGeometry temporalGeometry(temporalGeometryWkt); + if (!temporalGeometry.getGeometry()) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) return 0; + + // MEOS spatial-relation call — same shape as TemporalEDWithin's + // edwithin_tgeo_geo, but specific MEOS function per generated operator. + // Real MEOS spatial-rel signature: int fn(const Temporal *, const GSERIALIZED *) + // (no `atstart` flag — that's specific to geog_dwithin / edwithin's 3-arg variant). + return ecovers_tgeo_geo(temporalGeometry.getGeometry(), + staticGeometry.getGeometry()); + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalECoversGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "TemporalECoversGeometryPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + return TemporalECoversGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalECoversTCbufferCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalECoversTCbufferCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..3dec7d4dea --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalECoversTCbufferCbufferPhysicalFunction.cpp @@ -0,0 +1,126 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalECoversTCbufferCbufferPhysicalFunction::TemporalECoversTCbufferCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction cbufferLitFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(radiusFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(cbufferLitFunction)); +} + +VarVal TemporalECoversTCbufferCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto cbufLit = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + double radiusValue, + uint64_t timestampValue, + const char* cbufLitPtr, + uint32_t cbufLitSize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({} {}),{})@{}", + lonValue, latValue, radiusValue, timestampString); + std::string cbufferLiteral(cbufLitPtr, cbufLitSize); + + while (!cbufferLiteral.empty() && (cbufferLiteral.front() == '\'' || cbufferLiteral.front() == '"')) + cbufferLiteral.erase(cbufferLiteral.begin()); + while (!cbufferLiteral.empty() && (cbufferLiteral.back() == '\'' || cbufferLiteral.back() == '"')) + cbufferLiteral.pop_back(); + + if (tcbufferWkt.empty() || cbufferLiteral.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + Cbuffer* cb = cbuffer_in(cbufferLiteral.c_str()); + if (!cb) { free(tcbuffer); return 0; } + + int r = ecovers_tcbuffer_cbuffer(tcbuffer, cb); + free(tcbuffer); + free(cb); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, radius, timestamp, cbufLit.getContent(), cbufLit.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalECoversTCbufferCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalECoversTCbufferCbufferPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalECoversTCbufferCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalECoversTCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalECoversTCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..8bcadf9d84 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalECoversTCbufferPhysicalFunction.cpp @@ -0,0 +1,125 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalECoversTCbufferPhysicalFunction::TemporalECoversTCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(radiusFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalECoversTCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto geometry = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + double radiusValue, + uint64_t timestampValue, + const char* geometryPtr, + uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({} {}),{})@{}", + lonValue, latValue, radiusValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tcbufferWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tcbuffer); return 0; } + + int r = ecovers_tcbuffer_geo(tcbuffer, staticGeometry.getGeometry()); + free(tcbuffer); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, radius, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalECoversTCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalECoversTCbufferPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalECoversTCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalECoversTCbufferTCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalECoversTCbufferTCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..31e2d7115a --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalECoversTCbufferTCbufferPhysicalFunction.cpp @@ -0,0 +1,127 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalECoversTCbufferTCbufferPhysicalFunction::TemporalECoversTCbufferTCbufferPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction radiusAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction radiusBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(8); + parameterFunctions.push_back(std::move(lonAFunction)); + parameterFunctions.push_back(std::move(latAFunction)); + parameterFunctions.push_back(std::move(radiusAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(lonBFunction)); + parameterFunctions.push_back(std::move(latBFunction)); + parameterFunctions.push_back(std::move(radiusBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalECoversTCbufferTCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lonA = parameterValues[0].cast>(); + auto latA = parameterValues[1].cast>(); + auto radiusA = parameterValues[2].cast>(); + auto tsA = parameterValues[3].cast>(); + auto lonB = parameterValues[4].cast>(); + auto latB = parameterValues[5].cast>(); + auto radiusB = parameterValues[6].cast>(); + auto tsB = parameterValues[7].cast>(); + + const auto result = nautilus::invoke( + +[](double lonAValue, double latAValue, double radiusAValue, uint64_t tsAValue, + double lonBValue, double latBValue, double radiusBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonAValue >= -180.0 && lonAValue <= 180.0 && latAValue >= -90.0 && latAValue <= 90.0)) return 0; + if (!(lonBValue >= -180.0 && lonBValue <= 180.0 && latBValue >= -90.0 && latBValue <= 90.0)) return 0; + if (radiusAValue < 0.0 || radiusBValue < 0.0) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string wktA = fmt::format("Cbuffer(Point({} {}),{})@{}", lonAValue, latAValue, radiusAValue, tsAString); + std::string wktB = fmt::format("Cbuffer(Point({} {}),{})@{}", lonBValue, latBValue, radiusBValue, tsBString); + + Temporal* tA = tcbuffer_in(wktA.c_str()); + if (!tA) return 0; + Temporal* tB = tcbuffer_in(wktB.c_str()); + if (!tB) { free(tA); return 0; } + + int r = ecovers_tcbuffer_tcbuffer(tA, tB); + free(tA); + free(tB); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalECoversTCbufferTCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "TemporalECoversTCbufferTCbufferPhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + auto arg6 = std::move(arguments.childFunctions[6]); + auto arg7 = std::move(arguments.childFunctions[7]); + return TemporalECoversTCbufferTCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalECoversTGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalECoversTGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..e3f779641c --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalECoversTGeometryPhysicalFunction.cpp @@ -0,0 +1,117 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalECoversTGeometryPhysicalFunction::TemporalECoversTGeometryPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(6); + parameterFunctions.push_back(std::move(lonAFunction)); + parameterFunctions.push_back(std::move(latAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(lonBFunction)); + parameterFunctions.push_back(std::move(latBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalECoversTGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lonA = parameterValues[0].cast>(); + auto latA = parameterValues[1].cast>(); + auto tsA = parameterValues[2].cast>(); + auto lonB = parameterValues[3].cast>(); + auto latB = parameterValues[4].cast>(); + auto tsB = parameterValues[5].cast>(); + + const auto result = nautilus::invoke( + +[](double lonAValue, double latAValue, uint64_t tsAValue, + double lonBValue, double latBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonAValue >= -180.0 && lonAValue <= 180.0 && latAValue >= -90.0 && latAValue <= 90.0)) return 0; + if (!(lonBValue >= -180.0 && lonBValue <= 180.0 && latBValue >= -90.0 && latBValue <= 90.0)) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string temporalGeometryAWkt = fmt::format("SRID=4326;Point({} {})@{}", lonAValue, latAValue, tsAString); + std::string temporalGeometryBWkt = fmt::format("SRID=4326;Point({} {})@{}", lonBValue, latBValue, tsBString); + + MEOS::Meos::TemporalGeometry temporalGeometryA(temporalGeometryAWkt); + if (!temporalGeometryA.getGeometry()) return 0; + MEOS::Meos::TemporalGeometry temporalGeometryB(temporalGeometryBWkt); + if (!temporalGeometryB.getGeometry()) return 0; + + // MEOS *_tgeo_tgeo spatial-relation: int fn(const Temporal*, const Temporal*). + return ecovers_tgeo_tgeo(temporalGeometryA.getGeometry(), + temporalGeometryB.getGeometry()); + } + catch (const std::exception&) + { + return 0; + } + }, + lonA, latA, tsA, lonB, latB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalECoversTGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "TemporalECoversTGeometryPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + return TemporalECoversTGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalECoversTNpointGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalECoversTNpointGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..b5ea18d1a0 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalECoversTNpointGeometryPhysicalFunction.cpp @@ -0,0 +1,118 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalECoversTNpointGeometryPhysicalFunction::TemporalECoversTNpointGeometryPhysicalFunction(PhysicalFunction ridFunction, + PhysicalFunction fractionFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(4); + parameterFunctions.push_back(std::move(ridFunction)); + parameterFunctions.push_back(std::move(fractionFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalECoversTNpointGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto rid = parameterValues[0].cast>(); + auto fraction = parameterValues[1].cast>(); + auto timestamp = parameterValues[2].cast>(); + auto geometry = parameterValues[3].cast(); + + const auto result = nautilus::invoke( + +[](uint64_t ridValue, double fractionValue, uint64_t timestampValue, + const char* geometryPtr, uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tnpointWkt = fmt::format("NPoint({}, {})@{}", ridValue, fractionValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tnpointWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tnpoint = tnpoint_in(tnpointWkt.c_str()); + if (!tnpoint) return 0; + Temporal* tgeo = tnpoint_to_tgeompoint(tnpoint); + if (!tgeo) { free(tnpoint); return 0; } + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tgeo); free(tnpoint); return 0; } + + int r = ecovers_tgeo_geo(tgeo, staticGeometry.getGeometry()); + free(tgeo); + free(tnpoint); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + rid, fraction, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalECoversTNpointGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "TemporalECoversTNpointGeometryPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + return TemporalECoversTNpointGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalECoversTNpointTNpointPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalECoversTNpointTNpointPhysicalFunction.cpp new file mode 100644 index 0000000000..000b4cd7b5 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalECoversTNpointTNpointPhysicalFunction.cpp @@ -0,0 +1,126 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalECoversTNpointTNpointPhysicalFunction::TemporalECoversTNpointTNpointPhysicalFunction(PhysicalFunction ridAFunction, + PhysicalFunction fractionAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction ridBFunction, + PhysicalFunction fractionBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(6); + parameterFunctions.push_back(std::move(ridAFunction)); + parameterFunctions.push_back(std::move(fractionAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(ridBFunction)); + parameterFunctions.push_back(std::move(fractionBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalECoversTNpointTNpointPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto ridA = parameterValues[0].cast>(); + auto fractionA = parameterValues[1].cast>(); + auto tsA = parameterValues[2].cast>(); + auto ridB = parameterValues[3].cast>(); + auto fractionB = parameterValues[4].cast>(); + auto tsB = parameterValues[5].cast>(); + + const auto result = nautilus::invoke( + +[](uint64_t ridAValue, double fractionAValue, uint64_t tsAValue, + uint64_t ridBValue, double fractionBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string tnpointAWkt = fmt::format("NPoint({}, {})@{}", ridAValue, fractionAValue, tsAString); + std::string tnpointBWkt = fmt::format("NPoint({}, {})@{}", ridBValue, fractionBValue, tsBString); + + if (tnpointAWkt.empty() || tnpointBWkt.empty()) return 0; + + Temporal* tnpointA = tnpoint_in(tnpointAWkt.c_str()); + if (!tnpointA) return 0; + Temporal* tgeoA = tnpoint_to_tgeompoint(tnpointA); + if (!tgeoA) { free(tnpointA); return 0; } + Temporal* tnpointB = tnpoint_in(tnpointBWkt.c_str()); + if (!tnpointB) { free(tgeoA); free(tnpointA); return 0; } + Temporal* tgeoB = tnpoint_to_tgeompoint(tnpointB); + if (!tgeoB) { free(tnpointB); free(tgeoA); free(tnpointA); return 0; } + + int r = ecovers_tgeo_tgeo(tgeoA, tgeoB); + free(tgeoB); + free(tnpointB); + free(tgeoA); + free(tnpointA); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + ridA, fractionA, tsA, ridB, fractionB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalECoversTNpointTNpointPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "TemporalECoversTNpointTNpointPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + return TemporalECoversTNpointTNpointPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalECoversTPoseGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalECoversTPoseGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..6cf9f98956 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalECoversTPoseGeometryPhysicalFunction.cpp @@ -0,0 +1,124 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalECoversTPoseGeometryPhysicalFunction::TemporalECoversTPoseGeometryPhysicalFunction(PhysicalFunction xFunction, + PhysicalFunction yFunction, + PhysicalFunction thetaFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(xFunction)); + parameterFunctions.push_back(std::move(yFunction)); + parameterFunctions.push_back(std::move(thetaFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalECoversTPoseGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto x = parameterValues[0].cast>(); + auto y = parameterValues[1].cast>(); + auto theta = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto geometry = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double xValue, double yValue, double thetaValue, uint64_t timestampValue, + const char* geometryPtr, uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(xValue >= -180.0 && xValue <= 180.0 && yValue >= -90.0 && yValue <= 90.0)) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tposeWkt = fmt::format("Pose(Point({} {}), {})@{}", + xValue, yValue, thetaValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tposeWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tpose = tpose_in(tposeWkt.c_str()); + if (!tpose) return 0; + Temporal* tgeo = tpose_to_tpoint(tpose); + if (!tgeo) { free(tpose); return 0; } + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tgeo); free(tpose); return 0; } + + int r = ecovers_tgeo_geo(tgeo, staticGeometry.getGeometry()); + free(tgeo); + free(tpose); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + x, y, theta, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalECoversTPoseGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalECoversTPoseGeometryPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalECoversTPoseGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalECoversTPoseTPosePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalECoversTPoseTPosePhysicalFunction.cpp new file mode 100644 index 0000000000..57e165f1e4 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalECoversTPoseTPosePhysicalFunction.cpp @@ -0,0 +1,136 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalECoversTPoseTPosePhysicalFunction::TemporalECoversTPoseTPosePhysicalFunction(PhysicalFunction xAFunction, + PhysicalFunction yAFunction, + PhysicalFunction thetaAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction xBFunction, + PhysicalFunction yBFunction, + PhysicalFunction thetaBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(8); + parameterFunctions.push_back(std::move(xAFunction)); + parameterFunctions.push_back(std::move(yAFunction)); + parameterFunctions.push_back(std::move(thetaAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(xBFunction)); + parameterFunctions.push_back(std::move(yBFunction)); + parameterFunctions.push_back(std::move(thetaBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalECoversTPoseTPosePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto xA = parameterValues[0].cast>(); + auto yA = parameterValues[1].cast>(); + auto thetaA = parameterValues[2].cast>(); + auto tsA = parameterValues[3].cast>(); + auto xB = parameterValues[4].cast>(); + auto yB = parameterValues[5].cast>(); + auto thetaB = parameterValues[6].cast>(); + auto tsB = parameterValues[7].cast>(); + + const auto result = nautilus::invoke( + +[](double xAValue, double yAValue, double thetaAValue, uint64_t tsAValue, + double xBValue, double yBValue, double thetaBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(xAValue >= -180.0 && xAValue <= 180.0 && yAValue >= -90.0 && yAValue <= 90.0)) return 0; + if (!(xBValue >= -180.0 && xBValue <= 180.0 && yBValue >= -90.0 && yBValue <= 90.0)) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string tposeAWkt = fmt::format("Pose(Point({} {}), {})@{}", xAValue, yAValue, thetaAValue, tsAString); + std::string tposeBWkt = fmt::format("Pose(Point({} {}), {})@{}", xBValue, yBValue, thetaBValue, tsBString); + + if (tposeAWkt.empty() || tposeBWkt.empty()) return 0; + + Temporal* tposeA = tpose_in(tposeAWkt.c_str()); + if (!tposeA) return 0; + Temporal* tgeoA = tpose_to_tpoint(tposeA); + if (!tgeoA) { free(tposeA); return 0; } + Temporal* tposeB = tpose_in(tposeBWkt.c_str()); + if (!tposeB) { free(tgeoA); free(tposeA); return 0; } + Temporal* tgeoB = tpose_to_tpoint(tposeB); + if (!tgeoB) { free(tposeB); free(tgeoA); free(tposeA); return 0; } + + int r = ecovers_tgeo_tgeo(tgeoA, tgeoB); + free(tgeoB); + free(tposeB); + free(tgeoA); + free(tposeA); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + xA, yA, thetaA, tsA, xB, yB, thetaB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalECoversTPoseTPosePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "TemporalECoversTPoseTPosePhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + auto arg6 = std::move(arguments.childFunctions[6]); + auto arg7 = std::move(arguments.childFunctions[7]); + return TemporalECoversTPoseTPosePhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEDWithinTCbufferCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEDWithinTCbufferCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..47923bc6d3 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEDWithinTCbufferCbufferPhysicalFunction.cpp @@ -0,0 +1,126 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalEDWithinTCbufferCbufferPhysicalFunction::TemporalEDWithinTCbufferCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction cbufferLitFunction, + PhysicalFunction distFunction) +{ + parameterFunctions.reserve(6); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(radiusFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(cbufferLitFunction)); + parameterFunctions.push_back(std::move(distFunction)); +} + +VarVal TemporalEDWithinTCbufferCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto cbufLit = parameterValues[4].cast(); + auto dist = parameterValues[5].cast>(); + + const auto result = nautilus::invoke( + +[](double lonValue, double latValue, double radiusValue, uint64_t timestampValue, + const char* cbufLitPtr, uint32_t cbufLitSize, double distValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({} {}),{})@{}", + lonValue, latValue, radiusValue, timestampString); + std::string cbufferLiteral(cbufLitPtr, cbufLitSize); + + while (!cbufferLiteral.empty() && (cbufferLiteral.front() == '\'' || cbufferLiteral.front() == '"')) + cbufferLiteral.erase(cbufferLiteral.begin()); + while (!cbufferLiteral.empty() && (cbufferLiteral.back() == '\'' || cbufferLiteral.back() == '"')) + cbufferLiteral.pop_back(); + + if (tcbufferWkt.empty() || cbufferLiteral.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + Cbuffer* cb = cbuffer_in(cbufferLiteral.c_str()); + if (!cb) { free(tcbuffer); return 0; } + + int r = edwithin_tcbuffer_cbuffer(tcbuffer, cb, distValue); + free(tcbuffer); + free(cb); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, radius, timestamp, cbufLit.getContent(), cbufLit.getContentSize(), dist); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEDWithinTCbufferCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "TemporalEDWithinTCbufferCbufferPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + return TemporalEDWithinTCbufferCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEDWithinTCbufferGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEDWithinTCbufferGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..8477de56e0 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEDWithinTCbufferGeometryPhysicalFunction.cpp @@ -0,0 +1,125 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalEDWithinTCbufferGeometryPhysicalFunction::TemporalEDWithinTCbufferGeometryPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction, + PhysicalFunction distFunction) +{ + parameterFunctions.reserve(6); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(radiusFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); + parameterFunctions.push_back(std::move(distFunction)); +} + +VarVal TemporalEDWithinTCbufferGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto geometry = parameterValues[4].cast(); + auto dist = parameterValues[5].cast>(); + + const auto result = nautilus::invoke( + +[](double lonValue, double latValue, double radiusValue, uint64_t timestampValue, + const char* geometryPtr, uint32_t geometrySize, double distValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({} {}),{})@{}", + lonValue, latValue, radiusValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tcbufferWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tcbuffer); return 0; } + + int r = edwithin_tcbuffer_geo(tcbuffer, staticGeometry.getGeometry(), distValue); + free(tcbuffer); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, radius, timestamp, geometry.getContent(), geometry.getContentSize(), dist); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEDWithinTCbufferGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "TemporalEDWithinTCbufferGeometryPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + return TemporalEDWithinTCbufferGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEDWithinTCbufferTCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEDWithinTCbufferTCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..2733cef0ff --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEDWithinTCbufferTCbufferPhysicalFunction.cpp @@ -0,0 +1,132 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalEDWithinTCbufferTCbufferPhysicalFunction::TemporalEDWithinTCbufferTCbufferPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction radiusAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction radiusBFunction, + PhysicalFunction tsBFunction, + PhysicalFunction distFunction) +{ + parameterFunctions.reserve(9); + parameterFunctions.push_back(std::move(lonAFunction)); + parameterFunctions.push_back(std::move(latAFunction)); + parameterFunctions.push_back(std::move(radiusAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(lonBFunction)); + parameterFunctions.push_back(std::move(latBFunction)); + parameterFunctions.push_back(std::move(radiusBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); + parameterFunctions.push_back(std::move(distFunction)); +} + +VarVal TemporalEDWithinTCbufferTCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lonA = parameterValues[0].cast>(); + auto latA = parameterValues[1].cast>(); + auto radiusA = parameterValues[2].cast>(); + auto tsA = parameterValues[3].cast>(); + auto lonB = parameterValues[4].cast>(); + auto latB = parameterValues[5].cast>(); + auto radiusB = parameterValues[6].cast>(); + auto tsB = parameterValues[7].cast>(); + auto dist = parameterValues[8].cast>(); + + const auto result = nautilus::invoke( + +[](double lonAValue, double latAValue, double radiusAValue, uint64_t tsAValue, + double lonBValue, double latBValue, double radiusBValue, uint64_t tsBValue, + double distValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonAValue >= -180.0 && lonAValue <= 180.0 && latAValue >= -90.0 && latAValue <= 90.0)) return 0; + if (!(lonBValue >= -180.0 && lonBValue <= 180.0 && latBValue >= -90.0 && latBValue <= 90.0)) return 0; + if (radiusAValue < 0.0 || radiusBValue < 0.0) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string wktA = fmt::format("Cbuffer(Point({} {}),{})@{}", lonAValue, latAValue, radiusAValue, tsAString); + std::string wktB = fmt::format("Cbuffer(Point({} {}),{})@{}", lonBValue, latBValue, radiusBValue, tsBString); + + Temporal* tA = tcbuffer_in(wktA.c_str()); + if (!tA) return 0; + Temporal* tB = tcbuffer_in(wktB.c_str()); + if (!tB) { free(tA); return 0; } + + int r = edwithin_tcbuffer_tcbuffer(tA, tB, distValue); + free(tA); + free(tB); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB, dist); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEDWithinTCbufferTCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 9, + "TemporalEDWithinTCbufferTCbufferPhysicalFunction requires 9 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + auto arg6 = std::move(arguments.childFunctions[6]); + auto arg7 = std::move(arguments.childFunctions[7]); + auto arg8 = std::move(arguments.childFunctions[8]); + return TemporalEDWithinTCbufferTCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7), std::move(arg8)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEDWithinTGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEDWithinTGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..7dbe6d5745 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEDWithinTGeometryPhysicalFunction.cpp @@ -0,0 +1,124 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalEDWithinTGeometryPhysicalFunction::TemporalEDWithinTGeometryPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction tsBFunction, + PhysicalFunction distFunction) +{ + parameterFunctions.reserve(7); + parameterFunctions.push_back(std::move(lonAFunction)); + parameterFunctions.push_back(std::move(latAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(lonBFunction)); + parameterFunctions.push_back(std::move(latBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); + parameterFunctions.push_back(std::move(distFunction)); +} + +VarVal TemporalEDWithinTGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lonA = parameterValues[0].cast>(); + auto latA = parameterValues[1].cast>(); + auto tsA = parameterValues[2].cast>(); + auto lonB = parameterValues[3].cast>(); + auto latB = parameterValues[4].cast>(); + auto tsB = parameterValues[5].cast>(); + auto dist = parameterValues[6].cast>(); + + const auto result = nautilus::invoke( + +[](double lonAValue, double latAValue, uint64_t tsAValue, + double lonBValue, double latBValue, uint64_t tsBValue, + double distValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonAValue >= -180.0 && lonAValue <= 180.0 && latAValue >= -90.0 && latAValue <= 90.0)) return 0; + if (!(lonBValue >= -180.0 && lonBValue <= 180.0 && latBValue >= -90.0 && latBValue <= 90.0)) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string temporalGeometryAWkt = fmt::format("SRID=4326;Point({} {})@{}", lonAValue, latAValue, tsAString); + std::string temporalGeometryBWkt = fmt::format("SRID=4326;Point({} {})@{}", lonBValue, latBValue, tsBString); + + MEOS::Meos::TemporalGeometry temporalGeometryA(temporalGeometryAWkt); + if (!temporalGeometryA.getGeometry()) return 0; + MEOS::Meos::TemporalGeometry temporalGeometryB(temporalGeometryBWkt); + if (!temporalGeometryB.getGeometry()) return 0; + + // MEOS *_tgeo_tgeo with trailing distance arg + // — int fn(const Temporal*, const Temporal*, double). + return edwithin_tgeo_tgeo(temporalGeometryA.getGeometry(), + temporalGeometryB.getGeometry(), + distValue); + } + catch (const std::exception&) + { + return 0; + } + }, + lonA, latA, tsA, lonB, latB, tsB, dist); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEDWithinTGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "TemporalEDWithinTGeometryPhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + auto arg6 = std::move(arguments.childFunctions[6]); + return TemporalEDWithinTGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEDisjointGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEDisjointGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..495dc71785 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEDisjointGeometryPhysicalFunction.cpp @@ -0,0 +1,124 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalEDisjointGeometryPhysicalFunction::TemporalEDisjointGeometryPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(4); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalEDisjointGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto timestamp = parameterValues[2].cast>(); + auto geometry = parameterValues[3].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + uint64_t timestampValue, + const char* geometryPtr, + uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) { + return 0; + } + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string temporalGeometryWkt = fmt::format("SRID=4326;Point({} {})@{}", lonValue, latValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (temporalGeometryWkt.empty() || staticGeometryWkt.empty()) + return 0; + + MEOS::Meos::TemporalGeometry temporalGeometry(temporalGeometryWkt); + if (!temporalGeometry.getGeometry()) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) return 0; + + // MEOS spatial-relation call — same shape as TemporalEDWithin's + // edwithin_tgeo_geo, but specific MEOS function per generated operator. + // Real MEOS spatial-rel signature: int fn(const Temporal *, const GSERIALIZED *) + // (no `atstart` flag — that's specific to geog_dwithin / edwithin's 3-arg variant). + return edisjoint_tgeo_geo(temporalGeometry.getGeometry(), + staticGeometry.getGeometry()); + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEDisjointGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "TemporalEDisjointGeometryPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + return TemporalEDisjointGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEDisjointTCbufferCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEDisjointTCbufferCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..948c9cb2bc --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEDisjointTCbufferCbufferPhysicalFunction.cpp @@ -0,0 +1,126 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalEDisjointTCbufferCbufferPhysicalFunction::TemporalEDisjointTCbufferCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction cbufferLitFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(radiusFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(cbufferLitFunction)); +} + +VarVal TemporalEDisjointTCbufferCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto cbufLit = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + double radiusValue, + uint64_t timestampValue, + const char* cbufLitPtr, + uint32_t cbufLitSize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({} {}),{})@{}", + lonValue, latValue, radiusValue, timestampString); + std::string cbufferLiteral(cbufLitPtr, cbufLitSize); + + while (!cbufferLiteral.empty() && (cbufferLiteral.front() == '\'' || cbufferLiteral.front() == '"')) + cbufferLiteral.erase(cbufferLiteral.begin()); + while (!cbufferLiteral.empty() && (cbufferLiteral.back() == '\'' || cbufferLiteral.back() == '"')) + cbufferLiteral.pop_back(); + + if (tcbufferWkt.empty() || cbufferLiteral.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + Cbuffer* cb = cbuffer_in(cbufferLiteral.c_str()); + if (!cb) { free(tcbuffer); return 0; } + + int r = edisjoint_tcbuffer_cbuffer(tcbuffer, cb); + free(tcbuffer); + free(cb); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, radius, timestamp, cbufLit.getContent(), cbufLit.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEDisjointTCbufferCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalEDisjointTCbufferCbufferPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalEDisjointTCbufferCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEDisjointTCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEDisjointTCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..1fee5ab0bf --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEDisjointTCbufferPhysicalFunction.cpp @@ -0,0 +1,125 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalEDisjointTCbufferPhysicalFunction::TemporalEDisjointTCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(radiusFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalEDisjointTCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto geometry = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + double radiusValue, + uint64_t timestampValue, + const char* geometryPtr, + uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({} {}),{})@{}", + lonValue, latValue, radiusValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tcbufferWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tcbuffer); return 0; } + + int r = edisjoint_tcbuffer_geo(tcbuffer, staticGeometry.getGeometry()); + free(tcbuffer); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, radius, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEDisjointTCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalEDisjointTCbufferPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalEDisjointTCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEDisjointTGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEDisjointTGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..1ca54a8fc9 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEDisjointTGeometryPhysicalFunction.cpp @@ -0,0 +1,117 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalEDisjointTGeometryPhysicalFunction::TemporalEDisjointTGeometryPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(6); + parameterFunctions.push_back(std::move(lonAFunction)); + parameterFunctions.push_back(std::move(latAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(lonBFunction)); + parameterFunctions.push_back(std::move(latBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalEDisjointTGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lonA = parameterValues[0].cast>(); + auto latA = parameterValues[1].cast>(); + auto tsA = parameterValues[2].cast>(); + auto lonB = parameterValues[3].cast>(); + auto latB = parameterValues[4].cast>(); + auto tsB = parameterValues[5].cast>(); + + const auto result = nautilus::invoke( + +[](double lonAValue, double latAValue, uint64_t tsAValue, + double lonBValue, double latBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonAValue >= -180.0 && lonAValue <= 180.0 && latAValue >= -90.0 && latAValue <= 90.0)) return 0; + if (!(lonBValue >= -180.0 && lonBValue <= 180.0 && latBValue >= -90.0 && latBValue <= 90.0)) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string temporalGeometryAWkt = fmt::format("SRID=4326;Point({} {})@{}", lonAValue, latAValue, tsAString); + std::string temporalGeometryBWkt = fmt::format("SRID=4326;Point({} {})@{}", lonBValue, latBValue, tsBString); + + MEOS::Meos::TemporalGeometry temporalGeometryA(temporalGeometryAWkt); + if (!temporalGeometryA.getGeometry()) return 0; + MEOS::Meos::TemporalGeometry temporalGeometryB(temporalGeometryBWkt); + if (!temporalGeometryB.getGeometry()) return 0; + + // MEOS *_tgeo_tgeo spatial-relation: int fn(const Temporal*, const Temporal*). + return edisjoint_tgeo_tgeo(temporalGeometryA.getGeometry(), + temporalGeometryB.getGeometry()); + } + catch (const std::exception&) + { + return 0; + } + }, + lonA, latA, tsA, lonB, latB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEDisjointTGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "TemporalEDisjointTGeometryPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + return TemporalEDisjointTGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEDisjointTNpointGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEDisjointTNpointGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..46f7468653 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEDisjointTNpointGeometryPhysicalFunction.cpp @@ -0,0 +1,118 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalEDisjointTNpointGeometryPhysicalFunction::TemporalEDisjointTNpointGeometryPhysicalFunction(PhysicalFunction ridFunction, + PhysicalFunction fractionFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(4); + parameterFunctions.push_back(std::move(ridFunction)); + parameterFunctions.push_back(std::move(fractionFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalEDisjointTNpointGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto rid = parameterValues[0].cast>(); + auto fraction = parameterValues[1].cast>(); + auto timestamp = parameterValues[2].cast>(); + auto geometry = parameterValues[3].cast(); + + const auto result = nautilus::invoke( + +[](uint64_t ridValue, double fractionValue, uint64_t timestampValue, + const char* geometryPtr, uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tnpointWkt = fmt::format("NPoint({}, {})@{}", ridValue, fractionValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tnpointWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tnpoint = tnpoint_in(tnpointWkt.c_str()); + if (!tnpoint) return 0; + Temporal* tgeo = tnpoint_to_tgeompoint(tnpoint); + if (!tgeo) { free(tnpoint); return 0; } + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tgeo); free(tnpoint); return 0; } + + int r = edisjoint_tgeo_geo(tgeo, staticGeometry.getGeometry()); + free(tgeo); + free(tnpoint); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + rid, fraction, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEDisjointTNpointGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "TemporalEDisjointTNpointGeometryPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + return TemporalEDisjointTNpointGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEDisjointTNpointTNpointPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEDisjointTNpointTNpointPhysicalFunction.cpp new file mode 100644 index 0000000000..382139b115 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEDisjointTNpointTNpointPhysicalFunction.cpp @@ -0,0 +1,126 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalEDisjointTNpointTNpointPhysicalFunction::TemporalEDisjointTNpointTNpointPhysicalFunction(PhysicalFunction ridAFunction, + PhysicalFunction fractionAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction ridBFunction, + PhysicalFunction fractionBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(6); + parameterFunctions.push_back(std::move(ridAFunction)); + parameterFunctions.push_back(std::move(fractionAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(ridBFunction)); + parameterFunctions.push_back(std::move(fractionBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalEDisjointTNpointTNpointPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto ridA = parameterValues[0].cast>(); + auto fractionA = parameterValues[1].cast>(); + auto tsA = parameterValues[2].cast>(); + auto ridB = parameterValues[3].cast>(); + auto fractionB = parameterValues[4].cast>(); + auto tsB = parameterValues[5].cast>(); + + const auto result = nautilus::invoke( + +[](uint64_t ridAValue, double fractionAValue, uint64_t tsAValue, + uint64_t ridBValue, double fractionBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string tnpointAWkt = fmt::format("NPoint({}, {})@{}", ridAValue, fractionAValue, tsAString); + std::string tnpointBWkt = fmt::format("NPoint({}, {})@{}", ridBValue, fractionBValue, tsBString); + + if (tnpointAWkt.empty() || tnpointBWkt.empty()) return 0; + + Temporal* tnpointA = tnpoint_in(tnpointAWkt.c_str()); + if (!tnpointA) return 0; + Temporal* tgeoA = tnpoint_to_tgeompoint(tnpointA); + if (!tgeoA) { free(tnpointA); return 0; } + Temporal* tnpointB = tnpoint_in(tnpointBWkt.c_str()); + if (!tnpointB) { free(tgeoA); free(tnpointA); return 0; } + Temporal* tgeoB = tnpoint_to_tgeompoint(tnpointB); + if (!tgeoB) { free(tnpointB); free(tgeoA); free(tnpointA); return 0; } + + int r = edisjoint_tgeo_tgeo(tgeoA, tgeoB); + free(tgeoB); + free(tnpointB); + free(tgeoA); + free(tnpointA); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + ridA, fractionA, tsA, ridB, fractionB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEDisjointTNpointTNpointPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "TemporalEDisjointTNpointTNpointPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + return TemporalEDisjointTNpointTNpointPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEDisjointTPoseGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEDisjointTPoseGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..ecc47f1b43 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEDisjointTPoseGeometryPhysicalFunction.cpp @@ -0,0 +1,124 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalEDisjointTPoseGeometryPhysicalFunction::TemporalEDisjointTPoseGeometryPhysicalFunction(PhysicalFunction xFunction, + PhysicalFunction yFunction, + PhysicalFunction thetaFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(xFunction)); + parameterFunctions.push_back(std::move(yFunction)); + parameterFunctions.push_back(std::move(thetaFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalEDisjointTPoseGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto x = parameterValues[0].cast>(); + auto y = parameterValues[1].cast>(); + auto theta = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto geometry = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double xValue, double yValue, double thetaValue, uint64_t timestampValue, + const char* geometryPtr, uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(xValue >= -180.0 && xValue <= 180.0 && yValue >= -90.0 && yValue <= 90.0)) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tposeWkt = fmt::format("Pose(Point({} {}), {})@{}", + xValue, yValue, thetaValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tposeWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tpose = tpose_in(tposeWkt.c_str()); + if (!tpose) return 0; + Temporal* tgeo = tpose_to_tpoint(tpose); + if (!tgeo) { free(tpose); return 0; } + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tgeo); free(tpose); return 0; } + + int r = edisjoint_tgeo_geo(tgeo, staticGeometry.getGeometry()); + free(tgeo); + free(tpose); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + x, y, theta, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEDisjointTPoseGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalEDisjointTPoseGeometryPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalEDisjointTPoseGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEDisjointTPoseTPosePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEDisjointTPoseTPosePhysicalFunction.cpp new file mode 100644 index 0000000000..b80c5ba86b --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEDisjointTPoseTPosePhysicalFunction.cpp @@ -0,0 +1,136 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalEDisjointTPoseTPosePhysicalFunction::TemporalEDisjointTPoseTPosePhysicalFunction(PhysicalFunction xAFunction, + PhysicalFunction yAFunction, + PhysicalFunction thetaAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction xBFunction, + PhysicalFunction yBFunction, + PhysicalFunction thetaBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(8); + parameterFunctions.push_back(std::move(xAFunction)); + parameterFunctions.push_back(std::move(yAFunction)); + parameterFunctions.push_back(std::move(thetaAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(xBFunction)); + parameterFunctions.push_back(std::move(yBFunction)); + parameterFunctions.push_back(std::move(thetaBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalEDisjointTPoseTPosePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto xA = parameterValues[0].cast>(); + auto yA = parameterValues[1].cast>(); + auto thetaA = parameterValues[2].cast>(); + auto tsA = parameterValues[3].cast>(); + auto xB = parameterValues[4].cast>(); + auto yB = parameterValues[5].cast>(); + auto thetaB = parameterValues[6].cast>(); + auto tsB = parameterValues[7].cast>(); + + const auto result = nautilus::invoke( + +[](double xAValue, double yAValue, double thetaAValue, uint64_t tsAValue, + double xBValue, double yBValue, double thetaBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(xAValue >= -180.0 && xAValue <= 180.0 && yAValue >= -90.0 && yAValue <= 90.0)) return 0; + if (!(xBValue >= -180.0 && xBValue <= 180.0 && yBValue >= -90.0 && yBValue <= 90.0)) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string tposeAWkt = fmt::format("Pose(Point({} {}), {})@{}", xAValue, yAValue, thetaAValue, tsAString); + std::string tposeBWkt = fmt::format("Pose(Point({} {}), {})@{}", xBValue, yBValue, thetaBValue, tsBString); + + if (tposeAWkt.empty() || tposeBWkt.empty()) return 0; + + Temporal* tposeA = tpose_in(tposeAWkt.c_str()); + if (!tposeA) return 0; + Temporal* tgeoA = tpose_to_tpoint(tposeA); + if (!tgeoA) { free(tposeA); return 0; } + Temporal* tposeB = tpose_in(tposeBWkt.c_str()); + if (!tposeB) { free(tgeoA); free(tposeA); return 0; } + Temporal* tgeoB = tpose_to_tpoint(tposeB); + if (!tgeoB) { free(tposeB); free(tgeoA); free(tposeA); return 0; } + + int r = edisjoint_tgeo_tgeo(tgeoA, tgeoB); + free(tgeoB); + free(tposeB); + free(tgeoA); + free(tposeA); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + xA, yA, thetaA, tsA, xB, yB, thetaB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEDisjointTPoseTPosePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "TemporalEDisjointTPoseTPosePhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + auto arg6 = std::move(arguments.childFunctions[6]); + auto arg7 = std::move(arguments.childFunctions[7]); + return TemporalEDisjointTPoseTPosePhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEIntersectsGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEIntersectsGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..847b2cf06a --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEIntersectsGeometryPhysicalFunction.cpp @@ -0,0 +1,124 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalEIntersectsGeometryPhysicalFunction::TemporalEIntersectsGeometryPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(4); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalEIntersectsGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto timestamp = parameterValues[2].cast>(); + auto geometry = parameterValues[3].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + uint64_t timestampValue, + const char* geometryPtr, + uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) { + return 0; + } + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string temporalGeometryWkt = fmt::format("SRID=4326;Point({} {})@{}", lonValue, latValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (temporalGeometryWkt.empty() || staticGeometryWkt.empty()) + return 0; + + MEOS::Meos::TemporalGeometry temporalGeometry(temporalGeometryWkt); + if (!temporalGeometry.getGeometry()) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) return 0; + + // MEOS spatial-relation call — same shape as TemporalEDWithin's + // edwithin_tgeo_geo, but specific MEOS function per generated operator. + // Real MEOS spatial-rel signature: int fn(const Temporal *, const GSERIALIZED *) + // (no `atstart` flag — that's specific to geog_dwithin / edwithin's 3-arg variant). + return eintersects_tgeo_geo(temporalGeometry.getGeometry(), + staticGeometry.getGeometry()); + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEIntersectsGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "TemporalEIntersectsGeometryPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + return TemporalEIntersectsGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEIntersectsTCbufferCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEIntersectsTCbufferCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..d41dd7bdbb --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEIntersectsTCbufferCbufferPhysicalFunction.cpp @@ -0,0 +1,126 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalEIntersectsTCbufferCbufferPhysicalFunction::TemporalEIntersectsTCbufferCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction cbufferLitFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(radiusFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(cbufferLitFunction)); +} + +VarVal TemporalEIntersectsTCbufferCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto cbufLit = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + double radiusValue, + uint64_t timestampValue, + const char* cbufLitPtr, + uint32_t cbufLitSize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({} {}),{})@{}", + lonValue, latValue, radiusValue, timestampString); + std::string cbufferLiteral(cbufLitPtr, cbufLitSize); + + while (!cbufferLiteral.empty() && (cbufferLiteral.front() == '\'' || cbufferLiteral.front() == '"')) + cbufferLiteral.erase(cbufferLiteral.begin()); + while (!cbufferLiteral.empty() && (cbufferLiteral.back() == '\'' || cbufferLiteral.back() == '"')) + cbufferLiteral.pop_back(); + + if (tcbufferWkt.empty() || cbufferLiteral.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + Cbuffer* cb = cbuffer_in(cbufferLiteral.c_str()); + if (!cb) { free(tcbuffer); return 0; } + + int r = eintersects_tcbuffer_cbuffer(tcbuffer, cb); + free(tcbuffer); + free(cb); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, radius, timestamp, cbufLit.getContent(), cbufLit.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEIntersectsTCbufferCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalEIntersectsTCbufferCbufferPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalEIntersectsTCbufferCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEIntersectsTCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEIntersectsTCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..e35995fa24 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEIntersectsTCbufferPhysicalFunction.cpp @@ -0,0 +1,125 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalEIntersectsTCbufferPhysicalFunction::TemporalEIntersectsTCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(radiusFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalEIntersectsTCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto geometry = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + double radiusValue, + uint64_t timestampValue, + const char* geometryPtr, + uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({} {}),{})@{}", + lonValue, latValue, radiusValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tcbufferWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tcbuffer); return 0; } + + int r = eintersects_tcbuffer_geo(tcbuffer, staticGeometry.getGeometry()); + free(tcbuffer); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, radius, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEIntersectsTCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalEIntersectsTCbufferPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalEIntersectsTCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEIntersectsTCbufferTCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEIntersectsTCbufferTCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..2edfa8b7e8 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEIntersectsTCbufferTCbufferPhysicalFunction.cpp @@ -0,0 +1,127 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalEIntersectsTCbufferTCbufferPhysicalFunction::TemporalEIntersectsTCbufferTCbufferPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction radiusAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction radiusBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(8); + parameterFunctions.push_back(std::move(lonAFunction)); + parameterFunctions.push_back(std::move(latAFunction)); + parameterFunctions.push_back(std::move(radiusAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(lonBFunction)); + parameterFunctions.push_back(std::move(latBFunction)); + parameterFunctions.push_back(std::move(radiusBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalEIntersectsTCbufferTCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lonA = parameterValues[0].cast>(); + auto latA = parameterValues[1].cast>(); + auto radiusA = parameterValues[2].cast>(); + auto tsA = parameterValues[3].cast>(); + auto lonB = parameterValues[4].cast>(); + auto latB = parameterValues[5].cast>(); + auto radiusB = parameterValues[6].cast>(); + auto tsB = parameterValues[7].cast>(); + + const auto result = nautilus::invoke( + +[](double lonAValue, double latAValue, double radiusAValue, uint64_t tsAValue, + double lonBValue, double latBValue, double radiusBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonAValue >= -180.0 && lonAValue <= 180.0 && latAValue >= -90.0 && latAValue <= 90.0)) return 0; + if (!(lonBValue >= -180.0 && lonBValue <= 180.0 && latBValue >= -90.0 && latBValue <= 90.0)) return 0; + if (radiusAValue < 0.0 || radiusBValue < 0.0) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string wktA = fmt::format("Cbuffer(Point({} {}),{})@{}", lonAValue, latAValue, radiusAValue, tsAString); + std::string wktB = fmt::format("Cbuffer(Point({} {}),{})@{}", lonBValue, latBValue, radiusBValue, tsBString); + + Temporal* tA = tcbuffer_in(wktA.c_str()); + if (!tA) return 0; + Temporal* tB = tcbuffer_in(wktB.c_str()); + if (!tB) { free(tA); return 0; } + + int r = eintersects_tcbuffer_tcbuffer(tA, tB); + free(tA); + free(tB); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEIntersectsTCbufferTCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "TemporalEIntersectsTCbufferTCbufferPhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + auto arg6 = std::move(arguments.childFunctions[6]); + auto arg7 = std::move(arguments.childFunctions[7]); + return TemporalEIntersectsTCbufferTCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEIntersectsTGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEIntersectsTGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..2654e596fd --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEIntersectsTGeometryPhysicalFunction.cpp @@ -0,0 +1,117 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalEIntersectsTGeometryPhysicalFunction::TemporalEIntersectsTGeometryPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(6); + parameterFunctions.push_back(std::move(lonAFunction)); + parameterFunctions.push_back(std::move(latAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(lonBFunction)); + parameterFunctions.push_back(std::move(latBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalEIntersectsTGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lonA = parameterValues[0].cast>(); + auto latA = parameterValues[1].cast>(); + auto tsA = parameterValues[2].cast>(); + auto lonB = parameterValues[3].cast>(); + auto latB = parameterValues[4].cast>(); + auto tsB = parameterValues[5].cast>(); + + const auto result = nautilus::invoke( + +[](double lonAValue, double latAValue, uint64_t tsAValue, + double lonBValue, double latBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonAValue >= -180.0 && lonAValue <= 180.0 && latAValue >= -90.0 && latAValue <= 90.0)) return 0; + if (!(lonBValue >= -180.0 && lonBValue <= 180.0 && latBValue >= -90.0 && latBValue <= 90.0)) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string temporalGeometryAWkt = fmt::format("SRID=4326;Point({} {})@{}", lonAValue, latAValue, tsAString); + std::string temporalGeometryBWkt = fmt::format("SRID=4326;Point({} {})@{}", lonBValue, latBValue, tsBString); + + MEOS::Meos::TemporalGeometry temporalGeometryA(temporalGeometryAWkt); + if (!temporalGeometryA.getGeometry()) return 0; + MEOS::Meos::TemporalGeometry temporalGeometryB(temporalGeometryBWkt); + if (!temporalGeometryB.getGeometry()) return 0; + + // MEOS *_tgeo_tgeo spatial-relation: int fn(const Temporal*, const Temporal*). + return eintersects_tgeo_tgeo(temporalGeometryA.getGeometry(), + temporalGeometryB.getGeometry()); + } + catch (const std::exception&) + { + return 0; + } + }, + lonA, latA, tsA, lonB, latB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEIntersectsTGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "TemporalEIntersectsTGeometryPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + return TemporalEIntersectsTGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEIntersectsTNpointGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEIntersectsTNpointGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..f725c4834c --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEIntersectsTNpointGeometryPhysicalFunction.cpp @@ -0,0 +1,118 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalEIntersectsTNpointGeometryPhysicalFunction::TemporalEIntersectsTNpointGeometryPhysicalFunction(PhysicalFunction ridFunction, + PhysicalFunction fractionFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(4); + parameterFunctions.push_back(std::move(ridFunction)); + parameterFunctions.push_back(std::move(fractionFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalEIntersectsTNpointGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto rid = parameterValues[0].cast>(); + auto fraction = parameterValues[1].cast>(); + auto timestamp = parameterValues[2].cast>(); + auto geometry = parameterValues[3].cast(); + + const auto result = nautilus::invoke( + +[](uint64_t ridValue, double fractionValue, uint64_t timestampValue, + const char* geometryPtr, uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tnpointWkt = fmt::format("NPoint({}, {})@{}", ridValue, fractionValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tnpointWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tnpoint = tnpoint_in(tnpointWkt.c_str()); + if (!tnpoint) return 0; + Temporal* tgeo = tnpoint_to_tgeompoint(tnpoint); + if (!tgeo) { free(tnpoint); return 0; } + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tgeo); free(tnpoint); return 0; } + + int r = eintersects_tgeo_geo(tgeo, staticGeometry.getGeometry()); + free(tgeo); + free(tnpoint); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + rid, fraction, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEIntersectsTNpointGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "TemporalEIntersectsTNpointGeometryPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + return TemporalEIntersectsTNpointGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEIntersectsTNpointTNpointPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEIntersectsTNpointTNpointPhysicalFunction.cpp new file mode 100644 index 0000000000..e958e3f6dd --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEIntersectsTNpointTNpointPhysicalFunction.cpp @@ -0,0 +1,126 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalEIntersectsTNpointTNpointPhysicalFunction::TemporalEIntersectsTNpointTNpointPhysicalFunction(PhysicalFunction ridAFunction, + PhysicalFunction fractionAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction ridBFunction, + PhysicalFunction fractionBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(6); + parameterFunctions.push_back(std::move(ridAFunction)); + parameterFunctions.push_back(std::move(fractionAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(ridBFunction)); + parameterFunctions.push_back(std::move(fractionBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalEIntersectsTNpointTNpointPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto ridA = parameterValues[0].cast>(); + auto fractionA = parameterValues[1].cast>(); + auto tsA = parameterValues[2].cast>(); + auto ridB = parameterValues[3].cast>(); + auto fractionB = parameterValues[4].cast>(); + auto tsB = parameterValues[5].cast>(); + + const auto result = nautilus::invoke( + +[](uint64_t ridAValue, double fractionAValue, uint64_t tsAValue, + uint64_t ridBValue, double fractionBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string tnpointAWkt = fmt::format("NPoint({}, {})@{}", ridAValue, fractionAValue, tsAString); + std::string tnpointBWkt = fmt::format("NPoint({}, {})@{}", ridBValue, fractionBValue, tsBString); + + if (tnpointAWkt.empty() || tnpointBWkt.empty()) return 0; + + Temporal* tnpointA = tnpoint_in(tnpointAWkt.c_str()); + if (!tnpointA) return 0; + Temporal* tgeoA = tnpoint_to_tgeompoint(tnpointA); + if (!tgeoA) { free(tnpointA); return 0; } + Temporal* tnpointB = tnpoint_in(tnpointBWkt.c_str()); + if (!tnpointB) { free(tgeoA); free(tnpointA); return 0; } + Temporal* tgeoB = tnpoint_to_tgeompoint(tnpointB); + if (!tgeoB) { free(tnpointB); free(tgeoA); free(tnpointA); return 0; } + + int r = eintersects_tgeo_tgeo(tgeoA, tgeoB); + free(tgeoB); + free(tnpointB); + free(tgeoA); + free(tnpointA); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + ridA, fractionA, tsA, ridB, fractionB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEIntersectsTNpointTNpointPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "TemporalEIntersectsTNpointTNpointPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + return TemporalEIntersectsTNpointTNpointPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEIntersectsTPoseGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEIntersectsTPoseGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..02a357ae40 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEIntersectsTPoseGeometryPhysicalFunction.cpp @@ -0,0 +1,124 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalEIntersectsTPoseGeometryPhysicalFunction::TemporalEIntersectsTPoseGeometryPhysicalFunction(PhysicalFunction xFunction, + PhysicalFunction yFunction, + PhysicalFunction thetaFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(xFunction)); + parameterFunctions.push_back(std::move(yFunction)); + parameterFunctions.push_back(std::move(thetaFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalEIntersectsTPoseGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto x = parameterValues[0].cast>(); + auto y = parameterValues[1].cast>(); + auto theta = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto geometry = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double xValue, double yValue, double thetaValue, uint64_t timestampValue, + const char* geometryPtr, uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(xValue >= -180.0 && xValue <= 180.0 && yValue >= -90.0 && yValue <= 90.0)) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tposeWkt = fmt::format("Pose(Point({} {}), {})@{}", + xValue, yValue, thetaValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tposeWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tpose = tpose_in(tposeWkt.c_str()); + if (!tpose) return 0; + Temporal* tgeo = tpose_to_tpoint(tpose); + if (!tgeo) { free(tpose); return 0; } + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tgeo); free(tpose); return 0; } + + int r = eintersects_tgeo_geo(tgeo, staticGeometry.getGeometry()); + free(tgeo); + free(tpose); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + x, y, theta, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEIntersectsTPoseGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalEIntersectsTPoseGeometryPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalEIntersectsTPoseGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalEIntersectsTPoseTPosePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalEIntersectsTPoseTPosePhysicalFunction.cpp new file mode 100644 index 0000000000..a0ae84b98f --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalEIntersectsTPoseTPosePhysicalFunction.cpp @@ -0,0 +1,136 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalEIntersectsTPoseTPosePhysicalFunction::TemporalEIntersectsTPoseTPosePhysicalFunction(PhysicalFunction xAFunction, + PhysicalFunction yAFunction, + PhysicalFunction thetaAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction xBFunction, + PhysicalFunction yBFunction, + PhysicalFunction thetaBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(8); + parameterFunctions.push_back(std::move(xAFunction)); + parameterFunctions.push_back(std::move(yAFunction)); + parameterFunctions.push_back(std::move(thetaAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(xBFunction)); + parameterFunctions.push_back(std::move(yBFunction)); + parameterFunctions.push_back(std::move(thetaBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalEIntersectsTPoseTPosePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto xA = parameterValues[0].cast>(); + auto yA = parameterValues[1].cast>(); + auto thetaA = parameterValues[2].cast>(); + auto tsA = parameterValues[3].cast>(); + auto xB = parameterValues[4].cast>(); + auto yB = parameterValues[5].cast>(); + auto thetaB = parameterValues[6].cast>(); + auto tsB = parameterValues[7].cast>(); + + const auto result = nautilus::invoke( + +[](double xAValue, double yAValue, double thetaAValue, uint64_t tsAValue, + double xBValue, double yBValue, double thetaBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(xAValue >= -180.0 && xAValue <= 180.0 && yAValue >= -90.0 && yAValue <= 90.0)) return 0; + if (!(xBValue >= -180.0 && xBValue <= 180.0 && yBValue >= -90.0 && yBValue <= 90.0)) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string tposeAWkt = fmt::format("Pose(Point({} {}), {})@{}", xAValue, yAValue, thetaAValue, tsAString); + std::string tposeBWkt = fmt::format("Pose(Point({} {}), {})@{}", xBValue, yBValue, thetaBValue, tsBString); + + if (tposeAWkt.empty() || tposeBWkt.empty()) return 0; + + Temporal* tposeA = tpose_in(tposeAWkt.c_str()); + if (!tposeA) return 0; + Temporal* tgeoA = tpose_to_tpoint(tposeA); + if (!tgeoA) { free(tposeA); return 0; } + Temporal* tposeB = tpose_in(tposeBWkt.c_str()); + if (!tposeB) { free(tgeoA); free(tposeA); return 0; } + Temporal* tgeoB = tpose_to_tpoint(tposeB); + if (!tgeoB) { free(tposeB); free(tgeoA); free(tposeA); return 0; } + + int r = eintersects_tgeo_tgeo(tgeoA, tgeoB); + free(tgeoB); + free(tposeB); + free(tgeoA); + free(tposeA); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + xA, yA, thetaA, tsA, xB, yB, thetaB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalEIntersectsTPoseTPosePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "TemporalEIntersectsTPoseTPosePhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + auto arg6 = std::move(arguments.childFunctions[6]); + auto arg7 = std::move(arguments.childFunctions[7]); + return TemporalEIntersectsTPoseTPosePhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalETouchesGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalETouchesGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..b66b50a0d0 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalETouchesGeometryPhysicalFunction.cpp @@ -0,0 +1,124 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalETouchesGeometryPhysicalFunction::TemporalETouchesGeometryPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(4); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalETouchesGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto timestamp = parameterValues[2].cast>(); + auto geometry = parameterValues[3].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + uint64_t timestampValue, + const char* geometryPtr, + uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) { + return 0; + } + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string temporalGeometryWkt = fmt::format("SRID=4326;Point({} {})@{}", lonValue, latValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (temporalGeometryWkt.empty() || staticGeometryWkt.empty()) + return 0; + + MEOS::Meos::TemporalGeometry temporalGeometry(temporalGeometryWkt); + if (!temporalGeometry.getGeometry()) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) return 0; + + // MEOS spatial-relation call — same shape as TemporalEDWithin's + // edwithin_tgeo_geo, but specific MEOS function per generated operator. + // Real MEOS spatial-rel signature: int fn(const Temporal *, const GSERIALIZED *) + // (no `atstart` flag — that's specific to geog_dwithin / edwithin's 3-arg variant). + return etouches_tgeo_geo(temporalGeometry.getGeometry(), + staticGeometry.getGeometry()); + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalETouchesGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "TemporalETouchesGeometryPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + return TemporalETouchesGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalETouchesTCbufferCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalETouchesTCbufferCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..2d77b52141 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalETouchesTCbufferCbufferPhysicalFunction.cpp @@ -0,0 +1,126 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalETouchesTCbufferCbufferPhysicalFunction::TemporalETouchesTCbufferCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction cbufferLitFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(radiusFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(cbufferLitFunction)); +} + +VarVal TemporalETouchesTCbufferCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto cbufLit = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + double radiusValue, + uint64_t timestampValue, + const char* cbufLitPtr, + uint32_t cbufLitSize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({} {}),{})@{}", + lonValue, latValue, radiusValue, timestampString); + std::string cbufferLiteral(cbufLitPtr, cbufLitSize); + + while (!cbufferLiteral.empty() && (cbufferLiteral.front() == '\'' || cbufferLiteral.front() == '"')) + cbufferLiteral.erase(cbufferLiteral.begin()); + while (!cbufferLiteral.empty() && (cbufferLiteral.back() == '\'' || cbufferLiteral.back() == '"')) + cbufferLiteral.pop_back(); + + if (tcbufferWkt.empty() || cbufferLiteral.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + Cbuffer* cb = cbuffer_in(cbufferLiteral.c_str()); + if (!cb) { free(tcbuffer); return 0; } + + int r = etouches_tcbuffer_cbuffer(tcbuffer, cb); + free(tcbuffer); + free(cb); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, radius, timestamp, cbufLit.getContent(), cbufLit.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalETouchesTCbufferCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalETouchesTCbufferCbufferPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalETouchesTCbufferCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalETouchesTCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalETouchesTCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..ae6e9b6a87 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalETouchesTCbufferPhysicalFunction.cpp @@ -0,0 +1,125 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalETouchesTCbufferPhysicalFunction::TemporalETouchesTCbufferPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction radiusFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(radiusFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalETouchesTCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto geometry = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + double radiusValue, + uint64_t timestampValue, + const char* geometryPtr, + uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({} {}),{})@{}", + lonValue, latValue, radiusValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tcbufferWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tcbuffer); return 0; } + + int r = etouches_tcbuffer_geo(tcbuffer, staticGeometry.getGeometry()); + free(tcbuffer); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, radius, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalETouchesTCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalETouchesTCbufferPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalETouchesTCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalETouchesTCbufferTCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalETouchesTCbufferTCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..28ab4beb81 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalETouchesTCbufferTCbufferPhysicalFunction.cpp @@ -0,0 +1,127 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalETouchesTCbufferTCbufferPhysicalFunction::TemporalETouchesTCbufferTCbufferPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction radiusAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction radiusBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(8); + parameterFunctions.push_back(std::move(lonAFunction)); + parameterFunctions.push_back(std::move(latAFunction)); + parameterFunctions.push_back(std::move(radiusAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(lonBFunction)); + parameterFunctions.push_back(std::move(latBFunction)); + parameterFunctions.push_back(std::move(radiusBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalETouchesTCbufferTCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lonA = parameterValues[0].cast>(); + auto latA = parameterValues[1].cast>(); + auto radiusA = parameterValues[2].cast>(); + auto tsA = parameterValues[3].cast>(); + auto lonB = parameterValues[4].cast>(); + auto latB = parameterValues[5].cast>(); + auto radiusB = parameterValues[6].cast>(); + auto tsB = parameterValues[7].cast>(); + + const auto result = nautilus::invoke( + +[](double lonAValue, double latAValue, double radiusAValue, uint64_t tsAValue, + double lonBValue, double latBValue, double radiusBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonAValue >= -180.0 && lonAValue <= 180.0 && latAValue >= -90.0 && latAValue <= 90.0)) return 0; + if (!(lonBValue >= -180.0 && lonBValue <= 180.0 && latBValue >= -90.0 && latBValue <= 90.0)) return 0; + if (radiusAValue < 0.0 || radiusBValue < 0.0) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string wktA = fmt::format("Cbuffer(Point({} {}),{})@{}", lonAValue, latAValue, radiusAValue, tsAString); + std::string wktB = fmt::format("Cbuffer(Point({} {}),{})@{}", lonBValue, latBValue, radiusBValue, tsBString); + + Temporal* tA = tcbuffer_in(wktA.c_str()); + if (!tA) return 0; + Temporal* tB = tcbuffer_in(wktB.c_str()); + if (!tB) { free(tA); return 0; } + + int r = etouches_tcbuffer_tcbuffer(tA, tB); + free(tA); + free(tB); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalETouchesTCbufferTCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "TemporalETouchesTCbufferTCbufferPhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + auto arg6 = std::move(arguments.childFunctions[6]); + auto arg7 = std::move(arguments.childFunctions[7]); + return TemporalETouchesTCbufferTCbufferPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalETouchesTGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalETouchesTGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..092df2a3cf --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalETouchesTGeometryPhysicalFunction.cpp @@ -0,0 +1,117 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalETouchesTGeometryPhysicalFunction::TemporalETouchesTGeometryPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(6); + parameterFunctions.push_back(std::move(lonAFunction)); + parameterFunctions.push_back(std::move(latAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(lonBFunction)); + parameterFunctions.push_back(std::move(latBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalETouchesTGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lonA = parameterValues[0].cast>(); + auto latA = parameterValues[1].cast>(); + auto tsA = parameterValues[2].cast>(); + auto lonB = parameterValues[3].cast>(); + auto latB = parameterValues[4].cast>(); + auto tsB = parameterValues[5].cast>(); + + const auto result = nautilus::invoke( + +[](double lonAValue, double latAValue, uint64_t tsAValue, + double lonBValue, double latBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonAValue >= -180.0 && lonAValue <= 180.0 && latAValue >= -90.0 && latAValue <= 90.0)) return 0; + if (!(lonBValue >= -180.0 && lonBValue <= 180.0 && latBValue >= -90.0 && latBValue <= 90.0)) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string temporalGeometryAWkt = fmt::format("SRID=4326;Point({} {})@{}", lonAValue, latAValue, tsAString); + std::string temporalGeometryBWkt = fmt::format("SRID=4326;Point({} {})@{}", lonBValue, latBValue, tsBString); + + MEOS::Meos::TemporalGeometry temporalGeometryA(temporalGeometryAWkt); + if (!temporalGeometryA.getGeometry()) return 0; + MEOS::Meos::TemporalGeometry temporalGeometryB(temporalGeometryBWkt); + if (!temporalGeometryB.getGeometry()) return 0; + + // MEOS *_tgeo_tgeo spatial-relation: int fn(const Temporal*, const Temporal*). + return etouches_tgeo_tgeo(temporalGeometryA.getGeometry(), + temporalGeometryB.getGeometry()); + } + catch (const std::exception&) + { + return 0; + } + }, + lonA, latA, tsA, lonB, latB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalETouchesTGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "TemporalETouchesTGeometryPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + return TemporalETouchesTGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalETouchesTNpointGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalETouchesTNpointGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..1d5cac5d68 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalETouchesTNpointGeometryPhysicalFunction.cpp @@ -0,0 +1,118 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalETouchesTNpointGeometryPhysicalFunction::TemporalETouchesTNpointGeometryPhysicalFunction(PhysicalFunction ridFunction, + PhysicalFunction fractionFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(4); + parameterFunctions.push_back(std::move(ridFunction)); + parameterFunctions.push_back(std::move(fractionFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalETouchesTNpointGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto rid = parameterValues[0].cast>(); + auto fraction = parameterValues[1].cast>(); + auto timestamp = parameterValues[2].cast>(); + auto geometry = parameterValues[3].cast(); + + const auto result = nautilus::invoke( + +[](uint64_t ridValue, double fractionValue, uint64_t timestampValue, + const char* geometryPtr, uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tnpointWkt = fmt::format("NPoint({}, {})@{}", ridValue, fractionValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tnpointWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tnpoint = tnpoint_in(tnpointWkt.c_str()); + if (!tnpoint) return 0; + Temporal* tgeo = tnpoint_to_tgeompoint(tnpoint); + if (!tgeo) { free(tnpoint); return 0; } + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tgeo); free(tnpoint); return 0; } + + int r = etouches_tgeo_geo(tgeo, staticGeometry.getGeometry()); + free(tgeo); + free(tnpoint); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + rid, fraction, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalETouchesTNpointGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "TemporalETouchesTNpointGeometryPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + return TemporalETouchesTNpointGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalETouchesTNpointTNpointPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalETouchesTNpointTNpointPhysicalFunction.cpp new file mode 100644 index 0000000000..7c6c5ceb1f --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalETouchesTNpointTNpointPhysicalFunction.cpp @@ -0,0 +1,126 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalETouchesTNpointTNpointPhysicalFunction::TemporalETouchesTNpointTNpointPhysicalFunction(PhysicalFunction ridAFunction, + PhysicalFunction fractionAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction ridBFunction, + PhysicalFunction fractionBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(6); + parameterFunctions.push_back(std::move(ridAFunction)); + parameterFunctions.push_back(std::move(fractionAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(ridBFunction)); + parameterFunctions.push_back(std::move(fractionBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalETouchesTNpointTNpointPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto ridA = parameterValues[0].cast>(); + auto fractionA = parameterValues[1].cast>(); + auto tsA = parameterValues[2].cast>(); + auto ridB = parameterValues[3].cast>(); + auto fractionB = parameterValues[4].cast>(); + auto tsB = parameterValues[5].cast>(); + + const auto result = nautilus::invoke( + +[](uint64_t ridAValue, double fractionAValue, uint64_t tsAValue, + uint64_t ridBValue, double fractionBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string tnpointAWkt = fmt::format("NPoint({}, {})@{}", ridAValue, fractionAValue, tsAString); + std::string tnpointBWkt = fmt::format("NPoint({}, {})@{}", ridBValue, fractionBValue, tsBString); + + if (tnpointAWkt.empty() || tnpointBWkt.empty()) return 0; + + Temporal* tnpointA = tnpoint_in(tnpointAWkt.c_str()); + if (!tnpointA) return 0; + Temporal* tgeoA = tnpoint_to_tgeompoint(tnpointA); + if (!tgeoA) { free(tnpointA); return 0; } + Temporal* tnpointB = tnpoint_in(tnpointBWkt.c_str()); + if (!tnpointB) { free(tgeoA); free(tnpointA); return 0; } + Temporal* tgeoB = tnpoint_to_tgeompoint(tnpointB); + if (!tgeoB) { free(tnpointB); free(tgeoA); free(tnpointA); return 0; } + + int r = etouches_tgeo_tgeo(tgeoA, tgeoB); + free(tgeoB); + free(tnpointB); + free(tgeoA); + free(tnpointA); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + ridA, fractionA, tsA, ridB, fractionB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalETouchesTNpointTNpointPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "TemporalETouchesTNpointTNpointPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + return TemporalETouchesTNpointTNpointPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalETouchesTPoseGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalETouchesTPoseGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..762fb564bb --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalETouchesTPoseGeometryPhysicalFunction.cpp @@ -0,0 +1,124 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalETouchesTPoseGeometryPhysicalFunction::TemporalETouchesTPoseGeometryPhysicalFunction(PhysicalFunction xFunction, + PhysicalFunction yFunction, + PhysicalFunction thetaFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(5); + parameterFunctions.push_back(std::move(xFunction)); + parameterFunctions.push_back(std::move(yFunction)); + parameterFunctions.push_back(std::move(thetaFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalETouchesTPoseGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto x = parameterValues[0].cast>(); + auto y = parameterValues[1].cast>(); + auto theta = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto geometry = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double xValue, double yValue, double thetaValue, uint64_t timestampValue, + const char* geometryPtr, uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(xValue >= -180.0 && xValue <= 180.0 && yValue >= -90.0 && yValue <= 90.0)) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tposeWkt = fmt::format("Pose(Point({} {}), {})@{}", + xValue, yValue, thetaValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tposeWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tpose = tpose_in(tposeWkt.c_str()); + if (!tpose) return 0; + Temporal* tgeo = tpose_to_tpoint(tpose); + if (!tgeo) { free(tpose); return 0; } + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) { free(tgeo); free(tpose); return 0; } + + int r = etouches_tgeo_geo(tgeo, staticGeometry.getGeometry()); + free(tgeo); + free(tpose); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + x, y, theta, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalETouchesTPoseGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "TemporalETouchesTPoseGeometryPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + return TemporalETouchesTPoseGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalETouchesTPoseTPosePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalETouchesTPoseTPosePhysicalFunction.cpp new file mode 100644 index 0000000000..b3de0feea9 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalETouchesTPoseTPosePhysicalFunction.cpp @@ -0,0 +1,136 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +TemporalETouchesTPoseTPosePhysicalFunction::TemporalETouchesTPoseTPosePhysicalFunction(PhysicalFunction xAFunction, + PhysicalFunction yAFunction, + PhysicalFunction thetaAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction xBFunction, + PhysicalFunction yBFunction, + PhysicalFunction thetaBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(8); + parameterFunctions.push_back(std::move(xAFunction)); + parameterFunctions.push_back(std::move(yAFunction)); + parameterFunctions.push_back(std::move(thetaAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(xBFunction)); + parameterFunctions.push_back(std::move(yBFunction)); + parameterFunctions.push_back(std::move(thetaBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalETouchesTPoseTPosePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto xA = parameterValues[0].cast>(); + auto yA = parameterValues[1].cast>(); + auto thetaA = parameterValues[2].cast>(); + auto tsA = parameterValues[3].cast>(); + auto xB = parameterValues[4].cast>(); + auto yB = parameterValues[5].cast>(); + auto thetaB = parameterValues[6].cast>(); + auto tsB = parameterValues[7].cast>(); + + const auto result = nautilus::invoke( + +[](double xAValue, double yAValue, double thetaAValue, uint64_t tsAValue, + double xBValue, double yBValue, double thetaBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(xAValue >= -180.0 && xAValue <= 180.0 && yAValue >= -90.0 && yAValue <= 90.0)) return 0; + if (!(xBValue >= -180.0 && xBValue <= 180.0 && yBValue >= -90.0 && yBValue <= 90.0)) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string tposeAWkt = fmt::format("Pose(Point({} {}), {})@{}", xAValue, yAValue, thetaAValue, tsAString); + std::string tposeBWkt = fmt::format("Pose(Point({} {}), {})@{}", xBValue, yBValue, thetaBValue, tsBString); + + if (tposeAWkt.empty() || tposeBWkt.empty()) return 0; + + Temporal* tposeA = tpose_in(tposeAWkt.c_str()); + if (!tposeA) return 0; + Temporal* tgeoA = tpose_to_tpoint(tposeA); + if (!tgeoA) { free(tposeA); return 0; } + Temporal* tposeB = tpose_in(tposeBWkt.c_str()); + if (!tposeB) { free(tgeoA); free(tposeA); return 0; } + Temporal* tgeoB = tpose_to_tpoint(tposeB); + if (!tgeoB) { free(tposeB); free(tgeoA); free(tposeA); return 0; } + + int r = etouches_tgeo_tgeo(tgeoA, tgeoB); + free(tgeoB); + free(tposeB); + free(tgeoA); + free(tposeA); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + xA, yA, thetaA, tsA, xB, yB, thetaB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalETouchesTPoseTPosePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "TemporalETouchesTPoseTPosePhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + auto arg6 = std::move(arguments.childFunctions[6]); + auto arg7 = std::move(arguments.childFunctions[7]); + return TemporalETouchesTPoseTPosePhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalMinusGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalMinusGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..f0b5ff6ead --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalMinusGeometryPhysicalFunction.cpp @@ -0,0 +1,124 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalMinusGeometryPhysicalFunction::TemporalMinusGeometryPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(4); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalMinusGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto timestamp = parameterValues[2].cast>(); + auto geometry = parameterValues[3].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + uint64_t timestampValue, + const char* geometryPtr, + uint32_t geometrySize) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string temporalGeometryWkt = fmt::format("SRID=4326;Point({} {})@{}", lonValue, latValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (temporalGeometryWkt.empty() || staticGeometryWkt.empty()) return 0; + + MEOS::Meos::TemporalGeometry temporalGeometry(temporalGeometryWkt); + if (!temporalGeometry.getGeometry()) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) return 0; + + // MEOS restriction call — returns Temporal* (non-null if the + // input survived the restriction, null if clipped/empty). + // For per-event single-instant inputs this collapses to a + // filter predicate: 1 if the point survives, 0 if clipped. + Temporal* clipped = tgeo_minus_geom(temporalGeometry.getGeometry(), + staticGeometry.getGeometry()); + if (clipped == nullptr) return 0; + free(clipped); + return 1; + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalMinusGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "TemporalMinusGeometryPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + return TemporalMinusGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalNADFloatScalarPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalNADFloatScalarPhysicalFunction.cpp new file mode 100644 index 0000000000..501c547061 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalNADFloatScalarPhysicalFunction.cpp @@ -0,0 +1,96 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +TemporalNADFloatScalarPhysicalFunction::TemporalNADFloatScalarPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction timestampFunction, + PhysicalFunction scalarFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(scalarFunction)); +} + +VarVal TemporalNADFloatScalarPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto value = parameterValues[0].cast>(); + auto timestamp = parameterValues[1].cast>(); + auto scalar = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double valueValue, + uint64_t timestampValue, + double scalarValue) -> double { + try + { + MEOS::Meos::ensureMeosInitialized(); + const std::string tsString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string wkt = fmt::format("{}@{}", valueValue, tsString); + Temporal* temp = tfloat_in(wkt.c_str()); + if (!temp) return 0; + double r = nad_tfloat_float(temp, scalarValue); + free(temp); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + value, timestamp, scalar); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalNADFloatScalarPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TemporalNADFloatScalarPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TemporalNADFloatScalarPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalNADGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalNADGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..d91eafb8b2 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalNADGeometryPhysicalFunction.cpp @@ -0,0 +1,124 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalNADGeometryPhysicalFunction::TemporalNADGeometryPhysicalFunction(PhysicalFunction lonFunction, + PhysicalFunction latFunction, + PhysicalFunction timestampFunction, + PhysicalFunction geometryFunction) +{ + parameterFunctions.reserve(4); + parameterFunctions.push_back(std::move(lonFunction)); + parameterFunctions.push_back(std::move(latFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(geometryFunction)); +} + +VarVal TemporalNADGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto timestamp = parameterValues[2].cast>(); + auto geometry = parameterValues[3].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + uint64_t timestampValue, + const char* geometryPtr, + uint32_t geometrySize) -> double { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) { + return 0; + } + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string temporalGeometryWkt = fmt::format("SRID=4326;Point({} {})@{}", lonValue, latValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (temporalGeometryWkt.empty() || staticGeometryWkt.empty()) + return 0; + + MEOS::Meos::TemporalGeometry temporalGeometry(temporalGeometryWkt); + if (!temporalGeometry.getGeometry()) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) return 0; + + // MEOS spatial-relation call — same shape as TemporalEDWithin's + // edwithin_tgeo_geo, but specific MEOS function per generated operator. + // Real MEOS spatial-rel signature: int fn(const Temporal *, const GSERIALIZED *) + // (no `atstart` flag — that's specific to geog_dwithin / edwithin's 3-arg variant). + return nad_tgeo_geo(temporalGeometry.getGeometry(), + staticGeometry.getGeometry()); + } + catch (const std::exception&) + { + return 0; + } + }, + lon, lat, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalNADGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "TemporalNADGeometryPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + return TemporalNADGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalNADIntScalarPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalNADIntScalarPhysicalFunction.cpp new file mode 100644 index 0000000000..535d95c8d8 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalNADIntScalarPhysicalFunction.cpp @@ -0,0 +1,96 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +TemporalNADIntScalarPhysicalFunction::TemporalNADIntScalarPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction timestampFunction, + PhysicalFunction scalarFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(timestampFunction)); + parameterFunctions.push_back(std::move(scalarFunction)); +} + +VarVal TemporalNADIntScalarPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto value = parameterValues[0].cast>(); + auto timestamp = parameterValues[1].cast>(); + auto scalar = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](int32_t valueValue, + uint64_t timestampValue, + int32_t scalarValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + const std::string tsString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string wkt = fmt::format("{}@{}", valueValue, tsString); + Temporal* temp = tint_in(wkt.c_str()); + if (!temp) return 0; + int r = nad_tint_int(temp, scalarValue); + free(temp); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + value, timestamp, scalar); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalNADIntScalarPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TemporalNADIntScalarPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TemporalNADIntScalarPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalNADTFloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalNADTFloatPhysicalFunction.cpp new file mode 100644 index 0000000000..5cb88b6b93 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalNADTFloatPhysicalFunction.cpp @@ -0,0 +1,104 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +TemporalNADTFloatPhysicalFunction::TemporalNADTFloatPhysicalFunction(PhysicalFunction valueAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction valueBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(4); + parameterFunctions.push_back(std::move(valueAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(valueBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalNADTFloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto valueA = parameterValues[0].cast>(); + auto tsA = parameterValues[1].cast>(); + auto valueB = parameterValues[2].cast>(); + auto tsB = parameterValues[3].cast>(); + + const auto result = nautilus::invoke( + +[](double valueAValue, uint64_t tsAValue, + double valueBValue, uint64_t tsBValue) -> double { + try + { + MEOS::Meos::ensureMeosInitialized(); + const std::string tsAStr = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBStr = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string wktA = fmt::format("{}@{}", valueAValue, tsAStr); + std::string wktB = fmt::format("{}@{}", valueBValue, tsBStr); + Temporal* tempA = tfloat_in(wktA.c_str()); + if (!tempA) return 0; + Temporal* tempB = tfloat_in(wktB.c_str()); + if (!tempB) { free(tempA); return 0; } + double r = nad_tfloat_tfloat(tempA, tempB); + free(tempA); + free(tempB); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + valueA, tsA, valueB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalNADTFloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "TemporalNADTFloatPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + return TemporalNADTFloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalNADTGeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalNADTGeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..5afa3d52bc --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalNADTGeometryPhysicalFunction.cpp @@ -0,0 +1,117 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalNADTGeometryPhysicalFunction::TemporalNADTGeometryPhysicalFunction(PhysicalFunction lonAFunction, + PhysicalFunction latAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction lonBFunction, + PhysicalFunction latBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(6); + parameterFunctions.push_back(std::move(lonAFunction)); + parameterFunctions.push_back(std::move(latAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(lonBFunction)); + parameterFunctions.push_back(std::move(latBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalNADTGeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto lonA = parameterValues[0].cast>(); + auto latA = parameterValues[1].cast>(); + auto tsA = parameterValues[2].cast>(); + auto lonB = parameterValues[3].cast>(); + auto latB = parameterValues[4].cast>(); + auto tsB = parameterValues[5].cast>(); + + const auto result = nautilus::invoke( + +[](double lonAValue, double latAValue, uint64_t tsAValue, + double lonBValue, double latBValue, uint64_t tsBValue) -> double { + try + { + MEOS::Meos::ensureMeosInitialized(); + if (!(lonAValue >= -180.0 && lonAValue <= 180.0 && latAValue >= -90.0 && latAValue <= 90.0)) return 0; + if (!(lonBValue >= -180.0 && lonBValue <= 180.0 && latBValue >= -90.0 && latBValue <= 90.0)) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string temporalGeometryAWkt = fmt::format("SRID=4326;Point({} {})@{}", lonAValue, latAValue, tsAString); + std::string temporalGeometryBWkt = fmt::format("SRID=4326;Point({} {})@{}", lonBValue, latBValue, tsBString); + + MEOS::Meos::TemporalGeometry temporalGeometryA(temporalGeometryAWkt); + if (!temporalGeometryA.getGeometry()) return 0; + MEOS::Meos::TemporalGeometry temporalGeometryB(temporalGeometryBWkt); + if (!temporalGeometryB.getGeometry()) return 0; + + // MEOS *_tgeo_tgeo spatial-relation: int fn(const Temporal*, const Temporal*). + return nad_tgeo_tgeo(temporalGeometryA.getGeometry(), + temporalGeometryB.getGeometry()); + } + catch (const std::exception&) + { + return 0; + } + }, + lonA, latA, tsA, lonB, latB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalNADTGeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "TemporalNADTGeometryPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + auto arg4 = std::move(arguments.childFunctions[4]); + auto arg5 = std::move(arguments.childFunctions[5]); + return TemporalNADTGeometryPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalNADTIntPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalNADTIntPhysicalFunction.cpp new file mode 100644 index 0000000000..0f13bb8836 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalNADTIntPhysicalFunction.cpp @@ -0,0 +1,104 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +TemporalNADTIntPhysicalFunction::TemporalNADTIntPhysicalFunction(PhysicalFunction valueAFunction, + PhysicalFunction tsAFunction, + PhysicalFunction valueBFunction, + PhysicalFunction tsBFunction) +{ + parameterFunctions.reserve(4); + parameterFunctions.push_back(std::move(valueAFunction)); + parameterFunctions.push_back(std::move(tsAFunction)); + parameterFunctions.push_back(std::move(valueBFunction)); + parameterFunctions.push_back(std::move(tsBFunction)); +} + +VarVal TemporalNADTIntPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + { + parameterValues.emplace_back(function.execute(record, arena)); + } + + auto valueA = parameterValues[0].cast>(); + auto tsA = parameterValues[1].cast>(); + auto valueB = parameterValues[2].cast>(); + auto tsB = parameterValues[3].cast>(); + + const auto result = nautilus::invoke( + +[](int32_t valueAValue, uint64_t tsAValue, + int32_t valueBValue, uint64_t tsBValue) -> int { + try + { + MEOS::Meos::ensureMeosInitialized(); + const std::string tsAStr = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBStr = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string wktA = fmt::format("{}@{}", valueAValue, tsAStr); + std::string wktB = fmt::format("{}@{}", valueBValue, tsBStr); + Temporal* tempA = tint_in(wktA.c_str()); + if (!tempA) return 0; + Temporal* tempB = tint_in(wktB.c_str()); + if (!tempB) { free(tempA); return 0; } + int r = nad_tint_tint(tempA, tempB); + free(tempA); + free(tempB); + return r; + } + catch (const std::exception&) + { + return 0; + } + }, + valueA, tsA, valueB, tsB); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalNADTIntPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "TemporalNADTIntPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + return TemporalNADTIntPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-query-optimizer/src/RewriteRules/LowerToPhysical/LowerToPhysicalWindowedAggregation.cpp b/nes-query-optimizer/src/RewriteRules/LowerToPhysical/LowerToPhysicalWindowedAggregation.cpp index c994b91a9d..e8b68dbd8f 100644 --- a/nes-query-optimizer/src/RewriteRules/LowerToPhysical/LowerToPhysicalWindowedAggregation.cpp +++ b/nes-query-optimizer/src/RewriteRules/LowerToPhysical/LowerToPhysicalWindowedAggregation.cpp @@ -55,8 +55,54 @@ #include // Special-case lowering for TEMPORAL_SEQUENCE (multi-input) aggregation #include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace NES { @@ -160,6 +206,646 @@ getAggregationPhysicalFunctions(const WindowedAggregationLogicalOperator& logica continue; } + // Custom lowering path for TEMPORAL_LENGTH: same three-input shape as TEMPORAL_SEQUENCE, + // returns a FLOAT64 (the spheroidal length of the per-(window, group) trajectory) instead of a VARSIZED WKB blob. + if (name == std::string_view("TemporalLength")) + { + auto tlDescriptor = std::dynamic_pointer_cast(descriptor); + INVARIANT(tlDescriptor != nullptr, "Expected TemporalLengthAggregationLogicalFunction for TemporalLength"); + + auto lonPF = QueryCompilation::FunctionProvider::lowerFunction(tlDescriptor->getLonField()); + auto latPF = QueryCompilation::FunctionProvider::lowerFunction(tlDescriptor->getLatField()); + auto tsPF = QueryCompilation::FunctionProvider::lowerFunction(tlDescriptor->getTimestampField()); + + Schema stateSchema; + stateSchema.addField("lon", tlDescriptor->getLonField().getDataType()); + stateSchema.addField("lat", tlDescriptor->getLatField().getDataType()); + stateSchema.addField("timestamp", tlDescriptor->getTimestampField().getDataType()); + auto tupleBufferRef = Interface::BufferRef::TupleBufferRef::create(configuration.pageSize.getValue(), stateSchema); + + auto phys = std::make_shared( + std::move(physicalInputType), + std::move(physicalFinalType), + lonPF, + latPF, + tsPF, + resultFieldIdentifier, + tupleBufferRef); + aggregationPhysicalFunctions.push_back(std::move(phys)); + continue; + } + + // Custom lowering path for PAIR_MEETING (Q5): four input fields (lon, lat, ts, vehicle_id); + // returns a VARSIZED string-encoded list of meeting pairs. + if (name == std::string_view("PairMeeting")) + { + auto pmDescriptor = std::dynamic_pointer_cast(descriptor); + INVARIANT(pmDescriptor != nullptr, "Expected PairMeetingAggregationLogicalFunction for PairMeeting"); + + auto lonPF = QueryCompilation::FunctionProvider::lowerFunction(pmDescriptor->getLonField()); + auto latPF = QueryCompilation::FunctionProvider::lowerFunction(pmDescriptor->getLatField()); + auto tsPF = QueryCompilation::FunctionProvider::lowerFunction(pmDescriptor->getTimestampField()); + auto vidPF = QueryCompilation::FunctionProvider::lowerFunction(pmDescriptor->getVehicleIdField()); + + Schema stateSchema; + stateSchema.addField("lon", pmDescriptor->getLonField().getDataType()); + stateSchema.addField("lat", pmDescriptor->getLatField().getDataType()); + stateSchema.addField("timestamp", pmDescriptor->getTimestampField().getDataType()); + stateSchema.addField("vehicle_id", pmDescriptor->getVehicleIdField().getDataType()); + auto tupleBufferRef = Interface::BufferRef::TupleBufferRef::create(configuration.pageSize.getValue(), stateSchema); + + auto phys = std::make_shared( + std::move(physicalInputType), + std::move(physicalFinalType), + lonPF, + latPF, + tsPF, + vidPF, + pmDescriptor->getDMeetMetres(), + resultFieldIdentifier, + tupleBufferRef); + aggregationPhysicalFunctions.push_back(std::move(phys)); + continue; + } + + // Custom lowering path for CROSS_DISTANCE (Q9): four input fields (lon, lat, ts, vehicle_id); + // returns a FLOAT64 (distance between VID_A and VID_B latest positions in the window). + if (name == std::string_view("CrossDistance")) + { + auto cdDescriptor = std::dynamic_pointer_cast(descriptor); + INVARIANT(cdDescriptor != nullptr, "Expected CrossDistanceAggregationLogicalFunction for CrossDistance"); + + auto lonPF = QueryCompilation::FunctionProvider::lowerFunction(cdDescriptor->getLonField()); + auto latPF = QueryCompilation::FunctionProvider::lowerFunction(cdDescriptor->getLatField()); + auto tsPF = QueryCompilation::FunctionProvider::lowerFunction(cdDescriptor->getTimestampField()); + auto vidPF = QueryCompilation::FunctionProvider::lowerFunction(cdDescriptor->getVehicleIdField()); + + Schema stateSchema; + stateSchema.addField("lon", cdDescriptor->getLonField().getDataType()); + stateSchema.addField("lat", cdDescriptor->getLatField().getDataType()); + stateSchema.addField("timestamp", cdDescriptor->getTimestampField().getDataType()); + stateSchema.addField("vehicle_id", cdDescriptor->getVehicleIdField().getDataType()); + auto tupleBufferRef = Interface::BufferRef::TupleBufferRef::create(configuration.pageSize.getValue(), stateSchema); + + auto phys = std::make_shared( + std::move(physicalInputType), + std::move(physicalFinalType), + lonPF, + latPF, + tsPF, + vidPF, + cdDescriptor->getVidA(), + cdDescriptor->getVidB(), + resultFieldIdentifier, + tupleBufferRef); + aggregationPhysicalFunctions.push_back(std::move(phys)); + continue; + } + /* BEGIN CODEGEN AGGREGATION GLUE: TemporalNumInstants (optimizer lowering) */ + if (name == std::string_view("TemporalNumInstants")) + { + auto specificDescriptor = std::dynamic_pointer_cast(descriptor); + INVARIANT(specificDescriptor != nullptr, "Expected TemporalNumInstantsAggregationLogicalFunction for TemporalNumInstants"); + + auto lonPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getLonField()); + auto latPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getLatField()); + auto tsPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getTimestampField()); + + Schema stateSchema; + stateSchema.addField("lon", specificDescriptor->getLonField().getDataType()); + stateSchema.addField("lat", specificDescriptor->getLatField().getDataType()); + stateSchema.addField("timestamp", specificDescriptor->getTimestampField().getDataType()); + auto tupleBufferRef = Interface::BufferRef::TupleBufferRef::create(configuration.pageSize.getValue(), stateSchema); + + auto phys = std::make_shared( + std::move(physicalInputType), + std::move(physicalFinalType), + lonPF, + latPF, + tsPF, + resultFieldIdentifier, + tupleBufferRef); + aggregationPhysicalFunctions.push_back(std::move(phys)); + continue; + } + /* END CODEGEN AGGREGATION GLUE: TemporalNumInstants (optimizer lowering) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TemporalNumSequences (optimizer lowering) */ + if (name == std::string_view("TemporalNumSequences")) + { + auto specificDescriptor = std::dynamic_pointer_cast(descriptor); + INVARIANT(specificDescriptor != nullptr, "Expected TemporalNumSequencesAggregationLogicalFunction for TemporalNumSequences"); + + auto lonPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getLonField()); + auto latPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getLatField()); + auto tsPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getTimestampField()); + + Schema stateSchema; + stateSchema.addField("lon", specificDescriptor->getLonField().getDataType()); + stateSchema.addField("lat", specificDescriptor->getLatField().getDataType()); + stateSchema.addField("timestamp", specificDescriptor->getTimestampField().getDataType()); + auto tupleBufferRef = Interface::BufferRef::TupleBufferRef::create(configuration.pageSize.getValue(), stateSchema); + + auto phys = std::make_shared( + std::move(physicalInputType), + std::move(physicalFinalType), + lonPF, + latPF, + tsPF, + resultFieldIdentifier, + tupleBufferRef); + aggregationPhysicalFunctions.push_back(std::move(phys)); + continue; + } + /* END CODEGEN AGGREGATION GLUE: TemporalNumSequences (optimizer lowering) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TemporalNumTimestamps (optimizer lowering) */ + if (name == std::string_view("TemporalNumTimestamps")) + { + auto specificDescriptor = std::dynamic_pointer_cast(descriptor); + INVARIANT(specificDescriptor != nullptr, "Expected TemporalNumTimestampsAggregationLogicalFunction for TemporalNumTimestamps"); + + auto lonPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getLonField()); + auto latPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getLatField()); + auto tsPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getTimestampField()); + + Schema stateSchema; + stateSchema.addField("lon", specificDescriptor->getLonField().getDataType()); + stateSchema.addField("lat", specificDescriptor->getLatField().getDataType()); + stateSchema.addField("timestamp", specificDescriptor->getTimestampField().getDataType()); + auto tupleBufferRef = Interface::BufferRef::TupleBufferRef::create(configuration.pageSize.getValue(), stateSchema); + + auto phys = std::make_shared( + std::move(physicalInputType), + std::move(physicalFinalType), + lonPF, + latPF, + tsPF, + resultFieldIdentifier, + tupleBufferRef); + aggregationPhysicalFunctions.push_back(std::move(phys)); + continue; + } + /* END CODEGEN AGGREGATION GLUE: TemporalNumTimestamps (optimizer lowering) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TemporalTFloatStartValue (optimizer lowering) */ + if (name == std::string_view("TemporalTFloatStartValue")) + { + auto specificDescriptor = std::dynamic_pointer_cast(descriptor); + INVARIANT(specificDescriptor != nullptr, "Expected TemporalTFloatStartValueAggregationLogicalFunction for TemporalTFloatStartValue"); + + auto valuePF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getValueField()); + auto tsPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getTimestampField()); + + Schema stateSchema; + stateSchema.addField("value", specificDescriptor->getValueField().getDataType()); + stateSchema.addField("timestamp", specificDescriptor->getTimestampField().getDataType()); + auto tupleBufferRef = Interface::BufferRef::TupleBufferRef::create(configuration.pageSize.getValue(), stateSchema); + + auto phys = std::make_shared( + std::move(physicalInputType), + std::move(physicalFinalType), + valuePF, + tsPF, + resultFieldIdentifier, + tupleBufferRef); + aggregationPhysicalFunctions.push_back(std::move(phys)); + continue; + } + /* END CODEGEN AGGREGATION GLUE: TemporalTFloatStartValue (optimizer lowering) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TemporalTFloatEndValue (optimizer lowering) */ + if (name == std::string_view("TemporalTFloatEndValue")) + { + auto specificDescriptor = std::dynamic_pointer_cast(descriptor); + INVARIANT(specificDescriptor != nullptr, "Expected TemporalTFloatEndValueAggregationLogicalFunction for TemporalTFloatEndValue"); + + auto valuePF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getValueField()); + auto tsPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getTimestampField()); + + Schema stateSchema; + stateSchema.addField("value", specificDescriptor->getValueField().getDataType()); + stateSchema.addField("timestamp", specificDescriptor->getTimestampField().getDataType()); + auto tupleBufferRef = Interface::BufferRef::TupleBufferRef::create(configuration.pageSize.getValue(), stateSchema); + + auto phys = std::make_shared( + std::move(physicalInputType), + std::move(physicalFinalType), + valuePF, + tsPF, + resultFieldIdentifier, + tupleBufferRef); + aggregationPhysicalFunctions.push_back(std::move(phys)); + continue; + } + /* END CODEGEN AGGREGATION GLUE: TemporalTFloatEndValue (optimizer lowering) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TemporalTFloatMinValue (optimizer lowering) */ + if (name == std::string_view("TemporalTFloatMinValue")) + { + auto specificDescriptor = std::dynamic_pointer_cast(descriptor); + INVARIANT(specificDescriptor != nullptr, "Expected TemporalTFloatMinValueAggregationLogicalFunction for TemporalTFloatMinValue"); + + auto valuePF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getValueField()); + auto tsPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getTimestampField()); + + Schema stateSchema; + stateSchema.addField("value", specificDescriptor->getValueField().getDataType()); + stateSchema.addField("timestamp", specificDescriptor->getTimestampField().getDataType()); + auto tupleBufferRef = Interface::BufferRef::TupleBufferRef::create(configuration.pageSize.getValue(), stateSchema); + + auto phys = std::make_shared( + std::move(physicalInputType), + std::move(physicalFinalType), + valuePF, + tsPF, + resultFieldIdentifier, + tupleBufferRef); + aggregationPhysicalFunctions.push_back(std::move(phys)); + continue; + } + /* END CODEGEN AGGREGATION GLUE: TemporalTFloatMinValue (optimizer lowering) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TemporalTFloatMaxValue (optimizer lowering) */ + if (name == std::string_view("TemporalTFloatMaxValue")) + { + auto specificDescriptor = std::dynamic_pointer_cast(descriptor); + INVARIANT(specificDescriptor != nullptr, "Expected TemporalTFloatMaxValueAggregationLogicalFunction for TemporalTFloatMaxValue"); + + auto valuePF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getValueField()); + auto tsPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getTimestampField()); + + Schema stateSchema; + stateSchema.addField("value", specificDescriptor->getValueField().getDataType()); + stateSchema.addField("timestamp", specificDescriptor->getTimestampField().getDataType()); + auto tupleBufferRef = Interface::BufferRef::TupleBufferRef::create(configuration.pageSize.getValue(), stateSchema); + + auto phys = std::make_shared( + std::move(physicalInputType), + std::move(physicalFinalType), + valuePF, + tsPF, + resultFieldIdentifier, + tupleBufferRef); + aggregationPhysicalFunctions.push_back(std::move(phys)); + continue; + } + /* END CODEGEN AGGREGATION GLUE: TemporalTFloatMaxValue (optimizer lowering) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TemporalTNumberIntegral (optimizer lowering) */ + if (name == std::string_view("TemporalTNumberIntegral")) + { + auto specificDescriptor = std::dynamic_pointer_cast(descriptor); + INVARIANT(specificDescriptor != nullptr, "Expected TemporalTNumberIntegralAggregationLogicalFunction for TemporalTNumberIntegral"); + + auto valuePF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getValueField()); + auto tsPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getTimestampField()); + + Schema stateSchema; + stateSchema.addField("value", specificDescriptor->getValueField().getDataType()); + stateSchema.addField("timestamp", specificDescriptor->getTimestampField().getDataType()); + auto tupleBufferRef = Interface::BufferRef::TupleBufferRef::create(configuration.pageSize.getValue(), stateSchema); + + auto phys = std::make_shared( + std::move(physicalInputType), + std::move(physicalFinalType), + valuePF, + tsPF, + resultFieldIdentifier, + tupleBufferRef); + aggregationPhysicalFunctions.push_back(std::move(phys)); + continue; + } + /* END CODEGEN AGGREGATION GLUE: TemporalTNumberIntegral (optimizer lowering) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TemporalTIntStartValue (optimizer lowering) */ + if (name == std::string_view("TemporalTIntStartValue")) + { + auto specificDescriptor = std::dynamic_pointer_cast(descriptor); + INVARIANT(specificDescriptor != nullptr, "Expected TemporalTIntStartValueAggregationLogicalFunction for TemporalTIntStartValue"); + + auto valuePF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getValueField()); + auto tsPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getTimestampField()); + + Schema stateSchema; + stateSchema.addField("value", specificDescriptor->getValueField().getDataType()); + stateSchema.addField("timestamp", specificDescriptor->getTimestampField().getDataType()); + auto tupleBufferRef = Interface::BufferRef::TupleBufferRef::create(configuration.pageSize.getValue(), stateSchema); + + auto phys = std::make_shared( + std::move(physicalInputType), + std::move(physicalFinalType), + valuePF, + tsPF, + resultFieldIdentifier, + tupleBufferRef); + aggregationPhysicalFunctions.push_back(std::move(phys)); + continue; + } + /* END CODEGEN AGGREGATION GLUE: TemporalTIntStartValue (optimizer lowering) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TemporalTIntEndValue (optimizer lowering) */ + if (name == std::string_view("TemporalTIntEndValue")) + { + auto specificDescriptor = std::dynamic_pointer_cast(descriptor); + INVARIANT(specificDescriptor != nullptr, "Expected TemporalTIntEndValueAggregationLogicalFunction for TemporalTIntEndValue"); + + auto valuePF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getValueField()); + auto tsPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getTimestampField()); + + Schema stateSchema; + stateSchema.addField("value", specificDescriptor->getValueField().getDataType()); + stateSchema.addField("timestamp", specificDescriptor->getTimestampField().getDataType()); + auto tupleBufferRef = Interface::BufferRef::TupleBufferRef::create(configuration.pageSize.getValue(), stateSchema); + + auto phys = std::make_shared( + std::move(physicalInputType), + std::move(physicalFinalType), + valuePF, + tsPF, + resultFieldIdentifier, + tupleBufferRef); + aggregationPhysicalFunctions.push_back(std::move(phys)); + continue; + } + /* END CODEGEN AGGREGATION GLUE: TemporalTIntEndValue (optimizer lowering) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TemporalTIntMinValue (optimizer lowering) */ + if (name == std::string_view("TemporalTIntMinValue")) + { + auto specificDescriptor = std::dynamic_pointer_cast(descriptor); + INVARIANT(specificDescriptor != nullptr, "Expected TemporalTIntMinValueAggregationLogicalFunction for TemporalTIntMinValue"); + + auto valuePF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getValueField()); + auto tsPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getTimestampField()); + + Schema stateSchema; + stateSchema.addField("value", specificDescriptor->getValueField().getDataType()); + stateSchema.addField("timestamp", specificDescriptor->getTimestampField().getDataType()); + auto tupleBufferRef = Interface::BufferRef::TupleBufferRef::create(configuration.pageSize.getValue(), stateSchema); + + auto phys = std::make_shared( + std::move(physicalInputType), + std::move(physicalFinalType), + valuePF, + tsPF, + resultFieldIdentifier, + tupleBufferRef); + aggregationPhysicalFunctions.push_back(std::move(phys)); + continue; + } + /* END CODEGEN AGGREGATION GLUE: TemporalTIntMinValue (optimizer lowering) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TemporalTIntMaxValue (optimizer lowering) */ + if (name == std::string_view("TemporalTIntMaxValue")) + { + auto specificDescriptor = std::dynamic_pointer_cast(descriptor); + INVARIANT(specificDescriptor != nullptr, "Expected TemporalTIntMaxValueAggregationLogicalFunction for TemporalTIntMaxValue"); + + auto valuePF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getValueField()); + auto tsPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getTimestampField()); + + Schema stateSchema; + stateSchema.addField("value", specificDescriptor->getValueField().getDataType()); + stateSchema.addField("timestamp", specificDescriptor->getTimestampField().getDataType()); + auto tupleBufferRef = Interface::BufferRef::TupleBufferRef::create(configuration.pageSize.getValue(), stateSchema); + + auto phys = std::make_shared( + std::move(physicalInputType), + std::move(physicalFinalType), + valuePF, + tsPF, + resultFieldIdentifier, + tupleBufferRef); + aggregationPhysicalFunctions.push_back(std::move(phys)); + continue; + } + /* END CODEGEN AGGREGATION GLUE: TemporalTIntMaxValue (optimizer lowering) */ + /* BEGIN CODEGEN AGGREGATION GLUE: TemporalTFloatAvgValue (optimizer lowering) */ + if (name == std::string_view("TemporalTFloatAvgValue")) + { + auto specificDescriptor = std::dynamic_pointer_cast(descriptor); + INVARIANT(specificDescriptor != nullptr, "Expected TemporalTFloatAvgValueAggregationLogicalFunction for TemporalTFloatAvgValue"); + + auto valuePF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getValueField()); + auto tsPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getTimestampField()); + + Schema stateSchema; + stateSchema.addField("value", specificDescriptor->getValueField().getDataType()); + stateSchema.addField("timestamp", specificDescriptor->getTimestampField().getDataType()); + auto tupleBufferRef = Interface::BufferRef::TupleBufferRef::create(configuration.pageSize.getValue(), stateSchema); + + auto phys = std::make_shared( + std::move(physicalInputType), + std::move(physicalFinalType), + valuePF, + tsPF, + resultFieldIdentifier, + tupleBufferRef); + aggregationPhysicalFunctions.push_back(std::move(phys)); + continue; + } + /* END CODEGEN AGGREGATION GLUE: TemporalTFloatAvgValue (optimizer lowering) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TemporalTNumberTwAvg (optimizer lowering) */ + if (name == std::string_view("TemporalTNumberTwAvg")) + { + auto specificDescriptor = std::dynamic_pointer_cast(descriptor); + INVARIANT(specificDescriptor != nullptr, "Expected TemporalTNumberTwAvgAggregationLogicalFunction for TemporalTNumberTwAvg"); + + auto valuePF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getValueField()); + auto tsPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getTimestampField()); + + Schema stateSchema; + stateSchema.addField("value", specificDescriptor->getValueField().getDataType()); + stateSchema.addField("timestamp", specificDescriptor->getTimestampField().getDataType()); + auto tupleBufferRef = Interface::BufferRef::TupleBufferRef::create(configuration.pageSize.getValue(), stateSchema); + + auto phys = std::make_shared( + std::move(physicalInputType), + std::move(physicalFinalType), + valuePF, + tsPF, + resultFieldIdentifier, + tupleBufferRef); + aggregationPhysicalFunctions.push_back(std::move(phys)); + continue; + } + /* END CODEGEN AGGREGATION GLUE: TemporalTNumberTwAvg (optimizer lowering) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TemporalTIntAvgValue (optimizer lowering) */ + if (name == std::string_view("TemporalTIntAvgValue")) + { + auto specificDescriptor = std::dynamic_pointer_cast(descriptor); + INVARIANT(specificDescriptor != nullptr, "Expected TemporalTIntAvgValueAggregationLogicalFunction for TemporalTIntAvgValue"); + + auto valuePF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getValueField()); + auto tsPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getTimestampField()); + + Schema stateSchema; + stateSchema.addField("value", specificDescriptor->getValueField().getDataType()); + stateSchema.addField("timestamp", specificDescriptor->getTimestampField().getDataType()); + auto tupleBufferRef = Interface::BufferRef::TupleBufferRef::create(configuration.pageSize.getValue(), stateSchema); + + auto phys = std::make_shared( + std::move(physicalInputType), + std::move(physicalFinalType), + valuePF, + tsPF, + resultFieldIdentifier, + tupleBufferRef); + aggregationPhysicalFunctions.push_back(std::move(phys)); + continue; + } + /* END CODEGEN AGGREGATION GLUE: TemporalTIntAvgValue (optimizer lowering) */ + /* BEGIN CODEGEN AGGREGATION GLUE: TemporalStartTimestamp (optimizer lowering) */ + if (name == std::string_view("TemporalStartTimestamp")) + { + auto specificDescriptor = std::dynamic_pointer_cast(descriptor); + INVARIANT(specificDescriptor != nullptr, "Expected TemporalStartTimestampAggregationLogicalFunction for TemporalStartTimestamp"); + + auto lonPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getLonField()); + auto latPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getLatField()); + auto tsPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getTimestampField()); + + Schema stateSchema; + stateSchema.addField("lon", specificDescriptor->getLonField().getDataType()); + stateSchema.addField("lat", specificDescriptor->getLatField().getDataType()); + stateSchema.addField("timestamp", specificDescriptor->getTimestampField().getDataType()); + auto tupleBufferRef = Interface::BufferRef::TupleBufferRef::create(configuration.pageSize.getValue(), stateSchema); + + auto phys = std::make_shared( + std::move(physicalInputType), + std::move(physicalFinalType), + lonPF, + latPF, + tsPF, + resultFieldIdentifier, + tupleBufferRef); + aggregationPhysicalFunctions.push_back(std::move(phys)); + continue; + } + /* END CODEGEN AGGREGATION GLUE: TemporalStartTimestamp (optimizer lowering) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TemporalEndTimestamp (optimizer lowering) */ + if (name == std::string_view("TemporalEndTimestamp")) + { + auto specificDescriptor = std::dynamic_pointer_cast(descriptor); + INVARIANT(specificDescriptor != nullptr, "Expected TemporalEndTimestampAggregationLogicalFunction for TemporalEndTimestamp"); + + auto lonPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getLonField()); + auto latPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getLatField()); + auto tsPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getTimestampField()); + + Schema stateSchema; + stateSchema.addField("lon", specificDescriptor->getLonField().getDataType()); + stateSchema.addField("lat", specificDescriptor->getLatField().getDataType()); + stateSchema.addField("timestamp", specificDescriptor->getTimestampField().getDataType()); + auto tupleBufferRef = Interface::BufferRef::TupleBufferRef::create(configuration.pageSize.getValue(), stateSchema); + + auto phys = std::make_shared( + std::move(physicalInputType), + std::move(physicalFinalType), + lonPF, + latPF, + tsPF, + resultFieldIdentifier, + tupleBufferRef); + aggregationPhysicalFunctions.push_back(std::move(phys)); + continue; + } + /* END CODEGEN AGGREGATION GLUE: TemporalEndTimestamp (optimizer lowering) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TemporalLowerInc (optimizer lowering) */ + if (name == std::string_view("TemporalLowerInc")) + { + auto specificDescriptor = std::dynamic_pointer_cast(descriptor); + INVARIANT(specificDescriptor != nullptr, "Expected TemporalLowerIncAggregationLogicalFunction for TemporalLowerInc"); + + auto lonPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getLonField()); + auto latPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getLatField()); + auto tsPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getTimestampField()); + + Schema stateSchema; + stateSchema.addField("lon", specificDescriptor->getLonField().getDataType()); + stateSchema.addField("lat", specificDescriptor->getLatField().getDataType()); + stateSchema.addField("timestamp", specificDescriptor->getTimestampField().getDataType()); + auto tupleBufferRef = Interface::BufferRef::TupleBufferRef::create(configuration.pageSize.getValue(), stateSchema); + + auto phys = std::make_shared( + std::move(physicalInputType), + std::move(physicalFinalType), + lonPF, + latPF, + tsPF, + resultFieldIdentifier, + tupleBufferRef); + aggregationPhysicalFunctions.push_back(std::move(phys)); + continue; + } + /* END CODEGEN AGGREGATION GLUE: TemporalLowerInc (optimizer lowering) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TemporalUpperInc (optimizer lowering) */ + if (name == std::string_view("TemporalUpperInc")) + { + auto specificDescriptor = std::dynamic_pointer_cast(descriptor); + INVARIANT(specificDescriptor != nullptr, "Expected TemporalUpperIncAggregationLogicalFunction for TemporalUpperInc"); + + auto lonPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getLonField()); + auto latPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getLatField()); + auto tsPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getTimestampField()); + + Schema stateSchema; + stateSchema.addField("lon", specificDescriptor->getLonField().getDataType()); + stateSchema.addField("lat", specificDescriptor->getLatField().getDataType()); + stateSchema.addField("timestamp", specificDescriptor->getTimestampField().getDataType()); + auto tupleBufferRef = Interface::BufferRef::TupleBufferRef::create(configuration.pageSize.getValue(), stateSchema); + + auto phys = std::make_shared( + std::move(physicalInputType), + std::move(physicalFinalType), + lonPF, + latPF, + tsPF, + resultFieldIdentifier, + tupleBufferRef); + aggregationPhysicalFunctions.push_back(std::move(phys)); + continue; + } + /* END CODEGEN AGGREGATION GLUE: TemporalUpperInc (optimizer lowering) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TemporalTPointIsSimple (optimizer lowering) */ + if (name == std::string_view("TemporalTPointIsSimple")) + { + auto specificDescriptor = std::dynamic_pointer_cast(descriptor); + INVARIANT(specificDescriptor != nullptr, "Expected TemporalTPointIsSimpleAggregationLogicalFunction for TemporalTPointIsSimple"); + + auto lonPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getLonField()); + auto latPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getLatField()); + auto tsPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getTimestampField()); + + Schema stateSchema; + stateSchema.addField("lon", specificDescriptor->getLonField().getDataType()); + stateSchema.addField("lat", specificDescriptor->getLatField().getDataType()); + stateSchema.addField("timestamp", specificDescriptor->getTimestampField().getDataType()); + auto tupleBufferRef = Interface::BufferRef::TupleBufferRef::create(configuration.pageSize.getValue(), stateSchema); + + auto phys = std::make_shared( + std::move(physicalInputType), + std::move(physicalFinalType), + lonPF, + latPF, + tsPF, + resultFieldIdentifier, + tupleBufferRef); + aggregationPhysicalFunctions.push_back(std::move(phys)); + continue; + } + /* END CODEGEN AGGREGATION GLUE: TemporalTPointIsSimple (optimizer lowering) */ + + + + // Default path: use registry for single-input aggregations auto aggregationInputFunction = QueryCompilation::FunctionProvider::lowerFunction(descriptor->onField); auto aggregationArguments = AggregationPhysicalFunctionRegistryArguments( diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 256726e087..bdbbfd8ddc 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_LENGTH | PAIR_MEETING | CROSS_DISTANCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | TEMPORAL_ADISJOINT_GEOMETRY | TEMPORAL_ECONTAINS_TGEOMETRY | TEMPORAL_ECOVERS_TGEOMETRY | TEMPORAL_EDISJOINT_TGEOMETRY | TEMPORAL_EINTERSECTS_TGEOMETRY | TEMPORAL_ETOUCHES_TGEOMETRY | TEMPORAL_ACONTAINS_TGEOMETRY | TEMPORAL_ADISJOINT_TGEOMETRY | TEMPORAL_AINTERSECTS_TGEOMETRY | TEMPORAL_ATOUCHES_TGEOMETRY | TEMPORAL_NAD_GEOMETRY | TEMPORAL_NAD_TGEOMETRY | TEMPORAL_EDWITHIN_TGEOMETRY | TEMPORAL_ADWITHIN_GEOMETRY | TEMPORAL_ADWITHIN_TGEOMETRY | TEMPORAL_EDISJOINT_GEOMETRY | TEMPORAL_ATOUCHES_GEOMETRY | TEMPORAL_ECOVERS_GEOMETRY | TEMPORAL_ACONTAINS_GEOMETRY | TEMPORAL_ETOUCHES_GEOMETRY | TEMPORAL_NAD_FLOAT_SCALAR | TEMPORAL_NAD_INT_SCALAR | TEMPORAL_NAD_TFLOAT | TEMPORAL_NAD_TINT | TEMPORAL_AT_GEOMETRY | TEMPORAL_MINUS_GEOMETRY | TEMPORAL_NUM_INSTANTS | TEMPORAL_NUM_SEQUENCES | TEMPORAL_NUM_TIMESTAMPS | TEMPORAL_TFLOAT_START_VALUE | TEMPORAL_TFLOAT_END_VALUE | TEMPORAL_TFLOAT_MIN_VALUE | TEMPORAL_TFLOAT_MAX_VALUE | TEMPORAL_TNUMBER_INTEGRAL | TEMPORAL_TINT_START_VALUE | TEMPORAL_TINT_END_VALUE | TEMPORAL_TINT_MIN_VALUE | TEMPORAL_TINT_MAX_VALUE | TEMPORAL_TFLOAT_AVG_VALUE | TEMPORAL_TNUMBER_TWAVG | TEMPORAL_TINT_AVG_VALUE | TEMPORAL_START_TIMESTAMP | TEMPORAL_END_TIMESTAMP | TEMPORAL_LOWER_INC | TEMPORAL_UPPER_INC | TEMPORAL_TPOINT_IS_SIMPLE | TEMPORAL_ECONTAINS_TCBUFFER | TEMPORAL_ECOVERS_TCBUFFER | TEMPORAL_EDISJOINT_TCBUFFER | TEMPORAL_EINTERSECTS_TCBUFFER | TEMPORAL_ETOUCHES_TCBUFFER | TEMPORAL_ACONTAINS_TCBUFFER | TEMPORAL_ACOVERS_TCBUFFER | TEMPORAL_ADISJOINT_TCBUFFER | TEMPORAL_AINTERSECTS_TCBUFFER | TEMPORAL_ATOUCHES_TCBUFFER | TEMPORAL_ECONTAINS_TCBUFFER_CBUFFER | TEMPORAL_ECOVERS_TCBUFFER_CBUFFER | TEMPORAL_EDISJOINT_TCBUFFER_CBUFFER | TEMPORAL_EINTERSECTS_TCBUFFER_CBUFFER | TEMPORAL_ETOUCHES_TCBUFFER_CBUFFER | TEMPORAL_ACONTAINS_TCBUFFER_CBUFFER | TEMPORAL_ACOVERS_TCBUFFER_CBUFFER | TEMPORAL_ADISJOINT_TCBUFFER_CBUFFER | TEMPORAL_AINTERSECTS_TCBUFFER_CBUFFER | TEMPORAL_ATOUCHES_TCBUFFER_CBUFFER | TEMPORAL_ADISJOINT_TCBUFFER_TCBUFFER | TEMPORAL_AINTERSECTS_TCBUFFER_TCBUFFER | TEMPORAL_ATOUCHES_TCBUFFER_TCBUFFER | TEMPORAL_ECOVERS_TCBUFFER_TCBUFFER | TEMPORAL_EINTERSECTS_TCBUFFER_TCBUFFER | TEMPORAL_ETOUCHES_TCBUFFER_TCBUFFER | TEMPORAL_EDWITHIN_TCBUFFER_GEOMETRY | TEMPORAL_ADWITHIN_TCBUFFER_GEOMETRY | TEMPORAL_EDWITHIN_TCBUFFER_CBUFFER | TEMPORAL_ADWITHIN_TCBUFFER_CBUFFER | TEMPORAL_EDWITHIN_TCBUFFER_TCBUFFER | TEMPORAL_ADWITHIN_TCBUFFER_TCBUFFER | TEMPORAL_ECONTAINS_TPOSE_GEOMETRY | TEMPORAL_ECOVERS_TPOSE_GEOMETRY | TEMPORAL_EDISJOINT_TPOSE_GEOMETRY | TEMPORAL_EINTERSECTS_TPOSE_GEOMETRY | TEMPORAL_ETOUCHES_TPOSE_GEOMETRY | TEMPORAL_ACONTAINS_TPOSE_GEOMETRY | TEMPORAL_ADISJOINT_TPOSE_GEOMETRY | TEMPORAL_AINTERSECTS_TPOSE_GEOMETRY | TEMPORAL_ATOUCHES_TPOSE_GEOMETRY | TEMPORAL_ECONTAINS_TPOSE_TPOSE | TEMPORAL_ECOVERS_TPOSE_TPOSE | TEMPORAL_EDISJOINT_TPOSE_TPOSE | TEMPORAL_EINTERSECTS_TPOSE_TPOSE | TEMPORAL_ETOUCHES_TPOSE_TPOSE | TEMPORAL_ACONTAINS_TPOSE_TPOSE | TEMPORAL_ADISJOINT_TPOSE_TPOSE | TEMPORAL_AINTERSECTS_TPOSE_TPOSE | TEMPORAL_ATOUCHES_TPOSE_TPOSE | TEMPORAL_ECONTAINS_TNPOINT_GEOMETRY | TEMPORAL_ECONTAINS_TNPOINT_TNPOINT | TEMPORAL_ECOVERS_TNPOINT_GEOMETRY | TEMPORAL_ECOVERS_TNPOINT_TNPOINT | TEMPORAL_EDISJOINT_TNPOINT_GEOMETRY | TEMPORAL_EDISJOINT_TNPOINT_TNPOINT | TEMPORAL_EINTERSECTS_TNPOINT_GEOMETRY | TEMPORAL_EINTERSECTS_TNPOINT_TNPOINT | TEMPORAL_ETOUCHES_TNPOINT_GEOMETRY | TEMPORAL_ETOUCHES_TNPOINT_TNPOINT | TEMPORAL_ACONTAINS_TNPOINT_GEOMETRY | TEMPORAL_ACONTAINS_TNPOINT_TNPOINT | TEMPORAL_ADISJOINT_TNPOINT_GEOMETRY | TEMPORAL_ADISJOINT_TNPOINT_TNPOINT | TEMPORAL_AINTERSECTS_TNPOINT_GEOMETRY | TEMPORAL_AINTERSECTS_TNPOINT_TNPOINT | TEMPORAL_ATOUCHES_TNPOINT_GEOMETRY | TEMPORAL_ATOUCHES_TNPOINT_TNPOINT; sinkClause: INTO sink (',' sink)*; @@ -483,11 +483,132 @@ MEDIAN: 'MEDIAN' | 'median'; VAR: 'VAR' | 'var'; ARRAY_AGG: 'ARRAY_AGG' | 'array_agg'; TEMPORAL_SEQUENCE: 'TEMPORAL_SEQUENCE' | 'temporal_sequence'; +TEMPORAL_LENGTH: 'TEMPORAL_LENGTH' | 'temporal_length'; +PAIR_MEETING: 'PAIR_MEETING' | 'pair_meeting'; +CROSS_DISTANCE: 'CROSS_DISTANCE' | 'cross_distance'; TEMPORAL_EINTERSECTS_GEOMETRY: 'TEMPORAL_EINTERSECTS_GEOMETRY' | 'temporal_eintersects_geometry'; TEMPORAL_AINTERSECTS_GEOMETRY: 'TEMPORAL_AINTERSECTS_GEOMETRY' | 'temporal_aintersects_geometry'; TEMPORAL_ECONTAINS_GEOMETRY: 'TEMPORAL_ECONTAINS_GEOMETRY' | 'temporal_econtains_geometry'; EDWITHIN_TGEO_GEO: 'EDWITHIN_TGEO_GEO' | 'edwithin_tgeo_geo'; TGEO_AT_STBOX: 'TGEO_AT_STBOX' | 'tgeo_at_stbox'; +/* BEGIN CODEGEN LEXER TOKENS */ +TEMPORAL_ADISJOINT_GEOMETRY: 'TEMPORAL_ADISJOINT_GEOMETRY' | 'temporal_adisjoint_geometry'; +TEMPORAL_ECONTAINS_TGEOMETRY: 'TEMPORAL_ECONTAINS_TGEOMETRY' | 'temporal_econtains_tgeometry'; +TEMPORAL_ECOVERS_TGEOMETRY: 'TEMPORAL_ECOVERS_TGEOMETRY' | 'temporal_ecovers_tgeometry'; +TEMPORAL_EDISJOINT_TGEOMETRY: 'TEMPORAL_EDISJOINT_TGEOMETRY' | 'temporal_edisjoint_tgeometry'; +TEMPORAL_EINTERSECTS_TGEOMETRY: 'TEMPORAL_EINTERSECTS_TGEOMETRY' | 'temporal_eintersects_tgeometry'; +TEMPORAL_ETOUCHES_TGEOMETRY: 'TEMPORAL_ETOUCHES_TGEOMETRY' | 'temporal_etouches_tgeometry'; +TEMPORAL_ACONTAINS_TGEOMETRY: 'TEMPORAL_ACONTAINS_TGEOMETRY' | 'temporal_acontains_tgeometry'; +TEMPORAL_ADISJOINT_TGEOMETRY: 'TEMPORAL_ADISJOINT_TGEOMETRY' | 'temporal_adisjoint_tgeometry'; +TEMPORAL_AINTERSECTS_TGEOMETRY: 'TEMPORAL_AINTERSECTS_TGEOMETRY' | 'temporal_aintersects_tgeometry'; +TEMPORAL_ATOUCHES_TGEOMETRY: 'TEMPORAL_ATOUCHES_TGEOMETRY' | 'temporal_atouches_tgeometry'; +TEMPORAL_NAD_GEOMETRY: 'TEMPORAL_NAD_GEOMETRY' | 'temporal_nad_geometry'; +TEMPORAL_NAD_TGEOMETRY: 'TEMPORAL_NAD_TGEOMETRY' | 'temporal_nad_tgeometry'; +TEMPORAL_EDWITHIN_TGEOMETRY: 'TEMPORAL_EDWITHIN_TGEOMETRY' | 'temporal_edwithin_tgeometry'; +TEMPORAL_ADWITHIN_GEOMETRY: 'TEMPORAL_ADWITHIN_GEOMETRY' | 'temporal_adwithin_geometry'; +TEMPORAL_ADWITHIN_TGEOMETRY: 'TEMPORAL_ADWITHIN_TGEOMETRY' | 'temporal_adwithin_tgeometry'; +TEMPORAL_EDISJOINT_GEOMETRY: 'TEMPORAL_EDISJOINT_GEOMETRY' | 'temporal_edisjoint_geometry'; +TEMPORAL_ATOUCHES_GEOMETRY: 'TEMPORAL_ATOUCHES_GEOMETRY' | 'temporal_atouches_geometry'; +TEMPORAL_ECOVERS_GEOMETRY: 'TEMPORAL_ECOVERS_GEOMETRY' | 'temporal_ecovers_geometry'; +TEMPORAL_ACONTAINS_GEOMETRY: 'TEMPORAL_ACONTAINS_GEOMETRY' | 'temporal_acontains_geometry'; +TEMPORAL_ETOUCHES_GEOMETRY: 'TEMPORAL_ETOUCHES_GEOMETRY' | 'temporal_etouches_geometry'; +TEMPORAL_NAD_FLOAT_SCALAR: 'TEMPORAL_NAD_FLOAT_SCALAR' | 'temporal_nad_float_scalar'; +TEMPORAL_NAD_INT_SCALAR: 'TEMPORAL_NAD_INT_SCALAR' | 'temporal_nad_int_scalar'; +TEMPORAL_NAD_TFLOAT: 'TEMPORAL_NAD_TFLOAT' | 'temporal_nad_tfloat'; +TEMPORAL_NAD_TINT: 'TEMPORAL_NAD_TINT' | 'temporal_nad_tint'; +TEMPORAL_AT_GEOMETRY: 'TEMPORAL_AT_GEOMETRY' | 'temporal_at_geometry'; +TEMPORAL_MINUS_GEOMETRY: 'TEMPORAL_MINUS_GEOMETRY' | 'temporal_minus_geometry'; +TEMPORAL_ECONTAINS_TCBUFFER: 'TEMPORAL_ECONTAINS_TCBUFFER' | 'temporal_econtains_tcbuffer'; +TEMPORAL_ECOVERS_TCBUFFER: 'TEMPORAL_ECOVERS_TCBUFFER' | 'temporal_ecovers_tcbuffer'; +TEMPORAL_EDISJOINT_TCBUFFER: 'TEMPORAL_EDISJOINT_TCBUFFER' | 'temporal_edisjoint_tcbuffer'; +TEMPORAL_EINTERSECTS_TCBUFFER: 'TEMPORAL_EINTERSECTS_TCBUFFER' | 'temporal_eintersects_tcbuffer'; +TEMPORAL_ETOUCHES_TCBUFFER: 'TEMPORAL_ETOUCHES_TCBUFFER' | 'temporal_etouches_tcbuffer'; +TEMPORAL_ACONTAINS_TCBUFFER: 'TEMPORAL_ACONTAINS_TCBUFFER' | 'temporal_acontains_tcbuffer'; +TEMPORAL_ACOVERS_TCBUFFER: 'TEMPORAL_ACOVERS_TCBUFFER' | 'temporal_acovers_tcbuffer'; +TEMPORAL_ADISJOINT_TCBUFFER: 'TEMPORAL_ADISJOINT_TCBUFFER' | 'temporal_adisjoint_tcbuffer'; +TEMPORAL_AINTERSECTS_TCBUFFER: 'TEMPORAL_AINTERSECTS_TCBUFFER' | 'temporal_aintersects_tcbuffer'; +TEMPORAL_ATOUCHES_TCBUFFER: 'TEMPORAL_ATOUCHES_TCBUFFER' | 'temporal_atouches_tcbuffer'; +TEMPORAL_ECONTAINS_TCBUFFER_CBUFFER: 'TEMPORAL_ECONTAINS_TCBUFFER_CBUFFER' | 'temporal_econtains_tcbuffer_cbuffer'; +TEMPORAL_ECOVERS_TCBUFFER_CBUFFER: 'TEMPORAL_ECOVERS_TCBUFFER_CBUFFER' | 'temporal_ecovers_tcbuffer_cbuffer'; +TEMPORAL_EDISJOINT_TCBUFFER_CBUFFER: 'TEMPORAL_EDISJOINT_TCBUFFER_CBUFFER' | 'temporal_edisjoint_tcbuffer_cbuffer'; +TEMPORAL_EINTERSECTS_TCBUFFER_CBUFFER: 'TEMPORAL_EINTERSECTS_TCBUFFER_CBUFFER' | 'temporal_eintersects_tcbuffer_cbuffer'; +TEMPORAL_ETOUCHES_TCBUFFER_CBUFFER: 'TEMPORAL_ETOUCHES_TCBUFFER_CBUFFER' | 'temporal_etouches_tcbuffer_cbuffer'; +TEMPORAL_ACONTAINS_TCBUFFER_CBUFFER: 'TEMPORAL_ACONTAINS_TCBUFFER_CBUFFER' | 'temporal_acontains_tcbuffer_cbuffer'; +TEMPORAL_ACOVERS_TCBUFFER_CBUFFER: 'TEMPORAL_ACOVERS_TCBUFFER_CBUFFER' | 'temporal_acovers_tcbuffer_cbuffer'; +TEMPORAL_ADISJOINT_TCBUFFER_CBUFFER: 'TEMPORAL_ADISJOINT_TCBUFFER_CBUFFER' | 'temporal_adisjoint_tcbuffer_cbuffer'; +TEMPORAL_AINTERSECTS_TCBUFFER_CBUFFER: 'TEMPORAL_AINTERSECTS_TCBUFFER_CBUFFER' | 'temporal_aintersects_tcbuffer_cbuffer'; +TEMPORAL_ATOUCHES_TCBUFFER_CBUFFER: 'TEMPORAL_ATOUCHES_TCBUFFER_CBUFFER' | 'temporal_atouches_tcbuffer_cbuffer'; +TEMPORAL_ADISJOINT_TCBUFFER_TCBUFFER: 'TEMPORAL_ADISJOINT_TCBUFFER_TCBUFFER' | 'temporal_adisjoint_tcbuffer_tcbuffer'; +TEMPORAL_AINTERSECTS_TCBUFFER_TCBUFFER: 'TEMPORAL_AINTERSECTS_TCBUFFER_TCBUFFER' | 'temporal_aintersects_tcbuffer_tcbuffer'; +TEMPORAL_ATOUCHES_TCBUFFER_TCBUFFER: 'TEMPORAL_ATOUCHES_TCBUFFER_TCBUFFER' | 'temporal_atouches_tcbuffer_tcbuffer'; +TEMPORAL_ECOVERS_TCBUFFER_TCBUFFER: 'TEMPORAL_ECOVERS_TCBUFFER_TCBUFFER' | 'temporal_ecovers_tcbuffer_tcbuffer'; +TEMPORAL_EINTERSECTS_TCBUFFER_TCBUFFER: 'TEMPORAL_EINTERSECTS_TCBUFFER_TCBUFFER' | 'temporal_eintersects_tcbuffer_tcbuffer'; +TEMPORAL_ETOUCHES_TCBUFFER_TCBUFFER: 'TEMPORAL_ETOUCHES_TCBUFFER_TCBUFFER' | 'temporal_etouches_tcbuffer_tcbuffer'; +TEMPORAL_EDWITHIN_TCBUFFER_GEOMETRY: 'TEMPORAL_EDWITHIN_TCBUFFER_GEOMETRY' | 'temporal_edwithin_tcbuffer_geometry'; +TEMPORAL_ADWITHIN_TCBUFFER_GEOMETRY: 'TEMPORAL_ADWITHIN_TCBUFFER_GEOMETRY' | 'temporal_adwithin_tcbuffer_geometry'; +TEMPORAL_EDWITHIN_TCBUFFER_CBUFFER: 'TEMPORAL_EDWITHIN_TCBUFFER_CBUFFER' | 'temporal_edwithin_tcbuffer_cbuffer'; +TEMPORAL_ADWITHIN_TCBUFFER_CBUFFER: 'TEMPORAL_ADWITHIN_TCBUFFER_CBUFFER' | 'temporal_adwithin_tcbuffer_cbuffer'; +TEMPORAL_EDWITHIN_TCBUFFER_TCBUFFER: 'TEMPORAL_EDWITHIN_TCBUFFER_TCBUFFER' | 'temporal_edwithin_tcbuffer_tcbuffer'; +TEMPORAL_ADWITHIN_TCBUFFER_TCBUFFER: 'TEMPORAL_ADWITHIN_TCBUFFER_TCBUFFER' | 'temporal_adwithin_tcbuffer_tcbuffer'; +TEMPORAL_ECONTAINS_TPOSE_GEOMETRY: 'TEMPORAL_ECONTAINS_TPOSE_GEOMETRY' | 'temporal_econtains_tpose_geometry'; +TEMPORAL_ECOVERS_TPOSE_GEOMETRY: 'TEMPORAL_ECOVERS_TPOSE_GEOMETRY' | 'temporal_ecovers_tpose_geometry'; +TEMPORAL_EDISJOINT_TPOSE_GEOMETRY: 'TEMPORAL_EDISJOINT_TPOSE_GEOMETRY' | 'temporal_edisjoint_tpose_geometry'; +TEMPORAL_EINTERSECTS_TPOSE_GEOMETRY: 'TEMPORAL_EINTERSECTS_TPOSE_GEOMETRY' | 'temporal_eintersects_tpose_geometry'; +TEMPORAL_ETOUCHES_TPOSE_GEOMETRY: 'TEMPORAL_ETOUCHES_TPOSE_GEOMETRY' | 'temporal_etouches_tpose_geometry'; +TEMPORAL_ACONTAINS_TPOSE_GEOMETRY: 'TEMPORAL_ACONTAINS_TPOSE_GEOMETRY' | 'temporal_acontains_tpose_geometry'; +TEMPORAL_ADISJOINT_TPOSE_GEOMETRY: 'TEMPORAL_ADISJOINT_TPOSE_GEOMETRY' | 'temporal_adisjoint_tpose_geometry'; +TEMPORAL_AINTERSECTS_TPOSE_GEOMETRY: 'TEMPORAL_AINTERSECTS_TPOSE_GEOMETRY' | 'temporal_aintersects_tpose_geometry'; +TEMPORAL_ATOUCHES_TPOSE_GEOMETRY: 'TEMPORAL_ATOUCHES_TPOSE_GEOMETRY' | 'temporal_atouches_tpose_geometry'; +TEMPORAL_ECONTAINS_TPOSE_TPOSE: 'TEMPORAL_ECONTAINS_TPOSE_TPOSE' | 'temporal_econtains_tpose_tpose'; +TEMPORAL_ECOVERS_TPOSE_TPOSE: 'TEMPORAL_ECOVERS_TPOSE_TPOSE' | 'temporal_ecovers_tpose_tpose'; +TEMPORAL_EDISJOINT_TPOSE_TPOSE: 'TEMPORAL_EDISJOINT_TPOSE_TPOSE' | 'temporal_edisjoint_tpose_tpose'; +TEMPORAL_EINTERSECTS_TPOSE_TPOSE: 'TEMPORAL_EINTERSECTS_TPOSE_TPOSE' | 'temporal_eintersects_tpose_tpose'; +TEMPORAL_ETOUCHES_TPOSE_TPOSE: 'TEMPORAL_ETOUCHES_TPOSE_TPOSE' | 'temporal_etouches_tpose_tpose'; +TEMPORAL_ACONTAINS_TPOSE_TPOSE: 'TEMPORAL_ACONTAINS_TPOSE_TPOSE' | 'temporal_acontains_tpose_tpose'; +TEMPORAL_ADISJOINT_TPOSE_TPOSE: 'TEMPORAL_ADISJOINT_TPOSE_TPOSE' | 'temporal_adisjoint_tpose_tpose'; +TEMPORAL_AINTERSECTS_TPOSE_TPOSE: 'TEMPORAL_AINTERSECTS_TPOSE_TPOSE' | 'temporal_aintersects_tpose_tpose'; +TEMPORAL_ATOUCHES_TPOSE_TPOSE: 'TEMPORAL_ATOUCHES_TPOSE_TPOSE' | 'temporal_atouches_tpose_tpose'; +TEMPORAL_ECONTAINS_TNPOINT_GEOMETRY: 'TEMPORAL_ECONTAINS_TNPOINT_GEOMETRY' | 'temporal_econtains_tnpoint_geometry'; +TEMPORAL_ECONTAINS_TNPOINT_TNPOINT: 'TEMPORAL_ECONTAINS_TNPOINT_TNPOINT' | 'temporal_econtains_tnpoint_tnpoint'; +TEMPORAL_ECOVERS_TNPOINT_GEOMETRY: 'TEMPORAL_ECOVERS_TNPOINT_GEOMETRY' | 'temporal_ecovers_tnpoint_geometry'; +TEMPORAL_ECOVERS_TNPOINT_TNPOINT: 'TEMPORAL_ECOVERS_TNPOINT_TNPOINT' | 'temporal_ecovers_tnpoint_tnpoint'; +TEMPORAL_EDISJOINT_TNPOINT_GEOMETRY: 'TEMPORAL_EDISJOINT_TNPOINT_GEOMETRY' | 'temporal_edisjoint_tnpoint_geometry'; +TEMPORAL_EDISJOINT_TNPOINT_TNPOINT: 'TEMPORAL_EDISJOINT_TNPOINT_TNPOINT' | 'temporal_edisjoint_tnpoint_tnpoint'; +TEMPORAL_EINTERSECTS_TNPOINT_GEOMETRY: 'TEMPORAL_EINTERSECTS_TNPOINT_GEOMETRY' | 'temporal_eintersects_tnpoint_geometry'; +TEMPORAL_EINTERSECTS_TNPOINT_TNPOINT: 'TEMPORAL_EINTERSECTS_TNPOINT_TNPOINT' | 'temporal_eintersects_tnpoint_tnpoint'; +TEMPORAL_ETOUCHES_TNPOINT_GEOMETRY: 'TEMPORAL_ETOUCHES_TNPOINT_GEOMETRY' | 'temporal_etouches_tnpoint_geometry'; +TEMPORAL_ETOUCHES_TNPOINT_TNPOINT: 'TEMPORAL_ETOUCHES_TNPOINT_TNPOINT' | 'temporal_etouches_tnpoint_tnpoint'; +TEMPORAL_ACONTAINS_TNPOINT_GEOMETRY: 'TEMPORAL_ACONTAINS_TNPOINT_GEOMETRY' | 'temporal_acontains_tnpoint_geometry'; +TEMPORAL_ACONTAINS_TNPOINT_TNPOINT: 'TEMPORAL_ACONTAINS_TNPOINT_TNPOINT' | 'temporal_acontains_tnpoint_tnpoint'; +TEMPORAL_ADISJOINT_TNPOINT_GEOMETRY: 'TEMPORAL_ADISJOINT_TNPOINT_GEOMETRY' | 'temporal_adisjoint_tnpoint_geometry'; +TEMPORAL_ADISJOINT_TNPOINT_TNPOINT: 'TEMPORAL_ADISJOINT_TNPOINT_TNPOINT' | 'temporal_adisjoint_tnpoint_tnpoint'; +TEMPORAL_AINTERSECTS_TNPOINT_GEOMETRY: 'TEMPORAL_AINTERSECTS_TNPOINT_GEOMETRY' | 'temporal_aintersects_tnpoint_geometry'; +TEMPORAL_AINTERSECTS_TNPOINT_TNPOINT: 'TEMPORAL_AINTERSECTS_TNPOINT_TNPOINT' | 'temporal_aintersects_tnpoint_tnpoint'; +TEMPORAL_ATOUCHES_TNPOINT_GEOMETRY: 'TEMPORAL_ATOUCHES_TNPOINT_GEOMETRY' | 'temporal_atouches_tnpoint_geometry'; +TEMPORAL_ATOUCHES_TNPOINT_TNPOINT: 'TEMPORAL_ATOUCHES_TNPOINT_TNPOINT' | 'temporal_atouches_tnpoint_tnpoint'; +/* END CODEGEN LEXER TOKENS */ +/* BEGIN CODEGEN AGGREGATION LEXER TOKENS */ +TEMPORAL_NUM_INSTANTS: 'TEMPORAL_NUM_INSTANTS' | 'temporal_num_instants'; +TEMPORAL_NUM_SEQUENCES: 'TEMPORAL_NUM_SEQUENCES' | 'temporal_num_sequences'; +TEMPORAL_NUM_TIMESTAMPS: 'TEMPORAL_NUM_TIMESTAMPS' | 'temporal_num_timestamps'; +TEMPORAL_TFLOAT_START_VALUE: 'TEMPORAL_TFLOAT_START_VALUE' | 'temporal_tfloat_start_value'; +TEMPORAL_TFLOAT_END_VALUE: 'TEMPORAL_TFLOAT_END_VALUE' | 'temporal_tfloat_end_value'; +TEMPORAL_TFLOAT_MIN_VALUE: 'TEMPORAL_TFLOAT_MIN_VALUE' | 'temporal_tfloat_min_value'; +TEMPORAL_TFLOAT_MAX_VALUE: 'TEMPORAL_TFLOAT_MAX_VALUE' | 'temporal_tfloat_max_value'; +TEMPORAL_TNUMBER_INTEGRAL: 'TEMPORAL_TNUMBER_INTEGRAL' | 'temporal_tnumber_integral'; +TEMPORAL_TINT_START_VALUE: 'TEMPORAL_TINT_START_VALUE' | 'temporal_tint_start_value'; +TEMPORAL_TINT_END_VALUE: 'TEMPORAL_TINT_END_VALUE' | 'temporal_tint_end_value'; +TEMPORAL_TINT_MIN_VALUE: 'TEMPORAL_TINT_MIN_VALUE' | 'temporal_tint_min_value'; +TEMPORAL_TINT_MAX_VALUE: 'TEMPORAL_TINT_MAX_VALUE' | 'temporal_tint_max_value'; +TEMPORAL_TFLOAT_AVG_VALUE: 'TEMPORAL_TFLOAT_AVG_VALUE' | 'temporal_tfloat_avg_value'; +TEMPORAL_TNUMBER_TWAVG: 'TEMPORAL_TNUMBER_TWAVG' | 'temporal_tnumber_twavg'; +TEMPORAL_TINT_AVG_VALUE: 'TEMPORAL_TINT_AVG_VALUE' | 'temporal_tint_avg_value'; +TEMPORAL_START_TIMESTAMP: 'TEMPORAL_START_TIMESTAMP' | 'temporal_start_timestamp'; +TEMPORAL_END_TIMESTAMP: 'TEMPORAL_END_TIMESTAMP' | 'temporal_end_timestamp'; +TEMPORAL_LOWER_INC: 'TEMPORAL_LOWER_INC' | 'temporal_lower_inc'; +TEMPORAL_UPPER_INC: 'TEMPORAL_UPPER_INC' | 'temporal_upper_inc'; +TEMPORAL_TPOINT_IS_SIMPLE: 'TEMPORAL_TPOINT_IS_SIMPLE' | 'temporal_tpoint_is_simple'; +/* END CODEGEN AGGREGATION LEXER TOKENS */ WATERMARK: 'WATERMARK' | 'watermark'; OFFSET: 'OFFSET' | 'offset'; LOCALHOST: 'LOCALHOST' | 'localhost'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 4e9f1d7642..7d7affc06a 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -65,10 +65,128 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -915,14 +1033,14 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont helpers.top().functionBuilder.pop_back(); const auto longitudeFunction = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); - + // Verify all arguments are field access functions if (!longitudeFunction.tryGet() || !latitudeFunction.tryGet() || !timestampFunction.tryGet()) { throw InvalidQuerySyntax("TEMPORAL_SEQUENCE arguments must be field references"); } - + helpers.top().windowAggs.push_back( TemporalSequenceAggregationLogicalFunctionV2::create(longitudeFunction.get(), latitudeFunction.get(), @@ -932,6 +1050,151 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont helpers.top().functionBuilder.push_back(longitudeFunction); } break; + case AntlrSQLLexer::TEMPORAL_LENGTH: + // Same three-input shape as TEMPORAL_SEQUENCE; differs only in the + // result type (FLOAT64 instead of VARSIZED). Closes BerlinMOD-Q6 to a + // full streaming-form cell. + if (helpers.top().functionBuilder.size() != 3) { + throw InvalidQuerySyntax("TEMPORAL_LENGTH requires exactly three arguments (longitude, latitude, timestamp), but got {}", helpers.top().functionBuilder.size()); + } + { + const auto timestampFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto latitudeFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto longitudeFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + + if (!longitudeFunction.tryGet() || + !latitudeFunction.tryGet() || + !timestampFunction.tryGet()) { + throw InvalidQuerySyntax("TEMPORAL_LENGTH arguments must be field references"); + } + + helpers.top().windowAggs.push_back( + TemporalLengthAggregationLogicalFunction::create(longitudeFunction.get(), + latitudeFunction.get(), + timestampFunction.get())); + helpers.top().functionBuilder.push_back(longitudeFunction); + } + break; + case AntlrSQLLexer::PAIR_MEETING: + // Five-arg aggregation: lon, lat, ts, vehicle_id (FieldAccess) + dMeet + // (numeric constant — meeting-distance threshold in metres). The first four + // are pulled from functionBuilder; the fifth is pulled from constantBuilder + // (the parser parks numeric/string literals there). Closes Q5 × 3 cells to + // full; this branch makes the dMeet configurable per-query. + { + if (helpers.top().constantBuilder.empty()) { + throw InvalidQuerySyntax( + "PAIR_MEETING requires a numeric constant fifth argument (dMeet metres), " + "e.g. PAIR_MEETING(lon, lat, timestamp, vehicle_id, 200.0)"); + } + auto dMeetString = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + double dMeetMetres; + try { + dMeetMetres = std::stod(dMeetString); + } catch (const std::exception&) { + throw InvalidQuerySyntax( + "PAIR_MEETING fifth argument must be a numeric constant (dMeet metres), got `{}`", + dMeetString); + } + + if (helpers.top().functionBuilder.size() != 4) { + throw InvalidQuerySyntax( + "PAIR_MEETING requires exactly five arguments (lon, lat, timestamp, vehicle_id, dMeet), " + "got {} field args + 1 constant", + helpers.top().functionBuilder.size()); + } + + const auto vidFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto timestampFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto latitudeFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto longitudeFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + + if (!longitudeFunction.tryGet() || + !latitudeFunction.tryGet() || + !timestampFunction.tryGet() || + !vidFunction.tryGet()) { + throw InvalidQuerySyntax("PAIR_MEETING field arguments (lon, lat, timestamp, vehicle_id) must be field references"); + } + + helpers.top().windowAggs.push_back( + PairMeetingAggregationLogicalFunction::create(longitudeFunction.get(), + latitudeFunction.get(), + timestampFunction.get(), + vidFunction.get(), + dMeetMetres)); + helpers.top().functionBuilder.push_back(longitudeFunction); + } + break; + case AntlrSQLLexer::CROSS_DISTANCE: + // Six-arg aggregation: lon, lat, ts, vehicle_id (FieldAccess) + vidA, vidB + // (numeric constants — target vehicle IDs). The first four are pulled from + // functionBuilder; the fifth and sixth are pulled from constantBuilder. + // Closes Q9 × 3 cells to full; this branch makes the target vehicle pair + // configurable per-query. Mirrors PAIR_MEETING's 5-arg constant-parameterization + // pattern (PR #19). + { + // Pull the two vid constants from constantBuilder. Note: the constants + // are pushed in source order, so the LAST one pushed (vidB in the SQL + // call) is on top of the stack — pop in reverse order. + if (helpers.top().constantBuilder.size() < 2) { + throw InvalidQuerySyntax( + "CROSS_DISTANCE requires two numeric constant arguments (vidA, vidB), " + "e.g. CROSS_DISTANCE(lon, lat, timestamp, vehicle_id, 100, 200)"); + } + auto vidBString = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + auto vidAString = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + uint64_t vidA, vidB; + try { + vidA = std::stoull(vidAString); + vidB = std::stoull(vidBString); + } catch (const std::exception&) { + throw InvalidQuerySyntax( + "CROSS_DISTANCE constant arguments must be unsigned integers (vidA, vidB), got `{}` and `{}`", + vidAString, vidBString); + } + + if (helpers.top().functionBuilder.size() != 4) { + throw InvalidQuerySyntax( + "CROSS_DISTANCE requires exactly six arguments (lon, lat, timestamp, vehicle_id, vidA, vidB), " + "got {} field args + 2 constants", + helpers.top().functionBuilder.size()); + } + + const auto vidFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto timestampFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto latitudeFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto longitudeFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + + if (!longitudeFunction.tryGet() || + !latitudeFunction.tryGet() || + !timestampFunction.tryGet() || + !vidFunction.tryGet()) { + throw InvalidQuerySyntax("CROSS_DISTANCE field arguments (lon, lat, timestamp, vehicle_id) must be field references"); + } + + helpers.top().windowAggs.push_back( + CrossDistanceAggregationLogicalFunction::create(longitudeFunction.get(), + latitudeFunction.get(), + timestampFunction.get(), + vidFunction.get(), + vidA, vidB)); + helpers.top().functionBuilder.push_back(longitudeFunction); + } + break; case AntlrSQLLexer::TEMPORAL_EINTERSECTS_GEOMETRY: { // Convert constants from constantBuilder to ConstantValueLogicalFunction objects @@ -1188,42 +1451,3439 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; - default: - /// Check if the function is a constructor for a datatype - if (const auto dataType = DataTypeProvider::tryProvideDataType(funcName); dataType.has_value()) + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ADISJOINT_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_ADISJOINT_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 4) + throw InvalidQuerySyntax("TEMPORAL_ADISJOINT_GEOMETRY requires exactly 4 arguments (lon, lat, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) { - if (helpers.top().constantBuilder.empty()) - { - throw InvalidQuerySyntax("Expected constant, got nothing at {}", context->getText()); - } - helpers.top().hasUnnamedAggregation = false; - auto value = std::move(helpers.top().constantBuilder.back()); + auto v = std::move(helpers.top().constantBuilder.back()); helpers.top().constantBuilder.pop_back(); - auto constFunctionItem = ConstantValueLogicalFunction(*dataType, std::move(value)); - helpers.top().functionBuilder.emplace_back(constFunctionItem); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); } - else if (funcName == "VAR") + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalADisjointGeometryLogicalFunction(lon, lat, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ADISJOINT_GEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ECONTAINS_TGEOMETRY */ + case AntlrSQLLexer::TEMPORAL_ECONTAINS_TGEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 6) + throw InvalidQuerySyntax("TEMPORAL_ECONTAINS_TGEOMETRY requires exactly 6 arguments (lonA, latA, tsA, lonB, latB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalEContainsTGeometryLogicalFunction(lonA, latA, tsA, lonB, latB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ECONTAINS_TGEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ECOVERS_TGEOMETRY */ + case AntlrSQLLexer::TEMPORAL_ECOVERS_TGEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 6) + throw InvalidQuerySyntax("TEMPORAL_ECOVERS_TGEOMETRY requires exactly 6 arguments (lonA, latA, tsA, lonB, latB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalECoversTGeometryLogicalFunction(lonA, latA, tsA, lonB, latB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ECOVERS_TGEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_EDISJOINT_TGEOMETRY */ + case AntlrSQLLexer::TEMPORAL_EDISJOINT_TGEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 6) + throw InvalidQuerySyntax("TEMPORAL_EDISJOINT_TGEOMETRY requires exactly 6 arguments (lonA, latA, tsA, lonB, latB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalEDisjointTGeometryLogicalFunction(lonA, latA, tsA, lonB, latB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_EDISJOINT_TGEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_EINTERSECTS_TGEOMETRY */ + case AntlrSQLLexer::TEMPORAL_EINTERSECTS_TGEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 6) + throw InvalidQuerySyntax("TEMPORAL_EINTERSECTS_TGEOMETRY requires exactly 6 arguments (lonA, latA, tsA, lonB, latB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalEIntersectsTGeometryLogicalFunction(lonA, latA, tsA, lonB, latB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_EINTERSECTS_TGEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ETOUCHES_TGEOMETRY */ + case AntlrSQLLexer::TEMPORAL_ETOUCHES_TGEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 6) + throw InvalidQuerySyntax("TEMPORAL_ETOUCHES_TGEOMETRY requires exactly 6 arguments (lonA, latA, tsA, lonB, latB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalETouchesTGeometryLogicalFunction(lonA, latA, tsA, lonB, latB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ETOUCHES_TGEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ACONTAINS_TGEOMETRY */ + case AntlrSQLLexer::TEMPORAL_ACONTAINS_TGEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 6) + throw InvalidQuerySyntax("TEMPORAL_ACONTAINS_TGEOMETRY requires exactly 6 arguments (lonA, latA, tsA, lonB, latB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalAContainsTGeometryLogicalFunction(lonA, latA, tsA, lonB, latB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ACONTAINS_TGEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ADISJOINT_TGEOMETRY */ + case AntlrSQLLexer::TEMPORAL_ADISJOINT_TGEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 6) + throw InvalidQuerySyntax("TEMPORAL_ADISJOINT_TGEOMETRY requires exactly 6 arguments (lonA, latA, tsA, lonB, latB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalADisjointTGeometryLogicalFunction(lonA, latA, tsA, lonB, latB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ADISJOINT_TGEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_AINTERSECTS_TGEOMETRY */ + case AntlrSQLLexer::TEMPORAL_AINTERSECTS_TGEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 6) + throw InvalidQuerySyntax("TEMPORAL_AINTERSECTS_TGEOMETRY requires exactly 6 arguments (lonA, latA, tsA, lonB, latB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalAIntersectsTGeometryLogicalFunction(lonA, latA, tsA, lonB, latB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_AINTERSECTS_TGEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ATOUCHES_TGEOMETRY */ + case AntlrSQLLexer::TEMPORAL_ATOUCHES_TGEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 6) + throw InvalidQuerySyntax("TEMPORAL_ATOUCHES_TGEOMETRY requires exactly 6 arguments (lonA, latA, tsA, lonB, latB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalATouchesTGeometryLogicalFunction(lonA, latA, tsA, lonB, latB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ATOUCHES_TGEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_NAD_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_NAD_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 4) + throw InvalidQuerySyntax("TEMPORAL_NAD_GEOMETRY requires exactly 4 arguments (lon, lat, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) { - if (helpers.top().functionBuilder.empty()) - { - throw InvalidQuerySyntax("Aggregation requires argument at {}", context->getText()); - } - const auto& lastArg = helpers.top().functionBuilder.back().get(); - helpers.top().windowAggs.push_back(std::make_shared(lastArg)); + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); } - else if (funcName == "TEMPORAL_SEQUENCE") + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalNADGeometryLogicalFunction(lon, lat, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_NAD_GEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_NAD_TGEOMETRY */ + case AntlrSQLLexer::TEMPORAL_NAD_TGEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 6) + throw InvalidQuerySyntax("TEMPORAL_NAD_TGEOMETRY requires exactly 6 arguments (lonA, latA, tsA, lonB, latB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalNADTGeometryLogicalFunction(lonA, latA, tsA, lonB, latB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_NAD_TGEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_EDWITHIN_TGEOMETRY */ + case AntlrSQLLexer::TEMPORAL_EDWITHIN_TGEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 7) + throw InvalidQuerySyntax("TEMPORAL_EDWITHIN_TGEOMETRY requires exactly 7 arguments (lonA, latA, tsA, lonB, latB, tsB, distance), but got {}", argCount); + + /* Lift the distance constant */ + while (!helpers.top().constantBuilder.empty()) { - if (helpers.top().functionBuilder.size() < 3) + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::FLOAT64), std::move(v))); + } + + auto dist = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalEDWithinTGeometryLogicalFunction(lonA, latA, tsA, lonB, latB, tsB, dist)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_EDWITHIN_TGEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ADWITHIN_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_ADWITHIN_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_ADWITHIN_GEOMETRY requires exactly 5 arguments (lon, lat, timestamp, geometry, distance), but got {}", argCount); + + /* Lift constants (geometry + distance) — same shape as EDWITHIN_TGEO_GEO */ + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + + DataType dataType; + const auto upperValue = Util::toUpperCase(constantValue); + if (upperValue == "TRUE" || upperValue == "FALSE") { - throw InvalidQuerySyntax("TEMPORAL_SEQUENCE requires three arguments at {}", context->getText()); + dataType = DataTypeProvider::provideDataType(DataType::Type::BOOLEAN); } - const auto ts = helpers.top().functionBuilder.back().get(); - helpers.top().functionBuilder.pop_back(); - const auto lat = helpers.top().functionBuilder.back().get(); - helpers.top().functionBuilder.pop_back(); - const auto lon = helpers.top().functionBuilder.back().get(); - helpers.top().functionBuilder.pop_back(); - helpers.top().windowAggs.push_back(TemporalSequenceAggregationLogicalFunctionV2::create(lon, lat, ts)); + else + { + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + } + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + /* After lift: [lon, lat, ts, distance, geometry] (geometry pushed last because lifted last in LIFO) */ + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto dist = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalADWithinGeometryLogicalFunction(lon, lat, timestamp, geometry, dist)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ADWITHIN_GEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ADWITHIN_TGEOMETRY */ + case AntlrSQLLexer::TEMPORAL_ADWITHIN_TGEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 7) + throw InvalidQuerySyntax("TEMPORAL_ADWITHIN_TGEOMETRY requires exactly 7 arguments (lonA, latA, tsA, lonB, latB, tsB, distance), but got {}", argCount); + + /* Lift the distance constant */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::FLOAT64), std::move(v))); + } + + auto dist = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalADWithinTGeometryLogicalFunction(lonA, latA, tsA, lonB, latB, tsB, dist)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ADWITHIN_TGEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_EDISJOINT_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_EDISJOINT_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 4) + throw InvalidQuerySyntax("TEMPORAL_EDISJOINT_GEOMETRY requires exactly 4 arguments (lon, lat, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalEDisjointGeometryLogicalFunction(lon, lat, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_EDISJOINT_GEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ATOUCHES_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_ATOUCHES_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 4) + throw InvalidQuerySyntax("TEMPORAL_ATOUCHES_GEOMETRY requires exactly 4 arguments (lon, lat, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalATouchesGeometryLogicalFunction(lon, lat, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ATOUCHES_GEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ECOVERS_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_ECOVERS_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 4) + throw InvalidQuerySyntax("TEMPORAL_ECOVERS_GEOMETRY requires exactly 4 arguments (lon, lat, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalECoversGeometryLogicalFunction(lon, lat, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ECOVERS_GEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ACONTAINS_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_ACONTAINS_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 4) + throw InvalidQuerySyntax("TEMPORAL_ACONTAINS_GEOMETRY requires exactly 4 arguments (lon, lat, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalAContainsGeometryLogicalFunction(lon, lat, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ACONTAINS_GEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ETOUCHES_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_ETOUCHES_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 4) + throw InvalidQuerySyntax("TEMPORAL_ETOUCHES_GEOMETRY requires exactly 4 arguments (lon, lat, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalETouchesGeometryLogicalFunction(lon, lat, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ETOUCHES_GEOMETRY */ + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_NAD_FLOAT_SCALAR */ + case AntlrSQLLexer::TEMPORAL_NAD_FLOAT_SCALAR: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TEMPORAL_NAD_FLOAT_SCALAR requires exactly 3 arguments (value, timestamp, scalar), but got {}", argCount); + + /* Lift the scalar constant — accept FLOAT64 (strtod-clean) and INT32 */ + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto scalar = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto value = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalNADFloatScalarLogicalFunction(value, timestamp, scalar)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_NAD_FLOAT_SCALAR */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_NAD_INT_SCALAR */ + case AntlrSQLLexer::TEMPORAL_NAD_INT_SCALAR: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TEMPORAL_NAD_INT_SCALAR requires exactly 3 arguments (value, timestamp, scalar), but got {}", argCount); + + /* Lift the scalar constant — accept FLOAT64 (strtod-clean) and INT32 */ + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto scalar = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto value = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalNADIntScalarLogicalFunction(value, timestamp, scalar)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_NAD_INT_SCALAR */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_NAD_TFLOAT */ + case AntlrSQLLexer::TEMPORAL_NAD_TFLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 4) + throw InvalidQuerySyntax("TEMPORAL_NAD_TFLOAT requires exactly 4 arguments (valueA, tsA, valueB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto valueB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto valueA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalNADTFloatLogicalFunction(valueA, tsA, valueB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_NAD_TFLOAT */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_NAD_TINT */ + case AntlrSQLLexer::TEMPORAL_NAD_TINT: + { + const auto argCount = context->expression().size(); + if (argCount != 4) + throw InvalidQuerySyntax("TEMPORAL_NAD_TINT requires exactly 4 arguments (valueA, tsA, valueB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto valueB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto valueA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalNADTIntLogicalFunction(valueA, tsA, valueB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_NAD_TINT */ + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_AT_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_AT_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 4) + throw InvalidQuerySyntax("TEMPORAL_AT_GEOMETRY requires exactly 4 arguments (lon, lat, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalAtGeometryLogicalFunction(lon, lat, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_AT_GEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_MINUS_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_MINUS_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 4) + throw InvalidQuerySyntax("TEMPORAL_MINUS_GEOMETRY requires exactly 4 arguments (lon, lat, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalMinusGeometryLogicalFunction(lon, lat, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_MINUS_GEOMETRY */ + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ECONTAINS_TCBUFFER */ + case AntlrSQLLexer::TEMPORAL_ECONTAINS_TCBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_ECONTAINS_TCBUFFER requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalEContainsTCbufferLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ECONTAINS_TCBUFFER */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ECOVERS_TCBUFFER */ + case AntlrSQLLexer::TEMPORAL_ECOVERS_TCBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_ECOVERS_TCBUFFER requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalECoversTCbufferLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ECOVERS_TCBUFFER */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_EDISJOINT_TCBUFFER */ + case AntlrSQLLexer::TEMPORAL_EDISJOINT_TCBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_EDISJOINT_TCBUFFER requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalEDisjointTCbufferLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_EDISJOINT_TCBUFFER */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_EINTERSECTS_TCBUFFER */ + case AntlrSQLLexer::TEMPORAL_EINTERSECTS_TCBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_EINTERSECTS_TCBUFFER requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalEIntersectsTCbufferLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_EINTERSECTS_TCBUFFER */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ETOUCHES_TCBUFFER */ + case AntlrSQLLexer::TEMPORAL_ETOUCHES_TCBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_ETOUCHES_TCBUFFER requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalETouchesTCbufferLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ETOUCHES_TCBUFFER */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ACONTAINS_TCBUFFER */ + case AntlrSQLLexer::TEMPORAL_ACONTAINS_TCBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_ACONTAINS_TCBUFFER requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalAContainsTCbufferLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ACONTAINS_TCBUFFER */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ACOVERS_TCBUFFER */ + case AntlrSQLLexer::TEMPORAL_ACOVERS_TCBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_ACOVERS_TCBUFFER requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalACoversTCbufferLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ACOVERS_TCBUFFER */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ADISJOINT_TCBUFFER */ + case AntlrSQLLexer::TEMPORAL_ADISJOINT_TCBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_ADISJOINT_TCBUFFER requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalADisjointTCbufferLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ADISJOINT_TCBUFFER */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_AINTERSECTS_TCBUFFER */ + case AntlrSQLLexer::TEMPORAL_AINTERSECTS_TCBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_AINTERSECTS_TCBUFFER requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalAIntersectsTCbufferLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_AINTERSECTS_TCBUFFER */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ATOUCHES_TCBUFFER */ + case AntlrSQLLexer::TEMPORAL_ATOUCHES_TCBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_ATOUCHES_TCBUFFER requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalATouchesTCbufferLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ATOUCHES_TCBUFFER */ + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ECONTAINS_TCBUFFER_CBUFFER */ + case AntlrSQLLexer::TEMPORAL_ECONTAINS_TCBUFFER_CBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_ECONTAINS_TCBUFFER_CBUFFER requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalEContainsTCbufferCbufferLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ECONTAINS_TCBUFFER_CBUFFER */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ECOVERS_TCBUFFER_CBUFFER */ + case AntlrSQLLexer::TEMPORAL_ECOVERS_TCBUFFER_CBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_ECOVERS_TCBUFFER_CBUFFER requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalECoversTCbufferCbufferLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ECOVERS_TCBUFFER_CBUFFER */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_EDISJOINT_TCBUFFER_CBUFFER */ + case AntlrSQLLexer::TEMPORAL_EDISJOINT_TCBUFFER_CBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_EDISJOINT_TCBUFFER_CBUFFER requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalEDisjointTCbufferCbufferLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_EDISJOINT_TCBUFFER_CBUFFER */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_EINTERSECTS_TCBUFFER_CBUFFER */ + case AntlrSQLLexer::TEMPORAL_EINTERSECTS_TCBUFFER_CBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_EINTERSECTS_TCBUFFER_CBUFFER requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalEIntersectsTCbufferCbufferLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_EINTERSECTS_TCBUFFER_CBUFFER */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ETOUCHES_TCBUFFER_CBUFFER */ + case AntlrSQLLexer::TEMPORAL_ETOUCHES_TCBUFFER_CBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_ETOUCHES_TCBUFFER_CBUFFER requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalETouchesTCbufferCbufferLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ETOUCHES_TCBUFFER_CBUFFER */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ACONTAINS_TCBUFFER_CBUFFER */ + case AntlrSQLLexer::TEMPORAL_ACONTAINS_TCBUFFER_CBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_ACONTAINS_TCBUFFER_CBUFFER requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalAContainsTCbufferCbufferLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ACONTAINS_TCBUFFER_CBUFFER */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ACOVERS_TCBUFFER_CBUFFER */ + case AntlrSQLLexer::TEMPORAL_ACOVERS_TCBUFFER_CBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_ACOVERS_TCBUFFER_CBUFFER requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalACoversTCbufferCbufferLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ACOVERS_TCBUFFER_CBUFFER */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ADISJOINT_TCBUFFER_CBUFFER */ + case AntlrSQLLexer::TEMPORAL_ADISJOINT_TCBUFFER_CBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_ADISJOINT_TCBUFFER_CBUFFER requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalADisjointTCbufferCbufferLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ADISJOINT_TCBUFFER_CBUFFER */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_AINTERSECTS_TCBUFFER_CBUFFER */ + case AntlrSQLLexer::TEMPORAL_AINTERSECTS_TCBUFFER_CBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_AINTERSECTS_TCBUFFER_CBUFFER requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalAIntersectsTCbufferCbufferLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_AINTERSECTS_TCBUFFER_CBUFFER */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ATOUCHES_TCBUFFER_CBUFFER */ + case AntlrSQLLexer::TEMPORAL_ATOUCHES_TCBUFFER_CBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_ATOUCHES_TCBUFFER_CBUFFER requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalATouchesTCbufferCbufferLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ATOUCHES_TCBUFFER_CBUFFER */ + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ADISJOINT_TCBUFFER_TCBUFFER */ + case AntlrSQLLexer::TEMPORAL_ADISJOINT_TCBUFFER_TCBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 8) + throw InvalidQuerySyntax("TEMPORAL_ADISJOINT_TCBUFFER_TCBUFFER requires exactly 8 arguments (lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radiusB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radiusA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalADisjointTCbufferTCbufferLogicalFunction(lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ADISJOINT_TCBUFFER_TCBUFFER */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_AINTERSECTS_TCBUFFER_TCBUFFER */ + case AntlrSQLLexer::TEMPORAL_AINTERSECTS_TCBUFFER_TCBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 8) + throw InvalidQuerySyntax("TEMPORAL_AINTERSECTS_TCBUFFER_TCBUFFER requires exactly 8 arguments (lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radiusB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radiusA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalAIntersectsTCbufferTCbufferLogicalFunction(lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_AINTERSECTS_TCBUFFER_TCBUFFER */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ATOUCHES_TCBUFFER_TCBUFFER */ + case AntlrSQLLexer::TEMPORAL_ATOUCHES_TCBUFFER_TCBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 8) + throw InvalidQuerySyntax("TEMPORAL_ATOUCHES_TCBUFFER_TCBUFFER requires exactly 8 arguments (lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radiusB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radiusA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalATouchesTCbufferTCbufferLogicalFunction(lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ATOUCHES_TCBUFFER_TCBUFFER */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ECOVERS_TCBUFFER_TCBUFFER */ + case AntlrSQLLexer::TEMPORAL_ECOVERS_TCBUFFER_TCBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 8) + throw InvalidQuerySyntax("TEMPORAL_ECOVERS_TCBUFFER_TCBUFFER requires exactly 8 arguments (lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radiusB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radiusA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalECoversTCbufferTCbufferLogicalFunction(lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ECOVERS_TCBUFFER_TCBUFFER */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_EINTERSECTS_TCBUFFER_TCBUFFER */ + case AntlrSQLLexer::TEMPORAL_EINTERSECTS_TCBUFFER_TCBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 8) + throw InvalidQuerySyntax("TEMPORAL_EINTERSECTS_TCBUFFER_TCBUFFER requires exactly 8 arguments (lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radiusB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radiusA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalEIntersectsTCbufferTCbufferLogicalFunction(lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_EINTERSECTS_TCBUFFER_TCBUFFER */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ETOUCHES_TCBUFFER_TCBUFFER */ + case AntlrSQLLexer::TEMPORAL_ETOUCHES_TCBUFFER_TCBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 8) + throw InvalidQuerySyntax("TEMPORAL_ETOUCHES_TCBUFFER_TCBUFFER requires exactly 8 arguments (lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radiusB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radiusA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalETouchesTCbufferTCbufferLogicalFunction(lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ETOUCHES_TCBUFFER_TCBUFFER */ + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_EDWITHIN_TCBUFFER_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_EDWITHIN_TCBUFFER_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 6) + throw InvalidQuerySyntax("TEMPORAL_EDWITHIN_TCBUFFER_GEOMETRY requires exactly 6 arguments (lon, lat, radius, timestamp, blob, distance), but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto blobLast = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto distLast = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalEDWithinTCbufferGeometryLogicalFunction(lon, lat, radius, timestamp, blobLast, distLast)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_EDWITHIN_TCBUFFER_GEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ADWITHIN_TCBUFFER_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_ADWITHIN_TCBUFFER_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 6) + throw InvalidQuerySyntax("TEMPORAL_ADWITHIN_TCBUFFER_GEOMETRY requires exactly 6 arguments (lon, lat, radius, timestamp, blob, distance), but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto blobLast = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto distLast = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalADWithinTCbufferGeometryLogicalFunction(lon, lat, radius, timestamp, blobLast, distLast)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ADWITHIN_TCBUFFER_GEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_EDWITHIN_TCBUFFER_CBUFFER */ + case AntlrSQLLexer::TEMPORAL_EDWITHIN_TCBUFFER_CBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 6) + throw InvalidQuerySyntax("TEMPORAL_EDWITHIN_TCBUFFER_CBUFFER requires exactly 6 arguments (lon, lat, radius, timestamp, blob, distance), but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto blobLast = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto distLast = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalEDWithinTCbufferCbufferLogicalFunction(lon, lat, radius, timestamp, blobLast, distLast)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_EDWITHIN_TCBUFFER_CBUFFER */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ADWITHIN_TCBUFFER_CBUFFER */ + case AntlrSQLLexer::TEMPORAL_ADWITHIN_TCBUFFER_CBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 6) + throw InvalidQuerySyntax("TEMPORAL_ADWITHIN_TCBUFFER_CBUFFER requires exactly 6 arguments (lon, lat, radius, timestamp, blob, distance), but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto blobLast = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto distLast = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalADWithinTCbufferCbufferLogicalFunction(lon, lat, radius, timestamp, blobLast, distLast)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ADWITHIN_TCBUFFER_CBUFFER */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_EDWITHIN_TCBUFFER_TCBUFFER */ + case AntlrSQLLexer::TEMPORAL_EDWITHIN_TCBUFFER_TCBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 9) + throw InvalidQuerySyntax("TEMPORAL_EDWITHIN_TCBUFFER_TCBUFFER requires exactly 9 arguments (lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB, distance), but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::FLOAT64), std::move(v))); + } + + auto dist = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radiusB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radiusA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalEDWithinTCbufferTCbufferLogicalFunction(lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB, dist)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_EDWITHIN_TCBUFFER_TCBUFFER */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ADWITHIN_TCBUFFER_TCBUFFER */ + case AntlrSQLLexer::TEMPORAL_ADWITHIN_TCBUFFER_TCBUFFER: + { + const auto argCount = context->expression().size(); + if (argCount != 9) + throw InvalidQuerySyntax("TEMPORAL_ADWITHIN_TCBUFFER_TCBUFFER requires exactly 9 arguments (lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB, distance), but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::FLOAT64), std::move(v))); + } + + auto dist = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radiusB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radiusA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalADWithinTCbufferTCbufferLogicalFunction(lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB, dist)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ADWITHIN_TCBUFFER_TCBUFFER */ + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ECONTAINS_TPOSE_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_ECONTAINS_TPOSE_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_ECONTAINS_TPOSE_GEOMETRY requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalEContainsTPoseGeometryLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ECONTAINS_TPOSE_GEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ECOVERS_TPOSE_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_ECOVERS_TPOSE_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_ECOVERS_TPOSE_GEOMETRY requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalECoversTPoseGeometryLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ECOVERS_TPOSE_GEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_EDISJOINT_TPOSE_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_EDISJOINT_TPOSE_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_EDISJOINT_TPOSE_GEOMETRY requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalEDisjointTPoseGeometryLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_EDISJOINT_TPOSE_GEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_EINTERSECTS_TPOSE_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_EINTERSECTS_TPOSE_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_EINTERSECTS_TPOSE_GEOMETRY requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalEIntersectsTPoseGeometryLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_EINTERSECTS_TPOSE_GEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ETOUCHES_TPOSE_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_ETOUCHES_TPOSE_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_ETOUCHES_TPOSE_GEOMETRY requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalETouchesTPoseGeometryLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ETOUCHES_TPOSE_GEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ACONTAINS_TPOSE_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_ACONTAINS_TPOSE_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_ACONTAINS_TPOSE_GEOMETRY requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalAContainsTPoseGeometryLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ACONTAINS_TPOSE_GEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ADISJOINT_TPOSE_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_ADISJOINT_TPOSE_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_ADISJOINT_TPOSE_GEOMETRY requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalADisjointTPoseGeometryLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ADISJOINT_TPOSE_GEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_AINTERSECTS_TPOSE_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_AINTERSECTS_TPOSE_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_AINTERSECTS_TPOSE_GEOMETRY requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalAIntersectsTPoseGeometryLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_AINTERSECTS_TPOSE_GEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ATOUCHES_TPOSE_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_ATOUCHES_TPOSE_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("TEMPORAL_ATOUCHES_TPOSE_GEOMETRY requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalATouchesTPoseGeometryLogicalFunction(lon, lat, radius, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ATOUCHES_TPOSE_GEOMETRY */ + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ECONTAINS_TPOSE_TPOSE */ + case AntlrSQLLexer::TEMPORAL_ECONTAINS_TPOSE_TPOSE: + { + const auto argCount = context->expression().size(); + if (argCount != 8) + throw InvalidQuerySyntax("TEMPORAL_ECONTAINS_TPOSE_TPOSE requires exactly 8 arguments (xA, yA, thetaA, tsA, xB, yB, thetaB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto thetaB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto yB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto xB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto thetaA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto yA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto xA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalEContainsTPoseTPoseLogicalFunction(xA, yA, thetaA, tsA, xB, yB, thetaB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ECONTAINS_TPOSE_TPOSE */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ECOVERS_TPOSE_TPOSE */ + case AntlrSQLLexer::TEMPORAL_ECOVERS_TPOSE_TPOSE: + { + const auto argCount = context->expression().size(); + if (argCount != 8) + throw InvalidQuerySyntax("TEMPORAL_ECOVERS_TPOSE_TPOSE requires exactly 8 arguments (xA, yA, thetaA, tsA, xB, yB, thetaB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto thetaB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto yB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto xB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto thetaA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto yA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto xA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalECoversTPoseTPoseLogicalFunction(xA, yA, thetaA, tsA, xB, yB, thetaB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ECOVERS_TPOSE_TPOSE */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_EDISJOINT_TPOSE_TPOSE */ + case AntlrSQLLexer::TEMPORAL_EDISJOINT_TPOSE_TPOSE: + { + const auto argCount = context->expression().size(); + if (argCount != 8) + throw InvalidQuerySyntax("TEMPORAL_EDISJOINT_TPOSE_TPOSE requires exactly 8 arguments (xA, yA, thetaA, tsA, xB, yB, thetaB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto thetaB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto yB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto xB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto thetaA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto yA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto xA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalEDisjointTPoseTPoseLogicalFunction(xA, yA, thetaA, tsA, xB, yB, thetaB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_EDISJOINT_TPOSE_TPOSE */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_EINTERSECTS_TPOSE_TPOSE */ + case AntlrSQLLexer::TEMPORAL_EINTERSECTS_TPOSE_TPOSE: + { + const auto argCount = context->expression().size(); + if (argCount != 8) + throw InvalidQuerySyntax("TEMPORAL_EINTERSECTS_TPOSE_TPOSE requires exactly 8 arguments (xA, yA, thetaA, tsA, xB, yB, thetaB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto thetaB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto yB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto xB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto thetaA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto yA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto xA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalEIntersectsTPoseTPoseLogicalFunction(xA, yA, thetaA, tsA, xB, yB, thetaB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_EINTERSECTS_TPOSE_TPOSE */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ETOUCHES_TPOSE_TPOSE */ + case AntlrSQLLexer::TEMPORAL_ETOUCHES_TPOSE_TPOSE: + { + const auto argCount = context->expression().size(); + if (argCount != 8) + throw InvalidQuerySyntax("TEMPORAL_ETOUCHES_TPOSE_TPOSE requires exactly 8 arguments (xA, yA, thetaA, tsA, xB, yB, thetaB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto thetaB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto yB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto xB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto thetaA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto yA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto xA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalETouchesTPoseTPoseLogicalFunction(xA, yA, thetaA, tsA, xB, yB, thetaB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ETOUCHES_TPOSE_TPOSE */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ACONTAINS_TPOSE_TPOSE */ + case AntlrSQLLexer::TEMPORAL_ACONTAINS_TPOSE_TPOSE: + { + const auto argCount = context->expression().size(); + if (argCount != 8) + throw InvalidQuerySyntax("TEMPORAL_ACONTAINS_TPOSE_TPOSE requires exactly 8 arguments (xA, yA, thetaA, tsA, xB, yB, thetaB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto thetaB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto yB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto xB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto thetaA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto yA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto xA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalAContainsTPoseTPoseLogicalFunction(xA, yA, thetaA, tsA, xB, yB, thetaB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ACONTAINS_TPOSE_TPOSE */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ADISJOINT_TPOSE_TPOSE */ + case AntlrSQLLexer::TEMPORAL_ADISJOINT_TPOSE_TPOSE: + { + const auto argCount = context->expression().size(); + if (argCount != 8) + throw InvalidQuerySyntax("TEMPORAL_ADISJOINT_TPOSE_TPOSE requires exactly 8 arguments (xA, yA, thetaA, tsA, xB, yB, thetaB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto thetaB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto yB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto xB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto thetaA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto yA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto xA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalADisjointTPoseTPoseLogicalFunction(xA, yA, thetaA, tsA, xB, yB, thetaB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ADISJOINT_TPOSE_TPOSE */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_AINTERSECTS_TPOSE_TPOSE */ + case AntlrSQLLexer::TEMPORAL_AINTERSECTS_TPOSE_TPOSE: + { + const auto argCount = context->expression().size(); + if (argCount != 8) + throw InvalidQuerySyntax("TEMPORAL_AINTERSECTS_TPOSE_TPOSE requires exactly 8 arguments (xA, yA, thetaA, tsA, xB, yB, thetaB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto thetaB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto yB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto xB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto thetaA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto yA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto xA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalAIntersectsTPoseTPoseLogicalFunction(xA, yA, thetaA, tsA, xB, yB, thetaB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_AINTERSECTS_TPOSE_TPOSE */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ATOUCHES_TPOSE_TPOSE */ + case AntlrSQLLexer::TEMPORAL_ATOUCHES_TPOSE_TPOSE: + { + const auto argCount = context->expression().size(); + if (argCount != 8) + throw InvalidQuerySyntax("TEMPORAL_ATOUCHES_TPOSE_TPOSE requires exactly 8 arguments (xA, yA, thetaA, tsA, xB, yB, thetaB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto thetaB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto yB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto xB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto thetaA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto yA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto xA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalATouchesTPoseTPoseLogicalFunction(xA, yA, thetaA, tsA, xB, yB, thetaB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ATOUCHES_TPOSE_TPOSE */ + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ECONTAINS_TNPOINT_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_ECONTAINS_TNPOINT_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 4) + throw InvalidQuerySyntax("TEMPORAL_ECONTAINS_TNPOINT_GEOMETRY requires exactly 4 arguments (lon, lat, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalEContainsTNpointGeometryLogicalFunction(lon, lat, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ECONTAINS_TNPOINT_GEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ECONTAINS_TNPOINT_TNPOINT */ + case AntlrSQLLexer::TEMPORAL_ECONTAINS_TNPOINT_TNPOINT: + { + const auto argCount = context->expression().size(); + if (argCount != 6) + throw InvalidQuerySyntax("TEMPORAL_ECONTAINS_TNPOINT_TNPOINT requires exactly 6 arguments (lonA, latA, tsA, lonB, latB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalEContainsTNpointTNpointLogicalFunction(lonA, latA, tsA, lonB, latB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ECONTAINS_TNPOINT_TNPOINT */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ECOVERS_TNPOINT_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_ECOVERS_TNPOINT_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 4) + throw InvalidQuerySyntax("TEMPORAL_ECOVERS_TNPOINT_GEOMETRY requires exactly 4 arguments (lon, lat, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalECoversTNpointGeometryLogicalFunction(lon, lat, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ECOVERS_TNPOINT_GEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ECOVERS_TNPOINT_TNPOINT */ + case AntlrSQLLexer::TEMPORAL_ECOVERS_TNPOINT_TNPOINT: + { + const auto argCount = context->expression().size(); + if (argCount != 6) + throw InvalidQuerySyntax("TEMPORAL_ECOVERS_TNPOINT_TNPOINT requires exactly 6 arguments (lonA, latA, tsA, lonB, latB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalECoversTNpointTNpointLogicalFunction(lonA, latA, tsA, lonB, latB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ECOVERS_TNPOINT_TNPOINT */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_EDISJOINT_TNPOINT_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_EDISJOINT_TNPOINT_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 4) + throw InvalidQuerySyntax("TEMPORAL_EDISJOINT_TNPOINT_GEOMETRY requires exactly 4 arguments (lon, lat, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalEDisjointTNpointGeometryLogicalFunction(lon, lat, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_EDISJOINT_TNPOINT_GEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_EDISJOINT_TNPOINT_TNPOINT */ + case AntlrSQLLexer::TEMPORAL_EDISJOINT_TNPOINT_TNPOINT: + { + const auto argCount = context->expression().size(); + if (argCount != 6) + throw InvalidQuerySyntax("TEMPORAL_EDISJOINT_TNPOINT_TNPOINT requires exactly 6 arguments (lonA, latA, tsA, lonB, latB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalEDisjointTNpointTNpointLogicalFunction(lonA, latA, tsA, lonB, latB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_EDISJOINT_TNPOINT_TNPOINT */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_EINTERSECTS_TNPOINT_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_EINTERSECTS_TNPOINT_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 4) + throw InvalidQuerySyntax("TEMPORAL_EINTERSECTS_TNPOINT_GEOMETRY requires exactly 4 arguments (lon, lat, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalEIntersectsTNpointGeometryLogicalFunction(lon, lat, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_EINTERSECTS_TNPOINT_GEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_EINTERSECTS_TNPOINT_TNPOINT */ + case AntlrSQLLexer::TEMPORAL_EINTERSECTS_TNPOINT_TNPOINT: + { + const auto argCount = context->expression().size(); + if (argCount != 6) + throw InvalidQuerySyntax("TEMPORAL_EINTERSECTS_TNPOINT_TNPOINT requires exactly 6 arguments (lonA, latA, tsA, lonB, latB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalEIntersectsTNpointTNpointLogicalFunction(lonA, latA, tsA, lonB, latB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_EINTERSECTS_TNPOINT_TNPOINT */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ETOUCHES_TNPOINT_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_ETOUCHES_TNPOINT_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 4) + throw InvalidQuerySyntax("TEMPORAL_ETOUCHES_TNPOINT_GEOMETRY requires exactly 4 arguments (lon, lat, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalETouchesTNpointGeometryLogicalFunction(lon, lat, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ETOUCHES_TNPOINT_GEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ETOUCHES_TNPOINT_TNPOINT */ + case AntlrSQLLexer::TEMPORAL_ETOUCHES_TNPOINT_TNPOINT: + { + const auto argCount = context->expression().size(); + if (argCount != 6) + throw InvalidQuerySyntax("TEMPORAL_ETOUCHES_TNPOINT_TNPOINT requires exactly 6 arguments (lonA, latA, tsA, lonB, latB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalETouchesTNpointTNpointLogicalFunction(lonA, latA, tsA, lonB, latB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ETOUCHES_TNPOINT_TNPOINT */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ACONTAINS_TNPOINT_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_ACONTAINS_TNPOINT_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 4) + throw InvalidQuerySyntax("TEMPORAL_ACONTAINS_TNPOINT_GEOMETRY requires exactly 4 arguments (lon, lat, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalAContainsTNpointGeometryLogicalFunction(lon, lat, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ACONTAINS_TNPOINT_GEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ACONTAINS_TNPOINT_TNPOINT */ + case AntlrSQLLexer::TEMPORAL_ACONTAINS_TNPOINT_TNPOINT: + { + const auto argCount = context->expression().size(); + if (argCount != 6) + throw InvalidQuerySyntax("TEMPORAL_ACONTAINS_TNPOINT_TNPOINT requires exactly 6 arguments (lonA, latA, tsA, lonB, latB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalAContainsTNpointTNpointLogicalFunction(lonA, latA, tsA, lonB, latB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ACONTAINS_TNPOINT_TNPOINT */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ADISJOINT_TNPOINT_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_ADISJOINT_TNPOINT_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 4) + throw InvalidQuerySyntax("TEMPORAL_ADISJOINT_TNPOINT_GEOMETRY requires exactly 4 arguments (lon, lat, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalADisjointTNpointGeometryLogicalFunction(lon, lat, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ADISJOINT_TNPOINT_GEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ADISJOINT_TNPOINT_TNPOINT */ + case AntlrSQLLexer::TEMPORAL_ADISJOINT_TNPOINT_TNPOINT: + { + const auto argCount = context->expression().size(); + if (argCount != 6) + throw InvalidQuerySyntax("TEMPORAL_ADISJOINT_TNPOINT_TNPOINT requires exactly 6 arguments (lonA, latA, tsA, lonB, latB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalADisjointTNpointTNpointLogicalFunction(lonA, latA, tsA, lonB, latB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ADISJOINT_TNPOINT_TNPOINT */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_AINTERSECTS_TNPOINT_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_AINTERSECTS_TNPOINT_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 4) + throw InvalidQuerySyntax("TEMPORAL_AINTERSECTS_TNPOINT_GEOMETRY requires exactly 4 arguments (lon, lat, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalAIntersectsTNpointGeometryLogicalFunction(lon, lat, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_AINTERSECTS_TNPOINT_GEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_AINTERSECTS_TNPOINT_TNPOINT */ + case AntlrSQLLexer::TEMPORAL_AINTERSECTS_TNPOINT_TNPOINT: + { + const auto argCount = context->expression().size(); + if (argCount != 6) + throw InvalidQuerySyntax("TEMPORAL_AINTERSECTS_TNPOINT_TNPOINT requires exactly 6 arguments (lonA, latA, tsA, lonB, latB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalAIntersectsTNpointTNpointLogicalFunction(lonA, latA, tsA, lonB, latB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_AINTERSECTS_TNPOINT_TNPOINT */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ATOUCHES_TNPOINT_GEOMETRY */ + case AntlrSQLLexer::TEMPORAL_ATOUCHES_TNPOINT_GEOMETRY: + { + const auto argCount = context->expression().size(); + if (argCount != 4) + throw InvalidQuerySyntax("TEMPORAL_ATOUCHES_TNPOINT_GEOMETRY requires exactly 4 arguments (lon, lat, timestamp, geometry), but got {}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + { + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + } + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalATouchesTNpointGeometryLogicalFunction(lon, lat, timestamp, geometry)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ATOUCHES_TNPOINT_GEOMETRY */ + + /* BEGIN CODEGEN PARSER GLUE: TEMPORAL_ATOUCHES_TNPOINT_TNPOINT */ + case AntlrSQLLexer::TEMPORAL_ATOUCHES_TNPOINT_TNPOINT: + { + const auto argCount = context->expression().size(); + if (argCount != 6) + throw InvalidQuerySyntax("TEMPORAL_ATOUCHES_TNPOINT_TNPOINT requires exactly 6 arguments (lonA, latA, tsA, lonB, latB, tsB), but got {}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + TemporalATouchesTNpointTNpointLogicalFunction(lonA, latA, tsA, lonB, latB, tsB)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ATOUCHES_TNPOINT_TNPOINT */ + + + + + + + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_NUM_INSTANTS (case-switch) */ + case AntlrSQLLexer::TEMPORAL_NUM_INSTANTS: + // Per-(window, group) count of instants in the assembled tgeo trajectory. + if (helpers.top().functionBuilder.size() != 3) { + throw InvalidQuerySyntax("TEMPORAL_NUM_INSTANTS requires exactly three arguments (longitude, latitude, timestamp), but got {}", helpers.top().functionBuilder.size()); + } + { + const auto timestampFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto latitudeFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto longitudeFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + + if (!longitudeFunction.tryGet() || + !latitudeFunction.tryGet() || + !timestampFunction.tryGet()) { + throw InvalidQuerySyntax("TEMPORAL_NUM_INSTANTS arguments must be field references"); + } + + helpers.top().windowAggs.push_back( + TemporalNumInstantsAggregationLogicalFunction::create(longitudeFunction.get(), + latitudeFunction.get(), + timestampFunction.get())); + helpers.top().functionBuilder.push_back(longitudeFunction); + } + break; + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_NUM_INSTANTS (case-switch) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_NUM_SEQUENCES (case-switch) */ + case AntlrSQLLexer::TEMPORAL_NUM_SEQUENCES: + // Per-(window, group) count of sub-sequences in the assembled tgeo trajectory. + if (helpers.top().functionBuilder.size() != 3) { + throw InvalidQuerySyntax("TEMPORAL_NUM_SEQUENCES requires exactly three arguments (longitude, latitude, timestamp), but got {}", helpers.top().functionBuilder.size()); + } + { + const auto timestampFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto latitudeFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto longitudeFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + + if (!longitudeFunction.tryGet() || + !latitudeFunction.tryGet() || + !timestampFunction.tryGet()) { + throw InvalidQuerySyntax("TEMPORAL_NUM_SEQUENCES arguments must be field references"); + } + + helpers.top().windowAggs.push_back( + TemporalNumSequencesAggregationLogicalFunction::create(longitudeFunction.get(), + latitudeFunction.get(), + timestampFunction.get())); + helpers.top().functionBuilder.push_back(longitudeFunction); + } + break; + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_NUM_SEQUENCES (case-switch) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_NUM_TIMESTAMPS (case-switch) */ + case AntlrSQLLexer::TEMPORAL_NUM_TIMESTAMPS: + // Per-(window, group) count of distinct timestamps in the assembled tgeo trajectory. + if (helpers.top().functionBuilder.size() != 3) { + throw InvalidQuerySyntax("TEMPORAL_NUM_TIMESTAMPS requires exactly three arguments (longitude, latitude, timestamp), but got {}", helpers.top().functionBuilder.size()); + } + { + const auto timestampFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto latitudeFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto longitudeFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + + if (!longitudeFunction.tryGet() || + !latitudeFunction.tryGet() || + !timestampFunction.tryGet()) { + throw InvalidQuerySyntax("TEMPORAL_NUM_TIMESTAMPS arguments must be field references"); + } + + helpers.top().windowAggs.push_back( + TemporalNumTimestampsAggregationLogicalFunction::create(longitudeFunction.get(), + latitudeFunction.get(), + timestampFunction.get())); + helpers.top().functionBuilder.push_back(longitudeFunction); + } + break; + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_NUM_TIMESTAMPS (case-switch) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_TFLOAT_START_VALUE (case-switch) */ + case AntlrSQLLexer::TEMPORAL_TFLOAT_START_VALUE: + // Value at the first instant of the per-(window, group) tfloat sequence. + if (helpers.top().functionBuilder.size() != 2) { + throw InvalidQuerySyntax("TEMPORAL_TFLOAT_START_VALUE requires exactly two arguments (value, timestamp), but got {}", helpers.top().functionBuilder.size()); + } + { + const auto timestampFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto valueFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + + if (!valueFunction.tryGet() || + !timestampFunction.tryGet()) { + throw InvalidQuerySyntax("TEMPORAL_TFLOAT_START_VALUE arguments must be field references"); + } + + helpers.top().windowAggs.push_back( + TemporalTFloatStartValueAggregationLogicalFunction::create(valueFunction.get(), + timestampFunction.get())); + helpers.top().functionBuilder.push_back(valueFunction); + } + break; + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_TFLOAT_START_VALUE (case-switch) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_TFLOAT_END_VALUE (case-switch) */ + case AntlrSQLLexer::TEMPORAL_TFLOAT_END_VALUE: + // Value at the last instant of the per-(window, group) tfloat sequence. + if (helpers.top().functionBuilder.size() != 2) { + throw InvalidQuerySyntax("TEMPORAL_TFLOAT_END_VALUE requires exactly two arguments (value, timestamp), but got {}", helpers.top().functionBuilder.size()); + } + { + const auto timestampFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto valueFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + + if (!valueFunction.tryGet() || + !timestampFunction.tryGet()) { + throw InvalidQuerySyntax("TEMPORAL_TFLOAT_END_VALUE arguments must be field references"); + } + + helpers.top().windowAggs.push_back( + TemporalTFloatEndValueAggregationLogicalFunction::create(valueFunction.get(), + timestampFunction.get())); + helpers.top().functionBuilder.push_back(valueFunction); + } + break; + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_TFLOAT_END_VALUE (case-switch) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_TFLOAT_MIN_VALUE (case-switch) */ + case AntlrSQLLexer::TEMPORAL_TFLOAT_MIN_VALUE: + // Minimum value across instants of the per-(window, group) tfloat sequence. + if (helpers.top().functionBuilder.size() != 2) { + throw InvalidQuerySyntax("TEMPORAL_TFLOAT_MIN_VALUE requires exactly two arguments (value, timestamp), but got {}", helpers.top().functionBuilder.size()); + } + { + const auto timestampFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto valueFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + + if (!valueFunction.tryGet() || + !timestampFunction.tryGet()) { + throw InvalidQuerySyntax("TEMPORAL_TFLOAT_MIN_VALUE arguments must be field references"); + } + + helpers.top().windowAggs.push_back( + TemporalTFloatMinValueAggregationLogicalFunction::create(valueFunction.get(), + timestampFunction.get())); + helpers.top().functionBuilder.push_back(valueFunction); + } + break; + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_TFLOAT_MIN_VALUE (case-switch) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_TFLOAT_MAX_VALUE (case-switch) */ + case AntlrSQLLexer::TEMPORAL_TFLOAT_MAX_VALUE: + // Maximum value across instants of the per-(window, group) tfloat sequence. + if (helpers.top().functionBuilder.size() != 2) { + throw InvalidQuerySyntax("TEMPORAL_TFLOAT_MAX_VALUE requires exactly two arguments (value, timestamp), but got {}", helpers.top().functionBuilder.size()); + } + { + const auto timestampFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto valueFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + + if (!valueFunction.tryGet() || + !timestampFunction.tryGet()) { + throw InvalidQuerySyntax("TEMPORAL_TFLOAT_MAX_VALUE arguments must be field references"); + } + + helpers.top().windowAggs.push_back( + TemporalTFloatMaxValueAggregationLogicalFunction::create(valueFunction.get(), + timestampFunction.get())); + helpers.top().functionBuilder.push_back(valueFunction); + } + break; + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_TFLOAT_MAX_VALUE (case-switch) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_TNUMBER_INTEGRAL (case-switch) */ + case AntlrSQLLexer::TEMPORAL_TNUMBER_INTEGRAL: + // Time-weighted integral (area under the value-vs-time curve) of the per-(window, group) tfloat sequence. + if (helpers.top().functionBuilder.size() != 2) { + throw InvalidQuerySyntax("TEMPORAL_TNUMBER_INTEGRAL requires exactly two arguments (value, timestamp), but got {}", helpers.top().functionBuilder.size()); + } + { + const auto timestampFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto valueFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + + if (!valueFunction.tryGet() || + !timestampFunction.tryGet()) { + throw InvalidQuerySyntax("TEMPORAL_TNUMBER_INTEGRAL arguments must be field references"); + } + + helpers.top().windowAggs.push_back( + TemporalTNumberIntegralAggregationLogicalFunction::create(valueFunction.get(), + timestampFunction.get())); + helpers.top().functionBuilder.push_back(valueFunction); + } + break; + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_TNUMBER_INTEGRAL (case-switch) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_TINT_START_VALUE (case-switch) */ + case AntlrSQLLexer::TEMPORAL_TINT_START_VALUE: + // Value at the first instant of the per-(window, group) tint sequence. + if (helpers.top().functionBuilder.size() != 2) { + throw InvalidQuerySyntax("TEMPORAL_TINT_START_VALUE requires exactly two arguments (value, timestamp), but got {}", helpers.top().functionBuilder.size()); + } + { + const auto timestampFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto valueFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + + if (!valueFunction.tryGet() || + !timestampFunction.tryGet()) { + throw InvalidQuerySyntax("TEMPORAL_TINT_START_VALUE arguments must be field references"); + } + + helpers.top().windowAggs.push_back( + TemporalTIntStartValueAggregationLogicalFunction::create(valueFunction.get(), + timestampFunction.get())); + helpers.top().functionBuilder.push_back(valueFunction); + } + break; + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_TINT_START_VALUE (case-switch) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_TINT_END_VALUE (case-switch) */ + case AntlrSQLLexer::TEMPORAL_TINT_END_VALUE: + // Value at the last instant of the per-(window, group) tint sequence. + if (helpers.top().functionBuilder.size() != 2) { + throw InvalidQuerySyntax("TEMPORAL_TINT_END_VALUE requires exactly two arguments (value, timestamp), but got {}", helpers.top().functionBuilder.size()); + } + { + const auto timestampFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto valueFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + + if (!valueFunction.tryGet() || + !timestampFunction.tryGet()) { + throw InvalidQuerySyntax("TEMPORAL_TINT_END_VALUE arguments must be field references"); + } + + helpers.top().windowAggs.push_back( + TemporalTIntEndValueAggregationLogicalFunction::create(valueFunction.get(), + timestampFunction.get())); + helpers.top().functionBuilder.push_back(valueFunction); + } + break; + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_TINT_END_VALUE (case-switch) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_TINT_MIN_VALUE (case-switch) */ + case AntlrSQLLexer::TEMPORAL_TINT_MIN_VALUE: + // Minimum value across instants of the per-(window, group) tint sequence. + if (helpers.top().functionBuilder.size() != 2) { + throw InvalidQuerySyntax("TEMPORAL_TINT_MIN_VALUE requires exactly two arguments (value, timestamp), but got {}", helpers.top().functionBuilder.size()); + } + { + const auto timestampFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto valueFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + + if (!valueFunction.tryGet() || + !timestampFunction.tryGet()) { + throw InvalidQuerySyntax("TEMPORAL_TINT_MIN_VALUE arguments must be field references"); + } + + helpers.top().windowAggs.push_back( + TemporalTIntMinValueAggregationLogicalFunction::create(valueFunction.get(), + timestampFunction.get())); + helpers.top().functionBuilder.push_back(valueFunction); + } + break; + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_TINT_MIN_VALUE (case-switch) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_TINT_MAX_VALUE (case-switch) */ + case AntlrSQLLexer::TEMPORAL_TINT_MAX_VALUE: + // Maximum value across instants of the per-(window, group) tint sequence. + if (helpers.top().functionBuilder.size() != 2) { + throw InvalidQuerySyntax("TEMPORAL_TINT_MAX_VALUE requires exactly two arguments (value, timestamp), but got {}", helpers.top().functionBuilder.size()); + } + { + const auto timestampFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto valueFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + + if (!valueFunction.tryGet() || + !timestampFunction.tryGet()) { + throw InvalidQuerySyntax("TEMPORAL_TINT_MAX_VALUE arguments must be field references"); + } + + helpers.top().windowAggs.push_back( + TemporalTIntMaxValueAggregationLogicalFunction::create(valueFunction.get(), + timestampFunction.get())); + helpers.top().functionBuilder.push_back(valueFunction); + } + break; + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_TINT_MAX_VALUE (case-switch) */ + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_TFLOAT_AVG_VALUE (case-switch) */ + case AntlrSQLLexer::TEMPORAL_TFLOAT_AVG_VALUE: + // Arithmetic mean of all instant values in the per-(window, group) tfloat sequence. + if (helpers.top().functionBuilder.size() != 2) { + throw InvalidQuerySyntax("TEMPORAL_TFLOAT_AVG_VALUE requires exactly two arguments (value, timestamp), but got {}", helpers.top().functionBuilder.size()); + } + { + const auto timestampFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto valueFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + + if (!valueFunction.tryGet() || + !timestampFunction.tryGet()) { + throw InvalidQuerySyntax("TEMPORAL_TFLOAT_AVG_VALUE arguments must be field references"); + } + + helpers.top().windowAggs.push_back( + TemporalTFloatAvgValueAggregationLogicalFunction::create(valueFunction.get(), + timestampFunction.get())); + helpers.top().functionBuilder.push_back(valueFunction); + } + break; + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_TFLOAT_AVG_VALUE (case-switch) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_TNUMBER_TWAVG (case-switch) */ + case AntlrSQLLexer::TEMPORAL_TNUMBER_TWAVG: + // Time-weighted average of values across the per-(window, group) tfloat sequence. + if (helpers.top().functionBuilder.size() != 2) { + throw InvalidQuerySyntax("TEMPORAL_TNUMBER_TWAVG requires exactly two arguments (value, timestamp), but got {}", helpers.top().functionBuilder.size()); + } + { + const auto timestampFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto valueFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + + if (!valueFunction.tryGet() || + !timestampFunction.tryGet()) { + throw InvalidQuerySyntax("TEMPORAL_TNUMBER_TWAVG arguments must be field references"); + } + + helpers.top().windowAggs.push_back( + TemporalTNumberTwAvgAggregationLogicalFunction::create(valueFunction.get(), + timestampFunction.get())); + helpers.top().functionBuilder.push_back(valueFunction); + } + break; + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_TNUMBER_TWAVG (case-switch) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_TINT_AVG_VALUE (case-switch) */ + case AntlrSQLLexer::TEMPORAL_TINT_AVG_VALUE: + // Arithmetic mean (as double) of all instant values in the per-(window, group) tint sequence. + if (helpers.top().functionBuilder.size() != 2) { + throw InvalidQuerySyntax("TEMPORAL_TINT_AVG_VALUE requires exactly two arguments (value, timestamp), but got {}", helpers.top().functionBuilder.size()); + } + { + const auto timestampFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto valueFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + + if (!valueFunction.tryGet() || + !timestampFunction.tryGet()) { + throw InvalidQuerySyntax("TEMPORAL_TINT_AVG_VALUE arguments must be field references"); + } + + helpers.top().windowAggs.push_back( + TemporalTIntAvgValueAggregationLogicalFunction::create(valueFunction.get(), + timestampFunction.get())); + helpers.top().functionBuilder.push_back(valueFunction); + } + break; + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_TINT_AVG_VALUE (case-switch) */ + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_START_TIMESTAMP (case-switch) */ + case AntlrSQLLexer::TEMPORAL_START_TIMESTAMP: + // TimestampTz (MEOS μs-since-2000) of the first instant in the per-(window, group) tgeo trajectory. + if (helpers.top().functionBuilder.size() != 3) { + throw InvalidQuerySyntax("TEMPORAL_START_TIMESTAMP requires exactly three arguments (longitude, latitude, timestamp), but got {}", helpers.top().functionBuilder.size()); + } + { + const auto timestampFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto latitudeFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto longitudeFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + + if (!longitudeFunction.tryGet() || + !latitudeFunction.tryGet() || + !timestampFunction.tryGet()) { + throw InvalidQuerySyntax("TEMPORAL_START_TIMESTAMP arguments must be field references"); + } + + helpers.top().windowAggs.push_back( + TemporalStartTimestampAggregationLogicalFunction::create(longitudeFunction.get(), + latitudeFunction.get(), + timestampFunction.get())); + helpers.top().functionBuilder.push_back(longitudeFunction); + } + break; + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_START_TIMESTAMP (case-switch) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_END_TIMESTAMP (case-switch) */ + case AntlrSQLLexer::TEMPORAL_END_TIMESTAMP: + // TimestampTz (MEOS μs-since-2000) of the last instant in the per-(window, group) tgeo trajectory. + if (helpers.top().functionBuilder.size() != 3) { + throw InvalidQuerySyntax("TEMPORAL_END_TIMESTAMP requires exactly three arguments (longitude, latitude, timestamp), but got {}", helpers.top().functionBuilder.size()); + } + { + const auto timestampFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto latitudeFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto longitudeFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + + if (!longitudeFunction.tryGet() || + !latitudeFunction.tryGet() || + !timestampFunction.tryGet()) { + throw InvalidQuerySyntax("TEMPORAL_END_TIMESTAMP arguments must be field references"); + } + + helpers.top().windowAggs.push_back( + TemporalEndTimestampAggregationLogicalFunction::create(longitudeFunction.get(), + latitudeFunction.get(), + timestampFunction.get())); + helpers.top().functionBuilder.push_back(longitudeFunction); + } + break; + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_END_TIMESTAMP (case-switch) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_LOWER_INC (case-switch) */ + case AntlrSQLLexer::TEMPORAL_LOWER_INC: + // True if the per-(window, group) tgeo trajectory's lower period bound is inclusive. + if (helpers.top().functionBuilder.size() != 3) { + throw InvalidQuerySyntax("TEMPORAL_LOWER_INC requires exactly three arguments (longitude, latitude, timestamp), but got {}", helpers.top().functionBuilder.size()); + } + { + const auto timestampFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto latitudeFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto longitudeFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + + if (!longitudeFunction.tryGet() || + !latitudeFunction.tryGet() || + !timestampFunction.tryGet()) { + throw InvalidQuerySyntax("TEMPORAL_LOWER_INC arguments must be field references"); + } + + helpers.top().windowAggs.push_back( + TemporalLowerIncAggregationLogicalFunction::create(longitudeFunction.get(), + latitudeFunction.get(), + timestampFunction.get())); + helpers.top().functionBuilder.push_back(longitudeFunction); + } + break; + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_LOWER_INC (case-switch) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_UPPER_INC (case-switch) */ + case AntlrSQLLexer::TEMPORAL_UPPER_INC: + // True if the per-(window, group) tgeo trajectory's upper period bound is inclusive. + if (helpers.top().functionBuilder.size() != 3) { + throw InvalidQuerySyntax("TEMPORAL_UPPER_INC requires exactly three arguments (longitude, latitude, timestamp), but got {}", helpers.top().functionBuilder.size()); + } + { + const auto timestampFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto latitudeFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto longitudeFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + + if (!longitudeFunction.tryGet() || + !latitudeFunction.tryGet() || + !timestampFunction.tryGet()) { + throw InvalidQuerySyntax("TEMPORAL_UPPER_INC arguments must be field references"); + } + + helpers.top().windowAggs.push_back( + TemporalUpperIncAggregationLogicalFunction::create(longitudeFunction.get(), + latitudeFunction.get(), + timestampFunction.get())); + helpers.top().functionBuilder.push_back(longitudeFunction); + } + break; + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_UPPER_INC (case-switch) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_TPOINT_IS_SIMPLE (case-switch) */ + case AntlrSQLLexer::TEMPORAL_TPOINT_IS_SIMPLE: + // True if the per-(window, group) tgeo trajectory does not self-intersect. + if (helpers.top().functionBuilder.size() != 3) { + throw InvalidQuerySyntax("TEMPORAL_TPOINT_IS_SIMPLE requires exactly three arguments (longitude, latitude, timestamp), but got {}", helpers.top().functionBuilder.size()); + } + { + const auto timestampFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto latitudeFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto longitudeFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + + if (!longitudeFunction.tryGet() || + !latitudeFunction.tryGet() || + !timestampFunction.tryGet()) { + throw InvalidQuerySyntax("TEMPORAL_TPOINT_IS_SIMPLE arguments must be field references"); + } + + helpers.top().windowAggs.push_back( + TemporalTPointIsSimpleAggregationLogicalFunction::create(longitudeFunction.get(), + latitudeFunction.get(), + timestampFunction.get())); + helpers.top().functionBuilder.push_back(longitudeFunction); + } + break; + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_TPOINT_IS_SIMPLE (case-switch) */ + + + + + + + + default: + /// Check if the function is a constructor for a datatype + if (const auto dataType = DataTypeProvider::tryProvideDataType(funcName); dataType.has_value()) + { + if (helpers.top().constantBuilder.empty()) + { + throw InvalidQuerySyntax("Expected constant, got nothing at {}", context->getText()); + } + helpers.top().hasUnnamedAggregation = false; + auto value = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + auto constFunctionItem = ConstantValueLogicalFunction(*dataType, std::move(value)); + helpers.top().functionBuilder.emplace_back(constFunctionItem); + } + else if (funcName == "VAR") + { + if (helpers.top().functionBuilder.empty()) + { + throw InvalidQuerySyntax("Aggregation requires argument at {}", context->getText()); + } + const auto& lastArg = helpers.top().functionBuilder.back().get(); + helpers.top().windowAggs.push_back(std::make_shared(lastArg)); + } + else if (funcName == "TEMPORAL_SEQUENCE") + { + if (helpers.top().functionBuilder.size() < 3) + { + throw InvalidQuerySyntax("TEMPORAL_SEQUENCE requires three arguments at {}", context->getText()); + } + const auto ts = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto lat = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto lon = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + helpers.top().windowAggs.push_back(TemporalSequenceAggregationLogicalFunctionV2::create(lon, lat, ts)); + } + else if (funcName == "TEMPORAL_LENGTH") + { + if (helpers.top().functionBuilder.size() < 3) + { + throw InvalidQuerySyntax("TEMPORAL_LENGTH requires three arguments at {}", context->getText()); + } + const auto ts = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto lat = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto lon = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + helpers.top().windowAggs.push_back(TemporalLengthAggregationLogicalFunction::create(lon, lat, ts)); + } + else if (funcName == "PAIR_MEETING") + { + // Five-arg shape: 4 FieldAccess + 1 numeric constant (dMeet metres). + if (helpers.top().constantBuilder.empty()) + { + throw InvalidQuerySyntax( + "PAIR_MEETING requires a numeric constant fifth argument (dMeet metres) at {}", + context->getText()); + } + auto dMeetString = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + double dMeetMetres; + try { dMeetMetres = std::stod(dMeetString); } + catch (const std::exception&) { + throw InvalidQuerySyntax( + "PAIR_MEETING fifth argument must be a numeric constant (dMeet metres), got `{}` at {}", + dMeetString, context->getText()); + } + if (helpers.top().functionBuilder.size() < 4) + { + throw InvalidQuerySyntax( + "PAIR_MEETING requires four field args + 1 constant at {}", context->getText()); + } + const auto vid = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto ts = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto lat = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto lon = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + helpers.top().windowAggs.push_back(PairMeetingAggregationLogicalFunction::create(lon, lat, ts, vid, dMeetMetres)); + } + else if (funcName == "CROSS_DISTANCE") + { + // Six-arg shape: 4 FieldAccess + 2 numeric constants (vidA, vidB). + if (helpers.top().constantBuilder.size() < 2) + { + throw InvalidQuerySyntax( + "CROSS_DISTANCE requires two numeric constant arguments (vidA, vidB) at {}", + context->getText()); + } + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_NUM_INSTANTS (funcName chain) */ + else if (funcName == "TEMPORAL_NUM_INSTANTS") + { + if (helpers.top().functionBuilder.size() < 3) + { + throw InvalidQuerySyntax("TEMPORAL_NUM_INSTANTS requires three arguments at {}", context->getText()); + } + const auto ts = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto lat = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto lon = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + helpers.top().windowAggs.push_back(TemporalNumInstantsAggregationLogicalFunction::create(lon, lat, ts)); + } + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_NUM_INSTANTS (funcName chain) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_NUM_SEQUENCES (funcName chain) */ + else if (funcName == "TEMPORAL_NUM_SEQUENCES") + { + if (helpers.top().functionBuilder.size() < 3) + { + throw InvalidQuerySyntax("TEMPORAL_NUM_SEQUENCES requires three arguments at {}", context->getText()); + } + const auto ts = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto lat = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto lon = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + helpers.top().windowAggs.push_back(TemporalNumSequencesAggregationLogicalFunction::create(lon, lat, ts)); + } + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_NUM_SEQUENCES (funcName chain) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_NUM_TIMESTAMPS (funcName chain) */ + else if (funcName == "TEMPORAL_NUM_TIMESTAMPS") + { + if (helpers.top().functionBuilder.size() < 3) + { + throw InvalidQuerySyntax("TEMPORAL_NUM_TIMESTAMPS requires three arguments at {}", context->getText()); + } + const auto ts = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto lat = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto lon = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + helpers.top().windowAggs.push_back(TemporalNumTimestampsAggregationLogicalFunction::create(lon, lat, ts)); + } + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_NUM_TIMESTAMPS (funcName chain) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_TFLOAT_START_VALUE (funcName chain) */ + else if (funcName == "TEMPORAL_TFLOAT_START_VALUE") + { + if (helpers.top().functionBuilder.size() < 2) + { + throw InvalidQuerySyntax("TEMPORAL_TFLOAT_START_VALUE requires two arguments at {}", context->getText()); + } + const auto ts = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto value = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + helpers.top().windowAggs.push_back(TemporalTFloatStartValueAggregationLogicalFunction::create(value, ts)); + } + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_TFLOAT_START_VALUE (funcName chain) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_TFLOAT_END_VALUE (funcName chain) */ + else if (funcName == "TEMPORAL_TFLOAT_END_VALUE") + { + if (helpers.top().functionBuilder.size() < 2) + { + throw InvalidQuerySyntax("TEMPORAL_TFLOAT_END_VALUE requires two arguments at {}", context->getText()); + } + const auto ts = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto value = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + helpers.top().windowAggs.push_back(TemporalTFloatEndValueAggregationLogicalFunction::create(value, ts)); + } + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_TFLOAT_END_VALUE (funcName chain) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_TFLOAT_MIN_VALUE (funcName chain) */ + else if (funcName == "TEMPORAL_TFLOAT_MIN_VALUE") + { + if (helpers.top().functionBuilder.size() < 2) + { + throw InvalidQuerySyntax("TEMPORAL_TFLOAT_MIN_VALUE requires two arguments at {}", context->getText()); + } + const auto ts = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto value = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + helpers.top().windowAggs.push_back(TemporalTFloatMinValueAggregationLogicalFunction::create(value, ts)); + } + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_TFLOAT_MIN_VALUE (funcName chain) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_TFLOAT_MAX_VALUE (funcName chain) */ + else if (funcName == "TEMPORAL_TFLOAT_MAX_VALUE") + { + if (helpers.top().functionBuilder.size() < 2) + { + throw InvalidQuerySyntax("TEMPORAL_TFLOAT_MAX_VALUE requires two arguments at {}", context->getText()); + } + const auto ts = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto value = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + helpers.top().windowAggs.push_back(TemporalTFloatMaxValueAggregationLogicalFunction::create(value, ts)); + } + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_TFLOAT_MAX_VALUE (funcName chain) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_TNUMBER_INTEGRAL (funcName chain) */ + else if (funcName == "TEMPORAL_TNUMBER_INTEGRAL") + { + if (helpers.top().functionBuilder.size() < 2) + { + throw InvalidQuerySyntax("TEMPORAL_TNUMBER_INTEGRAL requires two arguments at {}", context->getText()); + } + const auto ts = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto value = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + helpers.top().windowAggs.push_back(TemporalTNumberIntegralAggregationLogicalFunction::create(value, ts)); + } + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_TNUMBER_INTEGRAL (funcName chain) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_TINT_START_VALUE (funcName chain) */ + else if (funcName == "TEMPORAL_TINT_START_VALUE") + { + if (helpers.top().functionBuilder.size() < 2) + { + throw InvalidQuerySyntax("TEMPORAL_TINT_START_VALUE requires two arguments at {}", context->getText()); + } + const auto ts = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto value = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + helpers.top().windowAggs.push_back(TemporalTIntStartValueAggregationLogicalFunction::create(value, ts)); + } + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_TINT_START_VALUE (funcName chain) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_TINT_END_VALUE (funcName chain) */ + else if (funcName == "TEMPORAL_TINT_END_VALUE") + { + if (helpers.top().functionBuilder.size() < 2) + { + throw InvalidQuerySyntax("TEMPORAL_TINT_END_VALUE requires two arguments at {}", context->getText()); + } + const auto ts = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto value = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + helpers.top().windowAggs.push_back(TemporalTIntEndValueAggregationLogicalFunction::create(value, ts)); + } + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_TINT_END_VALUE (funcName chain) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_TINT_MIN_VALUE (funcName chain) */ + else if (funcName == "TEMPORAL_TINT_MIN_VALUE") + { + if (helpers.top().functionBuilder.size() < 2) + { + throw InvalidQuerySyntax("TEMPORAL_TINT_MIN_VALUE requires two arguments at {}", context->getText()); + } + const auto ts = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto value = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + helpers.top().windowAggs.push_back(TemporalTIntMinValueAggregationLogicalFunction::create(value, ts)); + } + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_TINT_MIN_VALUE (funcName chain) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_TINT_MAX_VALUE (funcName chain) */ + else if (funcName == "TEMPORAL_TINT_MAX_VALUE") + { + if (helpers.top().functionBuilder.size() < 2) + { + throw InvalidQuerySyntax("TEMPORAL_TINT_MAX_VALUE requires two arguments at {}", context->getText()); + } + const auto ts = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto value = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + helpers.top().windowAggs.push_back(TemporalTIntMaxValueAggregationLogicalFunction::create(value, ts)); + } + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_TINT_MAX_VALUE (funcName chain) */ + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_TFLOAT_AVG_VALUE (funcName chain) */ + else if (funcName == "TEMPORAL_TFLOAT_AVG_VALUE") + { + if (helpers.top().functionBuilder.size() < 2) + { + throw InvalidQuerySyntax("TEMPORAL_TFLOAT_AVG_VALUE requires two arguments at {}", context->getText()); + } + const auto ts = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto value = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + helpers.top().windowAggs.push_back(TemporalTFloatAvgValueAggregationLogicalFunction::create(value, ts)); + } + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_TFLOAT_AVG_VALUE (funcName chain) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_TNUMBER_TWAVG (funcName chain) */ + else if (funcName == "TEMPORAL_TNUMBER_TWAVG") + { + if (helpers.top().functionBuilder.size() < 2) + { + throw InvalidQuerySyntax("TEMPORAL_TNUMBER_TWAVG requires two arguments at {}", context->getText()); + } + const auto ts = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto value = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + helpers.top().windowAggs.push_back(TemporalTNumberTwAvgAggregationLogicalFunction::create(value, ts)); + } + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_TNUMBER_TWAVG (funcName chain) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_TINT_AVG_VALUE (funcName chain) */ + else if (funcName == "TEMPORAL_TINT_AVG_VALUE") + { + if (helpers.top().functionBuilder.size() < 2) + { + throw InvalidQuerySyntax("TEMPORAL_TINT_AVG_VALUE requires two arguments at {}", context->getText()); + } + const auto ts = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto value = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + helpers.top().windowAggs.push_back(TemporalTIntAvgValueAggregationLogicalFunction::create(value, ts)); + } + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_TINT_AVG_VALUE (funcName chain) */ + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_START_TIMESTAMP (funcName chain) */ + else if (funcName == "TEMPORAL_START_TIMESTAMP") + { + if (helpers.top().functionBuilder.size() < 3) + { + throw InvalidQuerySyntax("TEMPORAL_START_TIMESTAMP requires three arguments at {}", context->getText()); + } + const auto ts = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto lat = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto lon = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + helpers.top().windowAggs.push_back(TemporalStartTimestampAggregationLogicalFunction::create(lon, lat, ts)); + } + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_START_TIMESTAMP (funcName chain) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_END_TIMESTAMP (funcName chain) */ + else if (funcName == "TEMPORAL_END_TIMESTAMP") + { + if (helpers.top().functionBuilder.size() < 3) + { + throw InvalidQuerySyntax("TEMPORAL_END_TIMESTAMP requires three arguments at {}", context->getText()); + } + const auto ts = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto lat = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto lon = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + helpers.top().windowAggs.push_back(TemporalEndTimestampAggregationLogicalFunction::create(lon, lat, ts)); + } + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_END_TIMESTAMP (funcName chain) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_LOWER_INC (funcName chain) */ + else if (funcName == "TEMPORAL_LOWER_INC") + { + if (helpers.top().functionBuilder.size() < 3) + { + throw InvalidQuerySyntax("TEMPORAL_LOWER_INC requires three arguments at {}", context->getText()); + } + const auto ts = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto lat = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto lon = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + helpers.top().windowAggs.push_back(TemporalLowerIncAggregationLogicalFunction::create(lon, lat, ts)); + } + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_LOWER_INC (funcName chain) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_UPPER_INC (funcName chain) */ + else if (funcName == "TEMPORAL_UPPER_INC") + { + if (helpers.top().functionBuilder.size() < 3) + { + throw InvalidQuerySyntax("TEMPORAL_UPPER_INC requires three arguments at {}", context->getText()); + } + const auto ts = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto lat = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto lon = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + helpers.top().windowAggs.push_back(TemporalUpperIncAggregationLogicalFunction::create(lon, lat, ts)); + } + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_UPPER_INC (funcName chain) */ + + /* BEGIN CODEGEN AGGREGATION GLUE: TEMPORAL_TPOINT_IS_SIMPLE (funcName chain) */ + else if (funcName == "TEMPORAL_TPOINT_IS_SIMPLE") + { + if (helpers.top().functionBuilder.size() < 3) + { + throw InvalidQuerySyntax("TEMPORAL_TPOINT_IS_SIMPLE requires three arguments at {}", context->getText()); + } + const auto ts = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto lat = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto lon = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + helpers.top().windowAggs.push_back(TemporalTPointIsSimpleAggregationLogicalFunction::create(lon, lat, ts)); + } + /* END CODEGEN AGGREGATION GLUE: TEMPORAL_TPOINT_IS_SIMPLE (funcName chain) */ + + + auto vidBString = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + auto vidAString = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + uint64_t vidA, vidB; + try { + vidA = std::stoull(vidAString); + vidB = std::stoull(vidBString); + } catch (const std::exception&) { + throw InvalidQuerySyntax( + "CROSS_DISTANCE constant arguments must be unsigned integers (vidA, vidB), got `{}` and `{}` at {}", + vidAString, vidBString, context->getText()); + } + if (helpers.top().functionBuilder.size() < 4) + { + throw InvalidQuerySyntax( + "CROSS_DISTANCE requires four field args + 2 constants at {}", context->getText()); + } + const auto vid = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto ts = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto lat = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto lon = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + helpers.top().windowAggs.push_back(CrossDistanceAggregationLogicalFunction::create(lon, lat, ts, vid, vidA, vidB)); } else if (auto logicalFunction = LogicalFunctionProvider::tryProvide(funcName, helpers.top().functionBuilder)) { diff --git a/nes-systests/function/meos/adwithin_tgeo_geo.test b/nes-systests/function/meos/adwithin_tgeo_geo.test new file mode 100644 index 0000000000..046dfe003f --- /dev/null +++ b/nes-systests/function/meos/adwithin_tgeo_geo.test @@ -0,0 +1,13 @@ +# name: MEOS_TemporalADWithinGeometry +# groups: [Function, MEOS, SpatioTemporal, TemporalGeometry, ADWithin] +CREATE LOGICAL SOURCE adw(id UINT32, lon FLOAT64, lat FLOAT64, timestamp UINT64); +CREATE PHYSICAL SOURCE FOR adw TYPE File SET('|' AS PARSER.FIELD_DELIMITER); +ATTACH INLINE +1|4.3658|50.6456|1609459200 +2|4.1000|50.8000|1609459200 + +CREATE SINK adw_out(adw.id UINT32, within INT32) TYPE File; +SELECT id, TEMPORAL_ADWITHIN_GEOMETRY(lon, lat, timestamp, 'SRID=4326;POINT(4.3658 50.6456)', FLOAT64(0.2)) AS within FROM adw INTO adw_out; +---- +1,1 +2,0 diff --git a/nes-systests/function/meos/at_geometry.test b/nes-systests/function/meos/at_geometry.test new file mode 100644 index 0000000000..fb72aab629 --- /dev/null +++ b/nes-systests/function/meos/at_geometry.test @@ -0,0 +1,18 @@ +# name: function/spatiotemporal/MEOS_AtGeometry_Restriction.test +# description: Per-event spatial restriction of a single-instant tgeompoint by a static polygon. Returns 1 if the point survives the at-restriction (lies inside the geom), 0 if clipped. Exercises the new one-tgeo-restriction codegen template (W6). +# groups: [Function, MEOS, SpatioTemporal, TemporalGeometry, Restriction, AtGeometry, Codegen] + +CREATE LOGICAL SOURCE at_geom_tests(id UINT32, lon FLOAT64, lat FLOAT64, timestamp UINT64, polygon_wkt VARSIZED); +CREATE PHYSICAL SOURCE FOR at_geom_tests TYPE File SET('|' AS PARSER.FIELD_DELIMITER); +ATTACH INLINE +1|4.5|50.5|1609459200|'SRID=4326;POLYGON((4.0 50.0, 5.0 50.0, 5.0 51.0, 4.0 51.0, 4.0 50.0))' +2|6.0|52.0|1609459260|'SRID=4326;POLYGON((4.0 50.0, 5.0 50.0, 5.0 51.0, 4.0 51.0, 4.0 50.0))' + +CREATE SINK at_geom_results(at_geom_tests.id UINT32, inside INT32) TYPE File; +SELECT id, + TEMPORAL_AT_GEOMETRY(lon, lat, timestamp, polygon_wkt) AS inside +FROM at_geom_tests +INTO at_geom_results; +---- +1,1 +2,0 diff --git a/nes-systests/function/meos/econtains_tcbuffer_cbuffer.test b/nes-systests/function/meos/econtains_tcbuffer_cbuffer.test new file mode 100644 index 0000000000..9db2987bec --- /dev/null +++ b/nes-systests/function/meos/econtains_tcbuffer_cbuffer.test @@ -0,0 +1,18 @@ +# name: function/spatiotemporal/MEOS_TemporalEContainsTCbufferCbuffer.test +# description: Per-event ever-contains between a single-instant tcbuffer (lon, lat, radius, ts) and a static Cbuffer literal. Exercises the W11 codegen shape — 5-arg lift with second-arg parsed via cbuffer_in() instead of the geometry parser used in W10. +# groups: [Function, MEOS, SpatioTemporal, TCbuffer, EContains, Codegen] + +CREATE LOGICAL SOURCE tcbuf_cbuf_tests(id UINT32, lon FLOAT64, lat FLOAT64, radius FLOAT64, timestamp UINT64, cbuffer_literal VARSIZED); +CREATE PHYSICAL SOURCE FOR tcbuf_cbuf_tests TYPE File SET('|' AS PARSER.FIELD_DELIMITER); +ATTACH INLINE +1|4.3658|50.6456|10.0|1609459200|'Cbuffer(Point(4.3658 50.6456),1.0)' +2|4.3658|50.6456|0.0001|1609459200|'Cbuffer(Point(4.4000 50.7000),0.0001)' + +CREATE SINK tcbuf_cbuf_results(tcbuf_cbuf_tests.id UINT32, contains INT32) TYPE File; +SELECT id, + TEMPORAL_ECONTAINS_TCBUFFER_CBUFFER(lon, lat, radius, timestamp, cbuffer_literal) AS contains +FROM tcbuf_cbuf_tests +INTO tcbuf_cbuf_results; +---- +1,1 +2,0 diff --git a/nes-systests/function/meos/econtains_tcbuffer_geo.test b/nes-systests/function/meos/econtains_tcbuffer_geo.test new file mode 100644 index 0000000000..eb1abe35ba --- /dev/null +++ b/nes-systests/function/meos/econtains_tcbuffer_geo.test @@ -0,0 +1,14 @@ +# name: MEOS_EContains_TCbuffer_Geo +# description: TEMPORAL_ECONTAINS_TCBUFFER: single-instant tcbuffer (lon,lat,radius) contains a static geometry constant. +# groups: [Function, MEOS, SpatioTemporal, TCbuffer, EContains] +CREATE LOGICAL SOURCE ecb(id UINT32, lon FLOAT64, lat FLOAT64, radius FLOAT64, timestamp UINT64); +CREATE PHYSICAL SOURCE FOR ecb TYPE File SET('|' AS PARSER.FIELD_DELIMITER); +ATTACH INLINE +1|4.3658|50.6456|1.0|1609459200 +2|10.0|10.0|0.5|1609459200 + +CREATE SINK ecb_out(ecb.id UINT32, contains INT32) TYPE File; +SELECT id, TEMPORAL_ECONTAINS_TCBUFFER(lon, lat, radius, timestamp, 'POINT(4.3658 50.6456)') AS contains FROM ecb INTO ecb_out; +---- +1,1 +2,0 diff --git a/nes-systests/function/meos/econtains_tpose_geo.test b/nes-systests/function/meos/econtains_tpose_geo.test new file mode 100644 index 0000000000..8724b5df88 --- /dev/null +++ b/nes-systests/function/meos/econtains_tpose_geo.test @@ -0,0 +1,14 @@ +# name: MEOS_EContains_TPose_Geo +# description: TEMPORAL_ECONTAINS_TPOSE_GEOMETRY: single-instant tpose (x,y,theta) lifted to a tgeompoint contains a static geometry constant (W14). +# groups: [Function, MEOS, SpatioTemporal, TPose, EContains] +CREATE LOGICAL SOURCE ecp(id UINT32, x FLOAT64, y FLOAT64, theta FLOAT64, timestamp UINT64); +CREATE PHYSICAL SOURCE FOR ecp TYPE File SET('|' AS PARSER.FIELD_DELIMITER); +ATTACH INLINE +1|4.3658|50.6456|0.5|1609459200 +2|4.4000|50.7000|0.5|1609459200 + +CREATE SINK ecp_out(ecp.id UINT32, contains INT32) TYPE File; +SELECT id, TEMPORAL_ECONTAINS_TPOSE_GEOMETRY(x, y, theta, timestamp, 'POINT(4.3658 50.6456)') AS contains FROM ecp INTO ecp_out; +---- +1,1 +2,0 diff --git a/nes-systests/function/meos/edisjoint_tgeo_geo.test b/nes-systests/function/meos/edisjoint_tgeo_geo.test new file mode 100644 index 0000000000..76937a3623 --- /dev/null +++ b/nes-systests/function/meos/edisjoint_tgeo_geo.test @@ -0,0 +1,18 @@ +# name: function/spatiotemporal/MEOS_EDisjoint_Temporal_Geometry_Static_Geometry.test +# description: Per-event ever-disjoint between a single-instant tgeompoint built from event fields and a static geometry. Exercises the 4-arg one-temporal-point codegen shape (W1). +# groups: [Function, MEOS, SpatioTemporal, TemporalGeometry, StaticGeometry, EDisjoint, Codegen] + +CREATE LOGICAL SOURCE edisjoint_tests(id UINT32, lon FLOAT64, lat FLOAT64, timestamp UINT64, geom_wkt VARSIZED); +CREATE PHYSICAL SOURCE FOR edisjoint_tests TYPE File SET('|' AS PARSER.FIELD_DELIMITER); +ATTACH INLINE +1|4.3658|50.6456|1609459200|'SRID=4326;POINT(4.3658 50.6456)' +2|4.1000|50.8000|1609459200|'SRID=4326;POINT(4.3658 50.6456)' + +CREATE SINK edisjoint_results(edisjoint_tests.id UINT32, disjoint INT32) TYPE File; +SELECT id, + TEMPORAL_EDISJOINT_GEOMETRY(lon, lat, timestamp, geom_wkt) AS disjoint +FROM edisjoint_tests +INTO edisjoint_results; +---- +1,0 +2,1 diff --git a/nes-systests/function/meos/edisjoint_tgeo_tgeo.test b/nes-systests/function/meos/edisjoint_tgeo_tgeo.test new file mode 100644 index 0000000000..980bd9ed9f --- /dev/null +++ b/nes-systests/function/meos/edisjoint_tgeo_tgeo.test @@ -0,0 +1,13 @@ +# name: MEOS_TemporalEDisjointTGeometry +# groups: [Function, MEOS, SpatioTemporal, TemporalGeometry, EDisjoint] +CREATE LOGICAL SOURCE edt(id UINT32, lonA FLOAT64, latA FLOAT64, tsA UINT64, lonB FLOAT64, latB FLOAT64, tsB UINT64); +CREATE PHYSICAL SOURCE FOR edt TYPE File SET('|' AS PARSER.FIELD_DELIMITER); +ATTACH INLINE +1|4.3658|50.6456|1609459200|4.4000|50.7000|1609459200 +2|4.3658|50.6456|1609459200|4.3658|50.6456|1609459200 + +CREATE SINK edt_out(edt.id UINT32, disjoint INT32) TYPE File; +SELECT id, TEMPORAL_EDISJOINT_TGEOMETRY(lonA, latA, tsA, lonB, latB, tsB) AS disjoint FROM edt INTO edt_out; +---- +1,1 +2,0 diff --git a/nes-systests/function/meos/edwithin_tcbuffer_tcbuffer.test b/nes-systests/function/meos/edwithin_tcbuffer_tcbuffer.test new file mode 100644 index 0000000000..a9764c82cf --- /dev/null +++ b/nes-systests/function/meos/edwithin_tcbuffer_tcbuffer.test @@ -0,0 +1,18 @@ +# name: function/spatiotemporal/MEOS_TemporalEDWithinTCbufferTCbuffer.test +# description: Per-event ever-distance-within between two single-instant tcbuffers under a fixed threshold. Exercises the W13 codegen shape — new 9-arg lift template with two tcbuffer_in() per-event constructions plus a trailing double distance. +# groups: [Function, MEOS, SpatioTemporal, TCbuffer, EDWithin, Codegen] + +CREATE LOGICAL SOURCE tcbuf_dw_tests(id UINT32, lonA FLOAT64, latA FLOAT64, radiusA FLOAT64, tsA UINT64, lonB FLOAT64, latB FLOAT64, radiusB FLOAT64, tsB UINT64); +CREATE PHYSICAL SOURCE FOR tcbuf_dw_tests TYPE File SET('|' AS PARSER.FIELD_DELIMITER); +ATTACH INLINE +1|0.0|0.0|1.0|1609459200|0.001|0.001|1.0|1609459200 +2|0.0|0.0|0.0001|1609459200|10.0|10.0|0.0001|1609459200 + +CREATE SINK tcbuf_dw_results(tcbuf_dw_tests.id UINT32, within INT32) TYPE File; +SELECT id, + TEMPORAL_EDWITHIN_TCBUFFER_TCBUFFER(lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB, FLOAT64(2.0)) AS within +FROM tcbuf_dw_tests +INTO tcbuf_dw_results; +---- +1,1 +2,0 diff --git a/nes-systests/function/meos/edwithin_tgeo_tgeo.test b/nes-systests/function/meos/edwithin_tgeo_tgeo.test new file mode 100644 index 0000000000..3abe936111 --- /dev/null +++ b/nes-systests/function/meos/edwithin_tgeo_tgeo.test @@ -0,0 +1,13 @@ +# name: MEOS_TemporalEDWithinTGeometry +# groups: [Function, MEOS, SpatioTemporal, TemporalGeometry, EDWithin] +CREATE LOGICAL SOURCE ewt(id UINT32, lonA FLOAT64, latA FLOAT64, tsA UINT64, lonB FLOAT64, latB FLOAT64, tsB UINT64); +CREATE PHYSICAL SOURCE FOR ewt TYPE File SET('|' AS PARSER.FIELD_DELIMITER); +ATTACH INLINE +1|4.3658|50.6456|1609459200|4.3658|50.6456|1609459200 +2|4.3658|50.6456|1609459200|4.4000|50.7000|1609459200 + +CREATE SINK ewt_out(ewt.id UINT32, within INT32) TYPE File; +SELECT id, TEMPORAL_EDWITHIN_TGEOMETRY(lonA, latA, tsA, lonB, latB, tsB, FLOAT64(0.001)) AS within FROM ewt INTO ewt_out; +---- +1,1 +2,0 diff --git a/nes-systests/function/meos/eintersects_tcbuffer_tcbuffer.test b/nes-systests/function/meos/eintersects_tcbuffer_tcbuffer.test new file mode 100644 index 0000000000..017cdae637 --- /dev/null +++ b/nes-systests/function/meos/eintersects_tcbuffer_tcbuffer.test @@ -0,0 +1,18 @@ +# name: function/spatiotemporal/MEOS_TemporalEIntersectsTCbufferTCbuffer.test +# description: Per-event ever-intersects between two single-instant tcbuffers (lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB). Exercises the W12 codegen shape — new 8-arg lift template with two tcbuffer_in() per-event constructions. +# groups: [Function, MEOS, SpatioTemporal, TCbuffer, EIntersects, Codegen] + +CREATE LOGICAL SOURCE tcbuf_tcbuf_tests(id UINT32, lonA FLOAT64, latA FLOAT64, radiusA FLOAT64, tsA UINT64, lonB FLOAT64, latB FLOAT64, radiusB FLOAT64, tsB UINT64); +CREATE PHYSICAL SOURCE FOR tcbuf_tcbuf_tests TYPE File SET('|' AS PARSER.FIELD_DELIMITER); +ATTACH INLINE +1|4.3658|50.6456|10.0|1609459200|4.3658|50.6456|5.0|1609459200 +2|4.3658|50.6456|0.0001|1609459200|4.5000|50.8000|0.0001|1609459200 + +CREATE SINK tcbuf_tcbuf_results(tcbuf_tcbuf_tests.id UINT32, intersects INT32) TYPE File; +SELECT id, + TEMPORAL_EINTERSECTS_TCBUFFER_TCBUFFER(lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB) AS intersects +FROM tcbuf_tcbuf_tests +INTO tcbuf_tcbuf_results; +---- +1,1 +2,0 diff --git a/nes-systests/function/meos/eintersects_tnpoint_tnpoint.test b/nes-systests/function/meos/eintersects_tnpoint_tnpoint.test new file mode 100644 index 0000000000..f0d8d0454d --- /dev/null +++ b/nes-systests/function/meos/eintersects_tnpoint_tnpoint.test @@ -0,0 +1,18 @@ +# name: function/spatiotemporal/MEOS_TemporalEIntersectsTNpointTNpoint.test +# description: Per-event ever-intersects between two single-instant tgeompoints, each resolved from a temporal network point (rid, fraction, ts) via tnpoint_to_tgeompoint at runtime. Exercises the W18 two-tnpoint composition codegen shape — two tnpoint_in -> two tnpoint_to_tgeompoint -> existing eintersects_tgeo_tgeo (shipped in W3). Both operands land in the network SRID, so no mixed-SRID concern. NOTE: running this test requires the MEOS ways network present at /usr/local/share/ways1000.csv (see meos/examples/data/ways1000.csv in MobilityDB); without it MEOS errors "Cannot open the ways CSV file". Two npoints on the same route at the same fraction and instant resolve to the same point (expect 1); on different routes they resolve to different points (expect 0). +# groups: [Function, MEOS, SpatioTemporal, TNpoint, EIntersects, Composition, Codegen, Network] + +CREATE LOGICAL SOURCE tnpoint_eintersects_tests(id UINT32, ridA UINT64, fractionA FLOAT64, tsA UINT64, ridB UINT64, fractionB FLOAT64, tsB UINT64); +CREATE PHYSICAL SOURCE FOR tnpoint_eintersects_tests TYPE File SET('|' AS PARSER.FIELD_DELIMITER); +ATTACH INLINE +1|55|0.5|1609459200|55|0.5|1609459200 +2|55|0.5|1609459200|99|0.5|1609459200 + +CREATE SINK tnpoint_eintersects_results(tnpoint_eintersects_tests.id UINT32, intersects INT32) TYPE File; +SELECT id, + TEMPORAL_EINTERSECTS_TNPOINT_TNPOINT(ridA, fractionA, tsA, ridB, fractionB, tsB) AS intersects +FROM tnpoint_eintersects_tests +INTO tnpoint_eintersects_results; +---- +1,1 +2,0 diff --git a/nes-systests/function/meos/eintersects_tpose_tpose.test b/nes-systests/function/meos/eintersects_tpose_tpose.test new file mode 100644 index 0000000000..41e03bb6e5 --- /dev/null +++ b/nes-systests/function/meos/eintersects_tpose_tpose.test @@ -0,0 +1,18 @@ +# name: function/spatiotemporal/MEOS_TemporalEIntersectsTPoseTPose.test +# description: Per-event ever-intersects between two single-instant tgeompoints, each lifted from a tpose (x, y, theta, ts) via tpose_to_tpoint at runtime. Exercises the W15 two-tpose composition codegen shape — two tpose_in -> two tpose_to_tpoint -> existing eintersects_tgeo_tgeo (shipped in W3). No new MEOS symbols are needed for tpose; mirrors MobilityDB PR #987's SQL-level composition recipe at the binding layer. +# groups: [Function, MEOS, SpatioTemporal, TPose, EIntersects, Composition, Codegen] + +CREATE LOGICAL SOURCE tpose_eintersects_tests(id UINT32, xA FLOAT64, yA FLOAT64, thetaA FLOAT64, tsA UINT64, xB FLOAT64, yB FLOAT64, thetaB FLOAT64, tsB UINT64); +CREATE PHYSICAL SOURCE FOR tpose_eintersects_tests TYPE File SET('|' AS PARSER.FIELD_DELIMITER); +ATTACH INLINE +1|4.3658|50.6456|0.5|1609459200|4.3658|50.6456|1.2|1609459200 +2|4.3658|50.6456|0.5|1609459200|4.4000|50.7000|1.2|1609459200 + +CREATE SINK tpose_eintersects_results(tpose_eintersects_tests.id UINT32, intersects INT32) TYPE File; +SELECT id, + TEMPORAL_EINTERSECTS_TPOSE_TPOSE(xA, yA, thetaA, tsA, xB, yB, thetaB, tsB) AS intersects +FROM tpose_eintersects_tests +INTO tpose_eintersects_results; +---- +1,1 +2,0 diff --git a/nes-systests/function/meos/nad_tfloat_float.test b/nes-systests/function/meos/nad_tfloat_float.test new file mode 100644 index 0000000000..3ae2d9855e --- /dev/null +++ b/nes-systests/function/meos/nad_tfloat_float.test @@ -0,0 +1,20 @@ +# name: function/spatiotemporal/MEOS_NAD_TFloat_Float.test +# description: Per-event nearest-approach distance between a single-instant tfloat and a scalar double. Exercises the 3-arg one-tnumber-point-with-scalar codegen shape (W5a). +# groups: [Function, MEOS, TNumber, TFloat, NAD, Codegen] + +CREATE LOGICAL SOURCE nad_tfloat_tests(id UINT32, value FLOAT64, timestamp UINT64); +CREATE PHYSICAL SOURCE FOR nad_tfloat_tests TYPE File SET('|' AS PARSER.FIELD_DELIMITER); +ATTACH INLINE +1|42.5|1609459200 +2|17.0|1609459260 +3|3.14|1609459320 + +CREATE SINK nad_tfloat_results(nad_tfloat_tests.id UINT32, distance FLOAT64) TYPE File; +SELECT id, + TEMPORAL_NAD_FLOAT_SCALAR(value, timestamp, FLOAT64(40.0)) AS distance +FROM nad_tfloat_tests +INTO nad_tfloat_results; +---- +1,2.5 +2,23.0 +3,36.86 diff --git a/nes-systests/function/meos/nad_tfloat_tfloat.test b/nes-systests/function/meos/nad_tfloat_tfloat.test new file mode 100644 index 0000000000..6b67ceb03c --- /dev/null +++ b/nes-systests/function/meos/nad_tfloat_tfloat.test @@ -0,0 +1,13 @@ +# name: MEOS_NAD_TFloat_TFloat +# groups: [Function, MEOS, TNumber, TFloat, NAD] +CREATE LOGICAL SOURCE ntf(id UINT32, vA FLOAT64, tsA UINT64, vB FLOAT64, tsB UINT64); +CREATE PHYSICAL SOURCE FOR ntf TYPE File SET('|' AS PARSER.FIELD_DELIMITER); +ATTACH INLINE +1|42.5|1609459200|40.0|1609459200 +2|10.0|1609459200|10.0|1609459200 + +CREATE SINK ntf_out(ntf.id UINT32, distance FLOAT64) TYPE File; +SELECT id, TEMPORAL_NAD_TFLOAT(vA, tsA, vB, tsB) AS distance FROM ntf INTO ntf_out; +---- +1,2.5 +2,0 diff --git a/nes-systests/function/meos/temporal_num_instants.test b/nes-systests/function/meos/temporal_num_instants.test new file mode 100644 index 0000000000..250feb9ffb --- /dev/null +++ b/nes-systests/function/meos/temporal_num_instants.test @@ -0,0 +1,17 @@ +# name: MEOS_TemporalNumInstants_Aggregation +# description: Windowed TEMPORAL_NUM_INSTANTS over per-(window,group) tgeo trajectory (W7 aggregation). +# groups: [Function, MEOS, SpatioTemporal, TemporalGeometry, Aggregation] +CREATE LOGICAL SOURCE nin(vehicle_id UINT64, lon FLOAT64, lat FLOAT64, timestamp UINT64); +CREATE PHYSICAL SOURCE FOR nin TYPE File SET('|' AS PARSER.FIELD_DELIMITER); +ATTACH INLINE +1|4.3658|50.6456|1609459200 +1|4.3700|50.6500|1609459201 +1|4.3750|50.6550|1609459202 +2|5.0000|51.0000|1609459200 +2|5.0100|51.0100|1609459201 + +CREATE SINK nin_out(nin.vehicle_id UINT64, nin.n_instants INT32) TYPE File; +SELECT vehicle_id, TEMPORAL_NUM_INSTANTS(lon, lat, timestamp) AS n_instants FROM nin GROUP BY vehicle_id WINDOW TUMBLING(timestamp, size 1 hour) INTO nin_out; +---- +1,3 +2,2 diff --git a/nes-systests/function/meos/temporal_tfloat_max_value.test b/nes-systests/function/meos/temporal_tfloat_max_value.test new file mode 100644 index 0000000000..761661ae0d --- /dev/null +++ b/nes-systests/function/meos/temporal_tfloat_max_value.test @@ -0,0 +1,17 @@ +# name: MEOS_TemporalTFloatMaxValue_Aggregation +# description: Windowed TEMPORAL_TFLOAT_MAX_VALUE over per-(window,group) tfloat (W7 aggregation). +# groups: [Function, MEOS, TNumber, TFloat, Aggregation] +CREATE LOGICAL SOURCE tfm(sensor_id UINT64, reading FLOAT64, timestamp UINT64); +CREATE PHYSICAL SOURCE FOR tfm TYPE File SET('|' AS PARSER.FIELD_DELIMITER); +ATTACH INLINE +1|10.5|1609459200 +1|22.7|1609459201 +1|18.3|1609459202 +2|5.0|1609459200 +2|99.9|1609459201 + +CREATE SINK tfm_out(tfm.sensor_id UINT64, tfm.peak FLOAT64) TYPE File; +SELECT sensor_id, TEMPORAL_TFLOAT_MAX_VALUE(reading, timestamp) AS peak FROM tfm GROUP BY sensor_id WINDOW TUMBLING(timestamp, size 1 hour) INTO tfm_out; +---- +1,22.7 +2,99.9 diff --git a/nes-systests/function/meos/temporal_tnumber_twavg.test b/nes-systests/function/meos/temporal_tnumber_twavg.test new file mode 100644 index 0000000000..a771d577a3 --- /dev/null +++ b/nes-systests/function/meos/temporal_tnumber_twavg.test @@ -0,0 +1,17 @@ +# name: MEOS_TemporalTNumberTwAvg_Aggregation +# description: Windowed TEMPORAL_TNUMBER_TWAVG (time-weighted average) over per-(window,group) tnumber (W8 aggregation). +# groups: [Function, MEOS, TNumber, Aggregation] +CREATE LOGICAL SOURCE twa(sensor_id UINT64, reading FLOAT64, timestamp UINT64); +CREATE PHYSICAL SOURCE FOR twa TYPE File SET('|' AS PARSER.FIELD_DELIMITER); +ATTACH INLINE +1|10.0|1609459200 +1|20.0|1609459210 +1|30.0|1609459220 +2|5.0|1609459200 +2|15.0|1609459220 + +CREATE SINK twa_out(twa.sensor_id UINT64, twa.tw_average FLOAT64) TYPE File; +SELECT sensor_id, TEMPORAL_TNUMBER_TWAVG(reading, timestamp) AS tw_average FROM twa GROUP BY sensor_id WINDOW TUMBLING(timestamp, size 1 hour) INTO twa_out; +---- +1,20.0 +2,10.0 diff --git a/nes-systests/function/meos/temporal_tpoint_is_simple.test b/nes-systests/function/meos/temporal_tpoint_is_simple.test new file mode 100644 index 0000000000..0c467e69c0 --- /dev/null +++ b/nes-systests/function/meos/temporal_tpoint_is_simple.test @@ -0,0 +1,18 @@ +# name: MEOS_TemporalTPointIsSimple_Aggregation +# description: Windowed TEMPORAL_TPOINT_IS_SIMPLE over per-(window,group) tgeo trajectory (W9 aggregation). +# groups: [Function, MEOS, SpatioTemporal, TemporalGeometry, Aggregation] +CREATE LOGICAL SOURCE tis(vehicle_id UINT64, lon FLOAT64, lat FLOAT64, timestamp UINT64); +CREATE PHYSICAL SOURCE FOR tis TYPE File SET('|' AS PARSER.FIELD_DELIMITER); +ATTACH INLINE +1|0.0|0.0|1609459200 +1|1.0|1.0|1609459210 +1|2.0|2.0|1609459220 +2|0.0|0.0|1609459200 +2|1.0|1.0|1609459210 +2|0.0|0.0|1609459220 + +CREATE SINK tis_out(tis.vehicle_id UINT64, tis.is_simple BOOLEAN) TYPE File; +SELECT vehicle_id, TEMPORAL_TPOINT_IS_SIMPLE(lon, lat, timestamp) AS is_simple FROM tis GROUP BY vehicle_id WINDOW TUMBLING(timestamp, size 1 hour) INTO tis_out; +---- +1,1 +2,0 diff --git a/tools/codegen/.gitignore b/tools/codegen/.gitignore new file mode 100644 index 0000000000..7a60b85e14 --- /dev/null +++ b/tools/codegen/.gitignore @@ -0,0 +1,2 @@ +__pycache__/ +*.pyc diff --git a/tools/codegen/README.md b/tools/codegen/README.md new file mode 100644 index 0000000000..f203c8a380 --- /dev/null +++ b/tools/codegen/README.md @@ -0,0 +1,172 @@ +# MobilityNebula MEOS-operator codegen — design + generator + +This directory contains the design proposal and Python generator for +scaling MobilityNebula's MEOS-operator surface from the current +~17 hand-written operators (PRs #14, #15, #16, #17) to a larger +fraction of MEOS' ~1,949 streamable public functions, mirroring the +infrastructure parity that the Flink and Kafka platforms reached via +their codegen + wirings stacks. + +## Why codegen on Nebula + +The streaming-platform parity audit +([assessment](../../docs/berlinmod-streaming-forms.md)) shows: + +| Platform | Wirable MEOS surface | +|---|---:| +| Flink | 2,097 / 2,097 (100%) via codegen + 5 generic wiring classes | +| Kafka | 2,097 / 2,097 (100%) via codegen + 5 generic wiring classes | +| **Nebula** | **~17 / 2,097 (~1%)** via hand-written 4-layer pipeline per function | + +The Nebula gap is structural: each MEOS function on NebulaStream +requires a full **4-layer pipeline tuple** — logical class, physical +class, parser dispatch, lowering rule — totalling ~350–400 LOC of +mostly-mechanical boilerplate per function. Hand-writing all of MEOS' +streamable surface this way is multi-month engineering; codegen makes +it tractable. + +## What this codegen produces + +For each MEOS scalar function `f` in the input list, the generator +emits the four NebulaStream pipeline-layer files following the +established style of the existing hand-written operators +(`TemporalEDWithinGeometryLogicalFunction` etc.): + +``` +nes-logical-operators/include/Functions/Meos/LogicalFunction.hpp +nes-logical-operators/src/Functions/Meos/LogicalFunction.cpp +nes-physical-operators/include/Functions/Meos/PhysicalFunction.hpp +nes-physical-operators/src/Functions/Meos/PhysicalFunction.cpp +``` + +Plus updates to: +- `nes-logical-operators/src/Functions/Meos/CMakeLists.txt` +- `nes-physical-operators/src/Functions/Meos/CMakeLists.txt` +- Parser dispatch: a single block per generated function inserted into + `nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp` (manual edit + recommended; the generator emits the dispatch snippet for + copy-paste) +- Parser grammar: a single token per function added to + `nes-sql-parser/AntlrSQL.g4` (same) + +## Scope of this PR + +**Generator infrastructure only.** No generated C++ committed. Reasons: + +1. **Compile-environment constraint.** The generator's author cannot + build NebulaStream (full C++23 + vcpkg toolchain). Committing + unverified generated code would ship potentially broken operators. +2. **Per-function review value.** Mariana (maintainer) can run the + generator against a small input list (e.g. one MEOS family at a + time), review the output, iterate on the templates if needed, and + ship operators in follow-up PRs at a controlled pace. +3. **Template iteration cost.** First-pass templates may need + adjustment after the first build — better to land the generator + and iterate on templates than to ship a large batch of generated + operators that all have the same wrong shape. + +## How to use the generator + +```bash +# Edit the input list to choose which MEOS functions to generate +$EDITOR tools/codegen/codegen_input.example.json + +# Run the generator +python3 tools/codegen/codegen_nebula.py \ + --input tools/codegen/codegen_input.example.json \ + --output-root . + +# Output: +# nes-logical-operators/include/Functions/Meos/LogicalFunction.hpp +# nes-logical-operators/src/Functions/Meos/LogicalFunction.cpp +# nes-physical-operators/include/Functions/Meos/PhysicalFunction.hpp +# nes-physical-operators/src/Functions/Meos/PhysicalFunction.cpp +# +# Plus a stderr-printed "parser snippet" per function that you paste into +# nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp (the parser dispatch), +# and a "grammar snippet" that you paste into AntlrSQL.g4 +``` + +## Input format + +`codegen_input.example.json` is a list of MEOS-function descriptors. +One descriptor per output operator: + +```json +{ + "operators": [ + { + "nebula_name": "TemporalEDisjointGeometry", + "sql_token": "TEMPORAL_EDISJOINT_GEOMETRY", + "meos_call": "edisjoint_tgeo_geo", + "args": [ + {"name": "lon", "nautilus_type": "double", "cpp_type": "double"}, + {"name": "lat", "nautilus_type": "double", "cpp_type": "double"}, + {"name": "timestamp","nautilus_type": "uint64_t", "cpp_type": "uint64_t"}, + {"name": "geometry", "nautilus_type": "VariableSizedData", "cpp_type": "const char*"} + ], + "return_type": "int", + "nautilus_return": "INT32", + "build_temporal_point": true, + "comment_one_liner": "Per-event ever-disjoint between a tgeompoint built from event fields and a static geometry." + } + ] +} +``` + +Field meanings: +- `nebula_name`: PascalCase NebulaStream class name (without `LogicalFunction` / `PhysicalFunction` suffix; the generator adds those) +- `sql_token`: the uppercase SQL function name (Antlr lexer token) +- `meos_call`: the underlying MEOS C function symbol the physical operator wraps +- `args`: ordered list of per-record argument fields; the generator builds the constructor + `parameters` vector from these +- `return_type` / `nautilus_return`: the MEOS function's C return type and the NebulaStream `DataType::Type` enum value +- `build_temporal_point`: if true, the physical operator builds a single-instant tgeompoint from `(lon, lat, timestamp)` before calling MEOS (the common pattern for spatial predicates); if false, the operator passes args directly to MEOS +- `comment_one_liner`: drops into the Javadoc-equivalent C++ doc comment + +## Templates + +The generator's templates are embedded in the Python source as +multi-line f-strings. They mirror the exact layout of the existing +hand-written operators (`TemporalEDWithinGeometryLogicalFunction` and +its physical sibling are the reference; the templates were derived by +1:1 inspection of those files). + +To adjust a template (e.g. when NebulaStream's `LogicalFunctionConcept` +adds a new override), edit the corresponding string in +`codegen_nebula.py`; the change applies to all subsequent +regenerations. + +## Scaling path (recommended sequence) + +| Wave | Scope | Expected output | Effort estimate | +|---|---|---|---| +| W1 | First batch: 5 MEOS spatial-relation E/A predicates (e.g. `TemporalEDisjoint`, `TemporalATouches`, `TemporalECovers`, `TemporalACrosses`, `TemporalAOverlaps`) | 20 generated files + 5 parser entries | Single follow-up PR after this generator lands | +| W2 | All ever / always spatial-relation predicates over `tgeo_geo` (~18 functions) | 72 generated files | ~1 follow-up PR | +| W3 | Distance functions over `tgeo_geo` and `tgeo_tgeo` (NAD, NAI, distance, etc.) | ~30 generated files | ~1 follow-up PR | +| W4 | Scalar accessors that decompose to per-event reads | template extension required (read MEOS handle) | design decision point | +| W5 | Aggregations (windowed / cross-stream) | separate generator (aggregation 4-layer pattern is different from scalar 4-layer pattern; the existing TEMPORAL_LENGTH / PAIR_MEETING / CROSS_DISTANCE shape) | full aggregation-codegen design | + +Per-PR scope keeps the review surface small and lets each batch land +with its own build verification. + +## What the generator does NOT do (deliberately) + +- **No build-system integration.** The CMakeLists updates are emitted + as text snippets for the maintainer to apply manually. This avoids + the generator silently corrupting CMakeLists on regeneration. +- **No parser/grammar integration.** Same reason — the dispatch and + grammar snippets are emitted to stderr for manual paste. +- **No aggregation-pattern support yet.** Aggregations require a + different 4-layer shape (lift/combine/lower/cleanup) that depends + on per-aggregation state design. A separate generator with the + aggregation-specific template is W5 in the table above. + +## Compile-verification note + +The generator's first output should be reviewed against an existing +hand-written operator for shape parity, then `mvn compile` (or the +NebulaStream `cmake --build` equivalent) should be run against a +single small batch (1–2 generated functions) before scaling up. The +generator's templates are derived 1:1 from the existing operator +shape but have not been compile-tested in this PR (out of the +generator author's environment). diff --git a/tools/codegen/codegen_aggregations.py b/tools/codegen/codegen_aggregations.py new file mode 100644 index 0000000000..c06ffb41aa --- /dev/null +++ b/tools/codegen/codegen_aggregations.py @@ -0,0 +1,1626 @@ +#!/usr/bin/env python3 +"""MobilityNebula MEOS-aggregation generator. + +Companion to ``codegen_nebula.py`` (per-event ops). This generator targets +the WINDOWED-aggregation surface: MEOS scalar functions of the shape +`` fn(const Temporal*)`` where the Temporal* is a per-(window, +group) sequence assembled across multiple events. + +For each operator in the JSON descriptor list, emits four C++ files +mirroring mariana's hand-written TemporalLengthAggregation 1:1: + + * nes-logical-operators/include/Operators/Windows/Aggregations/Meos/ + XXXAggregationLogicalFunction.hpp + * nes-logical-operators/src/Operators/Windows/Aggregations/Meos/ + XXXAggregationLogicalFunction.cpp + * nes-physical-operators/include/Aggregation/Function/Meos/ + XXXAggregationPhysicalFunction.hpp + * nes-physical-operators/src/Aggregation/Function/Meos/ + XXXAggregationPhysicalFunction.cpp + +And idempotently injects into 5 in-tree shared files: + + * nes-sql-parser/AntlrSQL.g4 + - lexer-token entries + - functionName: alternation list + * nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp + - case AntlrSQLLexer::TOKEN: dispatch in the dedicated-token switch + - else if (funcName == "TOKEN") dispatch in the IDENTIFIER fallback chain + * nes-query-optimizer/src/RewriteRules/LowerToPhysical/ + LowerToPhysicalWindowedAggregation.cpp + - if (name == "Xxx") { ... } block lowering logical → physical + * nes-{logical,physical}-operators/.../{Aggregation*}/CMakeLists.txt + - add_plugin(...) per layer + +All injections are bracketed with +``/* BEGIN CODEGEN AGGREGATION GLUE: TOKEN */ ... /* END ... */`` markers +so re-runs are no-ops and pre-existing hand-written cases (mariana's) are +detected by raw token match and skipped. + +Two lift-shape branches, picked by descriptor ``input_shape``: + * ``tgeo`` — 3 fields per event (lon, lat, ts); lower builds + ``{Point(lon lat)@ts, ...}`` trajectory string parsed via + ``MEOS::Meos::parseTemporalPoint``. + * ``tnumber``— 2 fields per event (value, ts); lower builds + ``{value@ts, ...}`` string parsed via ``tfloat_in`` or + ``tint_in`` per descriptor. + +Usage: + python3 codegen_aggregations.py --input \\ + --output-root /path/to/MobilityNebula \\ + [--no-parser-glue] [--no-cmake-entries] [--no-optimizer-glue] +""" +import argparse +import json +import re +import sys +from pathlib import Path + +# =========================================================================== +# Logical-layer .hpp template (mirrors TemporalLengthAggregationLogicalFunction.hpp). +# =========================================================================== +LOGICAL_HPP_TGEO = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +namespace NES +{{ + +/** + * @brief {comment_one_liner} + * + * Three-input (lon, lat, ts) tgeo aggregation. Lift accumulates the events + * into a paged vector; lower assembles the per-(window, group) trajectory + * and calls MEOS `{meos_scalar_fn}` to fold it to a single scalar. + */ +class {nebula_name}AggregationLogicalFunction : public WindowAggregationLogicalFunction +{{ +public: + static std::shared_ptr + create(const FieldAccessLogicalFunction& lonField, const FieldAccessLogicalFunction& latField, const FieldAccessLogicalFunction& timestampField); + + {nebula_name}AggregationLogicalFunction( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField); + + void inferStamp(const Schema& schema) override; + ~{nebula_name}AggregationLogicalFunction() override = default; + [[nodiscard]] NES::SerializableAggregationFunction serialize() const override; + [[nodiscard]] std::string_view getName() const noexcept override; + [[nodiscard]] bool requiresSequentialAggregation() const {{ return true; }} + + [[nodiscard]] const FieldAccessLogicalFunction& getLonField() const noexcept {{ return lonField; }} + [[nodiscard]] const FieldAccessLogicalFunction& getLatField() const noexcept {{ return latField; }} + [[nodiscard]] const FieldAccessLogicalFunction& getTimestampField() const noexcept {{ return timestampField; }} + +private: + static constexpr std::string_view NAME = "{class_name_token}"; + static constexpr DataType::Type partialAggregateStampType = DataType::Type::UNDEFINED; + static constexpr DataType::Type finalAggregateStampType = DataType::Type::{final_stamp_type}; + + FieldAccessLogicalFunction lonField; + FieldAccessLogicalFunction latField; + FieldAccessLogicalFunction timestampField; +}}; +}} +""" + +LOGICAL_HPP_TNUMBER = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +namespace NES +{{ + +/** + * @brief {comment_one_liner} + * + * Two-input (value, ts) tnumber aggregation. Lift accumulates the events + * into a paged vector; lower assembles the per-(window, group) tnumber + * sequence and calls MEOS `{meos_scalar_fn}` to fold it to a single scalar. + */ +class {nebula_name}AggregationLogicalFunction : public WindowAggregationLogicalFunction +{{ +public: + static std::shared_ptr + create(const FieldAccessLogicalFunction& valueField, const FieldAccessLogicalFunction& timestampField); + + {nebula_name}AggregationLogicalFunction( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField); + + void inferStamp(const Schema& schema) override; + ~{nebula_name}AggregationLogicalFunction() override = default; + [[nodiscard]] NES::SerializableAggregationFunction serialize() const override; + [[nodiscard]] std::string_view getName() const noexcept override; + [[nodiscard]] bool requiresSequentialAggregation() const {{ return true; }} + + [[nodiscard]] const FieldAccessLogicalFunction& getValueField() const noexcept {{ return valueField; }} + [[nodiscard]] const FieldAccessLogicalFunction& getTimestampField() const noexcept {{ return timestampField; }} + +private: + static constexpr std::string_view NAME = "{class_name_token}"; + static constexpr DataType::Type partialAggregateStampType = DataType::Type::UNDEFINED; + static constexpr DataType::Type finalAggregateStampType = DataType::Type::{final_stamp_type}; + + FieldAccessLogicalFunction valueField; + FieldAccessLogicalFunction timestampField; +}}; +}} +""" + +# Logical .cpp templates — share scaffold (ctor, inferStamp, serialize, registry) +# but differ in field count (3 for tgeo, 2 for tnumber). +LOGICAL_CPP_TGEO = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace NES +{{ + +{nebula_name}AggregationLogicalFunction::{nebula_name}AggregationLogicalFunction( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField) + : WindowAggregationLogicalFunction( + lonField.getDataType(), + DataTypeProvider::provideDataType(partialAggregateStampType), + DataTypeProvider::provideDataType(finalAggregateStampType), + lonField, + asField) + , lonField(lonField) + , latField(latField) + , timestampField(timestampField) +{{ +}} + +std::shared_ptr +{nebula_name}AggregationLogicalFunction::create( + const FieldAccessLogicalFunction& lonField, + const FieldAccessLogicalFunction& latField, + const FieldAccessLogicalFunction& timestampField) +{{ + return std::make_shared<{nebula_name}AggregationLogicalFunction>(lonField, latField, timestampField, lonField); +}} + +std::string_view {nebula_name}AggregationLogicalFunction::getName() const noexcept +{{ + return NAME; +}} + +void {nebula_name}AggregationLogicalFunction::inferStamp(const Schema& schema) +{{ + lonField = lonField.withInferredDataType(schema).get(); + latField = latField.withInferredDataType(schema).get(); + timestampField = timestampField.withInferredDataType(schema).get(); + + onField = lonField; + + if (!lonField.getDataType().isNumeric() || !latField.getDataType().isNumeric() || !timestampField.getDataType().isNumeric()) + {{ + throw CannotInferSchema("{nebula_name}AggregationLogicalFunction: lon, lat, and timestamp fields must be numeric."); + }} + + const auto onFieldName = onField.getFieldName(); + const auto asFieldName = asField.getFieldName(); + const auto attributeNameResolver = onFieldName.substr(0, onFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + if (asFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) == std::string::npos) + {{ + asField = asField.withFieldName(attributeNameResolver + asFieldName).get(); + }} + else + {{ + const auto fieldName = asFieldName.substr(asFieldName.find_last_of(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + asField = asField.withFieldName(attributeNameResolver + fieldName).get(); + }} + asField = asField.withDataType(getFinalAggregateStamp()).get(); + inputStamp = onField.getDataType(); +}} + +NES::SerializableAggregationFunction {nebula_name}AggregationLogicalFunction::serialize() const +{{ + auto saf = TemporalAggregationSerde::serializeTemporalSequence(lonField, latField, timestampField, asField); + saf.set_type(std::string(NAME)); + return saf; +}} + +AggregationLogicalFunctionRegistryReturnType AggregationLogicalFunctionGeneratedRegistrar::Register{nebula_name}AggregationLogicalFunction( + AggregationLogicalFunctionRegistryArguments arguments) +{{ + if (arguments.fields.size() == 4) + {{ + auto ptr = std::make_shared<{nebula_name}AggregationLogicalFunction>( + arguments.fields[0], arguments.fields[1], arguments.fields[2], arguments.fields[3]); + return ptr; + }} + throw CannotDeserialize( + "{nebula_name}AggregationLogicalFunction requires lon, lat, timestamp, and alias fields but got {{}}", + arguments.fields.size()); +}} + +}} // namespace NES +""" + +LOGICAL_CPP_TNUMBER = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace NES +{{ + +{nebula_name}AggregationLogicalFunction::{nebula_name}AggregationLogicalFunction( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField, + const FieldAccessLogicalFunction& asField) + : WindowAggregationLogicalFunction( + valueField.getDataType(), + DataTypeProvider::provideDataType(partialAggregateStampType), + DataTypeProvider::provideDataType(finalAggregateStampType), + valueField, + asField) + , valueField(valueField) + , timestampField(timestampField) +{{ +}} + +std::shared_ptr +{nebula_name}AggregationLogicalFunction::create( + const FieldAccessLogicalFunction& valueField, + const FieldAccessLogicalFunction& timestampField) +{{ + return std::make_shared<{nebula_name}AggregationLogicalFunction>(valueField, timestampField, valueField); +}} + +std::string_view {nebula_name}AggregationLogicalFunction::getName() const noexcept +{{ + return NAME; +}} + +void {nebula_name}AggregationLogicalFunction::inferStamp(const Schema& schema) +{{ + valueField = valueField.withInferredDataType(schema).get(); + timestampField = timestampField.withInferredDataType(schema).get(); + + onField = valueField; + + if (!valueField.getDataType().isNumeric() || !timestampField.getDataType().isNumeric()) + {{ + throw CannotInferSchema("{nebula_name}AggregationLogicalFunction: value and timestamp fields must be numeric."); + }} + + const auto onFieldName = onField.getFieldName(); + const auto asFieldName = asField.getFieldName(); + const auto attributeNameResolver = onFieldName.substr(0, onFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + if (asFieldName.find(Schema::ATTRIBUTE_NAME_SEPARATOR) == std::string::npos) + {{ + asField = asField.withFieldName(attributeNameResolver + asFieldName).get(); + }} + else + {{ + const auto fieldName = asFieldName.substr(asFieldName.find_last_of(Schema::ATTRIBUTE_NAME_SEPARATOR) + 1); + asField = asField.withFieldName(attributeNameResolver + fieldName).get(); + }} + asField = asField.withDataType(getFinalAggregateStamp()).get(); + inputStamp = onField.getDataType(); +}} + +NES::SerializableAggregationFunction {nebula_name}AggregationLogicalFunction::serialize() const +{{ + auto saf = TemporalAggregationSerde::serializeTemporalSequence(valueField, timestampField, valueField, asField); + saf.set_type(std::string(NAME)); + return saf; +}} + +AggregationLogicalFunctionRegistryReturnType AggregationLogicalFunctionGeneratedRegistrar::Register{nebula_name}AggregationLogicalFunction( + AggregationLogicalFunctionRegistryArguments arguments) +{{ + if (arguments.fields.size() == 3) + {{ + auto ptr = std::make_shared<{nebula_name}AggregationLogicalFunction>( + arguments.fields[0], arguments.fields[1], arguments.fields[2]); + return ptr; + }} + throw CannotDeserialize( + "{nebula_name}AggregationLogicalFunction requires value, timestamp, and alias fields but got {{}}", + arguments.fields.size()); +}} + +}} // namespace NES +""" + +# Physical-layer .hpp templates. +PHYSICAL_HPP_TGEO = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace NES +{{ + +class {nebula_name}AggregationPhysicalFunction : public AggregationPhysicalFunction +{{ +public: + {nebula_name}AggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction lonFunctionParam, + PhysicalFunction latFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef); + void lift( + const nautilus::val& aggregationState, + PipelineMemoryProvider& pipelineMemoryProvider, + const Nautilus::Record& record) + override; + void combine( + nautilus::val aggregationState1, + nautilus::val aggregationState2, + PipelineMemoryProvider& pipelineMemoryProvider) override; + Nautilus::Record lower(nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) override; + void reset(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + [[nodiscard]] size_t getSizeOfStateInBytes() const override; + ~{nebula_name}AggregationPhysicalFunction() override = default; + void cleanup(nautilus::val aggregationState) override; + +private: + std::shared_ptr bufferRef; + PhysicalFunction lonFunction; + PhysicalFunction latFunction; + PhysicalFunction timestampFunction; +}}; + +}} +""" + +PHYSICAL_HPP_TNUMBER = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace NES +{{ + +class {nebula_name}AggregationPhysicalFunction : public AggregationPhysicalFunction +{{ +public: + {nebula_name}AggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction valueFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef); + void lift( + const nautilus::val& aggregationState, + PipelineMemoryProvider& pipelineMemoryProvider, + const Nautilus::Record& record) + override; + void combine( + nautilus::val aggregationState1, + nautilus::val aggregationState2, + PipelineMemoryProvider& pipelineMemoryProvider) override; + Nautilus::Record lower(nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) override; + void reset(nautilus::val aggregationState, PipelineMemoryProvider& pipelineMemoryProvider) override; + [[nodiscard]] size_t getSizeOfStateInBytes() const override; + ~{nebula_name}AggregationPhysicalFunction() override = default; + void cleanup(nautilus::val aggregationState) override; + +private: + std::shared_ptr bufferRef; + PhysicalFunction valueFunction; + PhysicalFunction timestampFunction; +}}; + +}} +""" + +# Physical .cpp templates — the core logic. lift/combine/reset/cleanup are identical +# scaffold; lower() is the per-op differential (builds trajectory string + MEOS call). +PHYSICAL_CPP_TGEO = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +extern "C" {{ +#include +#include +}} + +namespace NES +{{ + +constexpr static std::string_view LonFieldName = "lon"; +constexpr static std::string_view LatFieldName = "lat"; +constexpr static std::string_view TimestampFieldName = "timestamp"; + +static std::mutex {mutex_name}; + + +{nebula_name}AggregationPhysicalFunction::{nebula_name}AggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction lonFunctionParam, + PhysicalFunction latFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef) + : AggregationPhysicalFunction(std::move(inputType), std::move(resultType), lonFunctionParam, std::move(resultFieldIdentifier)) + , bufferRef(std::move(bufferRef)) + , lonFunction(std::move(lonFunctionParam)) + , latFunction(std::move(latFunctionParam)) + , timestampFunction(std::move(timestampFunctionParam)) +{{ +}} + +void {nebula_name}AggregationPhysicalFunction::lift( + const nautilus::val& aggregationState, PipelineMemoryProvider& pipelineMemoryProvider, const Nautilus::Record& record) +{{ + const auto pagedVectorPtr = static_cast>(aggregationState); + + auto lonValue = lonFunction.execute(record, pipelineMemoryProvider.arena); + auto latValue = latFunction.execute(record, pipelineMemoryProvider.arena); + auto timestampValue = timestampFunction.execute(record, pipelineMemoryProvider.arena); + + Record aggregateStateRecord({{ + {{std::string(LonFieldName), lonValue}}, + {{std::string(LatFieldName), latValue}}, + {{std::string(TimestampFieldName), timestampValue}} + }}); + + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + pagedVectorRef.writeRecord(aggregateStateRecord, pipelineMemoryProvider.bufferProvider); +}} + +void {nebula_name}AggregationPhysicalFunction::combine( + const nautilus::val aggregationState1, + const nautilus::val aggregationState2, + PipelineMemoryProvider&) +{{ + const auto memArea1 = static_cast>(aggregationState1); + const auto memArea2 = static_cast>(aggregationState2); + + nautilus::invoke( + +[](Nautilus::Interface::PagedVector* vector1, const Nautilus::Interface::PagedVector* vector2) -> void + {{ vector1->copyFrom(*vector2); }}, + memArea1, + memArea2); +}} + +Nautilus::Record {nebula_name}AggregationPhysicalFunction::lower( + const nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) +{{ + MEOS::Meos::ensureMeosInitialized(); + + const auto pagedVectorPtr = static_cast>(aggregationState); + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + const auto allFieldNames = bufferRef->getMemoryLayout()->getSchema().getFieldNames(); + const auto numberOfEntries = invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) + {{ + return pagedVector->getTotalNumberOfEntries(); + }}, + pagedVectorPtr); + + if (numberOfEntries == nautilus::val(0)) {{ + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, nautilus::val<{return_cpp_type}>(0)); + return resultRecord; + }} + + auto trajectoryStr = nautilus::invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) -> char* + {{ + size_t bufferSize = pagedVector->getTotalNumberOfEntries() * 150 + 50; + char* buffer = (char*)malloc(bufferSize); + memset(buffer, 0, bufferSize); + strcpy(buffer, "{{"); + return buffer; + }}, + pagedVectorPtr); + + auto pointCounter = nautilus::val(0); + + const auto endIt = pagedVectorRef.end(allFieldNames); + for (auto candidateIt = pagedVectorRef.begin(allFieldNames); candidateIt != endIt; ++candidateIt) + {{ + const auto itemRecord = *candidateIt; + + const auto lonValue = itemRecord.read(std::string(LonFieldName)); + const auto latValue = itemRecord.read(std::string(LatFieldName)); + const auto timestampValue = itemRecord.read(std::string(TimestampFieldName)); + + auto lon = lonValue.cast>(); + auto lat = latValue.cast>(); + auto timestamp = timestampValue.cast>(); + + trajectoryStr = nautilus::invoke( + +[](char* buffer, double lonVal, double latVal, int64_t tsVal, int64_t counter) -> char* + {{ + if (counter > 0) {{ + strcat(buffer, ", "); + }} + + long long adjustedTime; + if (tsVal > 1000000000000LL) {{ + adjustedTime = tsVal / 1000; + }} else {{ + adjustedTime = tsVal; + }} + + std::string timestampString = MEOS::Meos::convertSecondsToTimestamp(adjustedTime); + const char* timestampStr = timestampString.c_str(); + + char pointStr[120]; + sprintf(pointStr, "Point(%.6f %.6f)@%s", lonVal, latVal, timestampStr); + strcat(buffer, pointStr); + return buffer; + }}, + trajectoryStr, + lon, + lat, + timestamp, + pointCounter); + + pointCounter = pointCounter + nautilus::val(1); + }} + + trajectoryStr = nautilus::invoke( + +[](char* buffer) -> char* + {{ + strcat(buffer, "}}"); + return buffer; + }}, + trajectoryStr); + + auto resultValue = nautilus::invoke( + +[](const char* trajStr) -> {return_cpp_type} + {{ + if (!trajStr || strlen(trajStr) == 0) {{ + free((void*)trajStr); + return ({return_cpp_type})0; + }} + + std::lock_guard lock({mutex_name}); + + std::string trajString(trajStr); + void* temp = MEOS::Meos::parseTemporalPoint(trajString); + if (!temp) {{ + free((void*)trajStr); + return ({return_cpp_type})0; + }} + + {return_cpp_type} value = {meos_scalar_fn}(static_cast(temp)); + + MEOS::Meos::freeTemporalObject(temp); + free((void*)trajStr); + return value; + }}, + trajectoryStr); + + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, resultValue); + return resultRecord; +}} + +void {nebula_name}AggregationPhysicalFunction::reset(const nautilus::val aggregationState, PipelineMemoryProvider&) +{{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + {{ + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + new (pagedVector) Nautilus::Interface::PagedVector(); + }}, + aggregationState); +}} + +size_t {nebula_name}AggregationPhysicalFunction::getSizeOfStateInBytes() const +{{ + return sizeof(Nautilus::Interface::PagedVector); +}} + +void {nebula_name}AggregationPhysicalFunction::cleanup(nautilus::val aggregationState) +{{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + {{ + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + pagedVector->~PagedVector(); + }}, + aggregationState); +}} + + +AggregationPhysicalFunctionRegistryReturnType AggregationPhysicalFunctionGeneratedRegistrar::Register{nebula_name}AggregationPhysicalFunction( + AggregationPhysicalFunctionRegistryArguments) +{{ + throw std::runtime_error("{class_name_token} aggregation cannot be created through the registry. " + "It requires three field functions (longitude, latitude, timestamp)"); +}} + +}} // namespace NES +""" + +PHYSICAL_CPP_TNUMBER = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +extern "C" {{ +#include +}} + +namespace NES +{{ + +constexpr static std::string_view ValueFieldName = "value"; +constexpr static std::string_view TimestampFieldName = "timestamp"; + +static std::mutex {mutex_name}; + + +{nebula_name}AggregationPhysicalFunction::{nebula_name}AggregationPhysicalFunction( + DataType inputType, + DataType resultType, + PhysicalFunction valueFunctionParam, + PhysicalFunction timestampFunctionParam, + Nautilus::Record::RecordFieldIdentifier resultFieldIdentifier, + std::shared_ptr bufferRef) + : AggregationPhysicalFunction(std::move(inputType), std::move(resultType), valueFunctionParam, std::move(resultFieldIdentifier)) + , bufferRef(std::move(bufferRef)) + , valueFunction(std::move(valueFunctionParam)) + , timestampFunction(std::move(timestampFunctionParam)) +{{ +}} + +void {nebula_name}AggregationPhysicalFunction::lift( + const nautilus::val& aggregationState, PipelineMemoryProvider& pipelineMemoryProvider, const Nautilus::Record& record) +{{ + const auto pagedVectorPtr = static_cast>(aggregationState); + + auto valueValue = valueFunction.execute(record, pipelineMemoryProvider.arena); + auto timestampValue = timestampFunction.execute(record, pipelineMemoryProvider.arena); + + Record aggregateStateRecord({{ + {{std::string(ValueFieldName), valueValue}}, + {{std::string(TimestampFieldName), timestampValue}} + }}); + + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + pagedVectorRef.writeRecord(aggregateStateRecord, pipelineMemoryProvider.bufferProvider); +}} + +void {nebula_name}AggregationPhysicalFunction::combine( + const nautilus::val aggregationState1, + const nautilus::val aggregationState2, + PipelineMemoryProvider&) +{{ + const auto memArea1 = static_cast>(aggregationState1); + const auto memArea2 = static_cast>(aggregationState2); + + nautilus::invoke( + +[](Nautilus::Interface::PagedVector* vector1, const Nautilus::Interface::PagedVector* vector2) -> void + {{ vector1->copyFrom(*vector2); }}, + memArea1, + memArea2); +}} + +Nautilus::Record {nebula_name}AggregationPhysicalFunction::lower( + const nautilus::val aggregationState, [[maybe_unused]] PipelineMemoryProvider& pipelineMemoryProvider) +{{ + MEOS::Meos::ensureMeosInitialized(); + + const auto pagedVectorPtr = static_cast>(aggregationState); + const Nautilus::Interface::PagedVectorRef pagedVectorRef(pagedVectorPtr, bufferRef); + const auto allFieldNames = bufferRef->getMemoryLayout()->getSchema().getFieldNames(); + const auto numberOfEntries = invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) + {{ + return pagedVector->getTotalNumberOfEntries(); + }}, + pagedVectorPtr); + + if (numberOfEntries == nautilus::val(0)) {{ + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, nautilus::val<{return_cpp_type}>(0)); + return resultRecord; + }} + + auto sequenceStr = nautilus::invoke( + +[](const Nautilus::Interface::PagedVector* pagedVector) -> char* + {{ + size_t bufferSize = pagedVector->getTotalNumberOfEntries() * 80 + 50; + char* buffer = (char*)malloc(bufferSize); + memset(buffer, 0, bufferSize); + strcpy(buffer, "{{"); + return buffer; + }}, + pagedVectorPtr); + + auto pointCounter = nautilus::val(0); + + const auto endIt = pagedVectorRef.end(allFieldNames); + for (auto candidateIt = pagedVectorRef.begin(allFieldNames); candidateIt != endIt; ++candidateIt) + {{ + const auto itemRecord = *candidateIt; + + const auto valueRaw = itemRecord.read(std::string(ValueFieldName)); + const auto timestampRaw = itemRecord.read(std::string(TimestampFieldName)); + + auto value = valueRaw.cast>(); + auto timestamp = timestampRaw.cast>(); + + sequenceStr = nautilus::invoke( + +[](char* buffer, {lift_value_cpp_type} valueVal, int64_t tsVal, int64_t counter) -> char* + {{ + if (counter > 0) {{ + strcat(buffer, ", "); + }} + + long long adjustedTime; + if (tsVal > 1000000000000LL) {{ + adjustedTime = tsVal / 1000; + }} else {{ + adjustedTime = tsVal; + }} + + std::string timestampString = MEOS::Meos::convertSecondsToTimestamp(adjustedTime); + const char* timestampStr = timestampString.c_str(); + + char itemStr[80]; + sprintf(itemStr, "{value_printf_fmt}@%s", valueVal, timestampStr); + strcat(buffer, itemStr); + return buffer; + }}, + sequenceStr, + value, + timestamp, + pointCounter); + + pointCounter = pointCounter + nautilus::val(1); + }} + + sequenceStr = nautilus::invoke( + +[](char* buffer) -> char* + {{ + strcat(buffer, "}}"); + return buffer; + }}, + sequenceStr); + + auto resultValue = nautilus::invoke( + +[](const char* seqStr) -> {return_cpp_type} + {{ + if (!seqStr || strlen(seqStr) == 0) {{ + free((void*)seqStr); + return ({return_cpp_type})0; + }} + + std::lock_guard lock({mutex_name}); + + Temporal* temp = {tnumber_in_fn}(seqStr); + if (!temp) {{ + free((void*)seqStr); + return ({return_cpp_type})0; + }} + + {return_cpp_type} value = {meos_scalar_fn}(temp); + + free(temp); + free((void*)seqStr); + return value; + }}, + sequenceStr); + + Nautilus::Record resultRecord; + resultRecord.write(resultFieldIdentifier, resultValue); + return resultRecord; +}} + +void {nebula_name}AggregationPhysicalFunction::reset(const nautilus::val aggregationState, PipelineMemoryProvider&) +{{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + {{ + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + new (pagedVector) Nautilus::Interface::PagedVector(); + }}, + aggregationState); +}} + +size_t {nebula_name}AggregationPhysicalFunction::getSizeOfStateInBytes() const +{{ + return sizeof(Nautilus::Interface::PagedVector); +}} + +void {nebula_name}AggregationPhysicalFunction::cleanup(nautilus::val aggregationState) +{{ + nautilus::invoke( + +[](AggregationState* pagedVectorMemArea) -> void + {{ + auto* pagedVector = reinterpret_cast(pagedVectorMemArea); + pagedVector->~PagedVector(); + }}, + aggregationState); +}} + + +AggregationPhysicalFunctionRegistryReturnType AggregationPhysicalFunctionGeneratedRegistrar::Register{nebula_name}AggregationPhysicalFunction( + AggregationPhysicalFunctionRegistryArguments) +{{ + throw std::runtime_error("{class_name_token} aggregation cannot be created through the registry. " + "It requires two field functions (value, timestamp)"); +}} + +}} // namespace NES +""" + +# =========================================================================== +# Parser-glue templates: TWO dispatch sites in AntlrSQLQueryPlanCreator.cpp. +# Site 1 is the dedicated-token case-switch (~line 965 in mariana's tree). +# Site 2 is the IDENTIFIER fallback `else if (funcName == "TOKEN")` chain +# (~line 2062 in mariana's tree). +# =========================================================================== + +# Site 1 — case-switch dispatch. Two shapes (tgeo 3-arg, tnumber 2-arg). +CASE_SWITCH_TGEO = """\ + /* BEGIN CODEGEN AGGREGATION GLUE: {sql_token} (case-switch) */ + case AntlrSQLLexer::{sql_token}: + // {comment_one_liner} + if (helpers.top().functionBuilder.size() != 3) {{ + throw InvalidQuerySyntax("{sql_token} requires exactly three arguments (longitude, latitude, timestamp), but got {{}}", helpers.top().functionBuilder.size()); + }} + {{ + const auto timestampFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto latitudeFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto longitudeFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + + if (!longitudeFunction.tryGet() || + !latitudeFunction.tryGet() || + !timestampFunction.tryGet()) {{ + throw InvalidQuerySyntax("{sql_token} arguments must be field references"); + }} + + helpers.top().windowAggs.push_back( + {nebula_name}AggregationLogicalFunction::create(longitudeFunction.get(), + latitudeFunction.get(), + timestampFunction.get())); + helpers.top().functionBuilder.push_back(longitudeFunction); + }} + break; + /* END CODEGEN AGGREGATION GLUE: {sql_token} (case-switch) */ +""" + +CASE_SWITCH_TNUMBER = """\ + /* BEGIN CODEGEN AGGREGATION GLUE: {sql_token} (case-switch) */ + case AntlrSQLLexer::{sql_token}: + // {comment_one_liner} + if (helpers.top().functionBuilder.size() != 2) {{ + throw InvalidQuerySyntax("{sql_token} requires exactly two arguments (value, timestamp), but got {{}}", helpers.top().functionBuilder.size()); + }} + {{ + const auto timestampFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + const auto valueFunction = helpers.top().functionBuilder.back(); + helpers.top().functionBuilder.pop_back(); + + if (!valueFunction.tryGet() || + !timestampFunction.tryGet()) {{ + throw InvalidQuerySyntax("{sql_token} arguments must be field references"); + }} + + helpers.top().windowAggs.push_back( + {nebula_name}AggregationLogicalFunction::create(valueFunction.get(), + timestampFunction.get())); + helpers.top().functionBuilder.push_back(valueFunction); + }} + break; + /* END CODEGEN AGGREGATION GLUE: {sql_token} (case-switch) */ +""" + +# Site 2 — funcName == "TOKEN" string chain. +FUNCNAME_CHAIN_TGEO = """\ + /* BEGIN CODEGEN AGGREGATION GLUE: {sql_token} (funcName chain) */ + else if (funcName == "{sql_token}") + {{ + if (helpers.top().functionBuilder.size() < 3) + {{ + throw InvalidQuerySyntax("{sql_token} requires three arguments at {{}}", context->getText()); + }} + const auto ts = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto lat = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto lon = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + helpers.top().windowAggs.push_back({nebula_name}AggregationLogicalFunction::create(lon, lat, ts)); + }} + /* END CODEGEN AGGREGATION GLUE: {sql_token} (funcName chain) */ +""" + +FUNCNAME_CHAIN_TNUMBER = """\ + /* BEGIN CODEGEN AGGREGATION GLUE: {sql_token} (funcName chain) */ + else if (funcName == "{sql_token}") + {{ + if (helpers.top().functionBuilder.size() < 2) + {{ + throw InvalidQuerySyntax("{sql_token} requires two arguments at {{}}", context->getText()); + }} + const auto ts = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + const auto value = helpers.top().functionBuilder.back().get(); + helpers.top().functionBuilder.pop_back(); + helpers.top().windowAggs.push_back({nebula_name}AggregationLogicalFunction::create(value, ts)); + }} + /* END CODEGEN AGGREGATION GLUE: {sql_token} (funcName chain) */ +""" + +# Site 3 — optimizer logical→physical lowering rule. +OPTIMIZER_LOWERING_TGEO = """\ + /* BEGIN CODEGEN AGGREGATION GLUE: {class_name_token} (optimizer lowering) */ + if (name == std::string_view("{class_name_token}")) + {{ + auto specificDescriptor = std::dynamic_pointer_cast<{nebula_name}AggregationLogicalFunction>(descriptor); + INVARIANT(specificDescriptor != nullptr, "Expected {nebula_name}AggregationLogicalFunction for {class_name_token}"); + + auto lonPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getLonField()); + auto latPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getLatField()); + auto tsPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getTimestampField()); + + Schema stateSchema; + stateSchema.addField("lon", specificDescriptor->getLonField().getDataType()); + stateSchema.addField("lat", specificDescriptor->getLatField().getDataType()); + stateSchema.addField("timestamp", specificDescriptor->getTimestampField().getDataType()); + auto tupleBufferRef = Interface::BufferRef::TupleBufferRef::create(configuration.pageSize.getValue(), stateSchema); + + auto phys = std::make_shared<{nebula_name}AggregationPhysicalFunction>( + std::move(physicalInputType), + std::move(physicalFinalType), + lonPF, + latPF, + tsPF, + resultFieldIdentifier, + tupleBufferRef); + aggregationPhysicalFunctions.push_back(std::move(phys)); + continue; + }} + /* END CODEGEN AGGREGATION GLUE: {class_name_token} (optimizer lowering) */ +""" + +OPTIMIZER_LOWERING_TNUMBER = """\ + /* BEGIN CODEGEN AGGREGATION GLUE: {class_name_token} (optimizer lowering) */ + if (name == std::string_view("{class_name_token}")) + {{ + auto specificDescriptor = std::dynamic_pointer_cast<{nebula_name}AggregationLogicalFunction>(descriptor); + INVARIANT(specificDescriptor != nullptr, "Expected {nebula_name}AggregationLogicalFunction for {class_name_token}"); + + auto valuePF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getValueField()); + auto tsPF = QueryCompilation::FunctionProvider::lowerFunction(specificDescriptor->getTimestampField()); + + Schema stateSchema; + stateSchema.addField("value", specificDescriptor->getValueField().getDataType()); + stateSchema.addField("timestamp", specificDescriptor->getTimestampField().getDataType()); + auto tupleBufferRef = Interface::BufferRef::TupleBufferRef::create(configuration.pageSize.getValue(), stateSchema); + + auto phys = std::make_shared<{nebula_name}AggregationPhysicalFunction>( + std::move(physicalInputType), + std::move(physicalFinalType), + valuePF, + tsPF, + resultFieldIdentifier, + tupleBufferRef); + aggregationPhysicalFunctions.push_back(std::move(phys)); + continue; + }} + /* END CODEGEN AGGREGATION GLUE: {class_name_token} (optimizer lowering) */ +""" + +# =========================================================================== +# Shape dispatchers + emit_operator. +# =========================================================================== + +def physical_template_for(op): + if op["input_shape"] == "tgeo": + return PHYSICAL_HPP_TGEO, PHYSICAL_CPP_TGEO + if op["input_shape"] == "tnumber": + return PHYSICAL_HPP_TNUMBER, PHYSICAL_CPP_TNUMBER + raise ValueError(f"unknown input_shape: {op['input_shape']}") + + +def logical_template_for(op): + if op["input_shape"] == "tgeo": + return LOGICAL_HPP_TGEO, LOGICAL_CPP_TGEO + if op["input_shape"] == "tnumber": + return LOGICAL_HPP_TNUMBER, LOGICAL_CPP_TNUMBER + raise ValueError(f"unknown input_shape: {op['input_shape']}") + + +def case_switch_template_for(op): + return CASE_SWITCH_TGEO if op["input_shape"] == "tgeo" else CASE_SWITCH_TNUMBER + + +def funcname_chain_template_for(op): + return FUNCNAME_CHAIN_TGEO if op["input_shape"] == "tgeo" else FUNCNAME_CHAIN_TNUMBER + + +def optimizer_lowering_template_for(op): + return OPTIMIZER_LOWERING_TGEO if op["input_shape"] == "tgeo" else OPTIMIZER_LOWERING_TNUMBER + + +def emit_operator(op, output_root: Path): + nebula_name = op["nebula_name"] + logical_hpp_tmpl, logical_cpp_tmpl = logical_template_for(op) + physical_hpp_tmpl, physical_cpp_tmpl = physical_template_for(op) + + # Common substitution dict. + fmt = { + "nebula_name": nebula_name, + "class_name_token": op["class_name_token"], + "sql_token": op["sql_token"], + "comment_one_liner": op["comment_one_liner"], + "meos_scalar_fn": op["meos_scalar_fn"], + "return_cpp_type": op["return_cpp_type"], + "final_stamp_type": op["final_stamp_type"], + "mutex_name": f"meos_{nebula_name.lower()}_mutex", + # tnumber-only extras (harmless for tgeo since unused) + "lift_value_cpp_type": op.get("lift_value_cpp_type", "double"), + "value_printf_fmt": op.get("value_printf_fmt", "%.6f"), + "tnumber_in_fn": op.get("tnumber_in_fn", "tfloat_in"), + } + + paths = { + "logical_hpp": output_root / "nes-logical-operators/include/Operators/Windows/Aggregations/Meos" / f"{nebula_name}AggregationLogicalFunction.hpp", + "logical_cpp": output_root / "nes-logical-operators/src/Operators/Windows/Aggregations/Meos" / f"{nebula_name}AggregationLogicalFunction.cpp", + "physical_hpp": output_root / "nes-physical-operators/include/Aggregation/Function/Meos" / f"{nebula_name}AggregationPhysicalFunction.hpp", + "physical_cpp": output_root / "nes-physical-operators/src/Aggregation/Function/Meos" / f"{nebula_name}AggregationPhysicalFunction.cpp", + } + for p in paths.values(): + p.parent.mkdir(parents=True, exist_ok=True) + + paths["logical_hpp"].write_text(logical_hpp_tmpl.format(**fmt)) + paths["logical_cpp"].write_text(logical_cpp_tmpl.format(**fmt)) + paths["physical_hpp"].write_text(physical_hpp_tmpl.format(**fmt)) + paths["physical_cpp"].write_text(physical_cpp_tmpl.format(**fmt)) + sys.stderr.write(f" ✓ {nebula_name}: emitted 4 files\n") + + +# =========================================================================== +# Idempotent injectors. +# =========================================================================== + +def inject_cmake_entries(operators, output_root: Path) -> int: + """Append per-op `add_plugin(...)` entries to both layers' aggregation + CMakeLists. Idempotent: skips entries already present.""" + n_added = 0 + # Layer (logical | physical) → (CMakeLists path, plugin suffix) + layers = [ + ("logical", output_root / "nes-logical-operators/src/Operators/Windows/Aggregations/Meos/CMakeLists.txt", "Logical"), + ("physical", output_root / "nes-physical-operators/src/Aggregation/Function/Meos/CMakeLists.txt", "Physical"), + ] + for label, cml, suffix in layers: + if not cml.exists(): + sys.stderr.write(f" ! cmake-entries: {cml} not found, skipping {label}\n") + continue + body = cml.read_text() + new_lines = [] + for op in operators: + # Target name must NOT include "Aggregation" suffix — the registry codegen + # appends "Aggregation" itself, so a "...Aggregation" target + # would yield a double-Aggregation symbol. Mariana's convention is the + # target name = the SQL-side aggregation name (e.g. "TemporalLength"), + # NOT the C++ class basename. We follow that. + target_name = op["nebula_name"] + suffix_kind = "AggregationLogicalFunction" if label == "logical" else "AggregationPhysicalFunction" + registry_kind = "AggregationLogicalFunction" if label == "logical" else "AggregationPhysicalFunction" + cpp_basename = f"{op['nebula_name']}{suffix_kind}.cpp" + entry = ( + f"add_plugin({target_name} {registry_kind} " + f"nes-{label}-operators {cpp_basename})" + ) + # Match by basename to be tolerant of formatting drift + marker = f"add_plugin({target_name} {registry_kind}" + if marker in body: + continue + new_lines.append(entry) + if new_lines: + with cml.open("a") as f: + f.write("\n".join(new_lines) + "\n") + sys.stderr.write(f" ✓ cmake-entries ({label}): appended {len(new_lines)} entry(ies)\n") + n_added += len(new_lines) + return n_added + + +def inject_g4(operators, g4_path: Path) -> int: + """Inject lexer-token + functionName alternation entries into AntlrSQL.g4.""" + if not g4_path.exists(): + sys.stderr.write(f" ! g4: {g4_path} not found, skipping\n") + return 0 + body = g4_path.read_text() + n_added = 0 + + new_tokens = [] + for op in operators: + tok = op["sql_token"] + if re.search(rf"^{re.escape(tok)}\s*:", body, re.MULTILINE): + continue + new_tokens.append(f"{tok}: '{tok}' | '{tok.lower()}';") + if new_tokens: + if "/* BEGIN CODEGEN AGGREGATION LEXER TOKENS */" in body: + body = re.sub( + r"(/\* BEGIN CODEGEN AGGREGATION LEXER TOKENS \*/\n)(.*?)(/\* END CODEGEN AGGREGATION LEXER TOKENS \*/)", + lambda mm: mm.group(1) + mm.group(2) + "\n".join(new_tokens) + "\n" + mm.group(3), + body, count=1, flags=re.DOTALL, + ) + else: + anchor_re = re.compile(r"^WATERMARK:.*$", re.MULTILINE) + m = anchor_re.search(body) + if m is None: + sys.stderr.write(f" ! g4: WATERMARK anchor not found\n") + else: + insertion = ( + "/* BEGIN CODEGEN AGGREGATION LEXER TOKENS */\n" + + "\n".join(new_tokens) + + "\n/* END CODEGEN AGGREGATION LEXER TOKENS */\n" + ) + body = body[: m.start()] + insertion + body[m.start():] + n_added += len(new_tokens) + sys.stderr.write(f" ✓ g4 lexer-tokens: added {len(new_tokens)} token(s)\n") + + # functionName alternation + fn_re = re.compile(r"^functionName:\s*([^;]+);", re.MULTILINE) + m = fn_re.search(body) + if m is None: + sys.stderr.write(f" ! g4: functionName production not found\n") + else: + alternation = m.group(1) + new_alts = [] + for op in operators: + tok = op["sql_token"] + if re.search(rf"\b{re.escape(tok)}\b", alternation): + continue + new_alts.append(tok) + if new_alts: + new_alt_text = alternation.rstrip() + " | " + " | ".join(new_alts) + body = body[: m.start()] + f"functionName: {new_alt_text};" + body[m.end():] + sys.stderr.write(f" ✓ g4 functionName: added {len(new_alts)} alternative(s)\n") + + g4_path.write_text(body) + return n_added + + +def inject_parser_cpp(operators, cpp_path: Path) -> int: + """Inject TWO dispatch sites + per-op #include.""" + if not cpp_path.exists(): + sys.stderr.write(f" ! parser-cpp: {cpp_path} not found, skipping\n") + return 0 + body = cpp_path.read_text() + n_added = 0 + + # 1) #includes — insert after the LAST `#include ` line. + new_includes = [] + for op in operators: + inc = f"#include " + if inc in body: + continue + new_includes.append(inc) + if new_includes: + agg_inc_re = re.compile(r"(^#include ]+>\s*\n)+", re.MULTILINE) + matches = list(agg_inc_re.finditer(body)) + if matches: + last = matches[-1] + body = body[: last.end()] + "\n".join(new_includes) + "\n" + body[last.end():] + sys.stderr.write(f" ✓ parser-cpp aggregation includes: added {len(new_includes)}\n") + else: + # Fall back: insert after any Meos include + meos_inc_re = re.compile(r"(^#include ]+>\s*\n)+", re.MULTILINE) + matches = list(meos_inc_re.finditer(body)) + if matches: + last = matches[-1] + body = body[: last.end()] + "\n".join(new_includes) + "\n" + body[last.end():] + sys.stderr.write(f" ✓ parser-cpp aggregation includes (fallback): added {len(new_includes)}\n") + else: + sys.stderr.write(f" ! parser-cpp: no Meos include anchor found\n") + + # 2) Case-switch dispatch — insert after the last `END CODEGEN AGGREGATION GLUE: ... (case-switch)` + # marker, else before the `default:` of the switch that contains TGEO_AT_STBOX. + new_case_blocks = [] + for op in operators: + tmpl = case_switch_template_for(op) + marker = f"/* BEGIN CODEGEN AGGREGATION GLUE: {op['sql_token']} (case-switch) */" + if marker in body: + continue + # Skip if pre-existing hand-written case + if re.search(rf"case\s+AntlrSQLLexer::{re.escape(op['sql_token'])}\s*:", body): + sys.stderr.write( + f" ! parser-cpp: pre-existing case for {op['sql_token']} (case-switch); skipping\n" + ) + continue + new_case_blocks.append(tmpl.format( + sql_token=op["sql_token"], nebula_name=op["nebula_name"], comment_one_liner=op["comment_one_liner"], + )) + if new_case_blocks: + # Anchor preference order: + # 1. last `END CODEGEN AGGREGATION GLUE: ... (case-switch)` (own marker) + # 2. last `END CODEGEN PARSER GLUE: ...` (codegen_nebula.py W4.5+) + # 3. TGEO_AT_STBOX → default: (pre-W4.5 layout) + last_end_agg = list(re.finditer(r"/\* END CODEGEN AGGREGATION GLUE: [^*]+\(case-switch\)\s*\*/", body)) + last_end_nebula = list(re.finditer(r"/\* END CODEGEN PARSER GLUE: [^*]+\*/", body)) + if last_end_agg: + insert_at = last_end_agg[-1].end() + body = body[:insert_at] + "\n" + "\n".join(new_case_blocks) + body[insert_at:] + sys.stderr.write(f" ✓ parser-cpp case-switch: added {len(new_case_blocks)} (after own marker)\n") + elif last_end_nebula: + insert_at = last_end_nebula[-1].end() + body = body[:insert_at] + "\n" + "\n".join(new_case_blocks) + body[insert_at:] + sys.stderr.write(f" ✓ parser-cpp case-switch: added {len(new_case_blocks)} (after codegen_nebula marker)\n") + else: + anchor_re = re.compile(r"(case AntlrSQLLexer::TGEO_AT_STBOX:[\s\S]+?\n\s*break;\n)(\s*default:)") + m = anchor_re.search(body) + if m is None: + sys.stderr.write(f" ! parser-cpp: no case-switch anchor found\n") + else: + insertion = m.group(1) + "\n" + "\n".join(new_case_blocks) + "\n" + m.group(2) + body = body[: m.start()] + insertion + body[m.end():] + sys.stderr.write(f" ✓ parser-cpp case-switch: added {len(new_case_blocks)} (before default:)\n") + n_added += len(new_case_blocks) + + # 3) funcName-chain dispatch — insert after the last `END CODEGEN AGGREGATION GLUE: ... (funcName chain)`, + # else after mariana's CrossDistance else-if block. + new_chain_blocks = [] + for op in operators: + tmpl = funcname_chain_template_for(op) + marker = f"/* BEGIN CODEGEN AGGREGATION GLUE: {op['sql_token']} (funcName chain) */" + if marker in body: + continue + if re.search(rf'funcName == "{re.escape(op["sql_token"])}"', body): + sys.stderr.write( + f" ! parser-cpp: pre-existing funcName chain for {op['sql_token']}; skipping\n" + ) + continue + new_chain_blocks.append(tmpl.format(sql_token=op["sql_token"], nebula_name=op["nebula_name"])) + if new_chain_blocks: + last_end_re = re.compile(r"/\* END CODEGEN AGGREGATION GLUE: [^*]+\(funcName chain\)\s*\*/") + ends = list(last_end_re.finditer(body)) + if ends: + insert_at = ends[-1].end() + body = body[:insert_at] + "\n" + "\n".join(new_chain_blocks) + body[insert_at:] + sys.stderr.write(f" ✓ parser-cpp funcName chain: added {len(new_chain_blocks)} (after marker)\n") + else: + anchor_re = re.compile( + r'(else if \(funcName == "CROSS_DISTANCE"\)[\s\S]+?\n\s*\}\n)', + ) + m = anchor_re.search(body) + if m is None: + sys.stderr.write(f" ! parser-cpp: no funcName chain anchor (after CROSS_DISTANCE) found\n") + else: + insertion = m.group(1) + "\n".join(new_chain_blocks) + body = body[: m.end()] + "\n".join(new_chain_blocks) + body[m.end():] + sys.stderr.write(f" ✓ parser-cpp funcName chain: added {len(new_chain_blocks)} (after CROSS_DISTANCE)\n") + n_added += len(new_chain_blocks) + + cpp_path.write_text(body) + return n_added + + +def inject_optimizer(operators, opt_path: Path) -> int: + """Inject `if (name == "...")` blocks into LowerToPhysicalWindowedAggregation.cpp.""" + if not opt_path.exists(): + sys.stderr.write(f" ! optimizer: {opt_path} not found, skipping\n") + return 0 + body = opt_path.read_text() + n_added = 0 + + # 1) #include for the physical class header + new_includes = [] + for op in operators: + inc = f"#include " + if inc in body: + continue + new_includes.append(inc) + # Also need the logical class header + new_logical_includes = [] + for op in operators: + inc = f"#include " + if inc in body: + continue + new_logical_includes.append(inc) + if new_includes or new_logical_includes: + agg_inc_re = re.compile(r"(^#include ]+>\s*\n)+", re.MULTILINE) + matches = list(agg_inc_re.finditer(body)) + if matches: + last = matches[-1] + inserts = [] + if new_includes: + inserts.extend(new_includes) + if new_logical_includes: + inserts.extend(new_logical_includes) + body = body[: last.end()] + "\n".join(inserts) + "\n" + body[last.end():] + sys.stderr.write(f" ✓ optimizer includes: added {len(new_includes)} phys + {len(new_logical_includes)} logical\n") + else: + sys.stderr.write(f" ! optimizer: no Aggregation/Function/Meos include anchor found\n") + + # 2) The if-name-match block. Insert after last codegen END marker, else after mariana's CrossDistance block. + new_blocks = [] + for op in operators: + tmpl = optimizer_lowering_template_for(op) + marker = f"/* BEGIN CODEGEN AGGREGATION GLUE: {op['class_name_token']} (optimizer lowering) */" + if marker in body: + continue + # Skip if a pre-existing hand-written block exists for this class_name_token + if re.search(rf'name == std::string_view\("{re.escape(op["class_name_token"])}"\)', body): + sys.stderr.write( + f" ! optimizer: pre-existing lowering block for {op['class_name_token']}; skipping\n" + ) + continue + new_blocks.append(tmpl.format(class_name_token=op["class_name_token"], nebula_name=op["nebula_name"])) + if new_blocks: + last_end_re = re.compile(r"/\* END CODEGEN AGGREGATION GLUE: [^*]+\(optimizer lowering\)\s*\*/") + ends = list(last_end_re.finditer(body)) + if ends: + insert_at = ends[-1].end() + body = body[:insert_at] + "\n" + "\n".join(new_blocks) + body[insert_at:] + sys.stderr.write(f" ✓ optimizer lowering: added {len(new_blocks)} (after marker)\n") + else: + # Anchor: insert just before the "Default path: use registry" comment. + anchor_re = re.compile(r"(\n\s*// Default path: use registry)") + m = anchor_re.search(body) + if m is None: + sys.stderr.write(f" ! optimizer: 'Default path' anchor not found\n") + else: + insertion = "\n" + "\n".join(new_blocks) + m.group(1) + body = body[: m.start()] + insertion + body[m.end():] + sys.stderr.write(f" ✓ optimizer lowering: added {len(new_blocks)} (before Default path)\n") + n_added += len(new_blocks) + + opt_path.write_text(body) + return n_added + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--input", required=True) + parser.add_argument("--output-root", required=True) + parser.add_argument("--no-parser-glue", action="store_true") + parser.add_argument("--no-cmake-entries", action="store_true") + parser.add_argument("--no-optimizer-glue", action="store_true") + args = parser.parse_args() + + with open(args.input) as f: + config = json.load(f) + operators = config["operators"] + + output_root = Path(args.output_root).resolve() + if not (output_root / "nes-logical-operators").exists(): + sys.exit(f"ERROR: {output_root} does not look like MobilityNebula root") + + sys.stderr.write(f"Emitting {len(operators)} aggregation operator(s):\n\n") + for op in operators: + emit_operator(op, output_root) + + if not args.no_cmake_entries: + sys.stderr.write("\nCMakeLists.txt:\n") + inject_cmake_entries(operators, output_root) + + if not args.no_parser_glue: + sys.stderr.write("\nParser glue:\n") + inject_g4(operators, output_root / "nes-sql-parser/AntlrSQL.g4") + inject_parser_cpp(operators, output_root / "nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp") + + if not args.no_optimizer_glue: + sys.stderr.write("\nOptimizer lowering glue:\n") + inject_optimizer(operators, output_root / "nes-query-optimizer/src/RewriteRules/LowerToPhysical/LowerToPhysicalWindowedAggregation.cpp") + + sys.stderr.write(f"\nDone. {len(operators) * 4} files emitted.\n") + + +if __name__ == "__main__": + main() diff --git a/tools/codegen/codegen_input.example.json b/tools/codegen/codegen_input.example.json new file mode 100644 index 0000000000..cbfd0ed15e --- /dev/null +++ b/tools/codegen/codegen_input.example.json @@ -0,0 +1,160 @@ +{ + "_comment": "Example input for codegen_nebula.py \u2014 first wave of MEOS spatial-relation E/A predicates. Each operator descriptor produces one logical .hpp/.cpp + one physical .hpp/.cpp file. Adjust the list to control which functions get generated.", + "operators": [ + { + "nebula_name": "TemporalEDisjointGeometry", + "sql_token": "TEMPORAL_EDISJOINT_GEOMETRY", + "meos_call": "edisjoint_tgeo_geo", + "args": [ + { + "name": "lon", + "nautilus_type": "double", + "cpp_type": "double" + }, + { + "name": "lat", + "nautilus_type": "double", + "cpp_type": "double" + }, + { + "name": "timestamp", + "nautilus_type": "uint64_t", + "cpp_type": "uint64_t" + }, + { + "name": "geometry", + "nautilus_type": "VariableSizedData", + "cpp_type": "const char*" + } + ], + "return_type": "int", + "nautilus_return": "INT32", + "build_temporal_point": true, + "comment_one_liner": "Per-event ever-disjoint between a single-instant tgeompoint built from event fields and a static geometry." + }, + { + "nebula_name": "TemporalATouchesGeometry", + "sql_token": "TEMPORAL_ATOUCHES_GEOMETRY", + "meos_call": "atouches_tgeo_geo", + "args": [ + { + "name": "lon", + "nautilus_type": "double", + "cpp_type": "double" + }, + { + "name": "lat", + "nautilus_type": "double", + "cpp_type": "double" + }, + { + "name": "timestamp", + "nautilus_type": "uint64_t", + "cpp_type": "uint64_t" + }, + { + "name": "geometry", + "nautilus_type": "VariableSizedData", + "cpp_type": "const char*" + } + ], + "return_type": "int", + "nautilus_return": "INT32", + "build_temporal_point": true, + "comment_one_liner": "Per-event always-touches between a single-instant tgeompoint and a static geometry." + }, + { + "nebula_name": "TemporalECoversGeometry", + "sql_token": "TEMPORAL_ECOVERS_GEOMETRY", + "meos_call": "ecovers_tgeo_geo", + "args": [ + { + "name": "lon", + "nautilus_type": "double", + "cpp_type": "double" + }, + { + "name": "lat", + "nautilus_type": "double", + "cpp_type": "double" + }, + { + "name": "timestamp", + "nautilus_type": "uint64_t", + "cpp_type": "uint64_t" + }, + { + "name": "geometry", + "nautilus_type": "VariableSizedData", + "cpp_type": "const char*" + } + ], + "return_type": "int", + "nautilus_return": "INT32", + "build_temporal_point": true, + "comment_one_liner": "Per-event ever-covers between a single-instant tgeompoint and a static geometry." + }, + { + "nebula_name": "TemporalAContainsGeometry", + "sql_token": "TEMPORAL_ACONTAINS_GEOMETRY", + "meos_call": "acontains_tgeo_geo", + "args": [ + { + "name": "lon", + "nautilus_type": "double", + "cpp_type": "double" + }, + { + "name": "lat", + "nautilus_type": "double", + "cpp_type": "double" + }, + { + "name": "timestamp", + "nautilus_type": "uint64_t", + "cpp_type": "uint64_t" + }, + { + "name": "geometry", + "nautilus_type": "VariableSizedData", + "cpp_type": "const char*" + } + ], + "return_type": "int", + "nautilus_return": "INT32", + "build_temporal_point": true, + "comment_one_liner": "Per-event always-contains between a single-instant tgeompoint and a static geometry." + }, + { + "nebula_name": "TemporalETouchesGeometry", + "sql_token": "TEMPORAL_ETOUCHES_GEOMETRY", + "meos_call": "etouches_tgeo_geo", + "args": [ + { + "name": "lon", + "nautilus_type": "double", + "cpp_type": "double" + }, + { + "name": "lat", + "nautilus_type": "double", + "cpp_type": "double" + }, + { + "name": "timestamp", + "nautilus_type": "uint64_t", + "cpp_type": "uint64_t" + }, + { + "name": "geometry", + "nautilus_type": "VariableSizedData", + "cpp_type": "const char*" + } + ], + "return_type": "int", + "nautilus_return": "INT32", + "build_temporal_point": true, + "comment_one_liner": "Per-event ever-touches between a single-instant tgeompoint and a static geometry." + } + ] +} diff --git a/tools/codegen/codegen_nebula.py b/tools/codegen/codegen_nebula.py new file mode 100644 index 0000000000..4851dd158b --- /dev/null +++ b/tools/codegen/codegen_nebula.py @@ -0,0 +1,2992 @@ +#!/usr/bin/env python3 +"""MobilityNebula MEOS-operator generator. + +Given a JSON descriptor list of MEOS scalar functions to wrap as +NebulaStream operators, emits the 4 pipeline-layer C++ files per +function (logical .hpp/.cpp + physical .hpp/.cpp) following the +established style of the existing hand-written operators (e.g. +TemporalEDWithinGeometryLogicalFunction), AND auto-injects: + +- per-op CMakeLists.txt entries in nes-{logical,physical}-operators/ + src/Functions/Meos/ +- AntlrSQL.g4 lexer-token + functionName-alternation entries +- AntlrSQLQueryPlanCreator.cpp #include + dispatch-case block + +Injection is idempotent — markers like +`/* BEGIN CODEGEN PARSER GLUE: */ … /* END CODEGEN PARSER GLUE */` +gate each per-op block, and the script skips on re-run when the marker +is already present. + +Usage: + python3 codegen_nebula.py --input codegen_input.example.json \\ + --output-root /path/to/MobilityNebula \\ + [--no-parser-glue] # skip .g4 + parser .cpp + [--no-cmake-entries] # skip CMakeLists.txt +""" +import argparse +import json +import re +import sys +from pathlib import Path + +# =========================================================================== +# Templates (mirror the hand-written TemporalEDWithinGeometry style 1:1). +# =========================================================================== + +LOGICAL_HPP_TEMPLATE = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES {{ + +/** + * @brief {comment_one_liner} + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `{meos_call}`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class {nebula_name}LogicalFunction : public LogicalFunctionConcept {{ +public: + static constexpr std::string_view NAME = "{nebula_name}"; + + {nebula_name}LogicalFunction({ctor_logical_args}); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}}; + +}} // namespace NES +""" + +LOGICAL_CPP_TEMPLATE = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{{ + +{nebula_name}LogicalFunction::{nebula_name}LogicalFunction({ctor_logical_args}) + : dataType(DataTypeProvider::provideDataType(DataType::Type::{nautilus_return})) +{{ + parameters.reserve({n_args}); +{ctor_logical_pushes} +}} + +DataType {nebula_name}LogicalFunction::getDataType() const +{{ + return dataType; +}} + +LogicalFunction {nebula_name}LogicalFunction::withDataType(const DataType& newDataType) const +{{ + auto copy = *this; + copy.dataType = newDataType; + return copy; +}} + +std::vector {nebula_name}LogicalFunction::getChildren() const +{{ + return parameters; +}} + +LogicalFunction {nebula_name}LogicalFunction::withChildren(const std::vector& children) const +{{ + PRECONDITION(children.size() == {n_args}, "{nebula_name}LogicalFunction requires {n_args} children, but got {{}}", children.size()); + auto copy = *this; + copy.parameters = children; + return copy; +}} + +std::string_view {nebula_name}LogicalFunction::getType() const +{{ + return NAME; +}} + +bool {nebula_name}LogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{{ + if (const auto* other = dynamic_cast(&rhs)) + {{ + return parameters == other->parameters; + }} + return false; +}} + +std::string {nebula_name}LogicalFunction::explain(ExplainVerbosity verbosity) const +{{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) + {{ + if (index > 0) + {{ + args += ", "; + }} + args += parameters[index].explain(verbosity); + }} + return fmt::format("{{}}({{}})", NAME, args); +}} + +LogicalFunction {nebula_name}LogicalFunction::withInferredDataType(const Schema& schema) const +{{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + {{ + newChildren.emplace_back(child.withInferredDataType(schema)); + }} + return withChildren(newChildren); +}} + +SerializableFunction {nebula_name}LogicalFunction::serialize() const +{{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + {{ + proto.add_children()->CopyFrom(child.serialize()); + }} + return proto; +}} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::Register{nebula_name}LogicalFunction( + LogicalFunctionRegistryArguments arguments) +{{ + PRECONDITION(arguments.children.size() == {n_args}, + "{nebula_name}LogicalFunction requires {n_args} children but got {{}}", + arguments.children.size()); +{registrar_pushes} +}} + +}} // namespace NES +""" + +PHYSICAL_HPP_TEMPLATE = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES {{ + +/** + * @brief Physical operator for `{meos_call}`. + * + * {comment_one_liner} + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class {nebula_name}PhysicalFunction : public PhysicalFunctionConcept {{ +public: + {nebula_name}PhysicalFunction({ctor_physical_args}); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}}; + +}} // namespace NES +""" + +# Physical .cpp template; the `body` placeholder is the MEOS-call body +# (the heart of the operator). For `build_temporal_point` operators +# we emit a per-event temporal-point build + MEOS call, mirroring +# TemporalEDWithinGeometry; for non-temporal-point operators (future +# templates) the body shape differs and a separate template branch +# would be added here. +PHYSICAL_CPP_TEMPLATE_TEMPORAL_POINT = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" {{ +#include +#include +}} + +namespace NES {{ + +{nebula_name}PhysicalFunction::{nebula_name}PhysicalFunction({ctor_physical_args}) +{{ + parameterFunctions.reserve({n_args}); +{ctor_physical_pushes} +}} + +VarVal {nebula_name}PhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + {{ + parameterValues.emplace_back(function.execute(record, arena)); + }} + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto timestamp = parameterValues[2].cast>(); + auto geometry = parameterValues[3].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + uint64_t timestampValue, + const char* geometryPtr, + uint32_t geometrySize) -> {return_type} {{ + try + {{ + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) {{ + return 0; + }} + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string temporalGeometryWkt = fmt::format("SRID=4326;Point({{}} {{}})@{{}}", lonValue, latValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (temporalGeometryWkt.empty() || staticGeometryWkt.empty()) + return 0; + + MEOS::Meos::TemporalGeometry temporalGeometry(temporalGeometryWkt); + if (!temporalGeometry.getGeometry()) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) return 0; + + // MEOS spatial-relation call — same shape as TemporalEDWithin's + // edwithin_tgeo_geo, but specific MEOS function per generated operator. + // Real MEOS spatial-rel signature: int fn(const Temporal *, const GSERIALIZED *) + // (no `atstart` flag — that's specific to geog_dwithin / edwithin's 3-arg variant). + return {meos_call}(temporalGeometry.getGeometry(), + staticGeometry.getGeometry()); + }} + catch (const std::exception&) + {{ + return 0; + }} + }}, + lon, lat, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +}} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::Register{nebula_name}PhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{{ + PRECONDITION(arguments.childFunctions.size() == {n_args}, + "{nebula_name}PhysicalFunction requires {n_args} children but got {{}}", + arguments.childFunctions.size()); +{registrar_pushes} +}} + +}} // namespace NES +""" + +# Physical .cpp template for two-temporal-points operators (e.g. *_tgeo_tgeo +# spatial-relations). Two single-instant tgeompoints are built from event +# fields (lonA/latA/tsA + lonB/latB/tsB) and passed to a MEOS function whose +# C signature is `int fn(const Temporal*, const Temporal*)`. Mirrors the +# one-temporal-point template above; the bodies differ only in arg shape +# and in the absence of a static-geometry argument. +PHYSICAL_CPP_TEMPLATE_TWO_TEMPORAL_POINTS = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" {{ +#include +#include +}} + +namespace NES {{ + +{nebula_name}PhysicalFunction::{nebula_name}PhysicalFunction({ctor_physical_args}) +{{ + parameterFunctions.reserve({n_args}); +{ctor_physical_pushes} +}} + +VarVal {nebula_name}PhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + {{ + parameterValues.emplace_back(function.execute(record, arena)); + }} + + auto lonA = parameterValues[0].cast>(); + auto latA = parameterValues[1].cast>(); + auto tsA = parameterValues[2].cast>(); + auto lonB = parameterValues[3].cast>(); + auto latB = parameterValues[4].cast>(); + auto tsB = parameterValues[5].cast>(); + + const auto result = nautilus::invoke( + +[](double lonAValue, double latAValue, uint64_t tsAValue, + double lonBValue, double latBValue, uint64_t tsBValue) -> {return_type} {{ + try + {{ + MEOS::Meos::ensureMeosInitialized(); + if (!(lonAValue >= -180.0 && lonAValue <= 180.0 && latAValue >= -90.0 && latAValue <= 90.0)) return 0; + if (!(lonBValue >= -180.0 && lonBValue <= 180.0 && latBValue >= -90.0 && latBValue <= 90.0)) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string temporalGeometryAWkt = fmt::format("SRID=4326;Point({{}} {{}})@{{}}", lonAValue, latAValue, tsAString); + std::string temporalGeometryBWkt = fmt::format("SRID=4326;Point({{}} {{}})@{{}}", lonBValue, latBValue, tsBString); + + MEOS::Meos::TemporalGeometry temporalGeometryA(temporalGeometryAWkt); + if (!temporalGeometryA.getGeometry()) return 0; + MEOS::Meos::TemporalGeometry temporalGeometryB(temporalGeometryBWkt); + if (!temporalGeometryB.getGeometry()) return 0; + + // MEOS *_tgeo_tgeo spatial-relation: int fn(const Temporal*, const Temporal*). + return {meos_call}(temporalGeometryA.getGeometry(), + temporalGeometryB.getGeometry()); + }} + catch (const std::exception&) + {{ + return 0; + }} + }}, + lonA, latA, tsA, lonB, latB, tsB); + + return VarVal(result); +}} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::Register{nebula_name}PhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{{ + PRECONDITION(arguments.childFunctions.size() == {n_args}, + "{nebula_name}PhysicalFunction requires {n_args} children but got {{}}", + arguments.childFunctions.size()); +{registrar_pushes} +}} + +}} // namespace NES +""" + + +# Physical .cpp template for one-temporal-point operators with a trailing +# `double dist` argument (e.g. edwithin_tgeo_geo / adwithin_tgeo_geo). Same +# layout as PHYSICAL_CPP_TEMPLATE_TEMPORAL_POINT but the MEOS call passes +# `dist` as the 3rd argument. +PHYSICAL_CPP_TEMPLATE_TEMPORAL_POINT_WITH_DIST = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" {{ +#include +#include +}} + +namespace NES {{ + +{nebula_name}PhysicalFunction::{nebula_name}PhysicalFunction({ctor_physical_args}) +{{ + parameterFunctions.reserve({n_args}); +{ctor_physical_pushes} +}} + +VarVal {nebula_name}PhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + {{ + parameterValues.emplace_back(function.execute(record, arena)); + }} + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto timestamp = parameterValues[2].cast>(); + auto geometry = parameterValues[3].cast(); + auto dist = parameterValues[4].cast>(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + uint64_t timestampValue, + const char* geometryPtr, + uint32_t geometrySize, + double distValue) -> {return_type} {{ + try + {{ + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string temporalGeometryWkt = fmt::format("SRID=4326;Point({{}} {{}})@{{}}", lonValue, latValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (temporalGeometryWkt.empty() || staticGeometryWkt.empty()) return 0; + + MEOS::Meos::TemporalGeometry temporalGeometry(temporalGeometryWkt); + if (!temporalGeometry.getGeometry()) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) return 0; + + // MEOS *_tgeo_geo with trailing distance arg + // — int fn(const Temporal*, const GSERIALIZED*, double). + return {meos_call}(temporalGeometry.getGeometry(), + staticGeometry.getGeometry(), + distValue); + }} + catch (const std::exception&) + {{ + return 0; + }} + }}, + lon, lat, timestamp, geometry.getContent(), geometry.getContentSize(), dist); + + return VarVal(result); +}} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::Register{nebula_name}PhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{{ + PRECONDITION(arguments.childFunctions.size() == {n_args}, + "{nebula_name}PhysicalFunction requires {n_args} children but got {{}}", + arguments.childFunctions.size()); +{registrar_pushes} +}} + +}} // namespace NES +""" + +# Physical .cpp template for two-temporal-points operators with a trailing +# `double dist` argument (edwithin_tgeo_tgeo / adwithin_tgeo_tgeo). +PHYSICAL_CPP_TEMPLATE_TWO_TEMPORAL_POINTS_WITH_DIST = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" {{ +#include +#include +}} + +namespace NES {{ + +{nebula_name}PhysicalFunction::{nebula_name}PhysicalFunction({ctor_physical_args}) +{{ + parameterFunctions.reserve({n_args}); +{ctor_physical_pushes} +}} + +VarVal {nebula_name}PhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + {{ + parameterValues.emplace_back(function.execute(record, arena)); + }} + + auto lonA = parameterValues[0].cast>(); + auto latA = parameterValues[1].cast>(); + auto tsA = parameterValues[2].cast>(); + auto lonB = parameterValues[3].cast>(); + auto latB = parameterValues[4].cast>(); + auto tsB = parameterValues[5].cast>(); + auto dist = parameterValues[6].cast>(); + + const auto result = nautilus::invoke( + +[](double lonAValue, double latAValue, uint64_t tsAValue, + double lonBValue, double latBValue, uint64_t tsBValue, + double distValue) -> {return_type} {{ + try + {{ + MEOS::Meos::ensureMeosInitialized(); + if (!(lonAValue >= -180.0 && lonAValue <= 180.0 && latAValue >= -90.0 && latAValue <= 90.0)) return 0; + if (!(lonBValue >= -180.0 && lonBValue <= 180.0 && latBValue >= -90.0 && latBValue <= 90.0)) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string temporalGeometryAWkt = fmt::format("SRID=4326;Point({{}} {{}})@{{}}", lonAValue, latAValue, tsAString); + std::string temporalGeometryBWkt = fmt::format("SRID=4326;Point({{}} {{}})@{{}}", lonBValue, latBValue, tsBString); + + MEOS::Meos::TemporalGeometry temporalGeometryA(temporalGeometryAWkt); + if (!temporalGeometryA.getGeometry()) return 0; + MEOS::Meos::TemporalGeometry temporalGeometryB(temporalGeometryBWkt); + if (!temporalGeometryB.getGeometry()) return 0; + + // MEOS *_tgeo_tgeo with trailing distance arg + // — int fn(const Temporal*, const Temporal*, double). + return {meos_call}(temporalGeometryA.getGeometry(), + temporalGeometryB.getGeometry(), + distValue); + }} + catch (const std::exception&) + {{ + return 0; + }} + }}, + lonA, latA, tsA, lonB, latB, tsB, dist); + + return VarVal(result); +}} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::Register{nebula_name}PhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{{ + PRECONDITION(arguments.childFunctions.size() == {n_args}, + "{nebula_name}PhysicalFunction requires {n_args} children but got {{}}", + arguments.childFunctions.size()); +{registrar_pushes} +}} + +}} // namespace NES +""" + + +def cpp_logical_type(arg): + """C++ constructor-arg type for a LogicalFunction parameter.""" + return "LogicalFunction" + + +def cpp_physical_type(arg): + """C++ constructor-arg type for a PhysicalFunction parameter.""" + return "PhysicalFunction" + + +def build_ctor_args(args, type_fn): + return ",\n ".join( + f"{type_fn(a)} {a['name']}" for a in args + ) + + +def build_pushes_logical(args): + return "\n".join(f" parameters.push_back(std::move({a['name']}));" for a in args) + + +def build_pushes_physical(args): + return "\n".join( + f" parameterFunctions.push_back(std::move({a['name']}Function));" for a in args + ) + + +def build_registrar_pushes_logical(args, nebula_name): + pushes = [] + for i, _ in enumerate(args): + pushes.append(f" auto arg{i} = std::move(arguments.children[{i}]);") + pushes.append( + f" return {nebula_name}LogicalFunction(" + ", ".join(f"std::move(arg{i})" for i in range(len(args))) + ");" + ) + return "\n".join(pushes) + + +def build_registrar_pushes_physical(args, nebula_name): + pushes = [] + for i, _ in enumerate(args): + # PhysicalFunctionRegistryArguments uses `childFunctions`, not `children` + # (LogicalFunctionRegistryArguments uses `children` — see registry headers). + pushes.append(f" auto arg{i} = std::move(arguments.childFunctions[{i}]);") + pushes.append( + f" return {nebula_name}PhysicalFunction(" + ", ".join(f"std::move(arg{i})" for i in range(len(args))) + ");" + ) + return "\n".join(pushes) + + +def emit_operator(op, output_root: Path): + nebula_name = op["nebula_name"] + n_args = len(op["args"]) + + # Logical .hpp constructor args (LogicalFunction type each) + ctor_logical_args = build_ctor_args(op["args"], cpp_logical_type) + # Physical .hpp / .cpp constructor args use 'XxxFunction' naming convention + physical_args = [{"name": a["name"] + "Function"} for a in op["args"]] + ctor_physical_args = ",\n ".join( + f"PhysicalFunction {a['name']}" for a in physical_args + ) + + ctor_logical_pushes = build_pushes_logical(op["args"]) + ctor_physical_pushes = build_pushes_physical(op["args"]) + registrar_l = build_registrar_pushes_logical(op["args"], nebula_name) + registrar_p = build_registrar_pushes_physical(op["args"], nebula_name) + + common = { + "nebula_name": nebula_name, + "comment_one_liner": op["comment_one_liner"], + "meos_call": op["meos_call"], + "n_args": n_args, + "nautilus_return": op["nautilus_return"], + "return_type": op["return_type"], + "ctor_logical_args": ctor_logical_args, + "ctor_physical_args": ctor_physical_args, + "ctor_logical_pushes": ctor_logical_pushes, + "ctor_physical_pushes": ctor_physical_pushes, + "registrar_pushes": registrar_l, + # tnumber-shape extras (only consumed by the two tnumber templates). + # tnumber_wkt_format is a fmt::format pattern that ends up in C++ as-is; + # Python single-pass .format() means we want raw `{}@{}` here (no doubling). + "tnumber_value_cpp_type": op.get("tnumber_value_cpp_type", "double"), + "scalar_cpp_type": op.get("scalar_cpp_type", "double"), + "tnumber_wkt_format": op.get("tnumber_wkt_format", "{}@{}"), + "tnumber_in_fn": op.get("tnumber_in_fn", "tfloat_in"), + } + + logical_hpp_path = output_root / "nes-logical-operators/include/Functions/Meos" / f"{nebula_name}LogicalFunction.hpp" + logical_cpp_path = output_root / "nes-logical-operators/src/Functions/Meos" / f"{nebula_name}LogicalFunction.cpp" + physical_hpp_path = output_root / "nes-physical-operators/include/Functions/Meos" / f"{nebula_name}PhysicalFunction.hpp" + physical_cpp_path = output_root / "nes-physical-operators/src/Functions/Meos" / f"{nebula_name}PhysicalFunction.cpp" + + for p in (logical_hpp_path, logical_cpp_path, physical_hpp_path, physical_cpp_path): + p.parent.mkdir(parents=True, exist_ok=True) + + logical_hpp_path.write_text(LOGICAL_HPP_TEMPLATE.format(**common)) + logical_cpp_path.write_text(LOGICAL_CPP_TEMPLATE.format(**common)) + physical_hpp_path.write_text(PHYSICAL_HPP_TEMPLATE.format(**common)) + + physical_common = dict(common) + physical_common["registrar_pushes"] = registrar_p + if op.get("build_two_temporal_points_with_dist"): + physical_cpp_path.write_text(PHYSICAL_CPP_TEMPLATE_TWO_TEMPORAL_POINTS_WITH_DIST.format(**physical_common)) + elif op.get("build_temporal_point_with_dist"): + physical_cpp_path.write_text(PHYSICAL_CPP_TEMPLATE_TEMPORAL_POINT_WITH_DIST.format(**physical_common)) + elif op.get("build_two_temporal_points"): + physical_cpp_path.write_text(PHYSICAL_CPP_TEMPLATE_TWO_TEMPORAL_POINTS.format(**physical_common)) + elif op.get("build_temporal_point_restriction"): + physical_cpp_path.write_text(PHYSICAL_CPP_TEMPLATE_TEMPORAL_POINT_RESTRICTION.format(**physical_common)) + elif op.get("build_two_tpose_points_via_composition"): + physical_cpp_path.write_text(PHYSICAL_CPP_TEMPLATE_TWO_TPOSE_POINTS_VIA_COMPOSITION.format(**physical_common)) + elif op.get("build_tpose_point_via_composition"): + physical_cpp_path.write_text(PHYSICAL_CPP_TEMPLATE_TPOSE_POINT_VIA_COMPOSITION.format(**physical_common)) + elif op.get("build_two_tnpoint_points_via_composition"): + physical_cpp_path.write_text(PHYSICAL_CPP_TEMPLATE_TWO_TNPOINT_POINTS_VIA_COMPOSITION.format(**physical_common)) + elif op.get("build_tnpoint_point_via_composition"): + physical_cpp_path.write_text(PHYSICAL_CPP_TEMPLATE_TNPOINT_POINT_VIA_COMPOSITION.format(**physical_common)) + elif op.get("build_two_tcbuffer_points_with_dist"): + physical_cpp_path.write_text(PHYSICAL_CPP_TEMPLATE_TWO_TCBUFFER_POINTS_WITH_DIST.format(**physical_common)) + elif op.get("build_tcbuffer_point_cbuffer_with_dist"): + physical_cpp_path.write_text(PHYSICAL_CPP_TEMPLATE_TCBUFFER_POINT_CBUFFER_WITH_DIST.format(**physical_common)) + elif op.get("build_tcbuffer_point_with_dist"): + physical_cpp_path.write_text(PHYSICAL_CPP_TEMPLATE_TCBUFFER_POINT_WITH_DIST.format(**physical_common)) + elif op.get("build_two_tcbuffer_points"): + physical_cpp_path.write_text(PHYSICAL_CPP_TEMPLATE_TWO_TCBUFFER_POINTS.format(**physical_common)) + elif op.get("build_tcbuffer_point_cbuffer"): + physical_cpp_path.write_text(PHYSICAL_CPP_TEMPLATE_TCBUFFER_POINT_CBUFFER.format(**physical_common)) + elif op.get("build_tcbuffer_point"): + physical_cpp_path.write_text(PHYSICAL_CPP_TEMPLATE_TCBUFFER_POINT.format(**physical_common)) + elif op.get("build_temporal_point"): + physical_cpp_path.write_text(PHYSICAL_CPP_TEMPLATE_TEMPORAL_POINT.format(**physical_common)) + elif op.get("build_tnumber_point_with_scalar"): + physical_cpp_path.write_text(PHYSICAL_CPP_TEMPLATE_TNUMBER_POINT_WITH_SCALAR.format(**physical_common)) + elif op.get("build_two_tnumber_points"): + physical_cpp_path.write_text(PHYSICAL_CPP_TEMPLATE_TWO_TNUMBER_POINTS.format(**physical_common)) + else: + sys.stderr.write( + f" ! {nebula_name}: physical-cpp template for non-temporal-point ops is not yet implemented; " + f"skipping .cpp — the .hpp + logical files are still emitted, but the .cpp must be hand-written.\n" + ) + + sys.stderr.write(f" ✓ {nebula_name}: emitted 4 files ({logical_hpp_path.relative_to(output_root)} + siblings)\n") + + +# Physical .cpp template for one-temporal-point restriction operators — +# MEOS signature `Temporal* fn(const Temporal*, const GSERIALIZED*)`. The +# returned Temporal* is checked for non-null (i.e. survived the restriction), +# freed, and reduced to an int (1 = survives, 0 = clipped/null/error). +# Per-event single-instant semantics: equivalent to a filter predicate. +# Mirrors mariana's TemporalAtStBox int-collapse pattern. +PHYSICAL_CPP_TEMPLATE_TEMPORAL_POINT_RESTRICTION = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" {{ +#include +#include +}} + +namespace NES {{ + +{nebula_name}PhysicalFunction::{nebula_name}PhysicalFunction({ctor_physical_args}) +{{ + parameterFunctions.reserve({n_args}); +{ctor_physical_pushes} +}} + +VarVal {nebula_name}PhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + {{ + parameterValues.emplace_back(function.execute(record, arena)); + }} + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto timestamp = parameterValues[2].cast>(); + auto geometry = parameterValues[3].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + uint64_t timestampValue, + const char* geometryPtr, + uint32_t geometrySize) -> {return_type} {{ + try + {{ + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string temporalGeometryWkt = fmt::format("SRID=4326;Point({{}} {{}})@{{}}", lonValue, latValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (temporalGeometryWkt.empty() || staticGeometryWkt.empty()) return 0; + + MEOS::Meos::TemporalGeometry temporalGeometry(temporalGeometryWkt); + if (!temporalGeometry.getGeometry()) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) return 0; + + // MEOS restriction call — returns Temporal* (non-null if the + // input survived the restriction, null if clipped/empty). + // For per-event single-instant inputs this collapses to a + // filter predicate: 1 if the point survives, 0 if clipped. + Temporal* clipped = {meos_call}(temporalGeometry.getGeometry(), + staticGeometry.getGeometry()); + if (clipped == nullptr) return 0; + free(clipped); + return 1; + }} + catch (const std::exception&) + {{ + return 0; + }} + }}, + lon, lat, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +}} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::Register{nebula_name}PhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{{ + PRECONDITION(arguments.childFunctions.size() == {n_args}, + "{nebula_name}PhysicalFunction requires {n_args} children but got {{}}", + arguments.childFunctions.size()); +{registrar_pushes} +}} + +}} // namespace NES +""" + + +# Physical .cpp template for one-tcbuffer-point operators with a static +# geometry — e.g. econtains_tcbuffer_geo. The MEOS call signature is +# ` fn(const Temporal*, const GSERIALIZED*)` where the Temporal is a +# tcbuffer (Cbuffer instant) built per-event from (lon, lat, radius, ts). +# WKT format: "Cbuffer(Point(lon lat),radius)@ts". +# 5 SQL args: lon, lat, radius, ts, geometry. +PHYSICAL_CPP_TEMPLATE_TCBUFFER_POINT = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" {{ +#include +#include +}} + +namespace NES {{ + +{nebula_name}PhysicalFunction::{nebula_name}PhysicalFunction({ctor_physical_args}) +{{ + parameterFunctions.reserve({n_args}); +{ctor_physical_pushes} +}} + +VarVal {nebula_name}PhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + {{ + parameterValues.emplace_back(function.execute(record, arena)); + }} + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto geometry = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + double radiusValue, + uint64_t timestampValue, + const char* geometryPtr, + uint32_t geometrySize) -> {return_type} {{ + try + {{ + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({{}} {{}}),{{}})@{{}}", + lonValue, latValue, radiusValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tcbufferWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) {{ free(tcbuffer); return 0; }} + + {return_type} r = {meos_call}(tcbuffer, staticGeometry.getGeometry()); + free(tcbuffer); + return r; + }} + catch (const std::exception&) + {{ + return 0; + }} + }}, + lon, lat, radius, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +}} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::Register{nebula_name}PhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{{ + PRECONDITION(arguments.childFunctions.size() == {n_args}, + "{nebula_name}PhysicalFunction requires {n_args} children but got {{}}", + arguments.childFunctions.size()); +{registrar_pushes} +}} + +}} // namespace NES +""" + + +# Physical .cpp template for tpose × static geom spatial-rels VIA +# COMPOSITION — the existing _tgeo_geo MEOS call is applied to a tpose +# converted to tgeompoint at run time. Per-event tpose instant from +# (x, y, theta, ts), then tpose_to_tpoint(), then the MEOS spatial-rel +# call. Matches MobilityDB PR #987's SQL-level composition recipe at the +# binding layer (no new MEOS spatial-rel symbols are needed for tpose). +# 5 SQL args: x, y, theta, ts, geometry. +PHYSICAL_CPP_TEMPLATE_TPOSE_POINT_VIA_COMPOSITION = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" {{ +#include +#include +#include +}} + +namespace NES {{ + +{nebula_name}PhysicalFunction::{nebula_name}PhysicalFunction({ctor_physical_args}) +{{ + parameterFunctions.reserve({n_args}); +{ctor_physical_pushes} +}} + +VarVal {nebula_name}PhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + {{ + parameterValues.emplace_back(function.execute(record, arena)); + }} + + auto x = parameterValues[0].cast>(); + auto y = parameterValues[1].cast>(); + auto theta = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto geometry = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double xValue, double yValue, double thetaValue, uint64_t timestampValue, + const char* geometryPtr, uint32_t geometrySize) -> {return_type} {{ + try + {{ + MEOS::Meos::ensureMeosInitialized(); + if (!(xValue >= -180.0 && xValue <= 180.0 && yValue >= -90.0 && yValue <= 90.0)) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tposeWkt = fmt::format("Pose(Point({{}} {{}}), {{}})@{{}}", + xValue, yValue, thetaValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tposeWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tpose = tpose_in(tposeWkt.c_str()); + if (!tpose) return 0; + Temporal* tgeo = tpose_to_tpoint(tpose); + if (!tgeo) {{ free(tpose); return 0; }} + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) {{ free(tgeo); free(tpose); return 0; }} + + {return_type} r = {meos_call}(tgeo, staticGeometry.getGeometry()); + free(tgeo); + free(tpose); + return r; + }} + catch (const std::exception&) + {{ + return 0; + }} + }}, + x, y, theta, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +}} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::Register{nebula_name}PhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{{ + PRECONDITION(arguments.childFunctions.size() == {n_args}, + "{nebula_name}PhysicalFunction requires {n_args} children but got {{}}", + arguments.childFunctions.size()); +{registrar_pushes} +}} + +}} // namespace NES +""" + + +# Physical .cpp template for tpose × tpose spatial-rels VIA COMPOSITION — +# the existing _tgeo_tgeo MEOS call is applied to two tposes each converted +# to a single-instant tgeompoint at run time. Per-event tpose instants from +# (xA, yA, thetaA, tsA) and (xB, yB, thetaB, tsB), each tpose_in() then +# tpose_to_tpoint(), then the MEOS two-temporal spatial-rel call. Mirrors the +# W14 one-tpose composition recipe; no new MEOS symbols are needed for tpose +# (the _tgeo_tgeo row was shipped in W3). 8 SQL args. +PHYSICAL_CPP_TEMPLATE_TWO_TPOSE_POINTS_VIA_COMPOSITION = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" {{ +#include +#include +#include +}} + +namespace NES {{ + +{nebula_name}PhysicalFunction::{nebula_name}PhysicalFunction({ctor_physical_args}) +{{ + parameterFunctions.reserve({n_args}); +{ctor_physical_pushes} +}} + +VarVal {nebula_name}PhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + {{ + parameterValues.emplace_back(function.execute(record, arena)); + }} + + auto xA = parameterValues[0].cast>(); + auto yA = parameterValues[1].cast>(); + auto thetaA = parameterValues[2].cast>(); + auto tsA = parameterValues[3].cast>(); + auto xB = parameterValues[4].cast>(); + auto yB = parameterValues[5].cast>(); + auto thetaB = parameterValues[6].cast>(); + auto tsB = parameterValues[7].cast>(); + + const auto result = nautilus::invoke( + +[](double xAValue, double yAValue, double thetaAValue, uint64_t tsAValue, + double xBValue, double yBValue, double thetaBValue, uint64_t tsBValue) -> {return_type} {{ + try + {{ + MEOS::Meos::ensureMeosInitialized(); + if (!(xAValue >= -180.0 && xAValue <= 180.0 && yAValue >= -90.0 && yAValue <= 90.0)) return 0; + if (!(xBValue >= -180.0 && xBValue <= 180.0 && yBValue >= -90.0 && yBValue <= 90.0)) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string tposeAWkt = fmt::format("Pose(Point({{}} {{}}), {{}})@{{}}", xAValue, yAValue, thetaAValue, tsAString); + std::string tposeBWkt = fmt::format("Pose(Point({{}} {{}}), {{}})@{{}}", xBValue, yBValue, thetaBValue, tsBString); + + if (tposeAWkt.empty() || tposeBWkt.empty()) return 0; + + Temporal* tposeA = tpose_in(tposeAWkt.c_str()); + if (!tposeA) return 0; + Temporal* tgeoA = tpose_to_tpoint(tposeA); + if (!tgeoA) {{ free(tposeA); return 0; }} + Temporal* tposeB = tpose_in(tposeBWkt.c_str()); + if (!tposeB) {{ free(tgeoA); free(tposeA); return 0; }} + Temporal* tgeoB = tpose_to_tpoint(tposeB); + if (!tgeoB) {{ free(tposeB); free(tgeoA); free(tposeA); return 0; }} + + {return_type} r = {meos_call}(tgeoA, tgeoB); + free(tgeoB); + free(tposeB); + free(tgeoA); + free(tposeA); + return r; + }} + catch (const std::exception&) + {{ + return 0; + }} + }}, + xA, yA, thetaA, tsA, xB, yB, thetaB, tsB); + + return VarVal(result); +}} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::Register{nebula_name}PhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{{ + PRECONDITION(arguments.childFunctions.size() == {n_args}, + "{nebula_name}PhysicalFunction requires {n_args} children but got {{}}", + arguments.childFunctions.size()); +{registrar_pushes} +}} + +}} // namespace NES +""" + + +# Physical .cpp template for tnpoint × static geom spatial-rels VIA +# COMPOSITION — a temporal network point is resolved to a temporal +# geometry point at run time (tnpoint_to_tgeompoint, which looks up each +# route's geometry from the MEOS ways network), then the existing +# _tgeo_geo spatial-rel is applied. Same shape as the tpose composition +# (W14); no new MEOS spatial-rel symbols are needed for tnpoint. +# NOTE: tnpoint_to_tgeompoint yields a tgeompoint in the *network* SRID, +# so the static geometry must use that SRID (else MEOS errors on mixed +# SRID). 4 SQL args: rid, fraction, ts, geometry. +PHYSICAL_CPP_TEMPLATE_TNPOINT_POINT_VIA_COMPOSITION = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" {{ +#include +#include +#include +}} + +namespace NES {{ + +{nebula_name}PhysicalFunction::{nebula_name}PhysicalFunction({ctor_physical_args}) +{{ + parameterFunctions.reserve({n_args}); +{ctor_physical_pushes} +}} + +VarVal {nebula_name}PhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + {{ + parameterValues.emplace_back(function.execute(record, arena)); + }} + + auto rid = parameterValues[0].cast>(); + auto fraction = parameterValues[1].cast>(); + auto timestamp = parameterValues[2].cast>(); + auto geometry = parameterValues[3].cast(); + + const auto result = nautilus::invoke( + +[](uint64_t ridValue, double fractionValue, uint64_t timestampValue, + const char* geometryPtr, uint32_t geometrySize) -> {return_type} {{ + try + {{ + MEOS::Meos::ensureMeosInitialized(); + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tnpointWkt = fmt::format("NPoint({{}}, {{}})@{{}}", ridValue, fractionValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tnpointWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tnpoint = tnpoint_in(tnpointWkt.c_str()); + if (!tnpoint) return 0; + Temporal* tgeo = tnpoint_to_tgeompoint(tnpoint); + if (!tgeo) {{ free(tnpoint); return 0; }} + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) {{ free(tgeo); free(tnpoint); return 0; }} + + {return_type} r = {meos_call}(tgeo, staticGeometry.getGeometry()); + free(tgeo); + free(tnpoint); + return r; + }} + catch (const std::exception&) + {{ + return 0; + }} + }}, + rid, fraction, timestamp, geometry.getContent(), geometry.getContentSize()); + + return VarVal(result); +}} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::Register{nebula_name}PhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{{ + PRECONDITION(arguments.childFunctions.size() == {n_args}, + "{nebula_name}PhysicalFunction requires {n_args} children but got {{}}", + arguments.childFunctions.size()); +{registrar_pushes} +}} + +}} // namespace NES +""" + + +# Physical .cpp template for tnpoint × tnpoint spatial-rels VIA +# COMPOSITION — two temporal network points each resolved to a temporal +# geometry point (tnpoint_to_tgeompoint), then the existing _tgeo_tgeo +# spatial-rel (W3) is applied. Both operands land in the network SRID, so +# no mixed-SRID concern (unlike tnpoint × static geom). 6 SQL args: +# ridA, fracA, tsA, ridB, fracB, tsB. +PHYSICAL_CPP_TEMPLATE_TWO_TNPOINT_POINTS_VIA_COMPOSITION = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" {{ +#include +#include +#include +}} + +namespace NES {{ + +{nebula_name}PhysicalFunction::{nebula_name}PhysicalFunction({ctor_physical_args}) +{{ + parameterFunctions.reserve({n_args}); +{ctor_physical_pushes} +}} + +VarVal {nebula_name}PhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + {{ + parameterValues.emplace_back(function.execute(record, arena)); + }} + + auto ridA = parameterValues[0].cast>(); + auto fractionA = parameterValues[1].cast>(); + auto tsA = parameterValues[2].cast>(); + auto ridB = parameterValues[3].cast>(); + auto fractionB = parameterValues[4].cast>(); + auto tsB = parameterValues[5].cast>(); + + const auto result = nautilus::invoke( + +[](uint64_t ridAValue, double fractionAValue, uint64_t tsAValue, + uint64_t ridBValue, double fractionBValue, uint64_t tsBValue) -> {return_type} {{ + try + {{ + MEOS::Meos::ensureMeosInitialized(); + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string tnpointAWkt = fmt::format("NPoint({{}}, {{}})@{{}}", ridAValue, fractionAValue, tsAString); + std::string tnpointBWkt = fmt::format("NPoint({{}}, {{}})@{{}}", ridBValue, fractionBValue, tsBString); + + if (tnpointAWkt.empty() || tnpointBWkt.empty()) return 0; + + Temporal* tnpointA = tnpoint_in(tnpointAWkt.c_str()); + if (!tnpointA) return 0; + Temporal* tgeoA = tnpoint_to_tgeompoint(tnpointA); + if (!tgeoA) {{ free(tnpointA); return 0; }} + Temporal* tnpointB = tnpoint_in(tnpointBWkt.c_str()); + if (!tnpointB) {{ free(tgeoA); free(tnpointA); return 0; }} + Temporal* tgeoB = tnpoint_to_tgeompoint(tnpointB); + if (!tgeoB) {{ free(tnpointB); free(tgeoA); free(tnpointA); return 0; }} + + {return_type} r = {meos_call}(tgeoA, tgeoB); + free(tgeoB); + free(tnpointB); + free(tgeoA); + free(tnpointA); + return r; + }} + catch (const std::exception&) + {{ + return 0; + }} + }}, + ridA, fractionA, tsA, ridB, fractionB, tsB); + + return VarVal(result); +}} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::Register{nebula_name}PhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{{ + PRECONDITION(arguments.childFunctions.size() == {n_args}, + "{nebula_name}PhysicalFunction requires {n_args} children but got {{}}", + arguments.childFunctions.size()); +{registrar_pushes} +}} + +}} // namespace NES +""" + + +# Physical .cpp template for one-tcbuffer-point + static geom + dist — +# e.g. edwithin_tcbuffer_geo. Same per-event tcbuffer construction as +# PHYSICAL_CPP_TEMPLATE_TCBUFFER_POINT but trailing `double dist`. +# 6 SQL args: lon, lat, radius, ts, geometry, dist. +PHYSICAL_CPP_TEMPLATE_TCBUFFER_POINT_WITH_DIST = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" {{ +#include +#include +}} + +namespace NES {{ + +{nebula_name}PhysicalFunction::{nebula_name}PhysicalFunction({ctor_physical_args}) +{{ + parameterFunctions.reserve({n_args}); +{ctor_physical_pushes} +}} + +VarVal {nebula_name}PhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + {{ + parameterValues.emplace_back(function.execute(record, arena)); + }} + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto geometry = parameterValues[4].cast(); + auto dist = parameterValues[5].cast>(); + + const auto result = nautilus::invoke( + +[](double lonValue, double latValue, double radiusValue, uint64_t timestampValue, + const char* geometryPtr, uint32_t geometrySize, double distValue) -> {return_type} {{ + try + {{ + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({{}} {{}}),{{}})@{{}}", + lonValue, latValue, radiusValue, timestampString); + std::string staticGeometryWkt(geometryPtr, geometrySize); + + while (!staticGeometryWkt.empty() && (staticGeometryWkt.front() == '\\'' || staticGeometryWkt.front() == '"')) + staticGeometryWkt.erase(staticGeometryWkt.begin()); + while (!staticGeometryWkt.empty() && (staticGeometryWkt.back() == '\\'' || staticGeometryWkt.back() == '"')) + staticGeometryWkt.pop_back(); + + if (tcbufferWkt.empty() || staticGeometryWkt.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + MEOS::Meos::StaticGeometry staticGeometry(staticGeometryWkt); + if (!staticGeometry.getGeometry()) {{ free(tcbuffer); return 0; }} + + {return_type} r = {meos_call}(tcbuffer, staticGeometry.getGeometry(), distValue); + free(tcbuffer); + return r; + }} + catch (const std::exception&) + {{ + return 0; + }} + }}, + lon, lat, radius, timestamp, geometry.getContent(), geometry.getContentSize(), dist); + + return VarVal(result); +}} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::Register{nebula_name}PhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{{ + PRECONDITION(arguments.childFunctions.size() == {n_args}, + "{nebula_name}PhysicalFunction requires {n_args} children but got {{}}", + arguments.childFunctions.size()); +{registrar_pushes} +}} + +}} // namespace NES +""" + +# Physical .cpp template for one-tcbuffer-point + static Cbuffer + dist — +# e.g. edwithin_tcbuffer_cbuffer. +# 6 SQL args: lon, lat, radius, ts, cbufferLiteral, dist. +PHYSICAL_CPP_TEMPLATE_TCBUFFER_POINT_CBUFFER_WITH_DIST = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" {{ +#include +#include +}} + +namespace NES {{ + +{nebula_name}PhysicalFunction::{nebula_name}PhysicalFunction({ctor_physical_args}) +{{ + parameterFunctions.reserve({n_args}); +{ctor_physical_pushes} +}} + +VarVal {nebula_name}PhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + {{ + parameterValues.emplace_back(function.execute(record, arena)); + }} + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto cbufLit = parameterValues[4].cast(); + auto dist = parameterValues[5].cast>(); + + const auto result = nautilus::invoke( + +[](double lonValue, double latValue, double radiusValue, uint64_t timestampValue, + const char* cbufLitPtr, uint32_t cbufLitSize, double distValue) -> {return_type} {{ + try + {{ + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({{}} {{}}),{{}})@{{}}", + lonValue, latValue, radiusValue, timestampString); + std::string cbufferLiteral(cbufLitPtr, cbufLitSize); + + while (!cbufferLiteral.empty() && (cbufferLiteral.front() == '\\'' || cbufferLiteral.front() == '"')) + cbufferLiteral.erase(cbufferLiteral.begin()); + while (!cbufferLiteral.empty() && (cbufferLiteral.back() == '\\'' || cbufferLiteral.back() == '"')) + cbufferLiteral.pop_back(); + + if (tcbufferWkt.empty() || cbufferLiteral.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + Cbuffer* cb = cbuffer_in(cbufferLiteral.c_str()); + if (!cb) {{ free(tcbuffer); return 0; }} + + {return_type} r = {meos_call}(tcbuffer, cb, distValue); + free(tcbuffer); + free(cb); + return r; + }} + catch (const std::exception&) + {{ + return 0; + }} + }}, + lon, lat, radius, timestamp, cbufLit.getContent(), cbufLit.getContentSize(), dist); + + return VarVal(result); +}} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::Register{nebula_name}PhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{{ + PRECONDITION(arguments.childFunctions.size() == {n_args}, + "{nebula_name}PhysicalFunction requires {n_args} children but got {{}}", + arguments.childFunctions.size()); +{registrar_pushes} +}} + +}} // namespace NES +""" + +# Physical .cpp template for two-tcbuffer-points + dist — e.g. +# edwithin_tcbuffer_tcbuffer. 9 SQL args: lonA, latA, radiusA, tsA, +# lonB, latB, radiusB, tsB, dist. +PHYSICAL_CPP_TEMPLATE_TWO_TCBUFFER_POINTS_WITH_DIST = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" {{ +#include +#include +}} + +namespace NES {{ + +{nebula_name}PhysicalFunction::{nebula_name}PhysicalFunction({ctor_physical_args}) +{{ + parameterFunctions.reserve({n_args}); +{ctor_physical_pushes} +}} + +VarVal {nebula_name}PhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + {{ + parameterValues.emplace_back(function.execute(record, arena)); + }} + + auto lonA = parameterValues[0].cast>(); + auto latA = parameterValues[1].cast>(); + auto radiusA = parameterValues[2].cast>(); + auto tsA = parameterValues[3].cast>(); + auto lonB = parameterValues[4].cast>(); + auto latB = parameterValues[5].cast>(); + auto radiusB = parameterValues[6].cast>(); + auto tsB = parameterValues[7].cast>(); + auto dist = parameterValues[8].cast>(); + + const auto result = nautilus::invoke( + +[](double lonAValue, double latAValue, double radiusAValue, uint64_t tsAValue, + double lonBValue, double latBValue, double radiusBValue, uint64_t tsBValue, + double distValue) -> {return_type} {{ + try + {{ + MEOS::Meos::ensureMeosInitialized(); + if (!(lonAValue >= -180.0 && lonAValue <= 180.0 && latAValue >= -90.0 && latAValue <= 90.0)) return 0; + if (!(lonBValue >= -180.0 && lonBValue <= 180.0 && latBValue >= -90.0 && latBValue <= 90.0)) return 0; + if (radiusAValue < 0.0 || radiusBValue < 0.0) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string wktA = fmt::format("Cbuffer(Point({{}} {{}}),{{}})@{{}}", lonAValue, latAValue, radiusAValue, tsAString); + std::string wktB = fmt::format("Cbuffer(Point({{}} {{}}),{{}})@{{}}", lonBValue, latBValue, radiusBValue, tsBString); + + Temporal* tA = tcbuffer_in(wktA.c_str()); + if (!tA) return 0; + Temporal* tB = tcbuffer_in(wktB.c_str()); + if (!tB) {{ free(tA); return 0; }} + + {return_type} r = {meos_call}(tA, tB, distValue); + free(tA); + free(tB); + return r; + }} + catch (const std::exception&) + {{ + return 0; + }} + }}, + lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB, dist); + + return VarVal(result); +}} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::Register{nebula_name}PhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{{ + PRECONDITION(arguments.childFunctions.size() == {n_args}, + "{nebula_name}PhysicalFunction requires {n_args} children but got {{}}", + arguments.childFunctions.size()); +{registrar_pushes} +}} + +}} // namespace NES +""" + + +# Physical .cpp template for TWO tcbuffer points (no static arg) — e.g. +# eintersects_tcbuffer_tcbuffer. Two per-event tcbuffer instants built +# from (lonA, latA, radiusA, tsA) and (lonB, latB, radiusB, tsB). +# MEOS signature: `int fn(const Temporal*, const Temporal*)`. +# 8 SQL args. +PHYSICAL_CPP_TEMPLATE_TWO_TCBUFFER_POINTS = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" {{ +#include +#include +}} + +namespace NES {{ + +{nebula_name}PhysicalFunction::{nebula_name}PhysicalFunction({ctor_physical_args}) +{{ + parameterFunctions.reserve({n_args}); +{ctor_physical_pushes} +}} + +VarVal {nebula_name}PhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + {{ + parameterValues.emplace_back(function.execute(record, arena)); + }} + + auto lonA = parameterValues[0].cast>(); + auto latA = parameterValues[1].cast>(); + auto radiusA = parameterValues[2].cast>(); + auto tsA = parameterValues[3].cast>(); + auto lonB = parameterValues[4].cast>(); + auto latB = parameterValues[5].cast>(); + auto radiusB = parameterValues[6].cast>(); + auto tsB = parameterValues[7].cast>(); + + const auto result = nautilus::invoke( + +[](double lonAValue, double latAValue, double radiusAValue, uint64_t tsAValue, + double lonBValue, double latBValue, double radiusBValue, uint64_t tsBValue) -> {return_type} {{ + try + {{ + MEOS::Meos::ensureMeosInitialized(); + if (!(lonAValue >= -180.0 && lonAValue <= 180.0 && latAValue >= -90.0 && latAValue <= 90.0)) return 0; + if (!(lonBValue >= -180.0 && lonBValue <= 180.0 && latBValue >= -90.0 && latBValue <= 90.0)) return 0; + if (radiusAValue < 0.0 || radiusBValue < 0.0) return 0; + + const std::string tsAString = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBString = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string wktA = fmt::format("Cbuffer(Point({{}} {{}}),{{}})@{{}}", lonAValue, latAValue, radiusAValue, tsAString); + std::string wktB = fmt::format("Cbuffer(Point({{}} {{}}),{{}})@{{}}", lonBValue, latBValue, radiusBValue, tsBString); + + Temporal* tA = tcbuffer_in(wktA.c_str()); + if (!tA) return 0; + Temporal* tB = tcbuffer_in(wktB.c_str()); + if (!tB) {{ free(tA); return 0; }} + + {return_type} r = {meos_call}(tA, tB); + free(tA); + free(tB); + return r; + }} + catch (const std::exception&) + {{ + return 0; + }} + }}, + lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB); + + return VarVal(result); +}} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::Register{nebula_name}PhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{{ + PRECONDITION(arguments.childFunctions.size() == {n_args}, + "{nebula_name}PhysicalFunction requires {n_args} children but got {{}}", + arguments.childFunctions.size()); +{registrar_pushes} +}} + +}} // namespace NES +""" + + +# Physical .cpp template for one-tcbuffer-point operators with a STATIC +# CBUFFER second arg — e.g. econtains_tcbuffer_cbuffer. Same per-event +# tcbuffer construction as PHYSICAL_CPP_TEMPLATE_TCBUFFER_POINT; the +# second arg is parsed via cbuffer_in() from a literal WKT +# "Cbuffer(Point(lon lat),radius)" instead of as a GSERIALIZED geometry. +# MEOS signature: `int fn(const Temporal*, const Cbuffer*)`. +# 5 SQL args: lon, lat, radius, ts, cbufferLiteral. +PHYSICAL_CPP_TEMPLATE_TCBUFFER_POINT_CBUFFER = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" {{ +#include +#include +}} + +namespace NES {{ + +{nebula_name}PhysicalFunction::{nebula_name}PhysicalFunction({ctor_physical_args}) +{{ + parameterFunctions.reserve({n_args}); +{ctor_physical_pushes} +}} + +VarVal {nebula_name}PhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + {{ + parameterValues.emplace_back(function.execute(record, arena)); + }} + + auto lon = parameterValues[0].cast>(); + auto lat = parameterValues[1].cast>(); + auto radius = parameterValues[2].cast>(); + auto timestamp = parameterValues[3].cast>(); + auto cbufLit = parameterValues[4].cast(); + + const auto result = nautilus::invoke( + +[](double lonValue, + double latValue, + double radiusValue, + uint64_t timestampValue, + const char* cbufLitPtr, + uint32_t cbufLitSize) -> {return_type} {{ + try + {{ + MEOS::Meos::ensureMeosInitialized(); + if (!(lonValue >= -180.0 && lonValue <= 180.0 && latValue >= -90.0 && latValue <= 90.0)) return 0; + if (radiusValue < 0.0) return 0; + + const std::string timestampString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string tcbufferWkt = fmt::format("Cbuffer(Point({{}} {{}}),{{}})@{{}}", + lonValue, latValue, radiusValue, timestampString); + std::string cbufferLiteral(cbufLitPtr, cbufLitSize); + + while (!cbufferLiteral.empty() && (cbufferLiteral.front() == '\\'' || cbufferLiteral.front() == '"')) + cbufferLiteral.erase(cbufferLiteral.begin()); + while (!cbufferLiteral.empty() && (cbufferLiteral.back() == '\\'' || cbufferLiteral.back() == '"')) + cbufferLiteral.pop_back(); + + if (tcbufferWkt.empty() || cbufferLiteral.empty()) return 0; + + Temporal* tcbuffer = tcbuffer_in(tcbufferWkt.c_str()); + if (!tcbuffer) return 0; + Cbuffer* cb = cbuffer_in(cbufferLiteral.c_str()); + if (!cb) {{ free(tcbuffer); return 0; }} + + {return_type} r = {meos_call}(tcbuffer, cb); + free(tcbuffer); + free(cb); + return r; + }} + catch (const std::exception&) + {{ + return 0; + }} + }}, + lon, lat, radius, timestamp, cbufLit.getContent(), cbufLit.getContentSize()); + + return VarVal(result); +}} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::Register{nebula_name}PhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{{ + PRECONDITION(arguments.childFunctions.size() == {n_args}, + "{nebula_name}PhysicalFunction requires {n_args} children but got {{}}", + arguments.childFunctions.size()); +{registrar_pushes} +}} + +}} // namespace NES +""" + + +# Physical .cpp template for one-tnumber-point operators with a trailing +# scalar (double or int) — e.g. nad_tfloat_float, nad_tint_int. The MEOS +# call signature is ` fn(const Temporal*, )`. +# 3 args: value, timestamp, scalar. +PHYSICAL_CPP_TEMPLATE_TNUMBER_POINT_WITH_SCALAR = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" {{ +#include +}} + +namespace NES {{ + +{nebula_name}PhysicalFunction::{nebula_name}PhysicalFunction({ctor_physical_args}) +{{ + parameterFunctions.reserve({n_args}); +{ctor_physical_pushes} +}} + +VarVal {nebula_name}PhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + {{ + parameterValues.emplace_back(function.execute(record, arena)); + }} + + auto value = parameterValues[0].cast>(); + auto timestamp = parameterValues[1].cast>(); + auto scalar = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[]({tnumber_value_cpp_type} valueValue, + uint64_t timestampValue, + {scalar_cpp_type} scalarValue) -> {return_type} {{ + try + {{ + MEOS::Meos::ensureMeosInitialized(); + const std::string tsString = MEOS::Meos::convertEpochToTimestamp(timestampValue); + std::string wkt = fmt::format("{tnumber_wkt_format}", valueValue, tsString); + Temporal* temp = {tnumber_in_fn}(wkt.c_str()); + if (!temp) return 0; + {return_type} r = {meos_call}(temp, scalarValue); + free(temp); + return r; + }} + catch (const std::exception&) + {{ + return 0; + }} + }}, + value, timestamp, scalar); + + return VarVal(result); +}} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::Register{nebula_name}PhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{{ + PRECONDITION(arguments.childFunctions.size() == {n_args}, + "{nebula_name}PhysicalFunction requires {n_args} children but got {{}}", + arguments.childFunctions.size()); +{registrar_pushes} +}} + +}} // namespace NES +""" + +# Physical .cpp template for two-tnumber-point operators (e.g. nad_tfloat_tfloat, +# nad_tint_tint). MEOS signature ` fn(const Temporal*, const Temporal*)`. +# 4 args: valueA, tsA, valueB, tsB. +PHYSICAL_CPP_TEMPLATE_TWO_TNUMBER_POINTS = """\ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" {{ +#include +}} + +namespace NES {{ + +{nebula_name}PhysicalFunction::{nebula_name}PhysicalFunction({ctor_physical_args}) +{{ + parameterFunctions.reserve({n_args}); +{ctor_physical_pushes} +}} + +VarVal {nebula_name}PhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + {{ + parameterValues.emplace_back(function.execute(record, arena)); + }} + + auto valueA = parameterValues[0].cast>(); + auto tsA = parameterValues[1].cast>(); + auto valueB = parameterValues[2].cast>(); + auto tsB = parameterValues[3].cast>(); + + const auto result = nautilus::invoke( + +[]({tnumber_value_cpp_type} valueAValue, uint64_t tsAValue, + {tnumber_value_cpp_type} valueBValue, uint64_t tsBValue) -> {return_type} {{ + try + {{ + MEOS::Meos::ensureMeosInitialized(); + const std::string tsAStr = MEOS::Meos::convertEpochToTimestamp(tsAValue); + const std::string tsBStr = MEOS::Meos::convertEpochToTimestamp(tsBValue); + std::string wktA = fmt::format("{tnumber_wkt_format}", valueAValue, tsAStr); + std::string wktB = fmt::format("{tnumber_wkt_format}", valueBValue, tsBStr); + Temporal* tempA = {tnumber_in_fn}(wktA.c_str()); + if (!tempA) return 0; + Temporal* tempB = {tnumber_in_fn}(wktB.c_str()); + if (!tempB) {{ free(tempA); return 0; }} + {return_type} r = {meos_call}(tempA, tempB); + free(tempA); + free(tempB); + return r; + }} + catch (const std::exception&) + {{ + return 0; + }} + }}, + valueA, tsA, valueB, tsB); + + return VarVal(result); +}} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::Register{nebula_name}PhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{{ + PRECONDITION(arguments.childFunctions.size() == {n_args}, + "{nebula_name}PhysicalFunction requires {n_args} children but got {{}}", + arguments.childFunctions.size()); +{registrar_pushes} +}} + +}} // namespace NES +""" + + +# =========================================================================== +# Parser-glue dispatch-case templates (one per shape). +# The shape is encoded by the build_* flag; the dispatch block produces a +# LogicalFunction ctor invocation matching the C++ operator's arg order. +# +# Mariana's existing TGEO_AT_STBOX and EDWITHIN_TGEO_GEO blocks are the +# in-tree reference for the constantBuilder→functionBuilder lift pattern. +# =========================================================================== + +# 4-arg shape: lon, lat, ts, geometry (geometry is the only constant — WKT). +DISPATCH_CASE_ONE_TEMPORAL_POINT = """\ + /* BEGIN CODEGEN PARSER GLUE: {sql_token} */ + case AntlrSQLLexer::{sql_token}: + {{ + const auto argCount = context->expression().size(); + if (argCount != 4) + throw InvalidQuerySyntax("{sql_token} requires exactly 4 arguments (lon, lat, timestamp, geometry), but got {{}}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + {{ + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + }} + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + {nebula_name}LogicalFunction(lon, lat, timestamp, geometry)); + }} + break; + /* END CODEGEN PARSER GLUE: {sql_token} */ +""" + +# 6-arg shape: lonA, latA, tsA, lonB, latB, tsB (no constants). +DISPATCH_CASE_TWO_TEMPORAL_POINTS = """\ + /* BEGIN CODEGEN PARSER GLUE: {sql_token} */ + case AntlrSQLLexer::{sql_token}: + {{ + const auto argCount = context->expression().size(); + if (argCount != 6) + throw InvalidQuerySyntax("{sql_token} requires exactly 6 arguments (lonA, latA, tsA, lonB, latB, tsB), but got {{}}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + {nebula_name}LogicalFunction(lonA, latA, tsA, lonB, latB, tsB)); + }} + break; + /* END CODEGEN PARSER GLUE: {sql_token} */ +""" + +# 8-arg shape: xA, yA, thetaA, tsA, xB, yB, thetaB, tsB — two tpose instants, +# each lifted to a tgeompoint via tpose_to_tpoint at run time (W15 composition). +DISPATCH_CASE_TWO_TPOSE_POINTS = """\ + /* BEGIN CODEGEN PARSER GLUE: {sql_token} */ + case AntlrSQLLexer::{sql_token}: + {{ + const auto argCount = context->expression().size(); + if (argCount != 8) + throw InvalidQuerySyntax("{sql_token} requires exactly 8 arguments (xA, yA, thetaA, tsA, xB, yB, thetaB, tsB), but got {{}}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto thetaB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto yB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto xB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto thetaA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto yA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto xA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + {nebula_name}LogicalFunction(xA, yA, thetaA, tsA, xB, yB, thetaB, tsB)); + }} + break; + /* END CODEGEN PARSER GLUE: {sql_token} */ +""" + +# 5-arg shape: lon, lat, ts, geometry, dist (both geometry and dist are constants). +# Constant lift uses mariana's pattern: TRUE/FALSE → BOOLEAN, strtod-clean → FLOAT64, else → VARSIZED. +DISPATCH_CASE_ONE_TEMPORAL_POINT_WITH_DIST = """\ + /* BEGIN CODEGEN PARSER GLUE: {sql_token} */ + case AntlrSQLLexer::{sql_token}: + {{ + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("{sql_token} requires exactly 5 arguments (lon, lat, timestamp, geometry, distance), but got {{}}", argCount); + + /* Lift constants (geometry + distance) — same shape as EDWITHIN_TGEO_GEO */ + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + + DataType dataType; + const auto upperValue = Util::toUpperCase(constantValue); + if (upperValue == "TRUE" || upperValue == "FALSE") + {{ + dataType = DataTypeProvider::provideDataType(DataType::Type::BOOLEAN); + }} + else + {{ + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + }} + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + /* After lift: [lon, lat, ts, distance, geometry] (geometry pushed last because lifted last in LIFO) */ + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto dist = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + {nebula_name}LogicalFunction(lon, lat, timestamp, geometry, dist)); + }} + break; + /* END CODEGEN PARSER GLUE: {sql_token} */ +""" + +# 7-arg shape: lonA, latA, tsA, lonB, latB, tsB, dist (only dist is constant). +DISPATCH_CASE_TWO_TEMPORAL_POINTS_WITH_DIST = """\ + /* BEGIN CODEGEN PARSER GLUE: {sql_token} */ + case AntlrSQLLexer::{sql_token}: + {{ + const auto argCount = context->expression().size(); + if (argCount != 7) + throw InvalidQuerySyntax("{sql_token} requires exactly 7 arguments (lonA, latA, tsA, lonB, latB, tsB, distance), but got {{}}", argCount); + + /* Lift the distance constant */ + while (!helpers.top().constantBuilder.empty()) + {{ + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::FLOAT64), std::move(v))); + }} + + auto dist = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + {nebula_name}LogicalFunction(lonA, latA, tsA, lonB, latB, tsB, dist)); + }} + break; + /* END CODEGEN PARSER GLUE: {sql_token} */ +""" + + +# 6-arg shape: lon, lat, radius, ts, geometry, dist — tcbuffer × static geom + dist. +DISPATCH_CASE_TCBUFFER_POINT_WITH_DIST = """\ + /* BEGIN CODEGEN PARSER GLUE: {sql_token} */ + case AntlrSQLLexer::{sql_token}: + {{ + const auto argCount = context->expression().size(); + if (argCount != 6) + throw InvalidQuerySyntax("{sql_token} requires exactly 6 arguments (lon, lat, radius, timestamp, blob, distance), but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto blobLast = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto distLast = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + {nebula_name}LogicalFunction(lon, lat, radius, timestamp, blobLast, distLast)); + }} + break; + /* END CODEGEN PARSER GLUE: {sql_token} */ +""" + +# 9-arg shape: lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB, dist — two tcbuffers + dist. +DISPATCH_CASE_TWO_TCBUFFER_POINTS_WITH_DIST = """\ + /* BEGIN CODEGEN PARSER GLUE: {sql_token} */ + case AntlrSQLLexer::{sql_token}: + {{ + const auto argCount = context->expression().size(); + if (argCount != 9) + throw InvalidQuerySyntax("{sql_token} requires exactly 9 arguments (lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB, distance), but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::FLOAT64), std::move(v))); + }} + + auto dist = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radiusB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radiusA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + {nebula_name}LogicalFunction(lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB, dist)); + }} + break; + /* END CODEGEN PARSER GLUE: {sql_token} */ +""" + +# 8-arg shape: lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB (no constants). +DISPATCH_CASE_TWO_TCBUFFER_POINTS = """\ + /* BEGIN CODEGEN PARSER GLUE: {sql_token} */ + case AntlrSQLLexer::{sql_token}: + {{ + const auto argCount = context->expression().size(); + if (argCount != 8) + throw InvalidQuerySyntax("{sql_token} requires exactly 8 arguments (lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB), but got {{}}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radiusB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radiusA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto latA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lonA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + {nebula_name}LogicalFunction(lonA, latA, radiusA, tsA, lonB, latB, radiusB, tsB)); + }} + break; + /* END CODEGEN PARSER GLUE: {sql_token} */ +""" + +# 5-arg shape: lon, lat, radius, ts, geometry — tcbuffer × static geom. +# Geometry is the only constant (lifted to FLOAT64 / VARSIZED via the same lift +# pattern as the existing with-dist templates). +DISPATCH_CASE_TCBUFFER_POINT = """\ + /* BEGIN CODEGEN PARSER GLUE: {sql_token} */ + case AntlrSQLLexer::{sql_token}: + {{ + const auto argCount = context->expression().size(); + if (argCount != 5) + throw InvalidQuerySyntax("{sql_token} requires exactly 5 arguments (lon, lat, radius, timestamp, geometry), but got {{}}", argCount); + + /* Lift the WKT constant into the function builder */ + while (!helpers.top().constantBuilder.empty()) + {{ + auto v = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back( + ConstantValueLogicalFunction( + DataTypeProvider::provideDataType(DataType::Type::VARSIZED), std::move(v))); + }} + + auto geometry = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto radius = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lat = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto lon = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + {nebula_name}LogicalFunction(lon, lat, radius, timestamp, geometry)); + }} + break; + /* END CODEGEN PARSER GLUE: {sql_token} */ +""" + +# 3-arg shape: value, ts, scalar (scalar may be FLOAT64 or INT32, only one constant). +DISPATCH_CASE_TNUMBER_POINT_WITH_SCALAR = """\ + /* BEGIN CODEGEN PARSER GLUE: {sql_token} */ + case AntlrSQLLexer::{sql_token}: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("{sql_token} requires exactly 3 arguments (value, timestamp, scalar), but got {{}}", argCount); + + /* Lift the scalar constant — accept FLOAT64 (strtod-clean) and INT32 */ + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto scalar = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto timestamp = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto value = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + {nebula_name}LogicalFunction(value, timestamp, scalar)); + }} + break; + /* END CODEGEN PARSER GLUE: {sql_token} */ +""" + +# 4-arg shape: valueA, tsA, valueB, tsB (no constants). +DISPATCH_CASE_TWO_TNUMBER_POINTS = """\ + /* BEGIN CODEGEN PARSER GLUE: {sql_token} */ + case AntlrSQLLexer::{sql_token}: + {{ + const auto argCount = context->expression().size(); + if (argCount != 4) + throw InvalidQuerySyntax("{sql_token} requires exactly 4 arguments (valueA, tsA, valueB, tsB), but got {{}}", argCount); + + auto tsB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto valueB = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto tsA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto valueA = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back( + {nebula_name}LogicalFunction(valueA, tsA, valueB, tsB)); + }} + break; + /* END CODEGEN PARSER GLUE: {sql_token} */ +""" + + +def dispatch_case_for(op): + """Pick the dispatch-case template that matches an operator's shape.""" + if op.get("build_two_temporal_points_with_dist"): + return DISPATCH_CASE_TWO_TEMPORAL_POINTS_WITH_DIST + if op.get("build_temporal_point_with_dist"): + return DISPATCH_CASE_ONE_TEMPORAL_POINT_WITH_DIST + if op.get("build_two_temporal_points"): + return DISPATCH_CASE_TWO_TEMPORAL_POINTS + if op.get("build_two_tpose_points_via_composition"): + return DISPATCH_CASE_TWO_TPOSE_POINTS + if op.get("build_tnpoint_point_via_composition"): + # 4-arg SQL shape (rid, fraction, ts, geometry) — same arity as a + # one-temporal-point op; the parser only pops/forwards by arity. + return DISPATCH_CASE_ONE_TEMPORAL_POINT + if op.get("build_two_tnpoint_points_via_composition"): + # 6-arg SQL shape (ridA, fracA, tsA, ridB, fracB, tsB) — same arity + # as a two-temporal-points op. + return DISPATCH_CASE_TWO_TEMPORAL_POINTS + if op.get("build_temporal_point") or op.get("build_temporal_point_restriction"): + # Both shapes share the same 4-arg dispatch (lon, lat, ts, geom); + # only the physical-cpp body differs (filter-predicate int return vs. + # restriction-survival int return). + return DISPATCH_CASE_ONE_TEMPORAL_POINT + if op.get("build_tcbuffer_point") or op.get("build_tcbuffer_point_cbuffer") \ + or op.get("build_tpose_point_via_composition"): + # All three shapes share the same 5-arg dispatch (lon/x, lat/y, radius/theta, ts, blob); + # only the physical-cpp body differs (blob parsed as GSERIALIZED vs Cbuffer; per-event + # type construction is tcbuffer vs tpose with optional tpose_to_tpoint composition). + return DISPATCH_CASE_TCBUFFER_POINT + if op.get("build_two_tcbuffer_points"): + return DISPATCH_CASE_TWO_TCBUFFER_POINTS + if op.get("build_tcbuffer_point_with_dist") or op.get("build_tcbuffer_point_cbuffer_with_dist"): + # Same 6-arg SQL dispatch for both — only physical-cpp body differs (blob parser). + return DISPATCH_CASE_TCBUFFER_POINT_WITH_DIST + if op.get("build_two_tcbuffer_points_with_dist"): + return DISPATCH_CASE_TWO_TCBUFFER_POINTS_WITH_DIST + if op.get("build_tnumber_point_with_scalar"): + return DISPATCH_CASE_TNUMBER_POINT_WITH_SCALAR + if op.get("build_two_tnumber_points"): + return DISPATCH_CASE_TWO_TNUMBER_POINTS + return None + + +# =========================================================================== +# Idempotent injectors — each scans for a per-op marker and inserts only +# if not present, so re-runs are safe. +# =========================================================================== + +def inject_cmake_entries(operators, output_root: Path) -> int: + """Append per-op `add_plugin(...)` entries to the Meos CMakeLists files + (logical + physical layers). Idempotent: skips ops already listed.""" + n_added = 0 + for layer in ("logical", "physical"): + cml = output_root / f"nes-{layer}-operators/src/Functions/Meos/CMakeLists.txt" + if not cml.exists(): + sys.stderr.write(f" ! cmake-entries: {cml} not found, skipping {layer} layer\n") + continue + body = cml.read_text() + layer_suffix = "Logical" if layer == "logical" else "Physical" + new_lines = [] + for op in operators: + entry = ( + f"add_plugin({op['nebula_name']} {layer_suffix}Function " + f"nes-{layer}-operators {op['nebula_name']}{layer_suffix}Function.cpp)" + ) + if entry in body or f"add_plugin({op['nebula_name']} {layer_suffix}Function" in body: + continue + new_lines.append(entry) + if new_lines: + with cml.open("a") as f: + f.write("\n".join(new_lines) + "\n") + sys.stderr.write(f" ✓ cmake-entries ({layer}): appended {len(new_lines)} entry(ies)\n") + n_added += len(new_lines) + return n_added + + +def inject_g4(operators, g4_path: Path) -> int: + """Inject lexer-token + functionName-alternation entries into AntlrSQL.g4. + Idempotent: skips tokens already present.""" + if not g4_path.exists(): + sys.stderr.write(f" ! g4: {g4_path} not found, skipping\n") + return 0 + body = g4_path.read_text() + n_added = 0 + + # 1) Lexer-token entries — insert just before the WATERMARK: lexer token. + new_tokens = [] + for op in operators: + tok = op["sql_token"] + if re.search(rf"^{re.escape(tok)}\s*:", body, re.MULTILINE): + continue + new_tokens.append( + f"{tok}: '{tok}' | '{tok.lower()}';" + ) + if new_tokens: + anchor_re = re.compile(r"^WATERMARK:.*$", re.MULTILINE) + m = anchor_re.search(body) + if m is None: + sys.stderr.write(f" ! g4: WATERMARK lexer anchor not found; cannot inject tokens\n") + else: + insertion = "/* BEGIN CODEGEN LEXER TOKENS */\n" + "\n".join(new_tokens) + "\n/* END CODEGEN LEXER TOKENS */\n" + # If the BEGIN marker already exists, append inside that block; else insert before WATERMARK. + if "/* BEGIN CODEGEN LEXER TOKENS */" in body: + body = re.sub( + r"(/\* BEGIN CODEGEN LEXER TOKENS \*/\n)(.*?)(/\* END CODEGEN LEXER TOKENS \*/)", + lambda mm: mm.group(1) + mm.group(2) + "\n".join(new_tokens) + "\n" + mm.group(3), + body, + count=1, + flags=re.DOTALL, + ) + else: + body = body[: m.start()] + insertion + body[m.start():] + n_added += len(new_tokens) + sys.stderr.write(f" ✓ g4 lexer-tokens: added {len(new_tokens)} token(s)\n") + + # 2) functionName: alternation — append missing tokens before the trailing ';'. + fn_re = re.compile(r"^functionName:\s*([^;]+);", re.MULTILINE) + m = fn_re.search(body) + if m is None: + sys.stderr.write(f" ! g4: functionName production not found\n") + else: + alternation = m.group(1) + new_alts = [] + for op in operators: + tok = op["sql_token"] + if re.search(rf"\b{re.escape(tok)}\b", alternation): + continue + new_alts.append(tok) + if new_alts: + new_alt_text = alternation.rstrip() + " | " + " | ".join(new_alts) + body = body[: m.start()] + f"functionName: {new_alt_text};" + body[m.end():] + sys.stderr.write(f" ✓ g4 functionName: added {len(new_alts)} alternative(s)\n") + + g4_path.write_text(body) + return n_added + + +def inject_parser_cpp(operators, cpp_path: Path) -> int: + """Inject #include + dispatch-case block into AntlrSQLQueryPlanCreator.cpp. + Idempotent: skips when the per-op BEGIN marker is already present.""" + if not cpp_path.exists(): + sys.stderr.write(f" ! parser-cpp: {cpp_path} not found, skipping\n") + return 0 + body = cpp_path.read_text() + n_added = 0 + + # 1) Per-op #include — append after the last existing Meos LogicalFunction include. + new_includes = [] + for op in operators: + inc = f"#include " + if inc in body: + continue + new_includes.append(inc) + if new_includes: + # Insert immediately after the last #include line. + meos_inc_re = re.compile(r"(^#include ]+>\s*\n)+", re.MULTILINE) + matches = list(meos_inc_re.finditer(body)) + if not matches: + sys.stderr.write(f" ! parser-cpp: could not find Meos include anchor\n") + else: + last = matches[-1] + body = body[: last.end()] + "\n".join(new_includes) + "\n" + body[last.end():] + sys.stderr.write(f" ✓ parser-cpp includes: added {len(new_includes)}\n") + + # 2) Per-op dispatch cases — insert just before the `default:` of the + # switch that already contains the TGEO_AT_STBOX case. + cases_block = [] + for op in operators: + tmpl = dispatch_case_for(op) + if tmpl is None: + sys.stderr.write(f" ! parser-cpp: {op['nebula_name']} has no dispatch shape, skipping case\n") + continue + marker = f"/* BEGIN CODEGEN PARSER GLUE: {op['sql_token']} */" + if marker in body: + continue + # Also skip if a pre-existing hand-written case for this token already + # exists (no marker, but a `case AntlrSQLLexer::TOKEN:` line is present). + if re.search(rf"case\s+AntlrSQLLexer::{re.escape(op['sql_token'])}\s*:", body): + sys.stderr.write( + f" ! parser-cpp: pre-existing hand-written case for {op['sql_token']} detected; " + f"skipping codegen injection (will not duplicate)\n" + ) + continue + cases_block.append(tmpl.format(sql_token=op["sql_token"], nebula_name=op["nebula_name"])) + n_added += 1 + if cases_block: + # Find the insertion point: prefer just after the LAST existing + # `/* END CODEGEN PARSER GLUE: ... */` marker (so successive codegen + # runs cluster their cases), else fall back to inserting before the + # `default:` that immediately follows the TGEO_AT_STBOX case block. + last_end_re = re.compile(r"/\* END CODEGEN PARSER GLUE: [^*]+\*/") + ends = list(last_end_re.finditer(body)) + if ends: + insert_at = ends[-1].end() + body = body[:insert_at] + "\n" + "\n".join(cases_block) + body[insert_at:] + sys.stderr.write(f" ✓ parser-cpp dispatch: added {len(cases_block)} case(s) after last codegen marker\n") + else: + anchor_re = re.compile( + r"(case AntlrSQLLexer::TGEO_AT_STBOX:[\s\S]+?\n\s*break;\n)(\s*default:)", + ) + m = anchor_re.search(body) + if m is None: + sys.stderr.write(f" ! parser-cpp: no anchor (TGEO_AT_STBOX→default or codegen END marker) found\n") + else: + insertion = m.group(1) + "\n" + "\n".join(cases_block) + "\n" + m.group(2) + body = body[: m.start()] + insertion + body[m.end():] + sys.stderr.write(f" ✓ parser-cpp dispatch: added {len(cases_block)} case(s) before default:\n") + + cpp_path.write_text(body) + return n_added + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--input", required=True, help="Path to JSON descriptor file") + parser.add_argument("--output-root", required=True, help="MobilityNebula repo root") + parser.add_argument("--no-parser-glue", action="store_true", + help="Skip .g4 + parser .cpp injection (default: inject)") + parser.add_argument("--no-cmake-entries", action="store_true", + help="Skip CMakeLists.txt injection (default: inject)") + args = parser.parse_args() + + with open(args.input) as f: + config = json.load(f) + + output_root = Path(args.output_root).resolve() + if not (output_root / "nes-logical-operators").exists(): + sys.exit(f"ERROR: {output_root} does not look like a MobilityNebula root (no nes-logical-operators/)") + + operators = config["operators"] + sys.stderr.write(f"Emitting {len(operators)} operator(s):\n\n") + for op in operators: + emit_operator(op, output_root) + + if not args.no_cmake_entries: + sys.stderr.write("\nCMakeLists.txt:\n") + inject_cmake_entries(operators, output_root) + + if not args.no_parser_glue: + sys.stderr.write("\nParser glue:\n") + inject_g4(operators, output_root / "nes-sql-parser/AntlrSQL.g4") + inject_parser_cpp(operators, output_root / "nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp") + + sys.stderr.write( + f"\nDone. {len(operators) * 4} files emitted " + f"(or 3 + .cpp-skipped for shapes without a physical-cpp template).\n" + ) + + +if __name__ == "__main__": + main()