SPL practice: solve space-time collision problem of trillion-scale calculations in only three minutes
Problem description Definition of space-time collision Dataset A contains the time and space information of n source objects A1, …, An, and each piece of information includes three attributes: ID (...

Source: DEV Community
Problem description Definition of space-time collision Dataset A contains the time and space information of n source objects A1, …, An, and each piece of information includes three attributes: ID (iA), location (lA) and time (tA). It can be assumed that the same Ai will not appear twice in A at the same time, or in other words, no two pieces of information have the same iA and tA. Dataset B, which has the same structure as A, contains m target objects B1, …, Bm (with the similar attributes iB, lB, tB) that are to be confirmed whether they collided with A. Likewise, it can be assumed that Bi will not appear twice in B at the same time. This article involves many set-oriented operations. Instead of using the term “record” to refer to information of data set, we use the set-related term “member”. Group the dataset A by iA to get n subsets, and still name these subsets A1…, An. And correspondingly, split the dataset B into m subsets B1…, Bm. If ‘a’ belongs to the subset Ai and ‘b’ belongs