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: backfill.go
    path of file: ./repos/aresdb/memstore
    
    the code of the file until where you have to start completion: //  Copyright (c) 2017-2018 Uber Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package memstore

import (
	"github.com/uber/aresdb/memstore/vectors"
	"sort"

	"github.com/uber/aresdb/utils"
	"time"

	memCom "github.com/uber/aresdb/memstore/common"
	metaCom "github.com/uber/aresdb/metastore/common"
)

// Backfill is the process of merging records with event time older than cutoff with
// archive batches.
func (m *memStoreImpl) Backfill(table string, shardID int, reporter BackfillJobDetailReporter) error {
	backfillTimer := utils.GetReporter(table, shardID).GetTimer(utils.BackfillTimingTotal)
	start := utils.Now()
	jobKey := getIdentifier(table, shardID, memCom.BackfillJobTyp
    
func (ctx *backfillContext) writePatchValueForUnsortedColumn(baseRecordID memCom.RecordID, changedPatchRow []*memCom.DataValue) (updated bool) {
	for columnID, patchValue := range changedPatchRow {
		if patchValue != nil && utils.IndexOfInt(ctx.sortColumns, columnID) < 0 {
			baseDataValue := ctx.new.Columns[columnID].GetDataValueByRow(int(baseRecordID.Index))
			if baseDataValue.Compare(*patchValue) != 0 {
				// For updates to unsorted columns, if the value changes, fork the column, and update in place
				// in the forked copy, this will make sure that ongoing queries do not see this change.
				if !ctx.columnsForked[columnID] {
					ctx.columnsToPurge = append(ctx.columnsToPurge, ctx.base.Columns[columnID].(memCom.ArchiveVectorParty))
					// For the forked columns, we will always allocate space for value vector and null vector despite
					// of the mode of the original vector.
					var bytes int64
					if ctx.base.Columns[columnID].IsList() {
						// will use original size for array vp
						bytes = ctx.base.Columns[columnID].GetBytes()
					} else {
						bytes = int64(vectors.CalculateVectorPartyBytes(
							ctx.base.Columns[columnID].GetDataType(), ctx.base.Size, true, false))
					}
					ctx.unmanagedMemoryBytes += bytes
					// Report before allocation.
					ctx.backfillStore.HostMemoryManager.ReportUnmanagedSpaceUsageChange(bytes)
					ctx.new.Columns[columnID] = ctx.base.Columns[columnID].(memCom.ArchiveVectorParty).CopyOnWrite(ctx.base.Size)
					ctx.columnsForked[columnID] = true
				}
				ctx.new.Columns[columnID].SetDataValue(int(baseRecordID.Index), *patchValue, memCom.CheckExistingCount)
				updated = true
			}
		}
	}
	return
}