File tree Expand file tree Collapse file tree 5 files changed +51
-12
lines changed
Expand file tree Collapse file tree 5 files changed +51
-12
lines changed Original file line number Diff line number Diff line change 1+ # Helper variables (override on invocation if needed).
2+ CARGO ?= cargo
3+ WASM_PACK ?= wasm-pack
4+ SQLLOGIC_PATH ?= tests/slt/**/*.slt
5+
6+ .PHONY : test test-wasm test-slt test-all wasm-build
7+
8+ # # Run default Rust tests in the current environment (non-WASM).
9+ test :
10+ $(CARGO ) test
11+
12+ # # Build the WebAssembly package (artifact goes to ./pkg).
13+ wasm-build :
14+ $(WASM_PACK ) build --release --target nodejs
15+
16+ # # Execute wasm-bindgen tests under Node.js (wasm32 target).
17+ test-wasm :
18+ $(WASM_PACK ) test --node --release
19+
20+ # # Run the sqllogictest harness against the configured .slt suite.
21+ test-slt :
22+ $(CARGO ) run -p sqllogictest-test -- --path $(SQLLOGIC_PATH )
23+
24+ # # Convenience target to run every suite in sequence.
25+ test-all : test test-wasm test-slt
Original file line number Diff line number Diff line change @@ -183,13 +183,13 @@ impl SortBy {
183183 let mut key = BumpBytes :: new_in ( arena) ;
184184
185185 expr. eval ( Some ( ( tuple, schema) ) ) ?
186- . memcomparable_encode ( & mut key) ?;
187- if !asc {
188- for byte in key. iter_mut ( ) {
186+ . memcomparable_encode_with_null_order ( & mut key, * nulls_first) ?;
187+
188+ if !asc && key. len ( ) > 1 {
189+ for byte in key. iter_mut ( ) . skip ( 1 ) {
189190 * byte ^= 0xFF ;
190191 }
191192 }
192- key. push ( if * nulls_first { u8:: MIN } else { u8:: MAX } ) ;
193193 full_key. extend ( key) ;
194194 }
195195 sort_keys. put ( ( i, full_key) )
Original file line number Diff line number Diff line change @@ -48,13 +48,12 @@ fn top_sort<'a>(
4848 {
4949 let mut key = BumpBytes :: new_in ( arena) ;
5050 expr. eval ( Some ( ( & tuple, & * * schema) ) ) ?
51- . memcomparable_encode ( & mut key) ?;
52- if !asc {
53- for byte in key. iter_mut ( ) {
51+ . memcomparable_encode_with_null_order ( & mut key, * nulls_first ) ?;
52+ if !asc && key . len ( ) > 1 {
53+ for byte in key. iter_mut ( ) . skip ( 1 ) {
5454 * byte ^= 0xFF ;
5555 }
5656 }
57- key. push ( if * nulls_first { u8:: MIN } else { u8:: MAX } ) ;
5857 full_key. extend ( key) ;
5958 }
6059
Original file line number Diff line number Diff line change @@ -218,6 +218,7 @@ mod wasm_tests {
218218 max: Bound :: Included ( DataValue :: Int32 ( 2 ) ) ,
219219 } ] ,
220220 true ,
221+ None ,
221222 ) ?;
222223
223224 let mut result = Vec :: new ( ) ;
Original file line number Diff line number Diff line change @@ -657,13 +657,22 @@ impl DataValue {
657657 }
658658 }
659659
660- #[ inline]
661- pub fn memcomparable_encode ( & self , b : & mut BumpBytes ) -> Result < ( ) , DatabaseError > {
660+ #[ inline( always) ]
661+ pub fn memcomparable_encode_with_null_order (
662+ & self ,
663+ b : & mut BumpBytes ,
664+ nulls_first : bool ,
665+ ) -> Result < ( ) , DatabaseError > {
666+ let ( null_tag, not_null_tag) = if nulls_first {
667+ ( NULL_TAG , NOTNULL_TAG )
668+ } else {
669+ ( NOTNULL_TAG , NULL_TAG )
670+ } ;
662671 if let DataValue :: Null = self {
663- b. push ( NULL_TAG ) ;
672+ b. push ( null_tag ) ;
664673 return Ok ( ( ) ) ;
665674 }
666- b. push ( NOTNULL_TAG ) ;
675+ b. push ( not_null_tag ) ;
667676
668677 match self {
669678 DataValue :: Null => ( ) ,
@@ -719,6 +728,11 @@ impl DataValue {
719728 Ok ( ( ) )
720729 }
721730
731+ #[ inline]
732+ pub fn memcomparable_encode ( & self , b : & mut BumpBytes ) -> Result < ( ) , DatabaseError > {
733+ self . memcomparable_encode_with_null_order ( b, true )
734+ }
735+
722736 pub fn memcomparable_decode < R : Read > (
723737 reader : & mut R ,
724738 ty : & LogicalType ,
You can’t perform that action at this time.
0 commit comments