You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: lag.eg.go
    path of file: ./repos/cockroach/pkg/sql/colexec/colexecwindow
    
    the code of the file until where you have to start completion: // Code generated by execgen; DO NOT EDIT.
// Copyright 2021 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

package colexecwindow

import (
	"context"

	"github.com/cockroachdb/cockroach/pkg/col/coldata"
	"github.com/cockroachdb/cockroach/pkg/col/typeconv"
	"github.com/cockroachdb/cockroach/pkg/sql/colexec/colexecutils"
	"github.com/cockroachdb/cockroach/pkg/sql/colexecop"
	"github.com/cockroachdb/cockroach/pkg/sql/types"
	"github.com/cockroachdb/errors"
)

// NewLagOperator creates a new Operator that computes window
// function lag. outputColIdx specifies in which coldata.Vec the operator
// should put its output (if there is no such column, a new column is appended).
func NewLagOperator(
	args *WindowArgs, argIdx int, offsetIdx int, defaultIdx int,
) (colexecop.ClosableOperator, error) {
	// Allow the direct-access buffer 10% of the available memory. The rest will
	// be given to the bufferedWindowOp queue. While it is somewhat more important
	// for the direct-access buffer tuples to be kept in-memory, it only has to
	// store a single column. TODO(drewk): play around with benchmarks to find a
	// good empirically-supported fraction to use.
	bufferMemLimit := int64(float64(args.MemoryLimit) * 0.10)
	mainMemLimit := args.MemoryLimit - bufferMemLimit
	buffer := colexecutils.NewSpillingBuffer(
		args.BufferAllocator, bufferMemLimit, args.QueueCfg, args.FdSemaphore,
		args.InputTypes, args.DiskAcc, args.ConverterMemAcc, argIdx,
	)
	base := lagBase{
		partitionSeekerBase: partitionSeekerBase{
			buffer:          buffer,
			partitionColIdx: args.PartitionColIdx,
		},
		outputColIdx: args.OutputColIdx,
		argIdx:       argIdx,
		offsetIdx:    offsetIdx,
		defaultIdx:   defaultIdx,
	}
	argType := args.InputTypes[argIdx]
	switch typeconv.TypeFamilyToCanonicalTypeFamily(argType.Family()) {
	case types.BoolFamily:
		switch argType.Width() {
		case -1:
		default:
			return newBufferedWindowOperator(
				args, &lagBoolWindow{lagBase: base}, argType, mainMemLimit), nil
		}
	case types.BytesFamily:
		switch argType.Width() {
		case -1:
		default:
			return newBufferedWindowOperator(
				args, &lagBytesWindow{lagBase: base}, argType, mainMemLimit), nil
		}
	case types.DecimalFamily:
		switch argType.Width() {
		case -1:
		default:
			return newBufferedWindowOperator(
				args, &lagDecimalWindow{lagBase: base}, argType, mainMemLimit), nil
		}
	case types.IntFamily:
		switch argType.Width() {
		case 16:
			return newBufferedWindowOperator(
				args, &lagInt16Window{lagBase: base}, argType, mainMemLimit), nil
		case 32:
			return newBufferedWindowOperator(
				args, &lagInt32Window{lagBase: base}, argType, mainMemLimit), nil
		case -1:
		default:
			return newBufferedWindowOperator(
				args, &lagInt64Window{lagBase: base}, argType, mainMemLimit), nil
		}
	case types.FloatFamily:
		switch argType.Width() {
		case -1:
		default:
			return newBufferedWindowOperator(
				args, &lagFloat64Window{lagBase: base}, argType, mainMemLimit), nil
		}
	case types.TimestampTZFamily:
		switch argType.Width() {
		case -1:
		default:
			return newBufferedWindowOperator(
				args, &lagTimestampWindow{lagBase: base}, argType, mainMemLimit), nil
		}
	case types.IntervalFamily:
		switch argType.Width(
    
func (w *lagDecimalWindow) processBatch(batch coldata.Batch, startIdx, endIdx int) {
	if startIdx >= endIdx {
		// No processing needs to be done for this portion of the current partition.
		return
	}
	leadLagVec := batch.ColVec(w.outputColIdx)
	leadLagCol := leadLagVec.Decimal()
	leadLagNulls := leadLagVec.Nulls()
	_ = leadLagCol.Get(startIdx)
	_ = leadLagCol.Get(endIdx - 1)

	offsetVec := batch.ColVec(w.offsetIdx)
	offsetCol := offsetVec.Int64()
	offsetNulls := offsetVec.Nulls()
	_ = offsetCol[startIdx]
	_ = offsetCol[endIdx-1]

	defaultVec := batch.ColVec(w.defaultIdx)
	defaultCol := defaultVec.Decimal()
	defaultNulls := defaultVec.Nulls()
	_ = defaultCol.Get(startIdx)
	_ = defaultCol.Get(endIdx - 1)

	if offsetNulls.MaybeHasNulls() {
		if defaultNulls.MaybeHasNulls() {
			for i := startIdx; i < endIdx; i++ {
				if offsetNulls.NullAt(i) {
					// When the offset is null, the output value is also null.
					leadLagNulls.SetNull(i)
					w.idx++
					continue
				}
				requestedIdx := w.idx - int(offsetCol[i])
				w.idx++
				if requestedIdx < 0 || requestedIdx >= w.partitionSize {
					// The offset is out of range, so set the output value to the default.
					if defaultNulls.NullAt(i) {
						leadLagNulls.SetNull(i)
						continue
					}
					val := defaultCol.Get(i)
					leadLagCol.Set(i, val)
					continue
				}
				vec, idx, _ := w.buffer.GetVecWithTuple(w.Ctx, 0 /* colIdx */, requestedIdx)
				if vec.Nulls().MaybeHasNulls() && vec.Nulls().NullAt(idx) {
					leadLagNulls.SetNull(i)
					continue
				}
				col := vec.Decimal()
				val := col.Get(idx)
				leadLagCol.Set(i, val)
			}
			return
		}
		for i := startIdx; i < endIdx; i++ {
			if offsetNulls.NullAt(i) {
				// When the offset is null, the output value is also null.
				leadLagNulls.SetNull(i)
				w.idx++
				continue
			}
			requestedIdx := w.idx - int(offsetCol[i])
			w.idx++
			if requestedIdx < 0 || requestedIdx >= w.partitionSize {
				// The offset is out of range, so set the output value to the default.
				val := defaultCol.Get(i)
				leadLagCol.Set(i, val)
				continue
			}
			vec, idx, _ := w.buffer.GetVecWithTuple(w.Ctx, 0 /* colIdx */, requestedIdx)
			if vec.Nulls().MaybeHasNulls() && vec.Nulls().NullAt(idx) {
				leadLagNulls.SetNull(i)
				continue
			}
			col := vec.Decimal()
			val := col.Get(idx)
			leadLagCol.Set(i, val)
		}
		return
	}
	if defaultNulls.MaybeHasNulls() {
		for i := startIdx; i < endIdx; i++ {
			requestedIdx := w.idx - int(offsetCol[i])
			w.idx++
			if requestedIdx < 0 || requestedIdx >= w.partitionSize {
				// The offset is out of range, so set the output value to the default.
				if defaultNulls.NullAt(i) {
					leadLagNulls.SetNull(i)
					continue
				}
				val := defaultCol.Get(i)
				leadLagCol.Set(i, val)
				continue
			}
			vec, idx, _ := w.buffer.GetVecWithTuple(w.Ctx, 0 /* colIdx */, requestedIdx)
			if vec.Nulls().MaybeHasNulls() && vec.Nulls().NullAt(idx) {
				leadLagNulls.SetNull(i)
				continue
			}
			col := vec.Decimal()
			val := col.Get(idx)
			leadLagCol.Set(i, val)
		}
		return
	}
	for i := startIdx; i < endIdx; i++ {
		requestedIdx := w.idx - int(offsetCol[i])
		w.idx++
		if requestedIdx < 0 || requestedIdx >= w.partitionSize {
			// The offset is out of range, so set the output value to the default.
			val := defaultCol.Get(i)
			leadLagCol.Set(i, val)
			continue
		}
		vec, idx, _ := w.buffer.GetVecWithTuple(w.Ctx, 0 /* colIdx */, requestedIdx)
		if vec.Nulls().MaybeHasNulls() && vec.Nulls().NullAt(idx) {
			leadLagNulls.SetNull(i)
			continue
		}
		col := vec.Decimal()
		val := col.Get(idx)
		leadLagCol.Set(i, val)
	}
}