當前位置: 首頁>>代碼示例>>Java>>正文


Java Table.size方法代碼示例

本文整理匯總了Java中com.google.common.collect.Table.size方法的典型用法代碼示例。如果您正苦於以下問題:Java Table.size方法的具體用法?Java Table.size怎麽用?Java Table.size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.collect.Table的用法示例。


在下文中一共展示了Table.size方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: calHangZhouIndexer

import com.google.common.collect.Table; //導入方法依賴的package包/類
private JSONObject calHangZhouIndexer(Table<Integer,Double,Integer> detail){

        double totalRemainHouseCount=0,totalPriceSum=0,totalDealCount=0;

        for(Table.Cell<Integer,Double,Integer> cell : detail.cellSet()){
            totalRemainHouseCount += cell.getRowKey();
            totalPriceSum += cell.getColumnKey();
            totalDealCount += cell.getValue();
        }

        totalPriceSum/=detail.size();


        double index = 0;
        if(totalRemainHouseCount != 0){
            index = totalPriceSum * 1000 * totalDealCount / totalRemainHouseCount;
        }

        ESOP.writeToES("log/daily_index_detail_es", String.format("[杭州市][%s]剩餘庫存:%f,銷售均價總和:%f,銷售數量:%f,指數:%f",
                LocalDateTime.now().toString(),totalRemainHouseCount,totalPriceSum,totalDealCount,index));

        JSONObject jsonObject = new JSONObject();
        jsonObject.put("district","杭州市");
        jsonObject.put("index",index);
        return jsonObject;
    }
 
開發者ID:deanjin,項目名稱:houseHunter,代碼行數:27,代碼來源:indexCalculator.java

示例2: readRatingDataTest

import com.google.common.collect.Table; //導入方法依賴的package包/類
/**
 * Read data from the data file. Note that we didn't take care of the
 * duplicated lines.
 * 
 * Each line is: user_id item_id publisher_id 1, user_id item_id
 * publisher_id 0, ...
 */
public void readRatingDataTest(String path) throws Exception {
	System.out.println("Loading rating from " + path);
	// Table {row-id, col-id, rate}
	Table<Integer, Integer, Float> dataTable = HashBasedTable.create();

	// Map {col-id, multiple row-id}: used to fast build rate matrix
	Multimap<Integer, Integer> colMap = HashMultimap.create();

	BufferedReader br = FileUtil.createReader(path);
	String line = null;
	while ((line = br.readLine()) != null) {
		String[] tuples = line.trim().split(",");

		for (String data : tuples) {
			String[] tuple = data.trim().split(" ");
			String user = tuple[0].trim();
			String item = tuple[1].trim();
			Float rate = Float.valueOf(tuple[2].trim());
			if (rate == 0) {
				rate = -1.0f;
			}

			int row = getId(userIds, user);
			int col = itemIds.containsKey(item) ? itemIds.get(item) : itemIds.size();

			itemIds.put(item, col);
			dataTable.put(row, col, rate);
			colMap.put(col, row);
		}
	}
	br.close();

	numRates = dataTable.size();
	int numRows = numUsers(), numCols = numItems();

	Logs.debug("Dataset: {Users, {}} = {{}, {}, {}, {}}", ("Items, Ratings"), numRows, numCols, numRates);

	// build rating matrix
	ratingMatrix = new SparseMatrix(numRows, numCols, dataTable, colMap);
	dataTable = null;
}
 
開發者ID:kite1988,項目名稱:famf,代碼行數:49,代碼來源:DataDAO.java


注:本文中的com.google.common.collect.Table.size方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。