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

Function sparsedata_contains

methods/svec/src/pg_gp/SparseData.c:915–962  ·  view source on GitHub ↗

Checks if one SparseData object contained in another * * First vector is said to contain second if all non-zero elements * of the second data object equal those of the first one * * Note: This function only works on SparseData of float8s at present. */

Source from the content-addressed store, hash-verified

913 * Note: This function only works on SparseData of float8s at present.
914 */
915bool sparsedata_contains(SparseData left, SparseData right)
916{
917 char * ix = left->index->data;
918 double* vals = (double *)left->vals->data;
919
920 char * rix = right->index->data;
921 double* rvals = (double *)right->vals->data;
922
923 int read = 0, rread = 0;
924 int i=-1, j=-1, minimum = 0;
925 int lsize, rsize;
926 lsize = left->total_value_count;
927 rsize = right->total_value_count;
928 if((rsize > lsize)&&(rvals[right->unique_value_count-1]!=0.0)){
929 return false;
930 }
931
932 minimum = (lsize > rsize)?rsize:lsize;
933
934 for (;(read < minimum)||(rread < minimum);) {
935 if(read < rread){
936 read += (int)compword_to_int8(ix);
937 ix +=int8compstoragesize(ix);
938 i++;
939 if ((memcmp(&(vals[i]),&(rvals[j]),sizeof(float8))!=0)&&(rvals[j]!=0.0)){
940 return false;
941 }
942 }else if(read > rread){
943 rread += (int)compword_to_int8(rix);
944 rix+=int8compstoragesize(rix);
945 j++;
946 if ((memcmp(&(vals[i]),&(rvals[j]),sizeof(float8))!=0)&&(rvals[j]!=0.0)){
947 return false;
948 }
949 }else{
950 read += (int)compword_to_int8(ix);
951 rread += (int)compword_to_int8(rix);
952 ix +=int8compstoragesize(ix);
953 rix+=int8compstoragesize(rix);
954 i++;
955 j++;
956 if ((memcmp(&(vals[i]),&(rvals[j]),sizeof(float8))!=0)&&(rvals[j]!=0.0)){
957 return false;
958 }
959 }
960 }
961 return true;
962}
963
964
965static inline double id(double x) { return x; }

Callers 1

svec_containsFunction · 0.85

Calls 1

compword_to_int8Function · 0.85

Tested by

no test coverage detected