List of usage examples for com.google.common.collect Table put
@Nullable V put(R rowKey, C columnKey, V value);
From source file:org.sonar.scanner.repository.DefaultProjectRepositoriesLoader.java
private static ProjectRepositories processStream(InputStream is, String projectKey) { try {//from w w w. ja v a 2 s . c om WsProjectResponse response = WsProjectResponse.parseFrom(is); Table<String, String, FileData> fileDataTable = HashBasedTable.create(); Table<String, String, String> settings = HashBasedTable.create(); Map<String, Settings> settingsByModule = response.getSettingsByModule(); for (Map.Entry<String, Settings> e1 : settingsByModule.entrySet()) { for (Map.Entry<String, String> e2 : e1.getValue().getSettings().entrySet()) { settings.put(e1.getKey(), e2.getKey(), e2.getValue()); } } Map<String, FileDataByPath> fileDataByModuleAndPath = response.getFileDataByModuleAndPath(); for (Map.Entry<String, FileDataByPath> e1 : fileDataByModuleAndPath.entrySet()) { for (Map.Entry<String, WsBatch.WsProjectResponse.FileData> e2 : e1.getValue().getFileDataByPath() .entrySet()) { FileData fd = new FileData(e2.getValue().getHash(), e2.getValue().getRevision()); fileDataTable.put(e1.getKey(), e2.getKey(), fd); } } return new ProjectRepositories(settings, fileDataTable, new Date(response.getLastAnalysisDate())); } catch (IOException e) { throw new IllegalStateException("Couldn't load project repository for " + projectKey, e); } finally { IOUtils.closeQuietly(is); } }
From source file:org.sonar.batch.repository.DefaultProjectRepositoriesLoader.java
private static ProjectRepositories processStream(InputStream is, String projectKey) { try {/*from w w w. j a va 2s . c o m*/ WsProjectResponse response = WsProjectResponse.parseFrom(is); Table<String, String, FileData> fileDataTable = HashBasedTable.create(); Table<String, String, String> settings = HashBasedTable.create(); Map<String, Settings> settingsByModule = response.getSettingsByModule(); for (Map.Entry<String, Settings> e1 : settingsByModule.entrySet()) { for (Map.Entry<String, String> e2 : e1.getValue().getSettings().entrySet()) { settings.put(e1.getKey(), e2.getKey(), e2.getValue()); } } Map<String, FileDataByPath> fileDataByModuleAndPath = response.getFileDataByModuleAndPath(); for (Map.Entry<String, FileDataByPath> e1 : fileDataByModuleAndPath.entrySet()) { for (Map.Entry<String, org.sonarqube.ws.WsBatch.WsProjectResponse.FileData> e2 : e1.getValue() .getFileDataByPath().entrySet()) { FileData fd = new FileData(e2.getValue().getHash(), e2.getValue().getRevision()); fileDataTable.put(e1.getKey(), e2.getKey(), fd); } } return new ProjectRepositories(settings, fileDataTable, new Date(response.getLastAnalysisDate())); } catch (IOException e) { throw new IllegalStateException("Couldn't load project repository for " + projectKey, e); } finally { IOUtils.closeQuietly(is); } }
From source file:org.jpmml.evaluator.InlineTableUtil.java
static public Table<Integer, String, String> parse(InlineTable inlineTable) { Table<Integer, String, String> result = HashBasedTable.create(); Integer rowKey = 1;/*from www. ja v a2s . c o m*/ List<Row> rows = inlineTable.getRows(); for (Row row : rows) { List<Object> cells = row.getContent(); for (Object cell : cells) { if (cell instanceof Element) { Element element = (Element) cell; result.put(rowKey, element.getTagName(), element.getTextContent()); } } rowKey += 1; } return result; }
From source file:org.sonar.db.version.v52.MoveProjectProfileAssociation.java
private static Table<String, String, String> getProfileKeysByLanguageThenName(final Context context) throws SQLException { final Table<String, String, String> profilesByLanguageAndName = HashBasedTable.create(); Select selectProfiles = context.prepareSelect("SELECT kee, name, language FROM rules_profiles"); try {// w w w. j a v a 2s .c o m selectProfiles.list(new RowReader<Void>() { @Override public Void read(Row row) throws SQLException { profilesByLanguageAndName.put(row.getString(3), row.getString(2), row.getString(1)); return null; } }); } finally { selectProfiles.close(); } return profilesByLanguageAndName; }
From source file:de.tudarmstadt.ukp.dkpro.c4corpus.hadoop.statistics.StatisticsTableCreator.java
public static Table<String, String, Long> loadTable(InputStream stream) throws IOException { Table<String, String, Long> result = TreeBasedTable.create(); LineIterator lineIterator = IOUtils.lineIterator(stream, "utf-8"); while (lineIterator.hasNext()) { String line = lineIterator.next(); System.out.println(line); String[] split = line.split("\t"); String language = split[0]; String license = split[1]; Long documents = Long.valueOf(split[2]); Long tokens = Long.valueOf(split[3]); result.put(language, "docs " + license, documents); result.put(language, "tokens " + license, tokens); }/* ww w. jav a 2 s . c om*/ return result; }
From source file:eu.itesla_project.commons.io.MathUtil.java
public static Table<String, String, Float> parseMatrix(Reader reader) throws IOException { Table<String, String, Float> table = HashBasedTable.create(); try (ICsvListReader csvReader = new CsvListReader(reader, CsvPreference.STANDARD_PREFERENCE)) { List<String> columnHeaders = csvReader.read(); List<String> row; while ((row = csvReader.read()) != null) { String rowHeader = row.get(0); for (int i = 1; i < row.size(); i++) { String columnHeader = columnHeaders.get(i); String value = row.get(i); table.put(rowHeader, columnHeader, value == null ? Float.NaN : Float.valueOf(value)); }//from w w w. ja v a 2 s .c o m } } return table; }
From source file:com.thinkbiganalytics.nifi.feedmgr.NifiEnvironmentProperties.java
/** * Returns a collection of the Service Name along with the Map of nifi Properties stripping the ENVIRONMENT_PROPERTY_SERVICE_PREFIX from the properties * * @param envProperties the map of environment (.properties) properties * @return the table of nifi ready properties *///from ww w. ja v a 2s . c o m public static Table<String, String, String> getEnvironmentControllerServiceProperties( Map<String, String> envProperties) { Table<String, String, String> allProps = HashBasedTable.create(); if (envProperties != null && !envProperties.isEmpty()) { for (Map.Entry<String, String> entry : envProperties.entrySet()) { if (entry.getKey().startsWith(getPrefix())) { String key = environmentPropertyToControllerServiceProperty(entry.getKey()); String serviceName = serviceNameForEnvironmentProperty(entry.getKey()); allProps.put(serviceName, key, entry.getValue()); } } } return allProps; }
From source file:org.splevo.jamopp.diffing.postprocessor.DifferenceStatisticLogger.java
/** * Write a log file about matched and unmatched resources. * * @param comparison//from w w w . j a v a 2 s. c om * model * @param logFilePath * the filename */ @SuppressWarnings("rawtypes") private static void logDiffingStatistics(Comparison comparison, String logFilePath) { Table<Class, DifferenceKind, Integer> statistics = HashBasedTable.create(); for (Diff diff : comparison.getDifferences()) { Integer current = statistics.get(diff.getClass(), diff.getKind()); if (current == null) { current = 0; } current++; statistics.put(diff.getClass(), diff.getKind(), current); } BufferedWriter writer = null; try { File logFile = new File(logFilePath); FileUtils.forceMkdir(logFile.getParentFile()); writer = new BufferedWriter(new FileWriter(logFile)); writer.write("Type , Kind , Count \n"); for (Class rowKey : statistics.rowKeySet()) { Map<DifferenceKind, Integer> row = statistics.row(rowKey); for (DifferenceKind kind : row.keySet()) { writer.write(rowKey.getSimpleName() + "," + kind.getLiteral() + "," + row.get(kind) + "\n"); } } } catch (IOException e) { e.printStackTrace(); } finally { if (writer != null) { try { writer.close(); } catch (IOException e) { e.printStackTrace(); } } } }
From source file:com.zxy.commons.poi.excel.ExcelUtils.java
/** * multimap?table/* w w w . j a v a2 s.c o m*/ * * @param multimap multimap * @return table */ public static Table<Integer, String, String> map2table(Multimap<String, String> multimap) { Table<Integer, String, String> table = TreeBasedTable.create(); Set<String> cloumns = multimap.keySet(); for (String cloumn : cloumns) { Collection<String> values = multimap.get(cloumn); int rowIndex = 1; for (String value : values) { table.put(rowIndex, cloumn, value); rowIndex++; } } return table; }
From source file:com.google.gerrit.server.ReviewerSet.java
public static ReviewerSet fromApprovals(Iterable<PatchSetApproval> approvals) { PatchSetApproval first = null;// www .jav a2 s . com Table<ReviewerStateInternal, Account.Id, Timestamp> reviewers = HashBasedTable.create(); for (PatchSetApproval psa : approvals) { if (first == null) { first = psa; } else { checkArgument( first.getKey().getParentKey().getParentKey() .equals(psa.getKey().getParentKey().getParentKey()), "multiple change IDs: %s, %s", first.getKey(), psa.getKey()); } Account.Id id = psa.getAccountId(); reviewers.put(REVIEWER, id, psa.getGranted()); if (psa.getValue() != 0) { reviewers.remove(CC, id); } } return new ReviewerSet(reviewers); }