Custom graph and igraph columns with relative values

When creating a custom column of the type graph and igraph. To create relative values we need to pre scan the folder to get the max value. For scripts like the Column - Custom Text and Regexp, or the Column: XML and XPath columns, it's expensive and complicate to do well.

@asakka has helped update the Column - Custom Text and Regexp script here, but it requires multiple scanning of the folder. I started working on alternate approaches but was not happy with the code and complexity.

Could the columns graph and igraph have an option to natively support a relative mode, instead of needing to provide a value between 0 and 100?

Keen to here any alternative thoughts.

Cheers

1 Like

@wowbagger thanks for mentioning my script update.
Actually I had already found a workaround for the "multiple scanning" problem, and my update doesn't do multiple scanning. I scan once and store the folder path and maximum value in script variables to avoid scanning again. I admit that it's not pretty solution, but it works and the performance is great.

Of course it would be definitely better if it's naively supported.

With the script caching the maximum, what happens if a new file appears that increases it?

Seems like something Opus could/should take care of for the script, but I don't know this part of the code well enough at the moment to say how much it makes sense. The idea seems good, though.

You are right @Leo
If a new file appears bigger than the current maximum, the cached maximum will not update. However, if you change to another folder and went back to the first folder, it will be re-scanned and the maximum will be updated.
I believe that will be enough for most cases, till we get native support for relative graph.

Not to split hairs, I believe it calculates each value twice.
Each item in the folder is read once to calculate the max value which we store in the var (nice idea btw). Then they are all read again to calculate the values of each item which is divided by the stored max value. The first value is not calculated until the max is first calculated.

The Regex script allows you to target the file name, file meta data, and file content. If you target the file content, this means for the first value to display all files must be read.

If the relative calculation logic was moved in to Dopus, it could behave similar to the size graph where, it dynamically changes as larger folders are calculated.

@wowbagger you are absolutely right about the fact that it's hitting each item twice, once within the maximum loop, and another time when getting the actual value. Actually I meant that it "scans the folder to get maximum value" once, in addition to (not instead) the original time when it gets the item value.

In fact - without my relative value loop - I found out that the original script actually hits each file several times, as it seems that the "multicol" feature is not working properly!!
For example, if you have 3 custom columns, c1, c2 and c3. If all three columns were added to lister, then function that loads "c1" value will access each item three times to get values of c1, c2 and c3. Then it does the same twice to load "c2" and "c3".
Which means that each item will be accessed 9 times (3*3)!!

A workaround to truly access files once (multiple columns values + relative), is to get the results of all columns values of all files once and store them in a json array inside a variable.
I'm just not sure if the variable limit would allow that in case of a folder containing huge number of files :thinking: :thinking:

In the next version we'll add "graphrel" etc. modes, which will cause Opus to keep track of the minimum and maximum values and calculate the relative percentage automatically.

2 Likes