presto-main/src/main/java/io/prestosql/operator/window/NthValueFunction.java/NthValueFunction/processRow
class NthValueFunction:    @Override
    public void processRow(BlockBuilder output, int frameStart, int frameEnd, int currentPosition)
    {
        if ((frameStart < 0) || windowIndex.isNull(offsetChannel, currentPosition)) {
            output.appendNull();
        }
        else {
            long offset = windowIndex.getLong(offsetChannel, currentPosition);
            checkCondition(offset >= 1, INVALID_FUNCTION_ARGUMENT, "Offset must be at least 1");

            long valuePosition;

            if (ignoreNulls) {
                long count = 0;
                valuePosition = frameStart;
                while (valuePosition >= 0 && valuePosition <= frameEnd) {
                    if (!windowIndex.isNull(valueChannel, toIntExact(valuePosition))) {
                        count++;
                        if (count == offset) {
                            break;
                        }
                    }
                    valuePosition++;
                }
            }
            else {
                // offset is base 1
                valuePosition = frameStart + (offset - 1);
            }

            if ((valuePosition >= frameStart) && (valuePosition <= frameEnd)) {
                windowIndex.appendTo(valueChannel, toIntExact(valuePosition), output);
            }
            else {
                output.appendNull();
            }
        }
    }