// lookupByTime takes a timestamp for expiration comparisions, and is only
// intended for testing.
761882
func (c *DNSCache) lookupByTime(now time.Time, name string) (ips []net.IP) {
	entries, found := c.forward[name]
	if !found {
		return nil
	}

	return entries.getIPs(now)
}
1037687
func compareTime(a, b MysqlTime) int {
	ta := datetimeToUint64(a)
	tb := datetimeToUint64(b)

	switch {
	case ta < tb:
		return -1
	case ta > tb:
		return 1
	}

	switch {
	case a.Microsecond() < b.Microsecond():
		return -1
	case a.Microsecond() > b.Microsecond():
		return 1
	}

	return 0
}
45647
func (swi *pluginStatusMap) LookupByState(state status.OperationalState) []string {
	return swi.mapping.ListNames(stateIndexKey, state.String())
}
1179021
func (c *Controller) lookupBundleByObjectByIndex(byIndex byIndexFunc, indexName string, indexKey indexKeyFunc) func(runtime.Object) ([]runtime.Object, error) {
	return func(obj runtime.Object) ([]runtime.Object /*bundles*/, error) {
		// obj is an object that is referred by some other object that might be in a Bundle
		objMeta := obj.(meta_v1.Object)
		// find all object that reference this obj
		objsFromIndex, err := byIndex(indexName, indexKey(objMeta.GetNamespace(), objMeta.GetName()))
		if err != nil {
			return nil, err
		}
		var bundles []runtime.Object
		for _, objFromIndex := range objsFromIndex {
			runtimeObjFromIndex := objFromIndex.(runtime.Object)
			metaObjFromIndex := objFromIndex.(meta_v1.Object)
			gvks, _, err := c.Scheme.ObjectKinds(runtimeObjFromIndex)
			if err != nil {
				// Log and continue to try to process other objects if there are any more in objsFromIndex
				// This shouldn't happen normally
				c.Logger.
					With(zap.Error(err), logz.Namespace(metaObjFromIndex), logz.Object(metaObjFromIndex)).
					Sugar().Errorf("Could not determine GVK of an object")
				continue
			}
			gks := make(map[schema.GroupKind]struct{}, len(gvks)) // not clear if duplicates are allowed, so de-dupe
			for _, gvk := range gvks {
				gks[gvk.GroupKind()] = struct{}{}
			}

			// find all Bundles that contain this object
			for gk := range gks {
				bundlesForObject, err := c.BundleStore.GetBundlesByObject(gk, metaObjFromIndex.GetNamespace(), metaObjFromIndex.GetName())
				if err != nil {
					// Log and continue to try to process other GKs
					c.Logger.
						With(zap.Error(err), logz.Namespace(metaObjFromIndex), logz.Object(metaObjFromIndex)).
						Sugar().Errorf("Failed to get Bundles by object")
					continue
				}
				for _, bundle := range bundlesForObject {
					bundles = append(bundles, bundle)
				}
			}
		}
		return bundles, nil
	}
}
615348
func (c *Cache) Lookup(typeURL string, resourceName string) (proto.Message, error) {
	res, err := c.GetResources(context.Background(), typeURL, 0, nil, []string{resourceName})
	if err != nil || res == nil || len(res.Resources) == 0 {
		return nil, err
	}
	return res.Resources[0], nil
}
1113569
func NullDateTimeFrom(ptr *DateTime) NullDateTime {
	if ptr == nil {
		return NullDateTime{}
	}
	return NullDateTime{
		DateTime: *ptr,
		Valid:    true,
	}
}
1238980
func (tc *TransCache) GetItemExpiryTime(chID, itmID string) (exp time.Time, ok bool) {
	tc.cacheMux.RLock()
	defer tc.cacheMux.RUnlock()
	return tc.cacheInstance(chID).GetItemExpiryTime(itmID)
}
1037431
func (r Row) GetTime(colIdx int) types.Time {
	col := r.c.columns[colIdx]
	return readTime(col.data[r.idx*16:])
}
157679
func IsZeroTime(t time.Time) bool {
	return t.IsZero() || t.Equal(unixEpochTime)
}
1174011
func (v *StorageVol) LookupPoolByVolume() (*StoragePool, error) {
	var err C.virError
	poolPtr := C.virStoragePoolLookupByVolumeWrapper(v.ptr, &err)
	if poolPtr == nil {
		return nil, makeError(&err)
	}
	return &StoragePool{ptr: poolPtr}, nil
}
797423
func (c *WS2Client) Lookup(entity MBLookupEntity, inc ...string) error {
	if entity.Id() == "" {
		return errors.New("can't perform lookup without ID.")
	}

	return c.getRequest(entity.lookupResult(), encodeInc(inc),
		path.Join(
			entity.apiEndpoint(),
			string(entity.Id()),
		),
	)
}
1003212
func (c *Connect) LookupStoragePoolByName(name string) (*StoragePool, error) {
	cName := C.CString(name)
	defer C.free(unsafe.Pointer(cName))
	var err C.virError
	ptr := C.virStoragePoolLookupByNameWrapper(c.ptr, cName, &err)
	if ptr == nil {
		return nil, makeError(&err)
	}
	return &StoragePool{ptr: ptr}, nil
}
215255
func (namespace *Namespace) KeyNameSpaceWithTime(key string, key_time goltime.Timestamp) string {
	return fmt.Sprintf("%s:%s", key, namespace.TimeKeyPart(key_time))
}
1081287
func (c *DNSCache) LookupByRegexp(re *regexp.Regexp) (matches map[string][]net.IP) {
	return c.lookupByRegexpByTime(time.Now(), re)
}
953186
func retrieveLastCommitTime(db *sql.DB) (timestamp time.Time, err error) {
	err = db.QueryRow(internal.SelectProposalsLastCommitTime).Scan(&timestamp)
	return
}
929817
func (c *DNSCache) ForceExpireByNames(expireLookupsBefore time.Time, names []string) (namesAffected []string) {
	c.Lock()
	defer c.Unlock()
	for _, name := range names {
		entries, exists := c.forward[name]
		if !exists {
			continue
		}

		// We pass expireLookupsBefore as the `now` parameter but it is redundant
		// because LookupTime must be before ExpirationTime.
		// The second expireLookupsBefore actually matches lookup times, and will
		// delete the entries completely.
		nameNeedsRegen := c.removeExpired(entries, expireLookupsBefore, expireLookupsBefore)
		if nameNeedsRegen {
			namesAffected = append(namesAffected, name)
		}
	}

	return namesAffected
}
36818
func (c *ExpirationCache) GetByKey(key string) (interface{}, bool, error) {
	obj, exists := c.getOrExpire(key)
	return obj, exists, nil
}