class PrimaryTermCollectorExpression extends LuceneCollectorExpression<Long> {

    private NumericDocValues primaryTerms = null;
    private int doc;

    @Override
    public void setNextReader(ReaderContext context) throws IOException {<FILL_FUNCTION_BODY>}

    @Override
    public void setNextDocId(int doc) {
        this.doc = doc;
    }

    @Override
    public Long value() {
        try {
            if (primaryTerms != null && primaryTerms.advanceExact(doc)) {
                return primaryTerms.longValue();
            }
            return null;
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }
}

        try {
            primaryTerms = context.reader().getNumericDocValues(DocSysColumns.PRIMARY_TERM.name());
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    
<methods>public void setNextDocId(int) ,public void setNextReader(io.crate.execution.engine.fetch.ReaderContext) throws java.io.IOException,public void setScorer(Scorable) ,public void startCollect(io.crate.expression.reference.doc.lucene.CollectorContext) <variables>