Package it.unimi.dsi.fastutil.longs

Examples of it.unimi.dsi.fastutil.longs.Long2IntMap


                final long user = r.getUserId();
                final long item = r.getItemId();
                final Preference p = r.getPreference();

                // get the item -> index map for this user
                Long2IntMap imap = uiIndexes.get(user);
                if (imap == null) {
                    imap = new Long2IntOpenHashMap();
                    imap.defaultReturnValue(-1);
                    uiIndexes.put(user, imap);
                }

                // have we seen the item?
                final int index = imap.get(item);
                if (index < 0) {    // we've never seen (user,item) before
                    // if this is not an unrate (a no-op), add the pref
                    if (p != null) {
                        int idx = bld.add(p);
                        imap.put(item, idx);
                    }
                } else {            // we have seen this rating before
                    if (p == null) {
                        // free the entry, no rating here
                        bld.release(index);
                        imap.put(item, -1);
                    } else {
                        // just overwrite the previous value
                        bld.set(index, p);
                    }
                }
View Full Code Here


     * @throws org.grouplens.lenskit.eval.TaskExecutionException
     */
    protected void writeTTFilesByUsers(RatingWriter[] trainWriters, RatingWriter[] testWriters) throws TaskExecutionException {
        logger.info("splitting data source {} to {} partitions by users",
                    getName(), partitionCount);
        Long2IntMap splits = splitUsers(source.getUserDAO());
        Cursor<UserHistory<Rating>> historyCursor = source.getUserEventDAO().streamEventsByUser(Rating.class);
        Holdout mode = this.getHoldout();
        try {
            for (UserHistory<Rating> history : historyCursor) {
                int foldNum = splits.get(history.getUserId());
                List<Rating> ratings = new ArrayList<Rating>(history);
                final int n = ratings.size();

                for (int f = 0; f < partitionCount; f++) {
                    if (f == foldNum) {
View Full Code Here

     *
     * @param dao The DAO of the source file
     * @return a map of users to partition numbers. Users not in a partition will return -1.
     */
    protected Long2IntMap splitUsers(UserDAO dao) {
        Long2IntMap userMap = new Long2IntOpenHashMap();
        userMap.defaultReturnValue(-1);

        switch (method) {
        case PARTITION_USERS:
            partitionUsers(userMap, dao.getUserIds());
            break;
View Full Code Here

TOP

Related Classes of it.unimi.dsi.fastutil.longs.Long2IntMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.