1. A method for setting elements in a result vector based on an input vector, comprising: in a processor, performing operations for: receiving the input vector and a predicate vector, wherein the input vector and the predicate vector include N elements; determining a location of a key element in the input vector that contains a true indicator, wherein determining a location of the key element comprises determining a location of the key element in a set of elements in the input vector for which corresponding elements in the predicate vector contain true indicators; and generating a result vector, wherein generating the result vector involves setting one or more elements of the result vector based on the location of the key element in the input vector.