A cache of dereferenced legislator objects.
337437
def _legislator_objects(self):
        '''
        '''
        kwargs = {}

        id_getter = operator.itemgetter('leg_id')
        ids = []
        for k in ('yes', 'no', 'other'):
            ids.extend(map(id_getter, self[k + '_votes']))
        objs = db.legislators.find({'_all_ids': {'$in': ids}}, **kwargs)

        # Handy to keep a reference to the vote on each legislator.
        objs = list(objs)
        id_cache = {}
        for obj in objs:
            obj.vote = self
            for _id in obj['_all_ids']:
                id_cache[_id] = obj

        return id_cache
789399
private synchronized void expungeStaleEntries()
    {
        if (size == 0) return;
        Object r;
        while ((r = queue.poll()) != null)
        {
            Entry e = (Entry) r;
            unlink(e);
            int h = e.hash;
            int i = indexFor(h, table.length);

            Entry prev = table[i];
            Entry p = prev;
            while (p != null)
            {
                Entry next = p.next;
                if (p == e)
                {
                    if (prev == e)
                        table[i] = next;
                    else
                        prev.next = next;
                    e.next = null;  // Help GC
                    size--;
                    break;
                }
                prev = p;
                p = next;
            }
        }
    }
1265295
def get_elections(self, obj):
        """"""
        election_day = ElectionDay.objects.get(
            date=self.context['election_date'])

        elections = list(obj.elections.filter(election_day=election_day))
        district = DivisionLevel.objects.get(name=DivisionLevel.DISTRICT)
        for district in obj.children.filter(level=district):
            elections.extend(
                list(district.elections.filter(
                    election_day=election_day,
                    meta__isnull=False
                ))
            )

        return ElectionSerializer(elections, many=True).data
1258449
function iterator(obj, iteratee, memo, keys, index, length) {
                  for (; index >= 0 && index < length; index += dir) {
                    var currentKey = keys ? keys[index] : index;
                    memo = iteratee(memo, obj[currentKey], currentKey, obj);
                  }
                  return memo;
                }
875237
def by_type(self, chamber, type, congress=CURRENT_CONGRESS):
        ""
        check_chamber(chamber)

        path = "{congress}/{chamber}/votes/{type}.json".format(
            congress=congress, chamber=chamber, type=type)
        return self.fetch(path)
1028399
def cached_items(self):
        
        for item in six.iteritems(self._page_cache):
            yield item
        for item in six.iteritems(self._direct_lookup_cache):
            yield item
610426
def get_states(self, obj):
        """"""
        return reverse(
            'electionnight_api_state-election-list',
            request=self.context['request'],
            kwargs={'date': obj.date}
        )
85241
def get_bodies(self, obj):
        """"""
        return reverse(
            'electionnight_api_body-election-list',
            request=self.context['request'],
            kwargs={'date': obj.date}
        )
679696
def upcoming(self, chamber, congress=CURRENT_CONGRESS):
        ""
        path = "bills/upcoming/{chamber}.json".format(chamber=chamber)
        return self.fetch(path)
550058
private Collection getOwnerObjects()
    {
        Collection owners = new Vector();
        while (hasNext())
        {
            owners.add(next());
        }
        return owners;
    }
242094
private Iterator<Record> decodeRows(List<Map.Entry<ByteBuffer, Key>> keys, final Rows<ByteBuffer, DeltaKey> rows,
                                        final int largeRowThreshold, final ReadConsistency consistency) {
        // Avoiding pinning multiple decoded rows into memory at once.
        return Iterators.transform(keys.iterator(), new Function<Map.Entry<ByteBuffer, Key>, Record>() {
            @Override
            public Record apply(Map.Entry<ByteBuffer, Key> entry) {
                Row<ByteBuffer, DeltaKey> row = rows.getRow(entry.getKey());
                if (row == null) {
                    return emptyRecord(entry.getValue());
                }
                // Convert the results into a Record object, lazily fetching the rest of the columns as necessary.
                return newRecord(entry.getValue(), row.getRawKey(), row.getColumns(), largeRowThreshold, consistency, null);
            }
        });
    }
544353
def collect(self):
        """"""
        for func in self._caches:
            cache = {}
            for key in self._caches[func]:
                if (time.time() - self._caches[func][key][1]) < self._timeouts[func]:
                    cache[key] = self._caches[func][key]
            self._caches[func] = cache
