Changeset 136
- Timestamp:
- 03/23/08 12:13:02 (8 months ago)
- Files:
-
- trunk/core/src/shooting_star_boost_wrapper.cpp (modified) (4 diffs)
- trunk/core/src/shooting_star.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/core/src/shooting_star_boost_wrapper.cpp
r124 r136 290 290 { 291 291 *err_msg = "Source edge not found"; 292 return - 1;292 return -2; 293 293 } 294 294 … … 308 308 { 309 309 *err_msg = "Target edge not found"; 310 return - 1;310 return -3; 311 311 } 312 312 … … 359 359 { 360 360 *err_msg = "Overflow"; 361 return - 1;361 return -4; 362 362 } 363 363 } … … 386 386 } 387 387 388 *err_msg = "Target was not reached"; 389 return -1; 390 388 391 } 389 392 trunk/core/src/shooting_star.c
r121 r136 189 189 int t; 190 190 191 DBG("fetching\n"); 192 191 193 for(t=0; t<MAX_RULE_LENGTH;++t) 192 194 target_edge->rule[t] = -1; 193 195 196 DBG("rule reset\n"); 197 194 198 binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->id, &isnull); 195 199 if (isnull) 196 200 elog(ERROR, "id contains a null value"); 197 201 target_edge->id = DatumGetInt32(binval); 202 DBG("id: %i\n", target_edge->id); 198 203 199 204 binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->source, &isnull); … … 201 206 elog(ERROR, "source contains a null value"); 202 207 target_edge->source = DatumGetInt32(binval); 208 DBG("source: %i\n", target_edge->source); 203 209 204 210 binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->target, &isnull); … … 206 212 elog(ERROR, "target contains a null value"); 207 213 target_edge->target = DatumGetInt32(binval); 214 DBG("target: %i\n", target_edge->target); 208 215 209 216 binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->cost, &isnull); … … 211 218 elog(ERROR, "cost contains a null value"); 212 219 target_edge->cost = DatumGetFloat8(binval); 220 DBG("cost: %f\n", target_edge->cost); 213 221 214 222 if (edge_columns->reverse_cost != -1) … … 219 227 elog(ERROR, "reverse_cost contains a null value"); 220 228 target_edge->reverse_cost = DatumGetFloat8(binval); 229 DBG("r_cost: %f\n", target_edge->reverse_cost); 230 221 231 } 222 232 … … 225 235 elog(ERROR, "source x contains a null value"); 226 236 target_edge->s_x = DatumGetFloat8(binval); 237 DBG("s_x: %f\n", target_edge->s_x); 227 238 228 239 binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->s_y, &isnull); … … 230 241 elog(ERROR, "source y contains a null value"); 231 242 target_edge->s_y = DatumGetFloat8(binval); 243 DBG("s_y: %f\n", target_edge->s_y); 232 244 233 245 binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->t_x, &isnull); … … 235 247 elog(ERROR, "target x contains a null value"); 236 248 target_edge->t_x = DatumGetFloat8(binval); 249 DBG("t_x: %f\n", target_edge->t_x); 237 250 238 251 binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->t_y, &isnull); … … 240 253 elog(ERROR, "target y contains a null value"); 241 254 target_edge->t_y = DatumGetFloat8(binval); 255 DBG("t_y: %f\n", target_edge->t_y); 242 256 243 257 binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->to_cost, &isnull); 244 258 if (isnull) 245 target_edge->to_cost = 0; 246 259 target_edge->to_cost = 0; 247 260 else 248 261 target_edge->to_cost = DatumGetFloat8(binval); 262 DBG("to_cost: %f\n", target_edge->to_cost); 249 263 250 264 char *str = DatumGetCString(SPI_getvalue(*tuple, *tupdesc, edge_columns->rule)); 251 252 char* pch; 265 266 if(str != NULL) 267 { 268 char *str2 = " rule loaded\n"; 269 char *str3; 270 271 str3 = (char *)calloc(strlen(str) + strlen(str2) + 1, sizeof(char)); 272 strcat(str3, str); 273 strcat(str3, str2); 274 275 DBG(str3); 276 277 free(str3); 278 279 char* pch = NULL; 253 280 int ci = MAX_RULE_LENGTH; 254 281 255 pch = (char *)strtok (str," ,"); 256 282 pch = strtok (str," ,"); 283 284 DBG("parsing rule\n"); 257 285 while (pch != NULL) 258 286 { … … 261 289 pch = (char *)strtok (NULL, " ,"); 262 290 } 263 291 DBG("rule: %i\n", target_edge->rule[0]); 292 } 264 293 } 265 294 … … 329 358 } 330 359 331 //DBG("***%i***", ret);360 // DBG("***%i***", ret); 332 361 333 362 ntuples = SPI_processed; 363 DBG("ntuples = %i", ntuples); 364 334 365 total_tuples += ntuples; 335 336 if (!edges) 366 DBG("<%i> tuples", total_tuples); 367 368 // if (!edges) 369 if (total_tuples <= TUPLIMIT) 337 370 edges = palloc(total_tuples * sizeof(edge_shooting_star_t)); 338 371 else 339 372 edges = repalloc(edges, total_tuples * sizeof(edge_shooting_star_t)); 373 374 DBG("memory for more %i ntuples allocated", ntuples); 340 375 341 376 if (edges == NULL) … … 349 384 int t; 350 385 SPITupleTable *tuptable = SPI_tuptable; 386 DBG("tuptable", ntuples); 351 387 TupleDesc tupdesc = SPI_tuptable->tupdesc; 388 389 DBG("tupdesc", ntuples); 352 390 353 391 for (t = 0; t < ntuples; t++) 354 392 { 355 393 HeapTuple tuple = tuptable->vals[t]; 394 DBG("tuple", ntuples); 356 395 fetch_edge_shooting_star(&tuple, &tupdesc, &edge_columns, 357 396 &edges[total_tuples - ntuples + t]); 397 DBG("fetch", ntuples); 358 398 } 359 399 SPI_freetuptable(tuptable); 400 DBG("freetuptable", ntuples); 360 401 } 361 402 else … … 366 407 367 408 368 DBG("Total %ituples", total_tuples);409 DBG("Total <%i> tuples", total_tuples); 369 410 370 411 … … 419 460 //time_t stime = time(NULL); 420 461 462 DBG("ret = %i\n",ret); 463 421 464 ret = boost_shooting_star(edges, total_tuples, source_edge_id, 422 465 target_edge_id, … … 437 480 ereport(ERROR, (errcode(ERRCODE_E_R_E_CONTAINING_SQL_NOT_PERMITTED), 438 481 errmsg("Error computing path: %s", err_msg))); 482 // errmsg("Error computing path: %i", ret))); 439 483 } 440 484 return finish(SPIcode, ret);

