Changeset 17498
- Timestamp:
- May 1, 2008, 2:10:43 PM (18 years ago)
- Location:
- branches/eam_branch_20080430/psLib/src/types
- Files:
-
- 3 edited
-
psMetadata.c (modified) (5 diffs)
-
psMetadata.h (modified) (2 diffs)
-
psMetadataConfig.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20080430/psLib/src/types/psMetadata.c
r17494 r17498 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1.168.6. 1$ $Name: not supported by cvs2svn $15 * @date $Date: 2008-0 4-30 21:04:22$14 * @version $Revision: 1.168.6.2 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2008-05-02 00:10:43 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 642 642 } 643 643 644 644 // XXX is it sensible that item is a 'const' here? 645 645 bool psMetadataAddItem(psMetadata *md, 646 646 const psMetadataItem *item, … … 648 648 psS32 flags) 649 649 { 650 char * key = NULL;651 psHash *mdTable = NULL;652 psList *mdList = NULL;653 psMetadataItem *existingEntry = NULL;654 655 650 PS_ASSERT_METADATA_NON_NULL(md,false); 656 651 PS_ASSERT_METADATA_ITEM_NON_NULL(item,false); 657 652 658 mdTable = md->hash;659 mdList = md->list;660 key = item->name;653 psHash *mdTable = md->hash; 654 psList *mdList = md->list; 655 char *key = item->name; 661 656 662 657 // See if key is already in table 663 existingEntry = (psMetadataItem*)psHashLookup(mdTable, key); 664 658 psMetadataItem *existingEntry = psHashLookup(mdTable, key); 659 660 // this block handles cases for the MULTI items 665 661 if (item->type == PS_DATA_METADATA_MULTI) { 666 662 // the incoming entry is PS_DATA_METADATA_MULTI 667 663 668 //Shouldn't have a second reference to the same MULTI in a single Metadata! 664 // Shouldn't have a second reference to the same MULTI in a single Metadata! 665 // XXX not sure I understand this case 669 666 if (item == existingEntry) { 670 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 671 "Cannot have 2 references to the same MULTI in a single Metadata!"); 667 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Cannot have 2 references to the same MULTI in a single Metadata!"); 672 668 return false; 673 669 } 674 670 675 // force the hash entry to be PS_DATA_METADATA_MULTI 676 existingEntry = makeMetaMulti(mdTable,key,existingEntry); 671 if (flags & PS_META_REPLACE) { 672 // drop the existing entry or entries 673 psMetadataRemoveKey(md, key); 674 } else { 675 // elevate the existing hash entry to be PS_DATA_METADATA_MULTI 676 existingEntry = makeMetaMulti(mdTable,key,existingEntry); 677 } 677 678 678 679 // add all the items in the incoming entry to metadata … … 690 691 } 691 692 693 // special block for items which are METADATA folders 694 if (item->type == PS_DATA_METADATA) { 695 if (flags & PS_META_REPLACE) { 696 // drop the existing entry (skip if we are replacing with same pointer) 697 // XXX what if existingEntry is a MULTI? drop all? 698 if (item != existingEntry) { 699 psMetadataRemoveKey(md, key); 700 } 701 } 702 if (flags & PS_META_UPDATE_FOLDER) { 703 if (existingEntry->type != PS_DATA_METADATA) { 704 psError(PS_ERR_UNKNOWN, false, "invalid to request UPDATE for metadata which matches another type"); 705 return false; 706 } 707 708 // merge the existing entry : this completes the insert 709 if (!psMetadataCopy ((psMetadata *)existingEntry->data.V, (psMetadata *)item->data.V)) { 710 psError(PS_ERR_UNKNOWN, false, "failed to copy new metadata on existing"); 711 return false; 712 } 713 return true; 714 } 715 } 716 692 717 // how the item is added to the hash depends on prior existence, flags, etc. 718 // XXX i think these cases are overloaded - are all combinations possible? 693 719 if (existingEntry) { // prior existence 694 if (existingEntry->type == PS_DATA_METADATA_MULTI || (flags & PS_META_DUPLICATE_OK)) { 695 // duplicate entries allowed - add another entry. 720 721 // duplicate entries allowed - add another entry. 722 if ((existingEntry->type == PS_DATA_METADATA_MULTI) || (flags & PS_META_DUPLICATE_OK)) { 696 723 697 724 // make sure the existing entry is PS_DATA_METADATA_MULTI 698 725 existingEntry = makeMetaMulti(mdTable,key,existingEntry); 699 726 700 // add to the hash's list of duplicate entries 701 if (!psListAdd(existingEntry->data.list, PS_LIST_TAIL, (psPtr)item) ) { 702 psError(PS_ERR_UNKNOWN, false, 703 _("Failed to add metadata item, %s, to metadata collection list."), 704 key); 727 // add item to the existing hash's list of duplicate entries 728 if (!psListAdd(existingEntry->data.list, PS_LIST_TAIL, (psMetadataItem *) item) ) { 729 psError(PS_ERR_UNKNOWN, false, _("Failed to add metadata item, %s, to metadata collection list."), key); 705 730 return false; 706 731 } 707 } else if (flags & PS_META_REPLACE) { 708 // replace entry instead of creating a duplicate entry. 732 // add to the metadata list of entries 733 if (!psListAdd(mdList, location, (psMetadataItem *) item)) { 734 psError(PS_ERR_UNKNOWN, false, _("Failed to add metadata item, %s, to metadata collection list."), key); 735 return false; 736 } 737 return true; 738 } 739 740 // replace entry instead of creating a duplicate entry. 741 if (flags & PS_META_REPLACE) { 709 742 710 743 if ((flags & PS_META_REQUIRE_TYPE) && (existingEntry->type != item->type)) { … … 716 749 // when you blow away what you're trying to add 717 750 psMetadataRemoveKey(md, key); 718 psHashAdd(mdTable, key, (psPtr)item); 719 } 720 } else { 721 // default is to error on duplicate entry. 722 if (flags & PS_META_NO_REPLACE) { 723 return true; 724 } 725 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 726 _("Duplicate metadata item name: %s is not allowed. " 727 "Use a psMetadataFlags option to allow such action."), item->name); 728 return false; 729 } 730 } else { 731 // OK, this is a new item. 732 if (flags & PS_META_REQUIRE_ENTRY) { 733 psError (PS_ERR_UNKNOWN, true, _("No matching item found for item requiring existing entry (%s)"), 734 key); 735 return false; 736 } 737 738 // Node doesn't exist - Add new metadata item to metadata collection's hash 739 /* The following is unneeded. HashAdd can't return false with non-null inputs. 740 741 if(!psHashAdd(mdTable, key, (psPtr)item)) { 742 psError(PS_ERR_UNKNOWN,false, 743 _("Failed to add metadata item, %s, to items table."),key); 744 return false; 745 } 746 */ 747 psHashAdd(mdTable, key, (psPtr)item); 748 // Create a multi, if required 749 if (flags & PS_META_DUPLICATE_OK) { 750 makeMetaMulti(mdTable,key,(psMetadataItem*)item); // Casting away const! 751 } 752 } 753 754 if(!psListAdd(mdList, location, (psPtr)item)) { 755 psError(PS_ERR_UNKNOWN, false, 756 _("Failed to add metadata item, %s, to metadata collection list."), key); 751 // add to the metadata has of entries 752 if (!psHashAdd(mdTable, key, (psMetadataItem *) item)) { 753 psError(PS_ERR_UNKNOWN, false, _("Failed to add metadata item, %s, to metadata collection list."), key); 754 return false; 755 } 756 // add to the metadata list of entries 757 if (!psListAdd(mdList, location, (psMetadataItem *) item)) { 758 psError(PS_ERR_UNKNOWN, false, _("Failed to add metadata item, %s, to metadata collection list."), key); 759 return false; 760 } 761 return true; 762 } 763 } 764 765 // if specified, keep the existing entry 766 if (flags & PS_META_NO_REPLACE) { 767 return true; 768 } 769 770 // default is to error on duplicate entry. 771 psError(PS_ERR_BAD_PARAMETER_VALUE, true, _("Duplicate metadata item name: %s is not allowed. Use a psMetadataFlags option to allow such action."), item->name); 772 return false; 773 } 774 775 // OK, this is a new item. 776 if (flags & PS_META_REQUIRE_ENTRY) { 777 psError (PS_ERR_UNKNOWN, true, _("No matching item found for item requiring existing entry (%s)"), key); 778 return false; 779 } 780 781 // Node doesn't exist - Add new metadata item to metadata collection's hash 782 psHashAdd(mdTable, key, (psMetadataItem *) item); 783 784 // Create a multi, if requested 785 if (flags & PS_META_DUPLICATE_OK) { 786 makeMetaMulti(mdTable, key, (psMetadataItem *) item); // Casting away const! 787 } 788 789 if (!psListAdd(mdList, location, (psPtr)item)) { 790 psError(PS_ERR_UNKNOWN, false, _("Failed to add metadata item, %s, to metadata collection list."), key); 757 791 return false; 758 792 } -
branches/eam_branch_20080430/psLib/src/types/psMetadata.h
r17494 r17498 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.103.12. 1$ $Name: not supported by cvs2svn $12 * @date $Date: 2008-0 4-30 21:04:22$11 * @version $Revision: 1.103.12.2 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2008-05-02 00:10:43 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 70 70 #define PS_METADATA_TYPE_MASK 0x00FFFFFF 71 71 72 #define PS_METADATA_ITEM_ TYPE(ITEM) (MD->type & PS_METADATA_TYPE_MASK)72 #define PS_METADATA_ITEM_GET_TYPE(MDITEM) (MDITEM->type & PS_METADATA_TYPE_MASK) 73 73 74 74 /** Metadata data structure. -
branches/eam_branch_20080430/psLib/src/types/psMetadataConfig.c
r17494 r17498 11 11 * @author Joshua Hoblitt, University of Hawaii 2006-2007 12 12 * 13 * @version $Revision: 1.142.8. 1$ $Name: not supported by cvs2svn $14 * @date $Date: 2008-0 4-30 21:04:22$13 * @version $Revision: 1.142.8.2 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2008-05-02 00:10:43 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 819 819 // found a directive, what does it say? 820 820 if (strcasecmp (strValue, "UPDATE") && strcasecmp (strValue, "UPDATE")) { 821 psError(PS_ERR_IO, true, _("Invalid directive %s for METADATA or MULTI." , strValue));821 psError(PS_ERR_IO, true, _("Invalid directive %s for METADATA or MULTI."), strValue); 822 822 psFree(strType); 823 823 psFree(strValue);
Note:
See TracChangeset
for help on using the changeset viewer.
