// ETLStateToThrift convert the dosa ETLState to the thrift ETLState enum type
542243
func ETLStateToThrift(etl dosa.ETLState) dosarpc.ETLState {
	switch etl {
	case dosa.EtlOn:
		return dosarpc.ETLStateOn
	case dosa.EtlOff:
		return dosarpc.ETLStateOff
	default:
		panic(fmt.Sprintf("bad ETL state: %v", etl))
	}
}
521639
func (t *SQLStringSlice) ToStringSlice() *[]string {
	if t == nil {
		return nil
	}
	data := []string(*t)
	return &data
}
1289687
func (v *GenerateServiceRequest) GetThriftRoot() (o string) {
	if v != nil {
		o = v.ThriftRoot
	}
	return
}
15225
func (e LoggedInError) ToStatus() (s keybase1.Status) {
	s.Code = SCAlreadyLoggedIn
	s.Name = "ALREADY_LOGGED_IN"
	s.Desc = "Already logged in as a different user"
	return
}
1201736
func (ef *FeeEstimator) Save() FeeEstimatorState {
	ef.mtx.Lock()
	defer ef.mtx.Unlock()

	// TODO figure out what the capacity should be.
	w := bytes.NewBuffer(make([]byte, 0))

	binary.Write(w, binary.BigEndian, uint32(estimateFeeSaveVersion))

	// Insert basic parameters.
	binary.Write(w, binary.BigEndian, &ef.maxRollback)
	binary.Write(w, binary.BigEndian, &ef.binSize)
	binary.Write(w, binary.BigEndian, &ef.maxReplacements)
	binary.Write(w, binary.BigEndian, &ef.minRegisteredBlocks)
	binary.Write(w, binary.BigEndian, &ef.lastKnownHeight)
	binary.Write(w, binary.BigEndian, &ef.numBlocksRegistered)

	// Put all the observed transactions in a sorted list.
	var txCount uint32
	ots := make([]*observedTransaction, len(ef.observed))
	for hash := range ef.observed {
		ots[txCount] = ef.observed[hash]
		txCount++
	}

	sort.Sort(observedTxSet(ots))

	txCount = 0
	observed := make(map[*observedTransaction]uint32)
	binary.Write(w, binary.BigEndian, uint32(len(ef.observed)))
	for _, ot := range ots {
		ot.Serialize(w)
		observed[ot] = txCount
		txCount++
	}

	// Save all the right bins.
	for _, list := range ef.bin {

		binary.Write(w, binary.BigEndian, uint32(len(list)))

		for _, o := range list {
			binary.Write(w, binary.BigEndian, observed[o])
		}
	}

	// Dropped transactions.
	binary.Write(w, binary.BigEndian, uint32(len(ef.dropped)))
	for _, registered := range ef.dropped {
		registered.serialize(w, observed)
	}

	// Commit the tx and return.
	return FeeEstimatorState(w.Bytes())
}
1101071
func (t EnumType) ConvertToStringSlice(value interface{}) ([]string, error) {
	if value != nil && !contains(t.Values, value) {
		return nil, errs.Errorf("value: %+v (%[1]T) is not part of allowed enum values: %+v", value, t.Values)
	}
	converted, err := t.BaseType.ConvertToStringSlice(value)
	if err != nil {
		return nil, errs.Wrapf(err, "failed to convert enum value to string slice: %+v", value)
	}
	return converted, nil
}
817159
func (l *StructLogger) CaptureState(env *EVM, pc uint64, op OpCode, gas, cost uint64, memory *Memory, stack *Stack, contract *Contract, depth int, err error) error {
	// check if already accumulated the specified number of logs
	if l.cfg.Limit != 0 && l.cfg.Limit <= len(l.logs) {
		return ErrTraceLimitReached
	}

	// initialise new changed values storage container for this contract
	// if not present.
	if l.changedValues[contract.Address()] == nil {
		l.changedValues[contract.Address()] = make(Storage)
	}

	// capture SSTORE opcodes and determine the changed value and store
	// it in the local storage container.
	if op == SSTORE && stack.len() >= 2 {
		var (
			value   = common.BigToHash(stack.data[stack.len()-2])
			address = common.BigToHash(stack.data[stack.len()-1])
		)
		l.changedValues[contract.Address()][address] = value
	}
	// Copy a snapshot of the current memory state to a new buffer
	var mem []byte
	if !l.cfg.DisableMemory {
		mem = make([]byte, len(memory.Data()))
		copy(mem, memory.Data())
	}
	// Copy a snapshot of the current stack state to a new buffer
	var stck []*big.Int
	if !l.cfg.DisableStack {
		stck = make([]*big.Int, len(stack.Data()))
		for i, item := range stack.Data() {
			stck[i] = new(big.Int).Set(item)
		}
	}
	// Copy a snapshot of the current storage to a new container
	var storage Storage
	if !l.cfg.DisableStorage {
		storage = l.changedValues[contract.Address()].Copy()
	}
	// create a new snapshot of the EVM.
	log := StructLog{pc, op, gas, cost, mem, memory.Len(), stck, storage, depth, env.StateDB.GetRefund(), err}

	l.logs = append(l.logs, log)
	return nil
}
1180553
func LexDdlTableStorage(l *Lexer) StateFn {

	l.SkipWhiteSpaces()
	if l.IsEnd() {
		return nil
	}

	r := l.Peek()
	if r == '=' {
		return LexEngineKeyValue
	}
	return nil
}
601121
func (c *ConfigLocal) GetTlfSyncState(tlfID tlf.ID) FolderSyncConfig {
	c.lock.RLock()
	defer c.lock.RUnlock()
	return c.syncedTlfs[tlfID]
}
693756
func (s *StackResourceDriftInformationSummary) SetStackResourceDriftStatus(v string) *StackResourceDriftInformationSummary {
	s.StackResourceDriftStatus = &v
	return s
}
97732
func (r *EtcdRegistry) SaveUnitState(jobName string, unitState *unit.UnitState, ttl time.Duration) {
	usm := unitStateToModel(unitState)
	if usm == nil {
		log.Errorf("Unable to save nil UnitState model")
		return
	}

	val, err := marshal(usm)
	if err != nil {
		log.Errorf("Error marshalling UnitState: %v", err)
		return
	}

	opts := &etcd.SetOptions{
		TTL: ttl,
	}

	legacyKey := r.legacyUnitStatePath(jobName)
	r.kAPI.Set(context.Background(), legacyKey, val, opts)

	newKey := r.unitStatePath(unitState.MachineID, jobName)
	r.kAPI.Set(context.Background(), newKey, val, opts)
}
234962
func (s *StateStore) UpsertEvalsTxn(index uint64, evals []*structs.Evaluation, txn Txn) error {
	// Do a nested upsert
	jobs := make(map[structs.NamespacedID]string, len(evals))
	for _, eval := range evals {
		if err := s.nestedUpsertEval(txn, index, eval); err != nil {
			return err
		}

		tuple := structs.NamespacedID{
			ID:        eval.JobID,
			Namespace: eval.Namespace,
		}
		jobs[tuple] = ""
	}

	// Set the job's status
	if err := s.setJobStatuses(index, txn, jobs, false); err != nil {
		return fmt.Errorf("setting job status failed: %v", err)
	}

	return nil
}
776148
func EncodeTLSToObject(t *tls.ConnectionState) interface{} {
	version := lookup(tlsVersions, t.Version)
	cipher := lookup(cipherSuites, t.CipherSuite)
	return &TLSDescription{
		version.Slug,
		cipher.Slug,
	}
}
1218772
func (msdw *MultiSplitDiffWorker) synchronizeSrcAndDestTxState(ctx context.Context) error {
	msdw.SetState(WorkerStateSyncReplication)
	var err error

	// 1. Find all the tablets we will need to work with
	masterInfos := make([]*topo.TabletInfo, len(msdw.destinationAliases))
	for i, shardInfo := range msdw.destinationShards {
		masterInfos[i], err = msdw.getMasterTabletInfoForShard(ctx, shardInfo)
		if err != nil {
			return err
		}
	}

	shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
	source, _ := msdw.wr.TopoServer().GetTablet(shortCtx, msdw.sourceAlias)
	cancel()

	var sourcePosition string

	// 2. Stop replication on destination
	destVreplicationPos, err := msdw.stopVreplicationOnAll(ctx, masterInfos)
	if err != nil {
		return err
	}

	// 3. Pause updates on the source and create consistent snapshot connections
	var scanners []TableScanner
	if msdw.useConsistentSnapshot {
		sourcePosition, scanners, err = msdw.useTransactionScanners(ctx, source)
	} else {
		sourcePosition, scanners, err = msdw.useNonTransactionalScanners(ctx, source, destVreplicationPos)
	}
	if err != nil {
		return err
	}

	msdw.scanners = make([]Scanners, msdw.parallelDiffsCount)
	for i := 0; i < msdw.parallelDiffsCount; i++ {
		// We'll create one of these Scanners struct per thread we want to run in parallel
		scanner := scanners[i]
		i2 := Scanners{
			sourceScanner:      scanner,
			destinationScanner: make([]TableScanner, len(msdw.destinationShards)),
		}
		msdw.scanners[i] = i2
	}

	// 4. Make sure all replicas have caught up with the master
	for i, shardInfo := range msdw.destinationShards {
		masterInfo := masterInfos[i]
		destinationAlias := msdw.destinationAliases[i]

		destinationPosition, err := msdw.stopVreplicationAt(ctx, shardInfo, sourcePosition, masterInfo)
		if err != nil {
			return err
		}

		shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
		destTabletInfo, err := msdw.wr.TopoServer().GetTablet(shortCtx, destinationAlias)
		cancel()
		if err != nil {
			return vterrors.Wrapf(err, "waitForDestinationTabletToReach: cannot get Tablet record for master %v", msdw.shardInfo.MasterAlias)
		}

		queryService, _ := tabletconn.GetDialer()(source.Tablet, true)
		var destScanners []TableScanner

		if msdw.useConsistentSnapshot {
			// loop to wait for the destinationAlias tablet in shardInfo to have reached destinationPosition
			err = msdw.waitForDestinationTabletToReach(ctx, destTabletInfo.Tablet, destinationPosition)
			if err != nil {
				return err
			}

			destScanners, _, err = CreateConsistentTableScanners(ctx, destTabletInfo, msdw.wr, msdw.cleaner, msdw.parallelDiffsCount)
			if err != nil {
				return err
			}
		} else {
			err = msdw.stopReplicationAt(ctx, destinationAlias, destinationPosition)
			if err != nil {
				return vterrors.Wrapf(err, "failed to stop replication on %v at position %v", destinationAlias, destinationPosition)
			}
			destScanners, err = msdw.createNonTransactionalTableScanners(ctx, queryService, destTabletInfo)
			if err != nil {
				return vterrors.Wrapf(err, "failed to stop create table scanners for %v using %v", destTabletInfo, queryService)
			}
		}

		// 5. Spread out destination scanners between the goroutines
		for j := 0; j < msdw.parallelDiffsCount; j++ {
			msdw.scanners[j].destinationScanner[i] = destScanners[j]
		}

		err = msdw.startVreplication(ctx, shardInfo, masterInfo)
		if err != nil {
			return vterrors.Wrapf(err, "failed to restart vreplication for shard %v on tablet %v", shardInfo, masterInfo)
		}

	}
	return nil
}
426065
func MakeThriftConcatEndpoint(client *addthrift.AddServiceClient) endpoint.Endpoint {
	return func(ctx context.Context, request interface{}) (interface{}, error) {
		req := request.(addendpoint.ConcatRequest)
		reply, err := client.Concat(ctx, req.A, req.B)
		return addendpoint.ConcatResponse{V: reply.Value, Err: err}, nil
	}
}
740552
func WriteTxLookupEntries(db ethdb.Writer, block *types.Block) {
	for _, tx := range block.Transactions() {
		if err := db.Put(txLookupKey(tx.Hash()), block.Number().Bytes()); err != nil {
			log.Crit("Failed to store transaction lookup entry", "err", err)
		}
	}
}
1001946
func (lst *LogStreamState) Save(withMeta bool) (ds.PropertyMap, error) {
	lst.Schema = CurrentSchemaVersion

	// Save default struct fields.
	pmap, err := ds.GetPLS(lst).Save(withMeta)
	if err != nil {
		return nil, err
	}

	pmap["_Terminated"] = ds.MkProperty(lst.Terminated())
	pmap[ArchivalStateKey] = ds.MkProperty(lst.ArchivalState())

	return pmap, nil
}