@@ -2,8 +2,7 @@ use crate::node_obj_deserializer::JsValueDeserializer;
22use crate :: transport:: MapCubeErrExt ;
33use cubeorchestrator:: query_message_parser:: QueryResult ;
44use cubeorchestrator:: query_result_transform:: {
5- get_final_cubestore_result_array, RequestResultArray , RequestResultData ,
6- RequestResultDataMulti , TransformedData ,
5+ RequestResultData , RequestResultDataMulti , TransformedData ,
76} ;
87use cubeorchestrator:: transport:: { JsRawData , TransformDataRequest } ;
98use cubesql:: CubeError ;
@@ -26,7 +25,6 @@ pub fn register_module(cx: &mut ModuleContext) -> NeonResult<()> {
2625 cx. export_function ( "getCubestoreResult" , get_cubestore_result) ?;
2726 cx. export_function ( "getFinalQueryResult" , final_query_result) ?;
2827 cx. export_function ( "getFinalQueryResultMulti" , final_query_result_multi) ?;
29- cx. export_function ( "getFinalQueryResultArray" , final_query_result_array) ?;
3028
3129 Ok ( ( ) )
3230}
@@ -99,7 +97,8 @@ impl ResultWrapper {
9997 Ok ( data) => data,
10098 Err ( _) => {
10199 return Err ( CubeError :: internal (
102- "Can't deserialize results raw data from JS ResultWrapper object" . to_string ( ) ,
100+ "Can't deserialize results raw data from JS ResultWrapper object"
101+ . to_string ( ) ,
103102 ) ) ;
104103 }
105104 } ;
@@ -127,12 +126,6 @@ impl ResultWrapper {
127126 }
128127}
129128
130- pub type JsResultDataVectors = (
131- Vec < TransformDataRequest > ,
132- Vec < Arc < QueryResult > > ,
133- Vec < RequestResultData > ,
134- ) ;
135-
136129fn json_to_array_buffer < ' a , C > (
137130 mut cx : C ,
138131 json_data : Result < String , anyhow:: Error > ,
@@ -250,74 +243,6 @@ pub fn final_query_result(mut cx: FunctionContext) -> JsResult<JsPromise> {
250243 Ok ( promise)
251244}
252245
253- pub fn convert_final_query_result_array_from_js (
254- cx : & mut FunctionContext < ' _ > ,
255- transform_data_array : Handle < JsValue > ,
256- data_array : Handle < JsArray > ,
257- results_data_array : Handle < JsValue > ,
258- ) -> NeonResult < JsResultDataVectors > {
259- let deserializer = JsValueDeserializer :: new ( cx, transform_data_array) ;
260- let transform_requests: Vec < TransformDataRequest > = match Deserialize :: deserialize ( deserializer)
261- {
262- Ok ( data) => data,
263- Err ( err) => return cx. throw_error ( err. to_string ( ) ) ,
264- } ;
265-
266- let mut cube_store_results: Vec < Arc < QueryResult > > = vec ! [ ] ;
267- for data_arg in data_array. to_vec ( cx) ? {
268- match extract_query_result ( cx, data_arg) {
269- Ok ( query_result) => cube_store_results. push ( query_result) ,
270- Err ( err) => return cx. throw_error ( err. to_string ( ) ) ,
271- } ;
272- }
273-
274- let deserializer = JsValueDeserializer :: new ( cx, results_data_array) ;
275- let request_results: Vec < RequestResultData > = match Deserialize :: deserialize ( deserializer) {
276- Ok ( data) => data,
277- Err ( err) => return cx. throw_error ( err. to_string ( ) ) ,
278- } ;
279-
280- Ok ( ( transform_requests, cube_store_results, request_results) )
281- }
282-
283- pub fn final_query_result_array ( mut cx : FunctionContext ) -> JsResult < JsPromise > {
284- let transform_data_array = cx. argument :: < JsValue > ( 0 ) ?;
285- let data_array = cx. argument :: < JsArray > ( 1 ) ?;
286- let results_data_array = cx. argument :: < JsValue > ( 2 ) ?;
287-
288- let convert_res = convert_final_query_result_array_from_js (
289- & mut cx,
290- transform_data_array,
291- data_array,
292- results_data_array,
293- ) ;
294- match convert_res {
295- Ok ( ( transform_requests, cube_store_results, mut request_results) ) => {
296- let promise = cx
297- . task ( move || {
298- get_final_cubestore_result_array (
299- & transform_requests,
300- & cube_store_results,
301- & mut request_results,
302- ) ?;
303-
304- let final_obj = RequestResultArray {
305- results : request_results,
306- } ;
307-
308- match serde_json:: to_string ( & final_obj) {
309- Ok ( json) => Ok ( json) ,
310- Err ( err) => Err ( anyhow:: Error :: from ( err) ) ,
311- }
312- } )
313- . promise ( move |cx, json_data| json_to_array_buffer ( cx, json_data) ) ;
314-
315- Ok ( promise)
316- }
317- Err ( err) => cx. throw_error ( err. to_string ( ) ) ,
318- }
319- }
320-
321246pub fn final_query_result_multi ( mut cx : FunctionContext ) -> JsResult < JsPromise > {
322247 let transform_data_array = cx. argument :: < JsValue > ( 0 ) ?;
323248 let deserializer = JsValueDeserializer :: new ( & mut cx, transform_data_array) ;
0 commit comments