Example #1
0
        public GenericDataModel(FastByIDMap <PreferenceArray> userData, FastByIDMap <FastByIDMap <DateTime?> > timestamps)
        {
            this.preferenceFromUsers = userData;
            FastByIDMap <List <Preference> > data = new FastByIDMap <List <Preference> >();
            FastIDSet set = new FastIDSet();
            int       num = 0;
            float     negativeInfinity = float.NegativeInfinity;
            float     positiveInfinity = float.PositiveInfinity;

            foreach (KeyValuePair <long, PreferenceArray> pair in this.preferenceFromUsers.entrySet())
            {
                PreferenceArray array = pair.Value;
                array.sortByItem();
                foreach (Preference preference in array)
                {
                    long key = preference.getItemID();
                    set.add(key);
                    List <Preference> list = data.get(key);
                    if (list == null)
                    {
                        list = new List <Preference>(2);
                        data.put(key, list);
                    }
                    list.Add(preference);
                    float num5 = preference.getValue();
                    if (num5 > negativeInfinity)
                    {
                        negativeInfinity = num5;
                    }
                    if (num5 < positiveInfinity)
                    {
                        positiveInfinity = num5;
                    }
                }
                if ((++num % 0x2710) == 0)
                {
                    log.info("Processed {0} users", new object[] { num });
                }
            }
            log.info("Processed {0} users", new object[] { num });
            this.setMinPreference(positiveInfinity);
            this.setMaxPreference(negativeInfinity);
            this.itemIDs = set.toArray();
            set          = null;
            Array.Sort <long>(this.itemIDs);
            this.preferenceForItems = toDataMap(data, false);
            foreach (KeyValuePair <long, PreferenceArray> pair in this.preferenceForItems.entrySet())
            {
                pair.Value.sortByUser();
            }
            this.userIDs = new long[userData.size()];
            int num6 = 0;

            foreach (long num7 in userData.Keys)
            {
                this.userIDs[num6++] = num7;
            }
            Array.Sort <long>(this.userIDs);
            this.timestamps = timestamps;
        }
Example #2
0
        public static FastByIDMap <PreferenceArray> toDataMap(FastByIDMap <List <Preference> > data, bool byUser)
        {
            FastByIDMap <PreferenceArray> map = new FastByIDMap <PreferenceArray>(data.size());

            foreach (KeyValuePair <long, List <Preference> > pair in data.entrySet())
            {
                List <Preference> prefs = pair.Value;
                map.put(pair.Key, byUser ? ((PreferenceArray) new GenericUserPreferenceArray(prefs)) : ((PreferenceArray) new GenericItemPreferenceArray(prefs)));
            }
            return(map);
        }
        public static FastByIDMap <FastIDSet> toDataMap(FastByIDMap <PreferenceArray> data)
        {
            FastByIDMap <FastIDSet> map = new FastByIDMap <FastIDSet>(data.size());

            foreach (KeyValuePair <long, PreferenceArray> pair in data.entrySet())
            {
                PreferenceArray array = pair.Value;
                int             size  = array.length();
                FastIDSet       set   = new FastIDSet(size);
                for (int i = 0; i < size; i++)
                {
                    set.add(array.getItemID(i));
                }
                map.put(pair.Key, set);
            }
            return(map);
        }
        public GenericBooleanPrefDataModel(FastByIDMap <FastIDSet> userData, FastByIDMap <FastByIDMap <DateTime?> > timestamps)
        {
            this.preferenceFromUsers = userData;
            this.preferenceForItems  = new FastByIDMap <FastIDSet>();
            FastIDSet set = new FastIDSet();

            foreach (KeyValuePair <long, FastIDSet> pair in this.preferenceFromUsers.entrySet())
            {
                long      key = pair.Key;
                FastIDSet c   = pair.Value;
                set.addAll(c);
                IEnumerator <long> enumerator = c.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    long      current = enumerator.Current;
                    FastIDSet set3    = this.preferenceForItems.get(current);
                    if (set3 == null)
                    {
                        set3 = new FastIDSet(2);
                        this.preferenceForItems.put(current, set3);
                    }
                    set3.add(key);
                }
            }
            this.itemIDs = set.toArray();
            set          = null;
            Array.Sort <long>(this.itemIDs);
            this.userIDs = new long[userData.size()];
            int num3 = 0;
            IEnumerator <long> enumerator2 = userData.Keys.GetEnumerator();

            while (enumerator2.MoveNext())
            {
                this.userIDs[num3++] = enumerator2.Current;
            }
            Array.Sort <long>(this.userIDs);
            this.timestamps = timestamps;
        }