MCPcopy Create free account
hub / github.com/apache/madlib / float8arr_equals_internal

Function float8arr_equals_internal

methods/svec/src/pg_gp/operators.c:697–746  ·  view source on GitHub ↗

* Provide some operators for Postgres FLOAT8OID arrays */ * Equality */

Source from the content-addressed store, hash-verified

695 * Equality
696 */
697static bool float8arr_equals_internal(ArrayType *left, ArrayType *right)
698{
699 /*
700 * Note that we are only defined for FLOAT8OID
701 */
702 int dimleft = ARR_NDIM(left), dimright = ARR_NDIM(right);
703 int *dimsleft = ARR_DIMS(left), *dimsright = ARR_DIMS(right);
704 int numleft = ArrayGetNItems(dimleft,dimsleft);
705 int numright = ArrayGetNItems(dimright,dimsright);
706 double *vals_left = (double *)ARR_DATA_PTR(left);
707 double *vals_right = (double *)ARR_DATA_PTR(right);
708 bits8 *bitmap_left = ARR_NULLBITMAP(left);
709 bits8 *bitmap_right = ARR_NULLBITMAP(right);
710 int bitmask = 1;
711
712 if ((dimsleft!=dimsright) || (numleft!=numright))
713 return false;
714
715 /*
716 * First we'll check to see if the null bitmaps are equivalent
717 */
718 if (bitmap_left)
719 if (! bitmap_right) return false;
720 if (bitmap_right)
721 if (! bitmap_left) return false;
722
723 if (bitmap_left)
724 {
725 for (int i=0; i<numleft; i++)
726 {
727 if ((*bitmap_left & bitmask) == 0)
728 if ((*bitmap_left & bitmask) != 0)
729 return false;
730 bitmask <<= 1;
731 if (bitmask == 0x100)
732 {
733 bitmap_left++;
734 bitmask = 1;
735 }
736 }
737 }
738
739 /*
740 * Now we check for equality of all array values
741 */
742 for (int i=0; i<numleft; i++)
743 if (vals_left[i] != vals_right[i]) return false;
744
745 return true;
746}
747
748/**
749 * float8arr_equals - checks whether two float8 arrays are identical

Callers 1

float8arr_equalsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected