Changeset 23868
- Timestamp:
- Apr 14, 2009, 4:50:37 PM (17 years ago)
- Location:
- trunk/ippTools/src
- Files:
-
- 2 edited
-
chiptool.c (modified) (5 diffs)
-
pxtools.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/chiptool.c
r23809 r23868 204 204 bool status; 205 205 char *end_stage = psMetadataLookupStr(&status, md, "end_stage"); 206 if (end_stage && strcasecmp(end_stage, "warp")) continue;206 if (end_stage && strcasecmp(end_stage, "warp")) continue; 207 207 208 208 char *raw_tess_id = psMetadataLookupStr(&status, md, "tess_id"); 209 if (raw_tess_id || tess_id) continue;209 if (raw_tess_id || tess_id) continue; 210 210 211 211 char *label = psMetadataLookupStr(&status, md, "label"); … … 213 213 214 214 if (!status) { 215 psError(PS_ERR_UNKNOWN, false, "cannot queue analysis to WARP without a defined tess id: label: %s, exp_id %" PRId64, label, exp_id);215 psError(PS_ERR_UNKNOWN, false, "cannot queue analysis to WARP without a defined tess id: label: %s, exp_id %" PRId64, label, exp_id); 216 216 psFree(output); 217 217 return false; … … 263 263 PXOPT_COPY_STR(config->args, where, "-state", "chipRun.state", "=="); 264 264 265 if (!psListLength(where->list) && 266 !psMetadataLookupBool(NULL, config->args, "-all")) {265 if (!psListLength(where->list) && 266 !psMetadataLookupBool(NULL, config->args, "-all")) { 267 267 psFree(where); 268 268 where = NULL; … … 566 566 PXOPT_COPY_S32(config->args, where, "-magicked", "chipRun.magicked", "=="); 567 567 568 if (!psListLength(where->list) && 569 !psMetadataLookupBool(NULL, config->args, "-all")) {568 if (!psListLength(where->list) && 569 !psMetadataLookupBool(NULL, config->args, "-all")) { 570 570 psFree(where); 571 571 psError(PXTOOLS_ERR_DATA, false, "search parameters (or -all) are required"); … … 1382 1382 bool importrunMode(pxConfig *config) 1383 1383 { 1384 unsigned int nFail; 1385 1386 int numImportTables = 2; 1387 1388 char tables[2] [80] = {"chipImfile", "chipProcessedImfile"}; 1389 1390 PS_ASSERT_PTR_NON_NULL(config, NULL); 1391 1392 PXOPT_LOOKUP_STR(infile, config->args, "-infile", true, false); 1393 1394 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false); 1395 1396 fprintf (stdout, "---- input ----\n"); 1397 psMetadataPrint (stderr, input, 1); 1398 1399 psMetadataItem *item = psMetadataLookup (input, "chipRun"); 1400 psAssert (item, "entry not in input?"); 1401 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 1402 1403 psMetadataItem *entry = psListGet (item->data.list, 0); 1404 assert (entry); 1405 assert (entry->type == PS_DATA_METADATA); 1406 chipRunRow *chipRun = chipRunObjectFromMetadata (entry->data.md); 1407 chipRunInsertObject (config->dbh, chipRun); 1408 1409 // fprintf (stdout, "---- chip run ----\n"); 1410 // psMetadataPrint (stderr, entry->data.md, 1); 1411 1412 for (int i = 0; i < numImportTables; i++) { 1413 psMetadataItem *item = psMetadataLookup (input, tables[i]); 1414 psAssert (item, "entry not in input?"); 1415 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 1416 1417 switch (i) { 1418 case 0: 1419 for (int i = 0; i < item->data.list->n; i++) { 1420 psMetadataItem *entry = psListGet (item->data.list, i); 1421 assert (entry); 1422 assert (entry->type == PS_DATA_METADATA); 1423 chipImfileRow *chipImfile = chipImfileObjectFromMetadata (entry->data.md); 1424 chipImfileInsertObject (config->dbh, chipImfile); 1425 1426 // fprintf (stdout, "---- row %d ----\n", i); 1427 // psMetadataPrint (stderr, entry->data.md, 1); 1428 } 1429 break; 1430 1431 case 1: 1432 for (int i = 0; i < item->data.list->n; i++) { 1433 psMetadataItem *entry = psListGet (item->data.list, i); 1434 assert (entry); 1435 assert (entry->type == PS_DATA_METADATA); 1436 chipProcessedImfileRow *chipProcessedImfile = chipProcessedImfileObjectFromMetadata (entry->data.md); 1437 chipProcessedImfileInsertObject (config->dbh, chipProcessedImfile); 1438 1439 // fprintf (stdout, "---- row %d ----\n", i); 1440 // psMetadataPrint (stderr, entry->data.md, 1); 1441 } 1442 break; 1443 } 1444 } 1445 1446 return true; 1447 } 1448 1449 1384 PS_ASSERT_PTR_NON_NULL(config, NULL); 1385 1386 PXOPT_LOOKUP_STR(infile, config->args, "-infile", true, false); 1387 unsigned int nFail = 0; // Number of failed lines 1388 psMetadata *input = psMetadataConfigRead(NULL, &nFail, infile, false); 1389 if (nFail) { 1390 psError(PS_ERR_IO, false, "%d failed lines in input", nFail); 1391 psFree(input); 1392 return false; 1393 } 1394 1395 psVector *identifiers = psVectorAllocEmpty(16, PS_TYPE_U64); // Identifiers inserted 1396 1397 if (!psDBTransaction(config->dbh)) { 1398 psError(PS_ERR_UNKNOWN, false, "database error"); 1399 return false; 1400 } 1401 1402 psMetadataIterator *iter = psMetadataIteratorAlloc(input, PS_LIST_HEAD, NULL); // Iterator 1403 psMetadataItem *item; // Item from iteration 1404 while ((item = psMetadataGetAndIncrement(iter))) { 1405 PXMIRROR_PRIMARY(item, "chipRun", chipRunRow, chipRunObjectFromMetadata, identifiers, chip_id, 1406 chipRunInsertObject, config->dbh, 1407 { psFree(iter); psFree(identifiers); psFree(input); }); 1408 1409 PXMIRROR_OTHER(item, "chipImfile", chipImfileRow, chipImfileObjectFromMetadata, identifiers, chip_id, 1410 chipImfileInsertObject, config->dbh, 1411 { psFree(iter); psFree(identifiers); psFree(input); }); 1412 1413 PXMIRROR_OTHER(item, "chipProcessedImfile", chipProcessedImfileRow, 1414 chipProcessedImfileObjectFromMetadata, identifiers, chip_id, 1415 chipProcessedImfileInsertObject, config->dbh, 1416 { psErrorStackPrint(stderr, "Error:"); psMetadataPrint(stderr, item->data.md, 0); psFree(iter); psFree(identifiers); psFree(input); }); 1417 } 1418 psFree(iter); 1419 psFree(input); 1420 1421 psLogMsg("chiptool", PS_LOG_INFO, "%ld chipRuns added", identifiers->n); 1422 psFree(identifiers); 1423 1424 return true; 1425 } 1426 1427 -
trunk/ippTools/src/pxtools.h
r23487 r23868 478 478 } 479 479 480 481 /// Add a primary item to the mirror database 482 /// 483 /// ITEM: Item to add (if it is of the correct type) 484 /// NAME: Name for table, to match item name 485 /// ROWTYPE: Type of the row (type returned by PARSEFUNC) 486 /// PARSEFUNC: Function to parse ITEM and return a ROWTYPE 487 /// IDENTIFIERS: Vector (of type U64) to store identifiers 488 /// IDNAME: Element of the row with U64 identifier 489 /// INSERTFUNC: Function to insert a row into the database 490 /// DATABASE: Database handle 491 /// CLEANUP: Operation(s) to perform to cleanup in case of an error 492 #define PXMIRROR_PRIMARY(ITEM, NAME, ROWTYPE, PARSEFUNC, IDENTIFIERS, IDNAME, INSERTFUNC, DATABASE, CLEANUP) \ 493 if (strcmp((ITEM)->name, NAME) == 0) { \ 494 if ((ITEM)->type != PS_DATA_METADATA) { \ 495 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Entry %s is not of type METADATA", (ITEM)->name); \ 496 CLEANUP; \ 497 return false; \ 498 } \ 499 ROWTYPE *row = PARSEFUNC((ITEM)->data.md); /* Row to insert */ \ 500 if (!row) { \ 501 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to generate %s row from metadata", (ITEM)->name); \ 502 CLEANUP; \ 503 return false; \ 504 } \ 505 if (!INSERTFUNC(DATABASE, row)) { \ 506 psError(PS_ERR_UNKNOWN, false, "Unable to add %s %" PRIu64, (ITEM)->name, row->IDNAME); \ 507 psFree(row); \ 508 CLEANUP; \ 509 return false; \ 510 } \ 511 psVectorAppend((IDENTIFIERS), row->IDNAME); \ 512 psFree(row); \ 513 } 514 515 /// Add a dependent item to the mirror database 516 /// 517 /// ITEM: Item to add (if it is of the correct type) 518 /// NAME: Name for table, to match item name 519 /// ROWTYPE: Type of the row (type returned by PARSEFUNC) 520 /// PARSEFUNC: Function to parse ITEM and return a ROWTYPE 521 /// IDENTIFIERS: Vector (of type U64) to check identifiers 522 /// IDNAME: Element of the row with U64 identifier 523 /// INSERTFUNC: Function to insert a row into the database 524 /// DATABASE: Database handle 525 /// CLEANUP: Operation(s) to perform to cleanup in case of an error 526 #define PXMIRROR_OTHER(ITEM, NAME, ROWTYPE, PARSEFUNC, IDENTIFIERS, IDNAME, INSERTFUNC, DATABASE, CLEANUP) \ 527 if (strcmp((ITEM)->name, NAME) == 0) { \ 528 if ((ITEM)->type != PS_DATA_METADATA) { \ 529 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Entry %s is not of type METADATA", (ITEM)->name); \ 530 CLEANUP; \ 531 return false; \ 532 } \ 533 ROWTYPE *row = PARSEFUNC(item->data.md); /* Row to insert */ \ 534 if (!row) { \ 535 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to generate %s row from metadata", (ITEM)->name); \ 536 CLEANUP; \ 537 return false; \ 538 } \ 539 bool found = false; /* Found the identifier? */ \ 540 for (int i = 0; i < (IDENTIFIERS)->n && !found; i++) { \ 541 if (row->IDNAME == (IDENTIFIERS)->data.U64[i]) { \ 542 found = true; \ 543 break; \ 544 } \ 545 } \ 546 if (!found) { \ 547 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Identifier not found for %s %" PRIu64, \ 548 (ITEM)->name, row->IDNAME); \ 549 psFree(row); \ 550 CLEANUP; \ 551 return false; \ 552 } \ 553 if (!INSERTFUNC(DATABASE, row)) { \ 554 psError(PS_ERR_UNKNOWN, false, "Unable to add %s %" PRIu64, (ITEM)->name, row->IDNAME); \ 555 psFree(row); \ 556 CLEANUP; \ 557 return false; \ 558 } \ 559 psFree(row); \ 560 } 561 480 562 #endif // PXTOOLS_H
Note:
See TracChangeset
for help on using the changeset viewer.
