public void putPastAndRank(String[] nameArray, int[] maxCount,
			StringBuilder sb) throws IOException {
		long time = System.currentTimeMillis();
		DatastoreService datastore = DatastoreServiceFactory
				.getDatastoreService();
		Entity past = null;
		try {
			past = datastore
					.get(KeyFactory.createKey("past_string", "onlyOne"));
		} catch (EntityNotFoundException e) {
		}
		past.setProperty("flag", false);
		past.setProperty("pflag", false);
		boolean putflag = false;
		// nameArray[1] = nameArray[1].split("[　_＿]")[0];
		// nameArray[2] = nameArray[2].split("[　_＿]")[0];
		sb.append("<!-- ppsetstart: "
				+ ((System.currentTimeMillis() - time) * -1) + "-->");
		String current_past_string = getPastString();
		String rank_update = (String) past.getProperty("rank_update");
		String pair_update = (String) past.getProperty("pair_update");
		Pattern p1 = Pattern.compile("^(.*?)(," + Pattern.quote(nameArray[1])
				+ "," + Pattern.quote(nameArray[2]) + ","
				+ "[0-9]+,[0-9]+)(.*)$");
		Pattern p2 = Pattern.compile("," + Pattern.quote(nameArray[1]) + ","
				+ Pattern.quote(nameArray[2]) + "," + "[0-9]+,[0-9]+");
		if (!p2.matcher(current_past_string).find()) {
			String past_update = getPastUpdate();
			past_update = "," + nameArray[1] + "＆" + nameArray[2] + past_update;
			String[] updateSplit = past_update.split(",");
			int i = 0;
			String updateRebuild = "";
			for (String sp : updateSplit) {
				if (sp.isEmpty())
					continue;
				updateRebuild += "," + sp;
				i++;
				if (i > 20)
					break;
			}
			past_update = updateRebuild;
			past.setProperty("past_update", past_update);
			cache.put("past_update", past_update);
			putflag = true;
		}
		Matcher m;
		while((m = p1.matcher(current_past_string)).find()){
			current_past_string = m.replaceAll("$1$3");
			m = p1.matcher(current_past_string);
		}
		String past_string = "," + nameArray[1] + "," + nameArray[2] + ","
				+ maxCount[0] + "," + maxCount[1]
				+ current_past_string;
		past.setProperty("text", new Text(past_string));
		cache.put("past_string", past_string);

/*		Pattern p_1 = Pattern.compile("^(.*?)([^0-9]+,)?("
				+ Pattern.quote(nameArray[1]) + ",)([^0-9]+,)?([0-9]+)(.*)$");
		Pattern p_2 = Pattern.compile("^(.*?)([^0-9]+,)?("
				+ Pattern.quote(nameArray[2]) + ",)([^0-9]+,)?([0-9]+)(.*)$");
		sb.append("<!-- pprankstart: "
				+ ((System.currentTimeMillis() - time) * -1) + "-->");
		if (maxCount[0] != 0 && WikiUtil.getMF(nameArray[1]) != 100
				&& WikiUtil.getMF(nameArray[2]) != 100) {
			Text rank_text = (Text) past.getProperty("rank");
			String oldrank_1 = "0", oldrank_2 = "0";
			String oldpair_1 = "", oldpair_2 = "";
			Matcher m_1 = p_1.matcher(rank_text.getValue());
			Matcher m_2 = p_2.matcher(rank_text.getValue());
			if (m_1.find()) {
				oldrank_1 = m_1.group(5);
				oldpair_1 = m_1.replaceAll("$2$4").replaceAll(",", "");
			}
			if (m_2.find()) {
				oldrank_2 = m_2.group(5);
				oldpair_2 = m_2.replaceAll("$2$4").replaceAll(",", "");
			}
			if (oldrank_1.equals("0") && oldrank_2.equals("0")) {
				sb.append("<script type=\"text/javascript\">window.alert(' -- 総合ランキング --\\n"
						+ nameArray[1]
						+ "＆"
						+ nameArray[2]
						+ "\\n\\nこのペアが新しくランクインしました。');</script>");
				past.setProperty("flag", true);
			} else if (maxCount[0] > Integer.parseInt(oldrank_1)
					&& maxCount[0] > Integer.parseInt(oldrank_2)
					&& !oldpair_2.equals(nameArray[1])
					&& !oldpair_1.equals(nameArray[2])) {
				sb.append("<script type=\"text/javascript\">window.alert(' -- 総合ランキング --\\n"
						+ nameArray[1]
						+ "＆"
						+ nameArray[2]
						+ "\\n\\nこのペアが新しくランクインしました。"
						+ "\\nこのペアよりも順位が下のランキングに変動があり、"
						+ "\\n特に、以下の人物はペアが組み直しになります。\\n\\n"
						+ oldpair_1
						+ "　"
						+ oldpair_2 + "');</script>");
				past.setProperty("flag", true);
			}
		}
		sb.append("<!-- pppairstart: "
				+ ((System.currentTimeMillis() - time) * -1) + "-->");
		if (maxCount[0] != 0
				&& WikiUtil.getMF(nameArray[1]) * WikiUtil.getMF(nameArray[2]) == -1) {
			Text pair_text = (Text) past.getProperty("pair");
			String oldrank_1 = "0";
			String oldrank_2 = "0";
			String oldpair_1 = "";
			String oldpair_2 = "";
			Matcher m_1 = p_1.matcher(pair_text.getValue());
			Matcher m_2 = p_2.matcher(pair_text.getValue());
			if (m_1.find()) {
				oldrank_1 = m_1.group(5);
				oldpair_1 = m_1.replaceAll("$2$4").replaceAll(",", "");
			}
			if (m_2.find()) {
				oldrank_2 = m_2.group(5);
				oldpair_2 = m_2.replaceAll("$2$4").replaceAll(",", "");
			}
			if (oldrank_1.equals("0") && oldrank_2.equals("0")) {
				sb.append("<script type=\"text/javascript\">window.alert(' -- 男女ランキング --\\n"
						+ nameArray[1]
						+ "＆"
						+ nameArray[2]
						+ "\\n\\nこのペアが新しくランクインしました。');</script>");
				past.setProperty("pflag", true);
			} else if (maxCount[0] > Integer.parseInt(oldrank_1)
					&& maxCount[0] > Integer.parseInt(oldrank_2)
					&& !oldpair_2.equals(nameArray[1])
					&& !oldpair_1.equals(nameArray[2])) {
				sb.append("<script type=\"text/javascript\">window.alert(' -- 男女ランキング --\\n"
						+ nameArray[1]
						+ "＆"
						+ nameArray[2]
						+ "\\n\\nこのペアが新しくランクインしました。"
						+ "\\nこのペアよりも順位が下のランキングに変動があり、"
						+ "\\n特に、以下の人物はペアが組み直しになります。\\n\\n"
						+ oldpair_1
						+ "　"
						+ oldpair_2 + "');</script>");
				past.setProperty("pflag", true);
			}
		}
		sb.append("<!-- ppqueuestart: "
				+ ((System.currentTimeMillis() - time) * -1) + "-->");

		if ((Boolean) past.getProperty("flag")) {
			rank_update = "," + nameArray[1] + "＆" + nameArray[2] + rank_update;
			String[] update_box = rank_update.split(",");
			int i = 0;
			String str = "";
			for (String b : update_box) {
				if (b.isEmpty())
					continue;
				str += "," + b;
				i++;
				if (i > 20)
					break;
			}
			past.setProperty("rank_update", str);
			putflag = true;
			Queue queue = QueueFactory.getDefaultQueue();
			queue.add(Builder.withUrl("/ranking?c=this").method(Method.GET));
		}
		if ((Boolean) past.getProperty("pflag")) {
			pair_update = "," + nameArray[1] + "＆" + nameArray[2] + pair_update;
			String[] update_box = pair_update.split(",");
			int i = 0;
			String str = "";
			for (String b : update_box) {
				if (b.isEmpty())
					continue;
				str += "," + b;
				i++;
				if (i > 20)
					break;
			}
			past.setProperty("pair_update", str);
			putflag = true;
			Queue queue = QueueFactory.getDefaultQueue();
			queue.add(Builder.withUrl("/pair").method(Method.GET));
		}
		sb.append("<!-- ppdostart: "
				+ ((System.currentTimeMillis() - time) * -1) + "-->");*/
		try {
			if (putflag == true)
				//if(false)
				datastore.put(past);
		} catch (Throwable t) {
		}
		sb.append("<!-- ppend: " + ((System.currentTimeMillis() - time) * -1)
				+ "-->");
	
	}