Mapping metadata array


#1

Hi all,

I have a 2-dimensional array:

AFL% show(fvNorm);  
{i} schema
{0} 'fvNorm<value:double> [patch_id=0:268729:0:1024; feature=0:1023:0:1024]'

In order to map some metadata to the above array i created a one dimensional metadata array:

AFL% show(patch_index);
{i} schema
{0} 'patch_index<patchname:string ,image:string ,coordinates:string > [patch_id=0:268729:0:1000000]'
AFL% 

The fvNorm’s patch_id dimension indices were created from the patch_index’ array patch_id dimension indices. So, e.g. the attribute values at patch_id 5 in the patch_index array hold metadata of the patch_id 5 in fvNorm array.

Can you tell me the most efficient way to retrieve all values in the fvNorm array that meet a certain criterion defined in the patch_index array?
Example: Retrieve a subarray where values in fvNorm belong to patch_ids mapped to the image ‘ws1’. Image to patch_id has a 1-to-n relationship.

I would have solved it in the following way:

filter(cross_join(fvNorm,patch_index,fvNorm.patch_id,patch_index.patch_id),image='ws1');

However this solution does not seem very efficient since all the 268’000 x 1024 values from fvNorm are now joined with the corresponding values from the patch_index, before doing the filtering. Is there any more efficient way?

Thank you!
-Ivan


#2

I think you are quite close. But consider placing the filter inside the join:

cross_join(
 fvNorm,
 filter(
  patch_index,
  image = 'ws1'
 ),
 fvNorm.patch_id,
 patch_index.patch_id
);

This is a common pattern.