:returns the TrajectoryInfoCache singleton instance
354832
def instance():
        
        if TrajectoryInfoCache._instance is None:
            # if we do not have a configuration director yet, we do not want to store
            if not config.cfg_dir:
                filename = None
            else:
                filename = os.path.join(config.cfg_dir, "traj_info.sqlite3")
            TrajectoryInfoCache._instance = TrajectoryInfoCache(filename)

        return TrajectoryInfoCache._instance
808689
@SuppressWarnings("unchecked")
    private static synchronized Map<String, Boolean> getCache(GraphRewrite event)
    {
        Map<String, Boolean> result = (Map<String, Boolean>)event.getRewriteContext().get(ClassificationServiceCache.class);
        if (result == null)
        {
            result = Collections.synchronizedMap(new LRUMap(30000));
            event.getRewriteContext().put(ClassificationServiceCache.class, result);
        }
        return result;
    }
1252941
private <T> T getInstance(DatastoreType datastoreType, TransactionalCache.Mode cacheMode) {
        DatastoreId id = getDatastoreId(datastoreType);
        Object instance = cache.get(id, cacheMode);
        if (instance == null) {
            DynamicType<?> types = getTypes(datastoreType);
            instance = newInstance(id, datastoreType, types, cacheMode);
            if (TransactionalCache.Mode.READ.equals(cacheMode)) {
                instanceListenerService.postLoad(instance);
            }
        }
        return (T) instance;
    }
441729
def detour_info(self):
        
        resource_list = self.traffic_incident()
        detour_info = namedtuple('detour_info', 'detour_info')
        if len(resource_list) == 1 and resource_list[0] is None:
            return None
        else:
            try:
                return [detour_info(resource['detour'])
                        for resource in resource_list]
            except (KeyError, TypeError):
                try:
                    return [detour_info(resource['detourInfo'])
                            for resource in resource_list]
                except KeyError:
                    return None
1156461
def getInstance(cls, *args):
        '''
        
        '''
        if not cls.__singleton:
            cls.__singleton = Heroku(*args)
        return cls.__singleton
23129
def isInCache(self):
    
    url = self.buildUrl(cache_friendly=True)
    return url in __class__.cache
67842
def get(self, CachableItem):
        
        return self.session.\
                        query(self.mapper.factory().__class__).\
                        filter(self.mapper.factory().__class__.__dict__[self.mapper.key()]==CachableItem.getId()).\
                        first()
1277772
def GetPathInfo(self, timestamp=None):
    
    path_info_timestamp = self._LastEntryTimestamp(self._path_infos, timestamp)
    try:
      result = self._path_infos[path_info_timestamp].Copy()
    except KeyError:
      result = rdf_objects.PathInfo(
          path_type=self._path_type, components=self._components)

    stat_entry_timestamp = self._LastEntryTimestamp(self._stat_entries,
                                                    timestamp)
    result.last_stat_entry_timestamp = stat_entry_timestamp
    result.stat_entry = self._stat_entries.get(stat_entry_timestamp)

    hash_entry_timestamp = self._LastEntryTimestamp(self._hash_entries,
                                                    timestamp)
    result.last_hash_entry_timestamp = hash_entry_timestamp
    result.hash_entry = self._hash_entries.get(hash_entry_timestamp)

    return result
249376
def load_trajectory(name, format=None, skip=1):
    '''

    '''
    df = datafile(name, format=format)

    ret = {}
    t, coords = df.read('trajectory', skip=skip)
    boxes = df.read('boxes')
    ret['t'] = t
    ret['coords'] = coords
    ret['boxes'] = boxes

    return ret
681991
def memorized_ttinfo(*args):
    ''''''
    try:
        return _ttinfo_cache[args]
    except KeyError:
        ttinfo = (
                memorized_timedelta(args[0]),
                memorized_timedelta(args[1]),
                args[2]
                )
        _ttinfo_cache[args] = ttinfo
        return ttinfo
