@ -153,10 +153,10 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
graph_name ,
graph_name ,
} = > Box ::new ( self . eval_plan ( & * child , from ) . flat_map_ok ( move | tuple | {
} = > Box ::new ( self . eval_plan ( & * child , from ) . flat_map_ok ( move | tuple | {
let mut iter = self . dataset . quads_for_pattern (
let mut iter = self . dataset . quads_for_pattern (
get_pattern_value ( & subject , & tuple ) ,
get_pattern_value ( subject , & tuple ) ,
get_pattern_value ( & predicate , & tuple ) ,
get_pattern_value ( predicate , & tuple ) ,
get_pattern_value ( & object , & tuple ) ,
get_pattern_value ( object , & tuple ) ,
get_pattern_value ( & graph_name , & tuple ) ,
get_pattern_value ( graph_name , & tuple ) ,
) ;
) ;
if subject . is_var ( ) & & subject = = predicate {
if subject . is_var ( ) & & subject = = predicate {
iter = Box ::new ( iter . filter ( | quad | match quad {
iter = Box ::new ( iter . filter ( | quad | match quad {
@ -199,10 +199,10 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
let iter : EncodedTuplesIterator < ' _ > = Box ::new ( iter . map ( move | quad | {
let iter : EncodedTuplesIterator < ' _ > = Box ::new ( iter . map ( move | quad | {
let quad = quad ? ;
let quad = quad ? ;
let mut new_tuple = tuple . clone ( ) ;
let mut new_tuple = tuple . clone ( ) ;
put_pattern_value ( & subject , quad . subject , & mut new_tuple ) ;
put_pattern_value ( subject , quad . subject , & mut new_tuple ) ;
put_pattern_value ( & predicate , quad . predicate , & mut new_tuple ) ;
put_pattern_value ( predicate , quad . predicate , & mut new_tuple ) ;
put_pattern_value ( & object , quad . object , & mut new_tuple ) ;
put_pattern_value ( object , quad . object , & mut new_tuple ) ;
put_pattern_value ( & graph_name , quad . graph_name , & mut new_tuple ) ;
put_pattern_value ( graph_name , quad . graph_name , & mut new_tuple ) ;
Ok ( new_tuple )
Ok ( new_tuple )
} ) ) ;
} ) ) ;
iter
iter
@ -214,15 +214,16 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
object ,
object ,
graph_name ,
graph_name ,
} = > Box ::new ( self . eval_plan ( & * child , from ) . flat_map_ok ( move | tuple | {
} = > Box ::new ( self . eval_plan ( & * child , from ) . flat_map_ok ( move | tuple | {
let input_subject = get_pattern_value ( & subject , & tuple ) ;
let input_subject = get_pattern_value ( subject , & tuple ) ;
let input_object = get_pattern_value ( & object , & tuple ) ;
let input_object = get_pattern_value ( object , & tuple ) ;
let input_graph_name =
let input_graph_name =
if let Some ( graph_name ) = get_pattern_value ( & graph_name , & tuple ) {
if let Some ( graph_name ) = get_pattern_value ( graph_name , & tuple ) {
graph_name
graph_name
} else {
} else {
return Box ::new ( once ( Err ( format_err ! (
let resul t : EncodedT uplesIte rator < ' _ > = Box ::new ( once ( Err ( format_err ! (
"Unknown graph name is not allowed when evaluating property path"
"Unknown graph name is not allowed when evaluating property path"
) ) ) ) as EncodedTuplesIterator < ' _ > ;
) ) ) ) ;
return result ;
} ;
} ;
match ( input_subject , input_object ) {
match ( input_subject , input_object ) {
( Some ( input_subject ) , Some ( input_object ) ) = > Box ::new (
( Some ( input_subject ) , Some ( input_object ) ) = > Box ::new (
@ -237,13 +238,12 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
}
}
Err ( error ) = > Some ( Err ( error ) ) ,
Err ( error ) = > Some ( Err ( error ) ) ,
} ) ,
} ) ,
)
) ,
as EncodedTuplesIterator < ' _ > ,
( Some ( input_subject ) , None ) = > Box ::new (
( Some ( input_subject ) , None ) = > Box ::new (
self . eval_path_from ( path , input_subject , input_graph_name )
self . eval_path_from ( path , input_subject , input_graph_name )
. map ( move | o | {
. map ( move | o | {
let mut new_tuple = tuple . clone ( ) ;
let mut new_tuple = tuple . clone ( ) ;
put_pattern_value ( & object , o ? , & mut new_tuple ) ;
put_pattern_value ( object , o ? , & mut new_tuple ) ;
Ok ( new_tuple )
Ok ( new_tuple )
} ) ,
} ) ,
) ,
) ,
@ -251,7 +251,7 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
self . eval_path_to ( path , input_object , input_graph_name )
self . eval_path_to ( path , input_object , input_graph_name )
. map ( move | s | {
. map ( move | s | {
let mut new_tuple = tuple . clone ( ) ;
let mut new_tuple = tuple . clone ( ) ;
put_pattern_value ( & subject , s ? , & mut new_tuple ) ;
put_pattern_value ( subject , s ? , & mut new_tuple ) ;
Ok ( new_tuple )
Ok ( new_tuple )
} ) ,
} ) ,
) ,
) ,
@ -259,8 +259,8 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
Box ::new ( self . eval_open_path ( path , input_graph_name ) . map ( move | so | {
Box ::new ( self . eval_open_path ( path , input_graph_name ) . map ( move | so | {
let mut new_tuple = tuple . clone ( ) ;
let mut new_tuple = tuple . clone ( ) ;
so . map ( move | ( s , o ) | {
so . map ( move | ( s , o ) | {
put_pattern_value ( & subject , s , & mut new_tuple ) ;
put_pattern_value ( subject , s , & mut new_tuple ) ;
put_pattern_value ( & object , o , & mut new_tuple ) ;
put_pattern_value ( object , o , & mut new_tuple ) ;
new_tuple
new_tuple
} )
} )
} ) )
} ) )
@ -302,7 +302,7 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
right ,
right ,
possible_problem_vars ,
possible_problem_vars ,
} = > {
} = > {
let problem_vars = bind_variables_in_set ( & from , & possible_problem_vars ) ;
let problem_vars = bind_variables_in_set ( & from , possible_problem_vars ) ;
let mut filtered_from = from . clone ( ) ;
let mut filtered_from = from . clone ( ) ;
unbind_variables ( & mut filtered_from , & problem_vars ) ;
unbind_variables ( & mut filtered_from , & problem_vars ) ;
let iter = LeftJoinIterator {
let iter = LeftJoinIterator {
@ -326,7 +326,7 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
Box ::new ( self . eval_plan ( & * child , from ) . filter ( move | tuple | {
Box ::new ( self . eval_plan ( & * child , from ) . filter ( move | tuple | {
match tuple {
match tuple {
Ok ( tuple ) = > eval
Ok ( tuple ) = > eval
. eval_expression ( & expression , tuple )
. eval_expression ( expression , tuple )
. and_then ( | term | eval . to_bool ( term ) )
. and_then ( | term | eval . to_bool ( term ) )
. unwrap_or ( false ) ,
. unwrap_or ( false ) ,
Err ( _ ) = > true ,
Err ( _ ) = > true ,
@ -335,7 +335,7 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
}
}
PlanNode ::Union { children } = > Box ::new ( UnionIterator {
PlanNode ::Union { children } = > Box ::new ( UnionIterator {
eval : self ,
eval : self ,
plans : & children ,
plans : children ,
input : from ,
input : from ,
current_iterator : Box ::new ( empty ( ) ) ,
current_iterator : Box ::new ( empty ( ) ) ,
current_plan : 0 ,
current_plan : 0 ,
@ -348,7 +348,7 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
let eval = self ;
let eval = self ;
Box ::new ( self . eval_plan ( & * child , from ) . map ( move | tuple | {
Box ::new ( self . eval_plan ( & * child , from ) . map ( move | tuple | {
let mut tuple = tuple ? ;
let mut tuple = tuple ? ;
if let Some ( value ) = eval . eval_expression ( & expression , & tuple ) {
if let Some ( value ) = eval . eval_expression ( expression , & tuple ) {
tuple . set ( * position , value )
tuple . set ( * position , value )
}
}
Ok ( tuple )
Ok ( tuple )
@ -370,14 +370,14 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
for comp in by {
for comp in by {
match comp {
match comp {
Comparator ::Asc ( expression ) = > {
Comparator ::Asc ( expression ) = > {
match self . cmp_according_to_expression ( a , b , & expression ) {
match self . cmp_according_to_expression ( a , b , expression ) {
Ordering ::Greater = > return Ordering ::Greater ,
Ordering ::Greater = > return Ordering ::Greater ,
Ordering ::Less = > return Ordering ::Less ,
Ordering ::Less = > return Ordering ::Less ,
Ordering ::Equal = > ( ) ,
Ordering ::Equal = > ( ) ,
}
}
}
}
Comparator ::Desc ( expression ) = > {
Comparator ::Desc ( expression ) = > {
match self . cmp_according_to_expression ( a , b , & expression ) {
match self . cmp_according_to_expression ( a , b , expression ) {
Ordering ::Greater = > return Ordering ::Less ,
Ordering ::Greater = > return Ordering ::Less ,
Ordering ::Less = > return Ordering ::Greater ,
Ordering ::Less = > return Ordering ::Greater ,
Ordering ::Equal = > ( ) ,
Ordering ::Equal = > ( ) ,
@ -451,7 +451,7 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
aggregate
aggregate
. parameter
. parameter
. as_ref ( )
. as_ref ( )
. and_then ( | parameter | self . eval_expression ( & parameter , & tuple ) ) ,
. and_then ( | parameter | self . eval_expression ( parameter , & tuple ) ) ,
) ;
) ;
}
}
} ) ;
} ) ;
@ -492,12 +492,12 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
from : & EncodedTuple ,
from : & EncodedTuple ,
) -> Result < EncodedTuplesIterator < ' b > > {
) -> Result < EncodedTuplesIterator < ' b > > {
let service_name = self . dataset . decode_named_node (
let service_name = self . dataset . decode_named_node (
get_pattern_value ( service_name , & from )
get_pattern_value ( service_name , from )
. ok_or_else ( | | format_err ! ( "The SERVICE name is not bound" ) ) ? ,
. ok_or_else ( | | format_err ! ( "The SERVICE name is not bound" ) ) ? ,
) ? ;
) ? ;
Ok ( self . encode_bindings (
Ok ( self . encode_bindings (
variables ,
variables ,
self . service_handler . handle ( & service_name , & graph_pattern ) ? ,
self . service_handler . handle ( & service_name , graph_pattern ) ? ,
) )
) )
}
}
@ -558,14 +558,14 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
. quads_for_pattern ( Some ( start ) , Some ( * p ) , None , Some ( graph_name ) )
. quads_for_pattern ( Some ( start ) , Some ( * p ) , None , Some ( graph_name ) )
. map ( | t | Ok ( t ? . object ) ) ,
. map ( | t | Ok ( t ? . object ) ) ,
) ,
) ,
PlanPropertyPath ::InversePath ( p ) = > self . eval_path_to ( & p , start , graph_name ) ,
PlanPropertyPath ::InversePath ( p ) = > self . eval_path_to ( p , start , graph_name ) ,
PlanPropertyPath ::SequencePath ( a , b ) = > Box ::new (
PlanPropertyPath ::SequencePath ( a , b ) = > Box ::new (
self . eval_path_from ( & a , start , graph_name )
self . eval_path_from ( a , start , graph_name )
. flat_map_ok ( move | middle | self . eval_path_from ( & b , middle , graph_name ) ) ,
. flat_map_ok ( move | middle | self . eval_path_from ( b , middle , graph_name ) ) ,
) ,
) ,
PlanPropertyPath ::AlternativePath ( a , b ) = > Box ::new (
PlanPropertyPath ::AlternativePath ( a , b ) = > Box ::new (
self . eval_path_from ( & a , start , graph_name )
self . eval_path_from ( a , start , graph_name )
. chain ( self . eval_path_from ( & b , start , graph_name ) ) ,
. chain ( self . eval_path_from ( b , start , graph_name ) ) ,
) ,
) ,
PlanPropertyPath ::ZeroOrMorePath ( p ) = > {
PlanPropertyPath ::ZeroOrMorePath ( p ) = > {
Box ::new ( transitive_closure ( Some ( Ok ( start ) ) , move | e | {
Box ::new ( transitive_closure ( Some ( Ok ( start ) ) , move | e | {
@ -577,16 +577,21 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
move | e | self . eval_path_from ( p , e , graph_name ) ,
move | e | self . eval_path_from ( p , e , graph_name ) ,
) ) ,
) ) ,
PlanPropertyPath ::ZeroOrOnePath ( p ) = > Box ::new ( hash_deduplicate (
PlanPropertyPath ::ZeroOrOnePath ( p ) = > Box ::new ( hash_deduplicate (
once ( Ok ( start ) ) . chain ( self . eval_path_from ( & p , start , graph_name ) ) ,
once ( Ok ( start ) ) . chain ( self . eval_path_from ( p , start , graph_name ) ) ,
) ) ,
) ) ,
PlanPropertyPath ::NegatedPropertySet ( ps ) = > Box ::new (
PlanPropertyPath ::NegatedPropertySet ( ps ) = > Box ::new (
self . dataset
self . dataset
. quads_for_pattern ( Some ( start ) , None , None , Some ( graph_name ) )
. quads_for_pattern ( Some ( start ) , None , None , Some ( graph_name ) )
. filter ( move | t | match t {
. filter_map ( move | t | match t {
Ok ( t ) = > ! ps . contains ( & t . predicate ) ,
Ok ( t ) = > {
Err ( _ ) = > true ,
if ps . contains ( & t . predicate ) {
} )
None
. map ( | t | Ok ( t ? . object ) ) ,
} else {
Some ( Ok ( t . object ) )
}
}
Err ( e ) = > Some ( Err ( e ) ) ,
} ) ,
) ,
) ,
}
}
}
}
@ -606,14 +611,14 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
. quads_for_pattern ( None , Some ( * p ) , Some ( end ) , Some ( graph_name ) )
. quads_for_pattern ( None , Some ( * p ) , Some ( end ) , Some ( graph_name ) )
. map ( | t | Ok ( t ? . subject ) ) ,
. map ( | t | Ok ( t ? . subject ) ) ,
) ,
) ,
PlanPropertyPath ::InversePath ( p ) = > self . eval_path_from ( & p , end , graph_name ) ,
PlanPropertyPath ::InversePath ( p ) = > self . eval_path_from ( p , end , graph_name ) ,
PlanPropertyPath ::SequencePath ( a , b ) = > Box ::new (
PlanPropertyPath ::SequencePath ( a , b ) = > Box ::new (
self . eval_path_to ( & b , end , graph_name )
self . eval_path_to ( b , end , graph_name )
. flat_map_ok ( move | middle | self . eval_path_to ( & a , middle , graph_name ) ) ,
. flat_map_ok ( move | middle | self . eval_path_to ( a , middle , graph_name ) ) ,
) ,
) ,
PlanPropertyPath ::AlternativePath ( a , b ) = > Box ::new (
PlanPropertyPath ::AlternativePath ( a , b ) = > Box ::new (
self . eval_path_to ( & a , end , graph_name )
self . eval_path_to ( a , end , graph_name )
. chain ( self . eval_path_to ( & b , end , graph_name ) ) ,
. chain ( self . eval_path_to ( b , end , graph_name ) ) ,
) ,
) ,
PlanPropertyPath ::ZeroOrMorePath ( p ) = > {
PlanPropertyPath ::ZeroOrMorePath ( p ) = > {
Box ::new ( transitive_closure ( Some ( Ok ( end ) ) , move | e | {
Box ::new ( transitive_closure ( Some ( Ok ( end ) ) , move | e | {
@ -625,16 +630,21 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
move | e | self . eval_path_to ( p , e , graph_name ) ,
move | e | self . eval_path_to ( p , e , graph_name ) ,
) ) ,
) ) ,
PlanPropertyPath ::ZeroOrOnePath ( p ) = > Box ::new ( hash_deduplicate (
PlanPropertyPath ::ZeroOrOnePath ( p ) = > Box ::new ( hash_deduplicate (
once ( Ok ( end ) ) . chain ( self . eval_path_to ( & p , end , graph_name ) ) ,
once ( Ok ( end ) ) . chain ( self . eval_path_to ( p , end , graph_name ) ) ,
) ) ,
) ) ,
PlanPropertyPath ::NegatedPropertySet ( ps ) = > Box ::new (
PlanPropertyPath ::NegatedPropertySet ( ps ) = > Box ::new (
self . dataset
self . dataset
. quads_for_pattern ( None , None , Some ( end ) , Some ( graph_name ) )
. quads_for_pattern ( None , None , Some ( end ) , Some ( graph_name ) )
. filter ( move | t | match t {
. filter_map ( move | t | match t {
Ok ( t ) = > ! ps . contains ( & t . predicate ) ,
Ok ( t ) = > {
Err ( _ ) = > true ,
if ps . contains ( & t . predicate ) {
} )
None
. map ( | t | Ok ( t ? . subject ) ) ,
} else {
Some ( Ok ( t . subject ) )
}
}
Err ( e ) = > Some ( Err ( e ) ) ,
} ) ,
) ,
) ,
}
}
}
}
@ -654,19 +664,19 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
. map ( | t | t . map ( | t | ( t . subject , t . object ) ) ) ,
. map ( | t | t . map ( | t | ( t . subject , t . object ) ) ) ,
) ,
) ,
PlanPropertyPath ::InversePath ( p ) = > Box ::new (
PlanPropertyPath ::InversePath ( p ) = > Box ::new (
self . eval_open_path ( & p , graph_name )
self . eval_open_path ( p , graph_name )
. map ( | t | t . map ( | ( s , o ) | ( o , s ) ) ) ,
. map ( | t | t . map ( | ( s , o ) | ( o , s ) ) ) ,
) ,
) ,
PlanPropertyPath ::SequencePath ( a , b ) = > Box ::new (
PlanPropertyPath ::SequencePath ( a , b ) = > Box ::new (
self . eval_open_path ( & a , graph_name )
self . eval_open_path ( a , graph_name )
. flat_map_ok ( move | ( start , middle ) | {
. flat_map_ok ( move | ( start , middle ) | {
self . eval_path_from ( & b , middle , graph_name )
self . eval_path_from ( b , middle , graph_name )
. map ( move | end | Ok ( ( start , end ? ) ) )
. map ( move | end | Ok ( ( start , end ? ) ) )
} ) ,
} ) ,
) ,
) ,
PlanPropertyPath ::AlternativePath ( a , b ) = > Box ::new (
PlanPropertyPath ::AlternativePath ( a , b ) = > Box ::new (
self . eval_open_path ( & a , graph_name )
self . eval_open_path ( a , graph_name )
. chain ( self . eval_open_path ( & b , graph_name ) ) ,
. chain ( self . eval_open_path ( b , graph_name ) ) ,
) ,
) ,
PlanPropertyPath ::ZeroOrMorePath ( p ) = > Box ::new ( transitive_closure (
PlanPropertyPath ::ZeroOrMorePath ( p ) = > Box ::new ( transitive_closure (
self . get_subject_or_object_identity_pairs ( graph_name ) , //TODO: avoid to inject everything
self . get_subject_or_object_identity_pairs ( graph_name ) , //TODO: avoid to inject everything
@ -684,16 +694,21 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
) ) ,
) ) ,
PlanPropertyPath ::ZeroOrOnePath ( p ) = > Box ::new ( hash_deduplicate (
PlanPropertyPath ::ZeroOrOnePath ( p ) = > Box ::new ( hash_deduplicate (
self . get_subject_or_object_identity_pairs ( graph_name )
self . get_subject_or_object_identity_pairs ( graph_name )
. chain ( self . eval_open_path ( & p , graph_name ) ) ,
. chain ( self . eval_open_path ( p , graph_name ) ) ,
) ) ,
) ) ,
PlanPropertyPath ::NegatedPropertySet ( ps ) = > Box ::new (
PlanPropertyPath ::NegatedPropertySet ( ps ) = > Box ::new (
self . dataset
self . dataset
. quads_for_pattern ( None , None , None , Some ( graph_name ) )
. quads_for_pattern ( None , None , None , Some ( graph_name ) )
. filter ( move | t | match t {
. filter_map ( move | t | match t {
Ok ( t ) = > ! ps . contains ( & t . predicate ) ,
Ok ( t ) = > {
Err ( _ ) = > true ,
if ps . contains ( & t . predicate ) {
} )
None
. map ( | t | t . map ( | t | ( t . subject , t . object ) ) ) ,
} else {
Some ( Ok ( ( t . subject , t . object ) ) )
}
}
Err ( e ) = > Some ( Err ( e ) ) ,
} ) ,
) ,
) ,
}
}
}
}
@ -708,6 +723,7 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
. map ( | e | e . map ( | e | ( e , e ) ) )
. map ( | e | e . map ( | e | ( e , e ) ) )
}
}
#[ allow(clippy::cast_possible_truncation, clippy::cast_precision_loss) ]
fn eval_expression < ' b > (
fn eval_expression < ' b > (
& ' b self ,
& ' b self ,
expression : & PlanExpression ,
expression : & PlanExpression ,
@ -1056,7 +1072,7 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
self . to_string_and_language ( self . eval_expression ( arg , tuple ) ? ) ? ;
self . to_string_and_language ( self . eval_expression ( arg , tuple ) ? ) ? ;
let replacement =
let replacement =
self . to_simple_string ( self . eval_expression ( replacement , tuple ) ? ) ? ;
self . to_simple_string ( self . eval_expression ( replacement , tuple ) ? ) ? ;
self . build_plain_literal ( & regex . replace_all ( & text , & replacement as & str ) , language )
self . build_plain_literal ( & regex . replace_all ( & text , replacement . as_str ( ) ) , language )
}
}
PlanExpression ::UCase ( e ) = > {
PlanExpression ::UCase ( e ) = > {
let ( value , language ) =
let ( value , language ) =
@ -1073,7 +1089,7 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
self . eval_expression ( arg1 , tuple ) ? ,
self . eval_expression ( arg1 , tuple ) ? ,
self . eval_expression ( arg2 , tuple ) ? ,
self . eval_expression ( arg2 , tuple ) ? ,
) ? ;
) ? ;
Some ( ( & arg1 ) . starts_with ( & arg2 as & str ) . into ( ) )
Some ( ( & arg1 ) . starts_with ( arg2 . as_str ( ) ) . into ( ) )
}
}
PlanExpression ::EncodeForURI ( ltrl ) = > {
PlanExpression ::EncodeForURI ( ltrl ) = > {
let ltlr = self . to_string ( self . eval_expression ( ltrl , tuple ) ? ) ? ;
let ltlr = self . to_string ( self . eval_expression ( ltrl , tuple ) ? ) ? ;
@ -1107,21 +1123,21 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
self . eval_expression ( arg1 , tuple ) ? ,
self . eval_expression ( arg1 , tuple ) ? ,
self . eval_expression ( arg2 , tuple ) ? ,
self . eval_expression ( arg2 , tuple ) ? ,
) ? ;
) ? ;
Some ( ( & arg1 ) . ends_with ( & arg2 as & str ) . into ( ) )
Some ( ( & arg1 ) . ends_with ( arg2 . as_str ( ) ) . into ( ) )
}
}
PlanExpression ::Contains ( arg1 , arg2 ) = > {
PlanExpression ::Contains ( arg1 , arg2 ) = > {
let ( arg1 , arg2 , _ ) = self . to_argument_compatible_strings (
let ( arg1 , arg2 , _ ) = self . to_argument_compatible_strings (
self . eval_expression ( arg1 , tuple ) ? ,
self . eval_expression ( arg1 , tuple ) ? ,
self . eval_expression ( arg2 , tuple ) ? ,
self . eval_expression ( arg2 , tuple ) ? ,
) ? ;
) ? ;
Some ( ( & arg1 ) . contains ( & arg2 as & str ) . into ( ) )
Some ( ( & arg1 ) . contains ( arg2 . as_str ( ) ) . into ( ) )
}
}
PlanExpression ::StrBefore ( arg1 , arg2 ) = > {
PlanExpression ::StrBefore ( arg1 , arg2 ) = > {
let ( arg1 , arg2 , language ) = self . to_argument_compatible_strings (
let ( arg1 , arg2 , language ) = self . to_argument_compatible_strings (
self . eval_expression ( arg1 , tuple ) ? ,
self . eval_expression ( arg1 , tuple ) ? ,
self . eval_expression ( arg2 , tuple ) ? ,
self . eval_expression ( arg2 , tuple ) ? ,
) ? ;
) ? ;
if let Some ( position ) = ( & arg1 ) . find ( & arg2 as & str ) {
if let Some ( position ) = ( & arg1 ) . find ( arg2 . as_str ( ) ) {
self . build_plain_literal ( & arg1 [ .. position ] , language )
self . build_plain_literal ( & arg1 [ .. position ] , language )
} else {
} else {
Some ( ENCODED_EMPTY_STRING_LITERAL )
Some ( ENCODED_EMPTY_STRING_LITERAL )
@ -1132,7 +1148,7 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
self . eval_expression ( arg1 , tuple ) ? ,
self . eval_expression ( arg1 , tuple ) ? ,
self . eval_expression ( arg2 , tuple ) ? ,
self . eval_expression ( arg2 , tuple ) ? ,
) ? ;
) ? ;
if let Some ( position ) = ( & arg1 ) . find ( & arg2 as & str ) {
if let Some ( position ) = ( & arg1 ) . find ( arg2 . as_str ( ) ) {
self . build_plain_literal ( & arg1 [ position + arg2 . len ( ) .. ] , language )
self . build_plain_literal ( & arg1 [ position + arg2 . len ( ) .. ] , language )
} else {
} else {
Some ( ENCODED_EMPTY_STRING_LITERAL )
Some ( ENCODED_EMPTY_STRING_LITERAL )
@ -1294,7 +1310,9 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
EncodedTerm ::DoubleLiteral ( value ) = > Some ( value . into ( ) ) ,
EncodedTerm ::DoubleLiteral ( value ) = > Some ( value . into ( ) ) ,
EncodedTerm ::IntegerLiteral ( value ) = > Some ( ( value as f64 ) . into ( ) ) ,
EncodedTerm ::IntegerLiteral ( value ) = > Some ( ( value as f64 ) . into ( ) ) ,
EncodedTerm ::DecimalLiteral ( value ) = > Some ( value . to_f64 ( ) . into ( ) ) ,
EncodedTerm ::DecimalLiteral ( value ) = > Some ( value . to_f64 ( ) . into ( ) ) ,
EncodedTerm ::BooleanLiteral ( value ) = > Some ( if value { 1 f64 } else { 0 f64 } . into ( ) ) ,
EncodedTerm ::BooleanLiteral ( value ) = > {
Some ( if value { 1_ f64 } else { 0_ f64 } . into ( ) )
}
EncodedTerm ::StringLiteral { value_id } = > {
EncodedTerm ::StringLiteral { value_id } = > {
parse_double_str ( & * self . dataset . get_str ( value_id ) . ok ( ) ? ? )
parse_double_str ( & * self . dataset . get_str ( value_id ) . ok ( ) ? ? )
}
}
@ -1305,7 +1323,9 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
EncodedTerm ::DoubleLiteral ( value ) = > Some ( ( value as f32 ) . into ( ) ) ,
EncodedTerm ::DoubleLiteral ( value ) = > Some ( ( value as f32 ) . into ( ) ) ,
EncodedTerm ::IntegerLiteral ( value ) = > Some ( ( value as f32 ) . into ( ) ) ,
EncodedTerm ::IntegerLiteral ( value ) = > Some ( ( value as f32 ) . into ( ) ) ,
EncodedTerm ::DecimalLiteral ( value ) = > Some ( value . to_f32 ( ) . into ( ) ) ,
EncodedTerm ::DecimalLiteral ( value ) = > Some ( value . to_f32 ( ) . into ( ) ) ,
EncodedTerm ::BooleanLiteral ( value ) = > Some ( if value { 1 f32 } else { 0 f32 } . into ( ) ) ,
EncodedTerm ::BooleanLiteral ( value ) = > {
Some ( if value { 1_ f32 } else { 0_ f32 } . into ( ) )
}
EncodedTerm ::StringLiteral { value_id } = > {
EncodedTerm ::StringLiteral { value_id } = > {
parse_float_str ( & * self . dataset . get_str ( value_id ) . ok ( ) ? ? )
parse_float_str ( & * self . dataset . get_str ( value_id ) . ok ( ) ? ? )
}
}
@ -1376,8 +1396,8 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
match term {
match term {
EncodedTerm ::BooleanLiteral ( value ) = > Some ( value ) ,
EncodedTerm ::BooleanLiteral ( value ) = > Some ( value ) ,
EncodedTerm ::StringLiteral { .. } = > Some ( term ! = ENCODED_EMPTY_STRING_LITERAL ) ,
EncodedTerm ::StringLiteral { .. } = > Some ( term ! = ENCODED_EMPTY_STRING_LITERAL ) ,
EncodedTerm ::FloatLiteral ( value ) = > Some ( value ! = 0 f32 ) ,
EncodedTerm ::FloatLiteral ( value ) = > Some ( value ! = 0_ f32 ) ,
EncodedTerm ::DoubleLiteral ( value ) = > Some ( value ! = 0 f64 ) ,
EncodedTerm ::DoubleLiteral ( value ) = > Some ( value ! = 0_ f64 ) ,
EncodedTerm ::IntegerLiteral ( value ) = > Some ( value ! = 0 ) ,
EncodedTerm ::IntegerLiteral ( value ) = > Some ( value ! = 0 ) ,
EncodedTerm ::DecimalLiteral ( value ) = > Some ( value ! = Decimal ::default ( ) ) ,
EncodedTerm ::DecimalLiteral ( value ) = > Some ( value ! = Decimal ::default ( ) ) ,
_ = > None ,
_ = > None ,
@ -1528,8 +1548,8 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
tuple : & EncodedTuple ,
tuple : & EncodedTuple ,
) -> Option < NumericBinaryOperands > {
) -> Option < NumericBinaryOperands > {
NumericBinaryOperands ::new (
NumericBinaryOperands ::new (
self . eval_expression ( & e1 , tuple ) ? ,
self . eval_expression ( e1 , tuple ) ? ,
self . eval_expression ( & e2 , tuple ) ? ,
self . eval_expression ( e2 , tuple ) ? ,
)
)
}
}
@ -1596,7 +1616,11 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
} ) )
} ) )
}
}
#[ allow(clippy::float_cmp) ]
#[ allow(
clippy ::float_cmp ,
clippy ::cast_possible_truncation ,
clippy ::cast_precision_loss
) ]
fn equals ( & self , a : EncodedTerm , b : EncodedTerm ) -> Option < bool > {
fn equals ( & self , a : EncodedTerm , b : EncodedTerm ) -> Option < bool > {
match a {
match a {
EncodedTerm ::DefaultGraph
EncodedTerm ::DefaultGraph
@ -1717,6 +1741,7 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
}
}
}
}
#[ allow(clippy::cast_precision_loss) ]
fn partial_cmp_literals ( & self , a : EncodedTerm , b : EncodedTerm ) -> Option < Ordering > {
fn partial_cmp_literals ( & self , a : EncodedTerm , b : EncodedTerm ) -> Option < Ordering > {
match a {
match a {
EncodedTerm ::StringLiteral { value_id : a } = > {
EncodedTerm ::StringLiteral { value_id : a } = > {
@ -1801,7 +1826,7 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> {
tuple : & EncodedTuple ,
tuple : & EncodedTuple ,
) -> Option < EncodedTerm > {
) -> Option < EncodedTerm > {
let input = self . to_simple_string ( self . eval_expression ( arg , tuple ) ? ) ? ;
let input = self . to_simple_string ( self . eval_expression ( arg , tuple ) ? ) ? ;
let hash = hex ::encode ( H ::new ( ) . chain ( & input as & str ) . result ( ) ) ;
let hash = hex ::encode ( H ::new ( ) . chain ( input . as_str ( ) ) . result ( ) ) ;
self . build_string_literal ( & hash )
self . build_string_literal ( & hash )
}
}
}
}
@ -1821,6 +1846,7 @@ enum NumericBinaryOperands {
}
}
impl NumericBinaryOperands {
impl NumericBinaryOperands {
#[ allow(clippy::cast_precision_loss) ]
fn new ( a : EncodedTerm , b : EncodedTerm ) -> Option < Self > {
fn new ( a : EncodedTerm , b : EncodedTerm ) -> Option < Self > {
match ( a , b ) {
match ( a , b ) {
( EncodedTerm ::FloatLiteral ( v1 ) , EncodedTerm ::FloatLiteral ( v2 ) ) = > {
( EncodedTerm ::FloatLiteral ( v1 ) , EncodedTerm ::FloatLiteral ( v2 ) ) = > {