public static void main (String[] args)
	{
		try
		{
			FileInputStream fis   = new FileInputStream("recs.jobj");
			ObjectInputStream ois = new ObjectInputStream(fis);
			Object o 			  = ois.readObject();
			Hashtable<Integer, RecPair> recs = (Hashtable<Integer, RecPair>)o;
			ois.close();
			fis.close();
			
			fis   = new FileInputStream("idf.jobj");
			ois = new ObjectInputStream(fis);
			o 			  = ois.readObject();
			Hashtable<Integer, Double> idf = (Hashtable<Integer, Double>)o;
			ois.close();
			fis.close();
			
			Class.forName("com.mysql.jdbc.Driver");
			
			Connection 							conn = DriverManager.getConnection(MySqlConnection.url, MySqlConnection.user, MySqlConnection.password);
			Statement 							stmt = conn.createStatement();
			ResultSet 							  rs = null;
			FileReader 							  fr = new FileReader("data/users.csv");
			BufferedReader 						  br = new BufferedReader(fr);
			String 								line = null;
			
			while ((line = br.readLine()) != null)
			{
				rs = stmt.executeQuery("select distinct iid from records where uid="+line);
				ArrayList<Integer> ids = new ArrayList<Integer>();
				ArrayList<Double> values = new ArrayList<Double>();
				while (rs.next())
				{
					int iid = rs.getInt(1);
					RecPair rec = recs.get(iid);
					if(rec != null)
					{
						for (int i = 0; i < rec.getRids().size(); i++)
						{
							int index = ids.indexOf(rec.getRids().get(i));
							if(index != -1)
							{
								values.set(index, values.get(index) + rec.getValues().get(i)*idf.get(rec.getRids().get(i)));
							}
							else
							{
								ids.add(rec.getRids().get(i));
								values.add(rec.getValues().get(i)*idf.get(rec.getRids().get(i)));
							}
						}
					}
				}
				rs.close();
				sort(ids, values);
				System.out.print(line+"\t");
				for (int i = 0; i < ids.size() && i < MAXSIZE; i++)
				{
					if(i == 0)
					{
						System.out.print(ids.get(i));
					}
					else
					{
						System.out.print(","+ids.get(i));
					}
				}
				System.out.println();
			}
			br.close();
			fr.close();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}