本文整理汇总了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;
}
示例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;
}