public static void rating_user(ArrayList<QueryPair> QuerySet, ArrayList<ArrayList<DataTuple>> UserFirstRating){
		ArrayList <Similarity> SimList = new ArrayList <Similarity>();
		
		for(QueryPair CurQuery : QuerySet){
			//get requested user info
			ArrayList<DataTuple> QueryUserInfo = new ArrayList<DataTuple>();
			SimList = new ArrayList <Similarity>();

			for(ArrayList<DataTuple> usr : UserFirstRating){		
				if(usr.get(0).getUser() == CurQuery.getUser()){
					for(DataTuple tmp : usr){
						QueryUserInfo.add(tmp);
					}
					break;
				}
			}
//			for(DataTuple tmp : QueryUserInfo)
//				System.out.println(tmp.getUser()+"  "+tmp.getMovie()+"  "+tmp.getRating());
			
			int zeroflag = 0;
			//compute similarity between user in query and every other query
			for(ArrayList<DataTuple> CompareUsr : UserFirstRating){
				if(CompareUsr.get(0).getUser() != QueryUserInfo.get(0).getUser()){
					Similarity CurSmiliar = new Similarity();

					int existflag = 0;
					for(DataTuple tmp : CompareUsr){
						if(tmp.getMovie() == CurQuery.getMovie()){
							existflag = 1;
							CurSmiliar.setItem2Score(tmp.getRating());
							break;
						}
					}
					
					if(existflag == 0)
						continue;
					
					int p1 = 0;
					int p2 = 0;
					while((p1 < QueryUserInfo.size()) && (p2 < CompareUsr.size())){
						
						if(QueryUserInfo.get(p1).getMovie() == CompareUsr.get(p2).getMovie()){
							CurSmiliar.setItem1(QueryUserInfo.get(p1).getUser());
							CurSmiliar.setItem2(CompareUsr.get(p2).getUser());
							CurSmiliar.setSimilar(CurSmiliar.getSimilar() + QueryUserInfo.get(p1).getRating() * CompareUsr.get(p2).getRating());
							p1++;
							p2++;
							continue;
						}
						
						if(QueryUserInfo.get(p1).getMovie() < CompareUsr.get(p2).getMovie()){
							p1++;
							continue;
						}
						
						if(QueryUserInfo.get(p1).getMovie() > CompareUsr.get(p2).getMovie()){
							p2++;
							continue;
						}
					}
					if (CurSmiliar.getSimilar() != 0.0){
						zeroflag = 1;
					}
					SimList.add(CurSmiliar);
				}
			}
			SimList.trimToSize();
			
			Rankcomparator comp = new Rankcomparator();
			Collections.sort(SimList, comp);
			
//			for(int i = 0; i < Math.min(K, SimList.size()); i++)
//				System.out.println(SimList.get(i).getItem1()+"  "+SimList.get(i).getItem2()+"  "+SimList.get(i).getSimilar() +"  "+SimList.get(i).getItem2Score());
			
			//predict query score with user neighbors' score
			double totalscore = 0;
			double totalweight = 0;
			for(int i = 0; i < Math.min(K, SimList.size()); i++){
				totalweight += SimList.get(i).getSimilar();
				
				if(zeroflag == 0){
					totalscore += SimList.get(i).getItem2Score();
				}
				else{
					totalscore += SimList.get(i).getSimilar() * SimList.get(i).getItem2Score();
				}
			}
			if(zeroflag == 0){
				CurQuery.setRating((double) totalscore / (double) Math.min(K, SimList.size()));
			}
			else{
				CurQuery.setRating(totalscore / totalweight);
			}
		}
	}