question

Chao Gao avatar image
0 Likes"
Chao Gao asked Jeff Nordgren commented

Pull one entry with largest field value from any partition in a list

If I have a list that's already partitioned due to other needs, then later in the process, I want to pull one entry out of the list that has the largest filed value of "Seq_Num", I don't care which partition it is from, just want to pull the entry that has the largest field value, how would I be able to achieve this?

The command listpull is not working in this case, as i have to specify the partition ID or make that 0, if I make that 0, it's going to treat 0 as the partition ID, not trying to pull from any partition IDs.

Thanks,

Chao

FlexSim 17.0.2
partition list
· 3
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jeff Nordgren avatar image Jeff Nordgren commented ·

@Chao Gao,

It appears that in the lispull command that partiionid and flags (last possible two parameters) are optional. What happens if you just put in the listpull - list,query,requestNum and requireNum and don't put in the partionId or the flags options?

0 Likes 0 ·
Matthew Gillespie avatar image Matthew Gillespie ♦♦ Jeff Nordgren commented ·

If you don't specify a partition Id it will use the default null partition. This is the same as entering 0.

0 Likes 0 ·
Jeff Nordgren avatar image Jeff Nordgren Matthew Gillespie ♦♦ commented ·

Good to know.

0 Likes 0 ·

1 Answer

Matthew Gillespie avatar image
3 Likes"
Matthew Gillespie answered

Currently there isn't a way to pull from multiple partitions at once.

The best solution I've found for this is to use a flat list with two fields: one that represents the partition and then Seq_Num. To pull from a specific partition you use a Where clause:

WHERE partition = 3

Pulling the highest Seq_Num regardless of partition is now a simple ORDER BY:

ORDER BY Seq_Num

Another way to deal with this is to pull multiple times. You can pull without actually pulling anything off just to query the list. Query the different partitions and then decide which one to pull from. I would recommend the first approach though.

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.