4D v13

Sets and named selections

Home

 
4D v13
Sets and named selections

Sets and named selections    


 

 

In addition to the manipulations explained in the video, you should also note that:

In terms of memory:

  • a selection needs 4 bytes per selection record, regardless of the number of records in the table (unlike sets).
  • A set requires 1 bit for each record in the table.
    Sets are composed of a series of bits. A set contains as many bits as there are records in the table. Each bit of a set corresponds to a quick report “included in the selection” or “not included” for the Xth record of the table at the moment the set is composed.

The table below sums up the all of possibilities for sets and temporary selections:

ThemeSetNamed Selection
Memory space for a record1 bit4 bytes
Keep order byNoYes
Keep the current recordNoYes
UnionYesNo
IntersectionYesNo
DifferenceYesNo
Save to diskYesNo
Memory size of a selection of 10 records out of 20,00020,000 bits or 2500 bytes10 x 4 bytes = 40 bytes
ScopeLocal, Process, InterprocessProcess, Interprocess

You can only compare sets from the same table.

Warning: The behavior of a set implies during a limited time and eventually using semaphores (see 4D documentation for more information).

In fact, a set makes a bit correspond to the physical position of each table record. In case of deleting and then adding records, the former content of a physical record could be replaced by the new content that is no longer in line with what the set is supposed to represent.

Be methodical in the use of sets, which remain an efficient and fast way to compare selections.

To keep a selection, there’s a third solution that involves using an array that contains your identification using the SELECTION TO ARRAY command.

You can use a fourth solution using stored clusters; for example, in BLOBs.

Of course, when selections are no longer necessary, you can free up memory by erasing them.

 CLEAR SET("SetName")
 CLEAR NAMED SELECTION("SelectionName")

 
 

 
PROPERTIES 

Product: 4D
Theme: Sets and named selections