From d4ba1a7dd87ecbc287b9912b8f351485f3654345 Mon Sep 17 00:00:00 2001 From: ligc Date: Tue, 4 Dec 2012 02:42:37 +0000 Subject: [PATCH] performance improvements for lsdef -l -t auditlog git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@14531 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/DBobjUtils.pm | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/perl-xCAT/xCAT/DBobjUtils.pm b/perl-xCAT/xCAT/DBobjUtils.pm index 465ed446a..bceddda1b 100644 --- a/perl-xCAT/xCAT/DBobjUtils.pm +++ b/perl-xCAT/xCAT/DBobjUtils.pm @@ -396,6 +396,44 @@ sub getobjdefs xCAT::MsgUtils->message("E", $rsp, $::callback); } } + } elsif ($objtype eq 'auditlog') { + # Special case for auditlog + # All the auditlog attributes are in auditlog table, + # Do not need to read the table multiple times for each attribute. + # The auditlog is likely be very big over time, + # performance is a big concern with the general logic + my @TableRowArray = xCAT::DBobjUtils->getDBtable('auditlog'); + foreach my $objname (sort @{$type_obj{$objtype}}) { + if (@TableRowArray) + { + my $foundinfo = 0; + foreach my $entry (@TableRowArray) + { + if ($entry->{recid} eq $objname) + { + foreach my $k (keys %{$entry}) + { + # recid is the object name, do not need to be in the attributes list + if ($k eq 'recid') { next; } + if (defined($entry->{$k}) ) { + $foundinfo++; + if ($verbose == 1) { + $objhash{$objname}{$k} = "$entry->{$k}\t(Table:auditlog - Key:$k)"; + } else { + $objhash{$objname}{$k} = $entry->{$k}; + } + } + } + if ($foundinfo) + { + $objhash{$objname}{'objtype'} = 'auditlog'; + } + # There should not be multiple entries with the same recid + last; + } # end if($entry-> + } # end foreach my $entry + } # end if(@TableTowArray + } # end foreach my $objname } else { # get the object type decription from Schema.pm my $datatype = $xCAT::Schema::defspec{$objtype};