// GetID returns the ID field if it's non-nil, zero value otherwise.
774973
func (a *App) GetID() int64 {
	if a == nil || a.ID == nil {
		return 0
	}
	return *a.ID
}
1117097
func (p *Plugin) GetID() string {
	p.mu.RLock()
	defer p.mu.RUnlock()

	return p.PluginObj.ID
}
282979
func (bt *Translator) GetID(field string, val interface{}) (id uint64, err error) {
	// ensure field existence
	bt.fmu.RLock()
	_, ok := bt.fields[field]
	bt.fmu.RUnlock()
	if !ok {
		err = bt.Db.Update(func(tx *bolt.Tx) error {
			ib := tx.Bucket(idBucket)
			vb := tx.Bucket(valBucket)
			_, _, err := bt.addField(ib, vb, field)
			return err
		})
		if err != nil {
			return 0, errors.Wrap(err, "adding fields in GetID")
		}
	}

	// check that val is of a supported type
	bsval, ok := val.([]byte)
	if !ok {
		return 0, errors.Errorf("val %v of type %T for field %v not supported by BoltTranslator - must be a []byte. ", val, val, field)
	}

	// look up to see if this val is already mapped to an id
	var ret []byte
	err = bt.Db.View(func(tx *bolt.Tx) error {
		vb := tx.Bucket(valBucket)
		fvb := vb.Bucket([]byte(field))
		ret = fvb.Get(bsval)
		return nil
	})
	if len(ret) == 8 {
		return binary.BigEndian.Uint64(ret), nil
	}

	// get new id, and map it in both directions
	err = bt.Db.Batch(func(tx *bolt.Tx) error {
		fib := tx.Bucket(idBucket).Bucket([]byte(field))
		fvb := tx.Bucket(valBucket).Bucket([]byte(field))

		id, err = fib.NextSequence()
		if err != nil {
			return err
		}
		keybytes := make([]byte, 8)
		binary.BigEndian.PutUint64(keybytes, id)
		err = fib.Put(keybytes, bsval)
		if err != nil {
			return errors.Wrap(err, "inserting into idKey bucket")
		}
		err = fvb.Put(bsval, keybytes)
		if err != nil {
			return errors.Wrap(err, "inserting into valKey bucket")
		}
		return nil
	})
	if err != nil {
		return 0, err
	}
	return id, nil
}
801884
func (r *RepoStatus) GetID() int64 {
	if r == nil || r.ID == nil {
		return 0
	}
	return *r.ID
}
1122004
func (i *Installation) GetID() int64 {
	if i == nil || i.ID == nil {
		return 0
	}
	return *i.ID
}
73644
func (r *RepositoryRelease) GetID() int64 {
	if r == nil || r.ID == nil {
		return 0
	}
	return *r.ID
}
330218
func (l *LabelResult) GetID() int64 {
	if l == nil || l.ID == nil {
		return 0
	}
	return *l.ID
}
107747
func (p *ProjectColumn) GetID() int64 {
	if p == nil || p.ID == nil {
		return 0
	}
	return *p.ID
}
423417
func (s *Source) GetID() int64 {
	if s == nil || s.ID == nil {
		return 0
	}
	return *s.ID
}
575090
func (v *memdbView) GetID(name string) (string, error) {
	s, err := v.txn.First(memdbNamesTable, memdbIDIndex, name)
	if err != nil {
		return "", err
	}
	if s == nil {
		return "", ErrNameNotReserved
	}
	return s.(nameAssociation).containerID, nil
}
1141977
func GetID(id uint32) (*loadbalancer.L3n4AddrID, error) {
	if enableGlobalServiceIDs {
		return getGlobalID(id)
	}

	return serviceIDAlloc.getLocalID(id)
}
685567
func (r *Reaction) GetID() int64 {
	if r == nil || r.ID == nil {
		return 0
	}
	return *r.ID
}
820093
func (a *Attachment) GetID() int64 {
	if a == nil || a.ID == nil {
		return 0
	}
	return *a.ID
}
68079
func (lft *FieldTranslator) GetID(val interface{}) (id uint64, err error) {
	var vall pdk.Literal
	switch valt := val.(type) {
	case []byte:
		vall = pdk.S(valt)
	case string:
		vall = pdk.S(valt)
	default:
		var ok bool
		if vall, ok = val.(pdk.Literal); !ok {
			return 0, errors.Errorf("val needs to be string, byte slice, or Literal, but is type: %T, val: '%v'", val, val)
		}
	}
	valBytes := pdk.ToBytes(vall)
	var data []byte

	// if you're expecting most of the mapping to already be done, this would be faster
	data, err = lft.valMap.Get(valBytes, &opt.ReadOptions{})
	if err != nil && err != leveldb.ErrNotFound {
		return 0, errors.Wrap(err, "trying to read value map")
	} else if err == nil {
		return binary.BigEndian.Uint64(data), nil
	}

	// else, val not found
	lft.lock.Lock(valBytes)
	defer lft.lock.Unlock(valBytes)
	// re-read after locking
	data, err = lft.valMap.Get(valBytes, &opt.ReadOptions{})
	if err != nil && err != leveldb.ErrNotFound {
		return 0, errors.Wrap(err, "trying to read value map")
	} else if err == nil {
		return binary.BigEndian.Uint64(data), nil
	}

	idBytes := make([]byte, 8)
	new := atomic.AddUint64(lft.curID, 1)
	binary.BigEndian.PutUint64(idBytes, new-1)
	err = lft.idMap.Put(idBytes, valBytes, &opt.WriteOptions{})
	if err != nil {
		return 0, errors.Wrap(err, "putting new id into idmap")
	}
	err = lft.valMap.Put(valBytes, idBytes, &opt.WriteOptions{})
	if err != nil {
		return 0, errors.Wrap(err, "putting new id into valmap")
	}
	return new - 1, nil
}
452989
func (g *GistComment) GetID() int64 {
	if g == nil || g.ID == nil {
		return 0
	}
	return *g.ID
}
31411
func getIds(u *user.User) (C.int, C.int, error) {
	uid, err := strconv.Atoi(u.Uid)
	if err != nil {
		return -1, -1, fmt.Errorf("invalid uid: %v", err)
	}

	gid, err := strconv.Atoi(u.Gid)
	if err != nil {
		return -1, -1, fmt.Errorf("invalid gid: %v", err)
	}
	return C.int(uid), C.int(gid), nil
}
1100341
func (t *Team) GetID() int64 {
	if t == nil || t.ID == nil {
		return 0
	}
	return *t.ID
}