# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0.  If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.

module mkey;

command rotate(v:lng, nbits:int) :lng
address MKEYrotate
comment "left-rotate an int by nbits";

pattern hash(v:any):lng
address MKEYhash
comment "calculate a hash value";

pattern hash(v:bit):lng
address MKEYhash
comment "calculate a hash value";
pattern hash(v:bte):lng
address MKEYhash
comment "calculate a hash value";
pattern hash(v:sht):lng
address MKEYhash
comment "calculate a hash value";
pattern hash(v:int):lng
address MKEYhash
comment "calculate a hash value";
pattern hash(v:flt):lng
address MKEYhash
comment "calculate a hash value";
pattern hash(v:dbl):lng
address MKEYhash
comment "calculate a hash value";
pattern hash(v:lng):lng
address MKEYhash
comment "calculate a hash value";
pattern hash(v:str):lng
address MKEYhash
comment "calculate a hash value";

pattern bulk_rotate_xor_hash(h:lng, nbits:int, v:any) :lng
address MKEYrotate_xor_hash
comment "post: [:xor=]([:rotate=](h, nbits), [hash](b))";

command bulk_rotate_xor_hash(h:lng, nbits:int, b:bat[:any_1])
	:bat[:lng]
address MKEYconstbulk_rotate_xor_hash
comment "pre:  h and b should be synced on head
         post: [:xor=]([:rotate=](h, nbits), [hash](b))";

pattern bulk_rotate_xor_hash(h:bat[:lng], nbits:int, v:any)
	:bat[:lng]
address MKEYbulkconst_rotate_xor_hash
comment "pre:  h and b should be synced on head
         post: [:xor=]([:rotate=](h, nbits), [hash](b))";

command bulk_rotate_xor_hash(h:bat[:lng], nbits:int, b:bat[:any_1])
	:bat[:lng]
address MKEYbulk_rotate_xor_hash
comment "pre:  h and b should be synced on head
         post: [:xor=]([:rotate=](h, nbits), [hash](b))";

module batmkey;

command hash(b:bat[:any_1]) :bat[:lng]
address MKEYbathash
comment "calculate a hash value";
