+////////////////////////////////////////////////////////
+// count_diff aggregate
+struct lfta_count_diff_scratch{
+ gs_uint32_t count;
+ union{
+ gs_uint32_t ui;
+ gs_int32_t i;
+ gs_uint64_t ul;
+ gs_int64_t l;
+ } first;
+ union{
+ gs_uint32_t ui;
+ gs_int32_t i;
+ gs_uint64_t ul;
+ gs_int64_t l;
+ } last;
+};
+
+// unsigned int
+void count_diff_lfta_ui_LFTA_AGGR_INIT_(gs_sp_t s) {
+ struct lfta_count_diff_scratch* scratch = (struct lfta_count_diff_scratch*)s;
+ scratch->count = 0;
+ scratch->first.l = 0;
+ scratch->last.l = 0;
+}
+void count_diff_lfta_ui_LFTA_AGGR_UPDATE_(gs_sp_t s, gs_uint32_t val) {
+ struct lfta_count_diff_scratch* scratch = (struct lfta_count_diff_scratch*)s;
+ if(scratch->count==0){
+ scratch->count = 1;
+ scratch->first.ui = val;
+ }else{
+ if(scratch->last.ui != val)
+ scratch->count++;
+ }
+ scratch->last.ui = val;
+}
+void count_diff_lfta_ui_LFTA_AGGR_OUTPUT_(struct gs_string * res, gs_sp_t scratch) {
+ res->data = (gs_sp_t)scratch;
+ res->length = sizeof(struct lfta_count_diff_scratch);
+ res->owner = NULL;
+}
+void count_diff_lfta_ui_LFTA_AGGR_DESTROY_(gs_sp_t s) { }
+
+gs_retval_t count_diff_lfta_ui_LFTA_AGGR_FLUSHME_(gs_sp_t s) {
+ return 0;
+}
+
+// int
+void count_diff_lfta_i_LFTA_AGGR_INIT_(gs_sp_t s) {
+ struct lfta_count_diff_scratch* scratch = (struct lfta_count_diff_scratch*)s;
+ scratch->count = 0;
+ scratch->first.l = 0;
+ scratch->last.l = 0;
+}
+void count_diff_lfta_i_LFTA_AGGR_UPDATE_(gs_sp_t s, gs_int32_t val) {
+ struct lfta_count_diff_scratch* scratch = (struct lfta_count_diff_scratch*)s;
+ if(scratch->count==0){
+ scratch->count = 1;
+ scratch->first.i = val;
+ }else{
+ if(scratch->last.i != val)
+ scratch->count++;
+ }
+ scratch->last.i = val;
+}
+void count_diff_lfta_i_LFTA_AGGR_OUTPUT_(struct gs_string * res, gs_sp_t scratch) {
+ res->data = (gs_sp_t)scratch;
+ res->length = sizeof(struct lfta_count_diff_scratch);
+ res->owner = NULL;
+}
+void count_diff_lfta_i_LFTA_AGGR_DESTROY_(gs_sp_t s) { }
+gs_retval_t count_diff_lfta_i_LFTA_AGGR_FLUSHME_(gs_sp_t s) {
+ return 0;
+}
+
+// unsigned long long int
+void count_diff_lfta_ul_LFTA_AGGR_INIT_(gs_sp_t s) {
+ struct lfta_count_diff_scratch* scratch = (struct lfta_count_diff_scratch*)s;
+ scratch->count = 0;
+ scratch->first.l = 0;
+ scratch->last.l = 0;
+}
+void count_diff_lfta_ul_LFTA_AGGR_UPDATE_(gs_sp_t s, gs_uint64_t val) {
+ struct lfta_count_diff_scratch* scratch = (struct lfta_count_diff_scratch*)s;
+ if(scratch->count==0){
+ scratch->count = 1;
+ scratch->first.ul = val;
+ }else{
+ if(scratch->last.ul != val)
+ scratch->count++;
+ }
+ scratch->last.ul = val;
+}
+void count_diff_lfta_ul_LFTA_AGGR_OUTPUT_(struct gs_string * res, gs_sp_t scratch) {
+ res->data = (gs_sp_t)scratch;
+ res->length = sizeof(struct lfta_count_diff_scratch);
+ res->owner = NULL;
+}
+void count_diff_lfta_ul_LFTA_AGGR_DESTROY_(gs_sp_t s) { }
+gs_retval_t count_diff_lfta_ul_LFTA_AGGR_FLUSHME_(gs_sp_t s) {
+ return 0;
+}
+
+// long long int
+void count_diff_lfta_l_LFTA_AGGR_INIT_(gs_sp_t s) {
+ struct lfta_count_diff_scratch* scratch = (struct lfta_count_diff_scratch*)s;
+ scratch->count = 0;
+ scratch->first.l = 0;
+ scratch->last.l = 0;
+}
+void count_diff_lfta_l_LFTA_AGGR_UPDATE_(gs_sp_t s, gs_int64_t val) {
+ struct lfta_count_diff_scratch* scratch = (struct lfta_count_diff_scratch*)s;
+ if(scratch->count==0){
+ scratch->count = 1;
+ scratch->first.l = val;
+ }else{
+ if(scratch->last.l != val)
+ scratch->count++;
+ }
+ scratch->last.l = val;
+}
+void count_diff_lfta_l_LFTA_AGGR_OUTPUT_(struct gs_string* res, gs_sp_t scratch) {
+ res->data = (gs_sp_t)scratch;
+ res->length = sizeof(struct lfta_count_diff_scratch);
+ res->owner = NULL;
+}
+void count_diff_lfta_l_LFTA_AGGR_DESTROY_(gs_sp_t s) { }
+gs_retval_t count_diff_lfta_l_LFTA_AGGR_FLUSHME_(gs_sp_t s) {
+ return 0;
+}
+
+// string
+
+static gs_uint64_t local_hash_string(struct gs_string *x){
+ gs_uint32_t i;
+ gs_uint64_t ret=0,tmp_sum = 0;
+ for(i=0;i<x->length;++i){
+ tmp_sum |= (x->data[i]) << (8*(i%4));
+ if((i%4) == 3){
+ ret = tmp_sum + 12916008961267169387ull * ret;
+ tmp_sum = 0;
+ }
+ }
+ if((i%4)!=0) ret = tmp_sum + 12916008961267169387ull * ret;
+ return(ret);
+}
+
+
+void count_diff_lfta_s_LFTA_AGGR_INIT_(gs_sp_t s) {
+ struct lfta_count_diff_scratch* scratch = (struct lfta_count_diff_scratch*)s;
+ scratch->count = 0;
+ scratch->first.ul = 0;
+ scratch->last.ul = 0;
+}
+void count_diff_lfta_s_LFTA_AGGR_UPDATE_(gs_sp_t s, struct gs_string* val) {
+ struct lfta_count_diff_scratch* scratch = (struct lfta_count_diff_scratch*)s;
+ gs_uint64_t hashval;
+ hashval = local_hash_string(val);
+ if(scratch->count==0){
+ scratch->count = 1;
+ scratch->first.ul = hashval;
+ }else{
+ if(scratch->last.ul != hashval)
+ scratch->count++;
+ }
+ scratch->last.ul = hashval;
+}
+void count_diff_lfta_s_LFTA_AGGR_OUTPUT_(struct gs_string* res, gs_sp_t scratch) {
+ res->data = (gs_sp_t)scratch;
+ res->length = sizeof(struct lfta_count_diff_scratch);
+ res->owner = NULL;
+}
+void count_diff_lfta_s_LFTA_AGGR_DESTROY_(gs_sp_t s) { }
+gs_retval_t count_diff_lfta_s_LFTA_AGGR_FLUSHME_(gs_sp_t s) {
+ return 0;
+}
+
+
+
+
+
+
+
+
+
+