690949
void markReferenceElements(PersistenceBroker broker)
    {
        // these cases will be handled by ObjectEnvelopeTable#cascadingDependents()
        // if(getModificationState().needsInsert() || getModificationState().needsDelete()) return;

        Map oldImage = getBeforeImage();
        Map newImage = getCurrentImage();

        Iterator iter = newImage.entrySet().iterator();
        while (iter.hasNext())
        {
            Map.Entry entry = (Map.Entry) iter.next();
            Object key = entry.getKey();
            // we only interested in references
            if(key instanceof ObjectReferenceDescriptor)
            {
                Image oldRefImage = (Image) oldImage.get(key);
                Image newRefImage = (Image) entry.getValue();
                newRefImage.performReferenceDetection(oldRefImage);
            }
        }
    }
109638
@Override
	public void cacheResult(
		List<CPRuleAssetCategoryRel> cpRuleAssetCategoryRels) {
		for (CPRuleAssetCategoryRel cpRuleAssetCategoryRel : cpRuleAssetCategoryRels) {
			if (entityCache.getResult(
						CPRuleAssetCategoryRelModelImpl.ENTITY_CACHE_ENABLED,
						CPRuleAssetCategoryRelImpl.class,
						cpRuleAssetCategoryRel.getPrimaryKey()) == null) {
				cacheResult(cpRuleAssetCategoryRel);
			}
			else {
				cpRuleAssetCategoryRel.resetOriginalValues();
			}
		}
	}
833720
def _objectify(items, container_name):
    """"""
    objects = []

    # Deal with objects and object pseudo-folders first, save subdirs for later
    for item in items:
        if item.get("subdir", None) is not None:
            object_cls = PseudoFolder
        else:
            object_cls = StorageObject

        objects.append(object_cls(item, container_name))

    return objects
136763
def from_dict(cls, d):
        """"""
        main_memory = MainMemory()
        caches = {}

        referred_caches = set()

        # First pass, create all named caches and collect references
        for name, conf in d.items():
            caches[name] = Cache(name=name,
                                 **{k: v for k, v in conf.items()
                                    if k not in ['store_to', 'load_from', 'victims_to']})
            if 'store_to' in conf:
                referred_caches.add(conf['store_to'])
            if 'load_from' in conf:
                referred_caches.add(conf['load_from'])
            if 'victims_to' in conf:
                referred_caches.add(conf['victims_to'])

        # Second pass, connect caches
        for name, conf in d.items():
            if 'store_to' in conf and conf['store_to'] is not None:
                caches[name].set_store_to(caches[conf['store_to']])
            if 'load_from' in conf and conf['load_from'] is not None:
                caches[name].set_load_from(caches[conf['load_from']])
            if 'victims_to' in conf and conf['victims_to'] is not None:
                caches[name].set_victims_to(caches[conf['victims_to']])

        # Find first level (not target of any load_from or store_to)
        first_level = set(d.keys()) - referred_caches
        assert len(first_level) == 1, "Unable to find first cache level."
        first_level = caches[list(first_level)[0]]

        # Find last level caches (has no load_from or store_to target)
        last_level_load = c = first_level
        while c is not None:
            last_level_load = c
            c = c.load_from
        assert last_level_load is not None, "Unable to find last cache level."
        last_level_store = c = first_level
        while c is not None:
            last_level_store = c
            c = c.store_to
        assert last_level_store is not None, "Unable to find last cache level."

        # Set main memory connections
        main_memory.load_to(last_level_load)
        main_memory.store_from(last_level_store)

        return cls(first_level, main_memory), caches, main_memory
1021068
private ReadResultEntry collectCachedEntries(long initialOffset, ReadResult readResult,
                                                 ArrayList<ReadResultEntryContents> cachedEntries) {
        long expectedOffset = initialOffset;
        while (readResult.hasNext()) {
            ReadResultEntry entry = readResult.next();
            if (entry.getType() == Cache) {
                Preconditions.checkState(entry.getStreamSegmentOffset() == expectedOffset,
                        "Data returned from read was not contiguous.");
                ReadResultEntryContents content = entry.getContent().getNow(null);
                expectedOffset += content.getLength();
                cachedEntries.add(content);
            } else {
                return entry;
            }
        }
        return null;
    }