dynamicGroupCumcount#

swordfish.function.dynamicGroupCumcount()#

The attribute and category of an event are fixed in most cases. In some scenarios, the category of an event, however, will change dynamically. For example, when processing real-time tick data, users may judge whether an order (attribute) is a large or a small one (category) based on the cumulative volume to analyze capital flow. As real-time data continues to flow in, trading volume keeps increasing, and thus a small order may change to a large one.

Function dynamicGroupCumcount is used in such scenarios to count the number of dynamically cumulative events of different categories.

Details are as follows:

  • If membership = prevMembership, count remains unchanged.

  • If membership ≠ prevMembership, the count of corresponding group of membership increases by 1, and the count of corresponding group of prevMembership decreases by 1.

  • If prevMembership is a null value (the first record of each group), the count of corresponding group of membership increases by 1.

Parameters:
  • membership (Constant) – A vector, of which elements must be integers in the interval [0, groupCount), indicating tags for the record at the current timestamp.

  • prevMembership (Constant) – A vector of INT type, of which elements can be null values (the first record of each group), indicating tags for the record at the previous timestamp of membership.

  • groupCount (Constant) – An integer in the interval [2, 8], indicating the number of tags.

Returns:

A tuple of length groupCount. Each element is a vector of the same length as membership, which sequentially records the cumulative count of each tag.

Note

The index of the tuple matches the tags, which means that the count of tag 0 is output to the vector at index 0 of the tuple.

Return type:

Constant