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: recovery.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/cluster/topology"
	"sync"

	"math"
	"sort"

	memcom "github.com/uber/aresdb/memstore/common"
	"github.com/uber/aresdb/utils"
)

// PlayRedoLog loads data for the table Shard from disk store and recovers the Shard for serving.
func (shard *TableShard) PlayRe
    
func (shard *TableShard) LoadSnapshot() error {
	loadTimer := utils.GetReporter(shard.Schema.Schema.Name, shard.ShardID).GetTimer(utils.SnapshotTimingLoad)
	start := utils.Now()
	defer func() {
		duration := utils.Now().Sub(start)
		loadTimer.Record(duration)
	}()

	redoLogFile, offset, _, lastReadRecord := shard.LiveStore.SnapshotManager.GetLastSnapshotInfo()
	if redoLogFile <= 0 {
		// no snapshot created yet
		return nil
	}
	tableName := shard.Schema.Schema.Name
	shardID := shard.ShardID

	utils.GetLogger().With(
		"job", "snapshot_load",
		"table", tableName,
		"shard", shardID).Info("Load data from snapshot")

	var batchIDs []int
	var err error
	if batchIDs, err = shard.diskStore.ListSnapshotBatches(tableName, shardID, redoLogFile, offset); err != nil {
		return err
	} else if len(batchIDs) == 0 {
		return utils.StackError(nil, "No snapshot file/directory found")
	}

	shard.LiveStore.WriterLock.Lock()
	defer shard.LiveStore.WriterLock.Unlock()
	for _, id := range batchIDs {
		batchID := int32(id)
		// find all columns in snapshot dir
		batchPos, err := shard.loadTableShardSnapshot(tableName, shardID, batchID, redoLogFile, offset)
		if err != nil {
			return err
		}
		if batchID == lastReadRecord.BatchID {
			batchPos = lastReadRecord.Index
		}
		shard.rebuildIndexForLiveStore(batchID, batchPos)
	}
	//reset back the read/write record position
	shard.LiveStore.Lock()
	shard.LiveStore.LastReadRecord = lastReadRecord
	shard.LiveStore.Unlock()
	shard.LiveStore.NextWriteRecord = lastReadRecord
	return nil
}