LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
altenbach

Associative Arrays!

Status: Completed

Available in LabVIEW 2019 with the Collection > Map functions and VIs. 

LabVIEW  has a somewhat hidden feature built into the variant attributes functionality that easily allows the implementation of high performance associative arrays. As discussed elsewhere, it is implemented as a red-black tree.

 

I wonder if this functionality could be exposed with a more intuitive set of tools that does not require dummy variants and somewhat obscure VIs hidden deeply in the variant palette (who would ever look there!).

 

Also, the key is currently restricted to strings (Of course we can flatten anything to strings to make a "name" for a more generalized use of all this).

 

I imagine a set of associative array tools:

 

 

  • Create associative array (key datatype, element datatype)
  • insert key/element pair (replace if key exists)
  • lookup key (index key) to get element
  • read all keys
  • delete key/element
  • delete all keys/elements
  • dump associative array to disk
  • restore associative array from disk
  • destroy associative array
  • ... (I probably forgot a few more)
 
 
I am currently writing such a tool set as a high performance cache to avoid duplicate expensive calculations during fitting (Key: flattened input parameters, element: calculated array).
 
However, I cannot easily write it in a truly generalized way, just as a version targeted for my specific datatype. I've done some casual testing and the variant attribute implementation is crazy fast for lookup and insertion. Somebody at NI really did a fantastic job and it would be great to get more exposure for it.
 
Example performance: (Key size: 1200bytes, element size 4096: bytes, 10000 elements) 
insert: ~60 microseconds
random lookup: ~12 microseconds
(compare with a random lookup using linear search (search array): 10ms average. 1000x slower!)
 
Thanks! 

 

25 Comments
Rob_Calhoun
Member

Customer service request is  #7777313 

BoKnows
Active Participant

This is being tracked with CAR 738428.  I've also reached out to the TSE working with your SR to ensure they're able to communicate this with you.

 

Thanks for giving maps some attention already and bringing this to our attention!

BoKnows
Active Participant

This CAR was fixed in the 2019 f1 patch.  You can find other details about that patch here: http://www.ni.com/product-documentation/55191/en/

 

Given your service request, I think you'll appreciate seeing the list of CARs addressed to focus on sets and maps.

 

As a heads up, the Idea Exchange isn't watched at the same cadence as the forums themselves are.  It's usually better to post potential CARs there versus here as they tend to get picked up and brought to our attention faster that way.

Rob_Calhoun
Member

I verified that the issue with Maps returning invalid data when using non-strings as keys is resolved in LabVIEW 2019 19.0.1f1 x64 (Windows).

 

Thank you!

 

AristosQueue (NI)
NI Employee (retired)

Rob: Thank you for letting us know.