Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

Array Intersections

I am looking for a suggestion here.
I have large arrays which are being displayed from an index table (my index, not an OI index) and some have 600,000 lines.
This reads the item and displays the table in around 3-5 seconds which is impressive.
There are generally about 3-8 columns, column 1 is a factor and column 2-8 is a code.

I am looking to introduce a filter option to allow a column to be selected and a filter applied, and then I want to quickly reduce the table to the lines which are applicable to the filters. Screen below although for testing I have only added 3 filters.

I checked out the SRP array function and cant see any toolset there for this.
At present I have tried a loop setting the row visible property, but am OK with generating a reduced table for display.
Any suggestions as how best to deal with this through any SRP tools.
I can improve my loop to use the reduce function in OI, but thought first I would consult SRP to see if there are any existing concepts I can use.

If not then I will look to make this a bit clever internally using my own code.

Thanks




Comments

  • edited October 2019
    Wouldn't the NOT operation of the SRP_Array( 'Join') function handle this?
    The logical NOT operation returns only those items that appear in LeftArray but not in RightArray. In other words, think of RightArray as an exclusion list
    We use this for filtering lists a lot!

    HTH, M@
  • Except that Colin only has one multidimensional array and wants to reduce it to say only "UNPAVED" items or only "CIRC FOOTPATH" items?

    Personally I've used the loop approach but I reckon I could break for lunch while it was happening if I was dealing with 600,000 items.
  • I will try this with the remove function which has proven to be quick.
    I will give it a go here and report back.
    Thanks for the input.
  • I think the bigger challenge with trying to use the SRP Array services is that one item is an array and the other is a list. At best you could find the intersection of one column in the array (i.e., the list of all elements in the column) with the compare list. This won't have an immediate impact on the original array. Thus, I think you will always be forced to iterate through the whole array and either remove the items that don't match or build a new array of those items that do match.
  • Thanks Don, I will deal with this in my code.
  • edited October 2019
    you only have to loop once though. The first time you loop, you could create an indexes, each of which contains the rows of a particular filter option.

    When when the user changes the filter option, you get the data directly from the index. The indexes would just be global variables in your code. If a user applies two filters at the same time, then you could get the intersection of the two indexes relating to those two filters.
Sign In or Register to comment.