---------------------------------------------------------------------------
-- Rules: 
-- ------
-- 1) Any DB objects should be created w/o schema prefix,
--    since this file is executed in a separate schema context.
-- 2) There should be no DROP statements in this script, since
--    all objects created in the default schema will be cleaned-up outside.
---------------------------------------------------------------------------

---------------------------------------------------------------------------
-- Test: 
---------------------------------------------------------------------------
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 0), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 1), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 2), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 3), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 4), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 5), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 6), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 7), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 8), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 9), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 10), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 11), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 12), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 13), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 14), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 15), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 16), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 17), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 18), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 19), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 20), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 21), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 22), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 23), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 24), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 25), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 26), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 27), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 28), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 29), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 30), 32, 0);
select MADLIB_SCHEMA.__sketch_rightmost_one(MADLIB_SCHEMA.__sketch_array_set_bit_in_place(E'\\000\\000\\000\\000', 1, 32, 0, 31), 32, 0);

select MADLIB_SCHEMA.__sketch_rightmost_one(E'\\177\\377\\377\\376\\000\\000\\000\\000', 32, 1);

select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\177\\377\\377\\377', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\277\\377\\377\\377', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\337\\377\\377\\377', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\357\\377\\377\\377', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\367\\377\\377\\377', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\373\\377\\377\\377', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\375\\377\\377\\377', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\376\\377\\377\\377', 32, 0);

select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\377\\177\\377\\377', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\377\\277\\377\\377', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\377\\337\\377\\377', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\377\\357\\377\\377', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\377\\367\\377\\377', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\377\\373\\377\\377', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\377\\375\\377\\377', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\377\\376\\377\\377', 32, 0);

select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\377\\377\\177\\377', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\377\\377\\277\\377', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\377\\377\\337\\377', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\377\\377\\357\\377', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\377\\377\\367\\377', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\377\\377\\373\\377', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\377\\377\\375\\377', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\377\\377\\376\\377', 32, 0);

select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\377\\377\\377\\177', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\377\\377\\377\\277', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\377\\377\\377\\337', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\377\\377\\377\\357', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\377\\377\\377\\367', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\377\\377\\377\\373', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\377\\377\\377\\375', 32, 0);
select MADLIB_SCHEMA.__sketch_leftmost_zero(E'\\377\\377\\377\\376', 32, 0);
