| 1175 | } |
| 1176 | |
| 1177 | void averageOnRecordsTest() { |
| 1178 | double sum = 0; |
| 1179 | double pred = 0; |
| 1180 | int i = 0; |
| 1181 | |
| 1182 | // insert a few keys |
| 1183 | for (double d = 0; d < 10000; d++, i++) { |
| 1184 | ups_key_t key = ups_make_key(&d, sizeof(d)); |
| 1185 | ups_record_t record = ups_make_record(&i, sizeof(i)); |
| 1186 | REQUIRE(0 == ups_db_insert(db, 0, &key, &record, 0)); |
| 1187 | sum += i; |
| 1188 | if (i < 5000) |
| 1189 | pred += i; |
| 1190 | } |
| 1191 | |
| 1192 | ResultProxy rp; |
| 1193 | REQUIRE(0 == uqi_select(env, "AVERAGE($record) from database 1", |
| 1194 | &rp.result)); |
| 1195 | rp.require("AVERAGE", UPS_TYPE_REAL64, sum / 10000.0) |
| 1196 | .close(); |
| 1197 | |
| 1198 | uqi_plugin_t record_plugin = {0}; |
| 1199 | record_plugin.name = "record_pred"; |
| 1200 | record_plugin.type = UQI_PLUGIN_PREDICATE; |
| 1201 | record_plugin.pred = record_predicate; |
| 1202 | REQUIRE(0 == uqi_register_plugin(&record_plugin)); |
| 1203 | REQUIRE(0 == uqi_select(env, "AVERAGE($record) from database 1 where " |
| 1204 | "record_pred($record)", &rp.result)); |
| 1205 | rp.require("AVERAGE", UPS_TYPE_REAL64, pred / 5000.0); |
| 1206 | } |
| 1207 | |
| 1208 | void pluginOnRecordsTest() { |
| 1209 | uint64_t sum = 0; |
no test coverage detected