741348
def get_singleton(cls, annotators=None, **options):
        
        if annotators is not None:
            annotators = tuple(annotators)
        if annotators not in cls._singletons:
            cls._singletons[annotators] = cls(annotators, **options)
        return cls._singletons[annotators]
527519
def patch_related_object_descriptor_caching(ro_descriptor):
    
    class NewSingleObjectDescriptor(LanguageCacheSingleObjectDescriptor, ro_descriptor.__class__):
        pass

    if django.VERSION[0] == 2:
        ro_descriptor.related.get_cache_name = partial(
            NewSingleObjectDescriptor.get_cache_name,
            ro_descriptor,
        )

    ro_descriptor.accessor = ro_descriptor.related.get_accessor_name()
    ro_descriptor.__class__ = NewSingleObjectDescriptor
350487
def load_remote_trajectory(url, format=None):
    '''
    
    '''
    from urllib import urlretrieve
    filename, headers = urlretrieve(url)
    load_trajectory(filename, format)
569065
def get_instances(self):
        
        if self._update_members: self.update()
        return iter(sorted(self.members.iteritems()))
1130034
public static final TracerFactory instance() {
        if(INSTANCE == null) throw new IllegalStateException(String.format("%s not initialized", TracerFactory.class.getSimpleName()));
        return INSTANCE;
    }
220044
def cached(key, path_info, details, locals)
      name, prefix, partial = path_info

      if key
        @cache.cache(key, name, prefix, partial, locals) do
          yield
        end
      else
        yield
      end
    end
854676
def get(cls, route, args, kwargs):
        
        # ---------
        # Namespace
        # ---------
        if None in args:
            namespace = None
        else:
            namespace = call(route.get('namespace'), args, kwargs) if route.get('namespace') \
                        else ".".join(map(str, [cls.__name__] + list(args)))

        # bool, can store in memory
        # _in_memory = route.get('memory', True)

        # ---------------
        # Get from Memory
        # ---------------
        # if _in_memory and namespace:
        # check for this namespace
        try:
            return debris.services.memory.get(namespace)
        except LookupError:
            pass

        # ------------------------
        # Constructed w/ init args
        # ------------------------
        # - this method bypasses many of the debris
        #   features for cacheing because the 
        #   kwargs should contain all the construction information
        # - replaces existing object in memory beceause this data is 
        #   given to be "newer" data
        if len(kwargs) > 0:
            cls = call(route.get('substitute'), args, kwargs) or cls
            obj = cls.__new__(cls, *args, **kwargs)
            obj.__init__(*args, **kwargs)
            if namespace:
                debris.services.memory.set(namespace, obj)
            return obj

        elif not namespace:
            raise LookupError("No id/key provided to initialize object "+namespace.replace('.', '(', 1).replace('.', ', ')+")")

        # -----------------
        # Retrieve the Data
        # -----------------
        insp = inspect.getargspec(cls.__init__)
        data = None
        if route.get('get'):
            for r in route['get']:
                if r['service'] == 'postgresql':
                    iwargs = dict([(k, args[i] if len(args) > i else None) for i, k in enumerate(insp.args[1:])])
                    data = r["bank"].get(r['query'], **iwargs)
                else:
                    data = r["bank"].get(namespace)
                if data:
                    break

            # -----------------
            # Retrieve the Data
            # -----------------
            if not data:
                raise LookupError("Data could not be found for "+namespace.replace('.', '(', 1).replace('.', ', ')+")")

        if not data:
            data = {}

        # --------------------
        # Manage Args / Kwargs
        # --------------------
        # remove the default "self" argument
        insp.args.pop(0)
        [data.pop(k) for k in insp.args if k in data]

        # substiture class w/ known data
        if route.get('substitute'):
            cls = callattr(cls, route['substitute'], args, data) or cls

        # ----------------
        # Initialize Class
        # ----------------
        obj = cls.__new__(cls, *args, **data)
        obj.__init__(*args, **data)

        # ---------------
        # Store in Memory
        # ---------------
        if namespace:
            debris.services.memory.set(namespace, obj)

        # return the constructed object
        return obj