classname_fieldname_project

Applies the current positional window and direction of another iterator to this persistent sequence field.

Prototype

    MCO_RET classname_fieldname_project(
        classname *handle,
        mco_seq_iterator_h result,
        mco_seq_iterator_h source);

Behavior

The function reads source's current next position, final position, and direction at call time, then initializes result over the corresponding positions of this field. It does not use source element values and does not consume source.

This operation is intended for positionally aligned sequences, for example to retrieve values from one field using a range found in an ordered timestamp field. If source has already been partially consumed, projection starts at its current position. Forward and reverse source ranges are both preserved.

The returned iterator borrows handle and its transaction, but does not retain source as an operand. MCO_S_NOTFOUND indicates an empty or non-overlapping range.

Example

    mco_seq_iterator_t time_range;
    mco_seq_iterator_t reading_range;
    MCO_RET rc;

    rc = Sensor_timestamps_search(
        &sensor, &time_range,
        100, MCO_SEQ_BOUNDARY_INCLUSIVE,
        200, MCO_SEQ_BOUNDARY_INCLUSIVE);
    if (rc == MCO_S_OK) {
        rc = Sensor_readings_project(
            &sensor, &reading_range, &time_range);
    }

Use classname_fieldname_map() instead when positions are arbitrary rather than one contiguous positional window.