Changes between Version 37 and Version 38 of Internal/InventoryV3


Ignore:
Timestamp:
Jan 10, 2011, 10:45:26 PM (14 years ago)
Author:
ssugrim
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Internal/InventoryV3

    v37 v38  
    357357
    358358Fixed a few bugs involving how the array slices were processed. I ran into a problem where the device count would get messed up if lshw returned non-unique values. I solved it be reversing the array before slicing (documented in the code).
     359
     360
     361
     362=== 1/8/2010 ===
     363
     364I've added the sql_query method to the main component class. All child classes will query sql the same way. The connect and disconncet methods are also component class Methods. I though previously I had added a discussion about various connections models. The two competeing ideas were:
     365 * Let each child handle their own connections
     366 * Let the main program handle the connection.
     367I decided to put the connection task in the main function because less connection attempts would be made (this should be more stable) and I can use a single begin/rescue/ensure block to make sure the connection closes.
     368
     369I've added an abstract method (see [http://groups.google.com/group/ruby-talk-google/browse_thread/thread/521f4588e3b24285 here])in the component called update (in the parent it raises a NotImplemented error). This forces all children to have an update method (which should then be implemented).
     370
     371I used an interesting construction in the sql_query method, thats worth mentioning. If given an array of parameters to glue together, I can string them with out a trailing separator like so A=[A,B,C,D] A.first(A.length-1).map{|a| a + ","} + A.last. This gets the the elements as a string with separators (join might also take a separator argument which might be cleaner, but doesn't work in the case if some elements are nil).
     372
     373I also started using Array.zip to iterate two arrays with map. If I have A and B arrays and I need to do something to both. I can do
     374C = A.zip(B).map{|x| f(x[0],x[1])}. I'm doing this with the individual data elements that need to be pushed back into the Tables, that way I can just zip the indvidual data arrays into one big one later. See the kind construct.
     375
     376Finally, the sql_query method has a .flatten in the last statmenet now since the row and query operations return a nested array. I've made it a policy that the query should return a flat array of answers.
     377
     378