// NewSimpleInsert creates an Insert for a Table.
508136
func NewSimpleInsert(opcode InsertOpcode, table *vindexes.Table, keyspace *vindexes.Keyspace) *Insert {
	return &Insert{
		Opcode:   opcode,
		Table:    table,
		Keyspace: keyspace,
	}
}
939637
func NewSimpleElection(electionId, id string, callback func(leader string), c client.Interface) (*leaderelection.LeaderElector, error) {
	return NewElection(electionId, id, api.NamespaceDefault, 10*time.Second, callback, c)
}
612818
func (m *Sqlbridge) parseSqlInsert() (*SqlInsert, error) {

	// insert into mytable (id, str) values (0, "a")
	req := NewSqlInsert()
	req.kw = m.Cur().T
	m.Next() // Consume Insert or Replace

	// INTO
	if m.Cur().T != lex.TokenInto {
		return nil, fmt.Errorf("expected INTO but got: %v", m.Cur())
	}
	m.Next() // Consume INTO

	// table name
	switch m.Cur().T {
	case lex.TokenTable:
		req.Table = m.Cur().V
		m.Next()
	default:
		return nil, fmt.Errorf("expected table name but got : %v", m.Cur().V)
	}

	// list of fields
	cols, err := m.parseFieldList()
	if err != nil {
		return nil, err
	}
	req.Columns = cols

	m.Next() // left paren starts lisf of values
	switch m.Cur().T {
	case lex.TokenValues:
		m.Next() // Consume Values keyword
	case lex.TokenSelect:
		sel, err := m.parseSqlSelect()
		if err != nil {
			return nil, err
		}
		if len(sel.From) == 0 {
			return nil, m.ErrMsg("Expected FROM <sources>")
		}
		req.Select = sel
		return req, nil
	default:
		return nil, m.ErrMsg("expected INSERT (columns) VALUES <values>")
	}

	colVals, err := m.parseValueList()
	if err != nil {
		return nil, err
	}
	req.Rows = colVals
	return req, nil
}
413504
func (dct *DjangoContentType) Insert(db XODB) error {
	var err error

	// if already exist, bail
	if dct._exists {
		return errors.New("insert failed: already exists")
	}

	// sql query
	const sqlstr = `INSERT INTO django.django_content_type (` +
		`app_label, model` +
		`) VALUES (` +
		`:1, :2` +
		`) RETURNING id /*lastInsertId*/ INTO :pk`

	// run query
	XOLog(sqlstr, dct.AppLabel, dct.Model, nil)
	res, err := db.Exec(sqlstr, dct.AppLabel, dct.Model, nil)
	if err != nil {
		return err
	}

	// retrieve id
	id, err := res.LastInsertId()
	if err != nil {
		return err
	}

	// set primary key and existence
	dct.ID = float64(id)
	dct._exists = true

	return nil
}
430106
func (d *dbBase) InsertMulti(q dbQuerier, mi *modelInfo, sind reflect.Value, bulk int, tz *time.Location) (int64, error) {
	var (
		cnt    int64
		nums   int
		values []interface{}
		names  []string
	)

	// typ := reflect.Indirect(mi.addrField).Type()

	length := sind.Len()

	for i := 1; i <= length; i++ {

		ind := reflect.Indirect(sind.Index(i - 1))

		// Is this needed ?
		// if !ind.Type().AssignableTo(typ) {
		// 	return cnt, ErrArgs
		// }

		if i == 1 {
			vus, err := d.collectValues(mi, ind, mi.fields.dbcols, true, true, &names, tz)
			if err != nil {
				return cnt, err
			}
			values = make([]interface{}, bulk*len(vus))
			nums += copy(values, vus)

		} else {

			vus, err := d.collectValues(mi, ind, mi.fields.dbcols, true, true, nil, tz)
			if err != nil {
				return cnt, err
			}

			if len(vus) != len(names) {
				return cnt, ErrArgs
			}

			nums += copy(values[nums:], vus)
		}

		if i > 1 && i%bulk == 0 || length == i {
			num, err := d.InsertValue(q, mi, true, names, values[:nums])
			if err != nil {
				return cnt, err
			}
			cnt += num
			nums = 0
		}
	}

	return cnt, nil
}
611119
func (s Int) Insert(items ...int) {
	for _, item := range items {
		s[item] = Empty{}
	}
}
677281
func (p *PriorityQueue) Insert(v interface{}, priority float64) {
	_, ok := p.lookup[v]
	if ok {
		return
	}

	newItem := &item{
		value:    v,
		priority: priority,
	}
	heap.Push(p.itemHeap, newItem)
	p.lookup[v] = newItem
}
1175890
func Insert(i interface{}) {
	t := reflect.ValueOf(i).Type()
	tname := nameof(t)
	if _, found := typemap[tname]; !found {
		typemap[tname] = t
	}
}
240521
func NewSimple(in interface{}, context *compiler.Context) (*Simple, error) {
	errors := make([]error, 0)
	x := &Simple{}
	m, ok := compiler.UnpackMap(in)
	if !ok {
		message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
		errors = append(errors, compiler.NewError(context, message))
	} else {
		allowedKeys := []string{"multipart", "path"}
		var allowedPatterns []*regexp.Regexp
		invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
		if len(invalidKeys) > 0 {
			message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
			errors = append(errors, compiler.NewError(context, message))
		}
		// bool multipart = 1;
		v1 := compiler.MapValueForKey(m, "multipart")
		if v1 != nil {
			x.Multipart, ok = v1.(bool)
			if !ok {
				message := fmt.Sprintf("has unexpected value for multipart: %+v (%T)", v1, v1)
				errors = append(errors, compiler.NewError(context, message))
			}
		}
		// string path = 2;
		v2 := compiler.MapValueForKey(m, "path")
		if v2 != nil {
			x.Path, ok = v2.(string)
			if !ok {
				message := fmt.Sprintf("has unexpected value for path: %+v (%T)", v2, v2)
				errors = append(errors, compiler.NewError(context, message))
			}
		}
	}
	return x, compiler.NewErrorGroupOrNil(errors)
}
766961
func NewSimpleBlock(e *edtd.Elem) (*SimpleBlock, error) {
	data, err := e.Bytes()
	if err != nil {
		return nil, err
	}
	
	return parseAsSimpleBlock(data)
}
786856
func BatchInsert(db Database, col string) DocWriter {
	if bi, ok := db.(BatchInserter); ok {
		return bi.BatchInsert(col)
	}
	return &seqInsert{db: db, col: col}
}
1013844
func (tx *Tx) Upsert(list ...interface{}) error {
	return insertObjects(tx.Context(), tx.DB, tx, getUpsert, list, opUpsert)
}
1128593
func (s *ChocolateStorage) Insert(c model.Chocolate) string {
	id := fmt.Sprintf("%d", s.idCount)
	c.ID = id
	s.chocolates[id] = &c
	s.idCount++
	return id
}
1360974
func (this *Engine) RawInsert(table string, sets map[string]interface{}) (lastId int64, err error) {
	var (
		fields string
		values string
		params []interface{}
		delim  string
	)
	for k, v := range sets {
		fields += delim + this.Quote(k)
		values += delim + "?"
		params = append(params, v)
		delim = ","
	}
	sql := `INSERT INTO ` + this.fullTableName(table) + ` (` + fields + `) VALUES (` + values + `)`
	return this.RawExec(sql, true, params...)
}
1014600
func (s *session) Insert(tables ...Table) error {
	for _, table := range tables {
		action, err := s.update(table, true)
		if err != nil {
			return s.catch("Insert: "+action, err)
		}
	}
	return nil
}
1140582
func NewInsert(tags core.TagSlice) (*Insert, error) {
	insert := new(Insert)

	// set defaults
	insert.ScaleFactorX = 1.0
	insert.ScaleFactorY = 1.0
	insert.ScaleFactorZ = 1.0
	insert.RotationAngle = 0.0
	insert.ColumnCount = 1
	insert.RowCount = 1
	insert.ColumnSpacing = 0.0
	insert.RowSpacing = 0.0
	insert.Entities = make(EntitySlice, 0)
	insert.ExtrusionDirection = core.Point{X: 0.0, Y: 0.0, Z: 1.0}

	insert.InitBaseEntityParser()
	insert.Update(map[int]core.TypeParser{
		2:  core.NewStringTypeParserToVar(&insert.BlockName),
		10: core.NewFloatTypeParserToVar(&insert.InsertionPoint.X),
		20: core.NewFloatTypeParserToVar(&insert.InsertionPoint.Y),
		30: core.NewFloatTypeParserToVar(&insert.InsertionPoint.Z),
		41: core.NewFloatTypeParserToVar(&insert.ScaleFactorX),
		42: core.NewFloatTypeParserToVar(&insert.ScaleFactorY),
		43: core.NewFloatTypeParserToVar(&insert.ScaleFactorZ),
		44: core.NewFloatTypeParserToVar(&insert.ColumnSpacing),
		45: core.NewFloatTypeParserToVar(&insert.RowSpacing),
		50: core.NewFloatTypeParserToVar(&insert.RotationAngle),
		66: core.NewIntTypeParser(func(value int) {
			insert.AttributesFollow = value == 1
		}),
		70:  core.NewIntTypeParserToVar(&insert.ColumnCount),
		71:  core.NewIntTypeParserToVar(&insert.RowCount),
		210: core.NewFloatTypeParserToVar(&insert.ExtrusionDirection.X),
		220: core.NewFloatTypeParserToVar(&insert.ExtrusionDirection.Y),
		230: core.NewFloatTypeParserToVar(&insert.ExtrusionDirection.Z),
	})

	err := insert.Parse(tags)
	return insert, err
}
1142597
func (trie *Trie) Insert(key Prefix, item Item) (inserted bool) {
	return trie.put(key, item, false)
}