Skip to main content
Documentation

Bulk Operations

Most types in the Function Development Kit represent built-in functions that provide access to bulks of objects.
They extend the types 'Bulk' and 'BuiltInFunction'.

Examples: Entity, Link, Event.

Bulk BuiltInFunction


Diafunc code works with types that represent bulks rather than single elements.
A single element is handled as a bulk that contains only that element.
Most operations are therefore bulk-oriented, although the types are named in the singular.

Union

Elements which are in A, in B, or in both A and B
ABA ∪ B

Union
var union = a.union(b);

Intersection

All elements of A that also belong to B
ABA ∩ B

Intersection
var intersection = a.intersection(b);

Difference

Elements of A that don't belong to B
ABA − B

Difference
var difference = a.difference(b);

Symmetric Difference

Elements which are in either of the sets, but not in their intersection
ABA ∆ B

Symmetric Difference
var symmetricDifference = a.symmetricDifference(b);

Filtering and Sorting

Every bulk can be filtered with a custom predicate and sorted by a custom key extractor. For bulks of selections there are additional dedicated operations; filtering and sorting of selections is covered in detail on the Selections page.

Uniqueness

Filtering duplicate selections to ensure uniqueness

Uniqueness
var uniqueElements = a.distinct();

Evaluation

The Function Development Kit (FDK) supports many built-in functions to evaluate a bulk:

Evaluation
var isDisjoint = a.disjoint(b);
var isSubset = a.subset(b);
var isProperSubset = a.properSubset(b);
var isSuperset = a.superset(b);
var isProperSuperset = a.properSuperset(b);

var allMatch = bulk.all(predicate);
var anyMatches = bulk.any(predicate);
var min3Match = bulk.min(3, predicate);
var exact3Match = bulk.exact(3, predicate);
var max3Match = bulk.max(3, predicate);
var noneMatch = bulk.none(predicate);

var count = bulk.count();
var exists = bulk.exists();
var notExists = bulk.notExists();

What next?