Bitwise wish list


#1

It’d be nice to have the bitwise operators (~,|,&, ^, >>, <<), as built-in functions for SciDB. This would make it much easier to have flag attributes. I can, of course, roll my own, but I can’t change the AQL or AFL syntax, and ‘|’ is so much more elegant than ‘bitor’, right?

Also, why no conversions between string<->bool?


#2

One of the features we’ve tried to emphasize with SciDB is type and function extensibility.

If what you want is a “bit vector” type–we’d call these User-Defined Types or UDTs–and a collection of logical functions–we’d call these User-Defined Types–we’ve built the engine to let you do just that. Have a look for the various “examples” UDT/UDF extensions that ship with the engine. Start with one of those, and modify it to your requirements. You should be able to do things like this:

CREATE ARRAY Foo <
Value : double,
Mask : bit_mask

[ I = 0:9999,1000,0, J=0:9999,1000, 0 ];

CREATE ARRAY Bar <
Mask : bit_mask

[ MaskID(string) = *,1000,0 ];

Q: Which I/J values in Foo contain a mask with a hamming distance of less than 100 from ‘MyMask’ in Bar?

filter ( cross_join ( Foo, slice ( Bar, I, ‘MyMask’ ) ), num_bits ( XOR ( Foo.Mask, Bar.Mask ) ) < 100 ));