List of usage examples for com.google.common.collect Table put
@Nullable V put(R rowKey, C columnKey, V value);
From source file:de.tudarmstadt.ukp.experiments.argumentation.sequence.significance.SignificanceMain.java
/** * Test significance between all methods in the folder and prints them as a CSV table * * @param mainFolder folder//w w w . ja v a 2 s. co m * @param folderResultPrefix prefix of folders to test, i.e. "cv_" * @throws IOException */ public static void compareMethods(File mainFolder, final String folderResultPrefix) throws IOException { File[] cvResults = mainFolder.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { return pathname.isDirectory() && pathname.getName().startsWith(folderResultPrefix); } }); Table<String, String, Boolean> table = TreeBasedTable.create(); for (int i = 0; i < cvResults.length; i++) { for (int j = 0; j < cvResults.length; j++) { if (i != j) { File one = cvResults[i]; File two = cvResults[j]; double pValue = TestSignificanceTwoFiles.compareId2OutcomeFiles( new File(one, TOKEN_LEVEL_PREDICTIONS_CSV), new File(two, TOKEN_LEVEL_PREDICTIONS_CSV), new OutcomeSuccessMapReaderSequenceTokenCSVImpl()); // order of methods does not matter List<String> methods = new ArrayList<>(); methods.add(one.getName()); methods.add(two.getName()); Collections.sort(methods); table.put(methods.get(0), methods.get(1), pValue < P_VALUE); // and make symmetric matrix table.put(methods.get(1), methods.get(0), pValue < P_VALUE); } } } System.out.println(tableToCsv(table)); }
From source file:com.gradleware.tooling.toolingmodel.repository.internal.DefaultOmniBuildInvocationsContainerBuilder.java
private static void collectAllTasksRecursively(GradleProject project, Table<String, Path, String> tasksWithDescription, Collection<String> publicTasks, boolean enforceAllTasksPublic) { for (GradleTask task : project.getTasks()) { // convert to OmniProjectTask to have the version-specific logic and default-values applied OmniProjectTask projectTask = DefaultOmniProjectTask.from(task, enforceAllTasksPublic); // 1) store the path since the task selectors keep all the paths of the tasks they select // 2) store the description first by task name and then by path // this allows to later fish out the description of the task whose name matches the selector name and // whose path is the smallest for the given task name (the first entry of the table column) // store null description as empty string to avoid that Guava chokes tasksWithDescription.put(projectTask.getName(), projectTask.getPath(), projectTask.getDescription() != null ? projectTask.getDescription() : NULL_STRING); // visible tasks are specified by Gradle as those that have a non-empty group if (projectTask.isPublic()) { publicTasks.add(task.getName()); }// w w w . ja v a 2s . c o m } for (GradleProject childProject : project.getChildren()) { collectAllTasksRecursively(childProject, tasksWithDescription, publicTasks, enforceAllTasksPublic); } }
From source file:org.opendaylight.groupbasedpolicy.util.ContractResolverUtils.java
static void selectContracts(Table<TenantId, ContractId, List<ConsumerContractMatch>> consumerMatches, Table<EgKey, EgKey, List<ContractMatch>> contractMatches, Tenant tenant) { // For each endpoint group, match consumer selectors // against contracts to get a set of matching consumer selectors Policy policy = tenant.getPolicy(); if (policy == null || policy.getEndpointGroup() == null) { return;// w ww . j a v a 2 s .c om } for (EndpointGroup group : policy.getEndpointGroup()) { List<ConsumerContractMatch> r = matchConsumerContracts(tenant, group); for (ConsumerContractMatch ccm : r) { List<ConsumerContractMatch> cms = consumerMatches.get(tenant.getId(), ccm.contract.getId()); if (cms == null) { cms = new ArrayList<>(); consumerMatches.put(tenant.getId(), ccm.contract.getId(), cms); } cms.add(ccm); } } // Match provider selectors, and check each match for a corresponding // consumer selector match. for (EndpointGroup group : policy.getEndpointGroup()) { List<ContractMatch> matches = matchProviderContracts(tenant, group, consumerMatches); for (ContractMatch cm : matches) { EgKey consumerKey = new EgKey(cm.consumerTenant.getId(), cm.consumer.getId()); EgKey providerKey = new EgKey(cm.providerTenant.getId(), cm.provider.getId()); List<ContractMatch> egPairMatches = contractMatches.get(consumerKey, providerKey); if (egPairMatches == null) { egPairMatches = new ArrayList<>(); contractMatches.put(consumerKey, providerKey, egPairMatches); } egPairMatches.add(cm); } } }
From source file:org.mousephenotype.dcc.exportlibrary.fullTraverser.FullTraverser.java
private void loadSubmissionTrackerIDs(Calendar date) { if (date == null) { logger.info("loading every submission by trackerID"); trackerIDs = this.hibernateManager.nativeQuery( "select distinct trackerID from SUBMISSION where trackerID >= 5867 order by trackerID"); } else {/* w ww . j a va 2s . co m*/ Table<String, Class, Object> parameters = HashBasedTable.create(); parameters.put("colonyID", Calendar.class, date); Map<String, org.hibernate.type.Type> scalars = ImmutableMap.<String, org.hibernate.type.Type>builder() .put("trackerID", LongType.INSTANCE).build(); trackerIDs = this.hibernateManager.nativeQuery( "select distinct trackerID from SUBMISSION submission order by trackerID where submission.submissionDate < :submissionDate", scalars, parameters); } }
From source file:com.przemo.conjunctions.Joiner.java
/** * Builds a joined table, taking the set of rows and array of columns to include * @param frows//from www . ja va2 s. c o m * @param columnJoinName * @param cl * @param tables * @param resultingColumns * @return */ protected Table buildJoinedTable(Set<Object> frows, String columnJoinName, Map cl, Table[] tables, String[] resultingColumns) { Table tr = HashBasedTable.create(); if (resultingColumns != null) { //create the tables based on a resulting rows set for (Object r : frows) { Table nt = HashBasedTable.create(); nt.put(r, columnJoinName, cl.get(r)); int ti = 0; for (Table ct : tables) { for (String col : resultingColumns) { if (ct.containsColumn(col) && !col.equals(columnJoinName)) { Object v = ct.get(r, col); if (v != null) { if (nt.get(r, col) != null) { col += "_" + ti; } nt.put(r, col, v); } } } ti++; } tr.putAll(nt); } } return tr; }
From source file:com.zxy.commons.poi.excel.ExcelUtils.java
/** * ?Excelsheet/*from w w w . j a v a 2 s .c o m*/ * * @param inputPath ???Excel * @return Excel? * @throws IOException IOException */ public static Map<String, Table<Integer, String, String>> readAll2table(String inputPath) throws IOException { Map<String, Table<Integer, String, String>> tables = Maps.newLinkedHashMap(); FileInputStream inputStream = null; HSSFWorkbook wb = null; try { inputStream = new FileInputStream(inputPath); BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream); // HSSFWorkbook POIFSFileSystem fs = new POIFSFileSystem(bufferedInputStream); wb = new HSSFWorkbook(fs); List<String> columnNames = Lists.newLinkedList(); for (int sheetIndex = 0; sheetIndex < wb.getNumberOfSheets(); sheetIndex++) { Table<Integer, String, String> table = TreeBasedTable.create(); HSSFSheet st = wb.getSheetAt(sheetIndex); String sheetName = st.getSheetName(); for (int rowIndex = 0; rowIndex <= st.getLastRowNum(); rowIndex++) { HSSFRow row = st.getRow(rowIndex); for (int columnIndex = 0; columnIndex < row.getLastCellNum(); columnIndex++) { HSSFCell cell = row.getCell(columnIndex); if (cell != null) { if (rowIndex == 0) { // columnNames.add(cell.getStringCellValue()); } else { String value = cell.getStringCellValue(); table.put(rowIndex, columnNames.get(columnIndex), value); } } } } tables.put(sheetName, table); } return tables; } finally { if (wb != null) { wb.close(); } if (inputStream != null) { inputStream.close(); } } }
From source file:com.android.tools.idea.uibuilder.property.NlProperties.java
private static void setUpSrcCompat(@NotNull Table<String, String, NlPropertyItem> properties, @NotNull AndroidFacet facet, @NotNull List<NlComponent> components, @NotNull GradleDependencyManager dependencyManager) { NlPropertyItem srcProperty = properties.get(ANDROID_URI, ATTR_SRC); if (srcProperty != null && shouldAddSrcCompat(facet, components, dependencyManager)) { AttributeDefinition srcDefinition = srcProperty.getDefinition(); assert srcDefinition != null; AttributeDefinition srcCompatDefinition = new AttributeDefinition(ATTR_SRC_COMPAT, null, srcDefinition.getFormats()); srcCompatDefinition.getParentStyleables().addAll(srcDefinition.getParentStyleables()); NlPropertyItem srcCompatProperty = new NlPropertyItem(components, AUTO_URI, srcCompatDefinition); properties.put(AUTO_URI, ATTR_SRC_COMPAT, srcCompatProperty); }/* w w w .j a v a 2 s . co m*/ }
From source file:es.usc.citius.composit.iserve.match.iServeSetMatchFunction.java
@Override public MatchTable<URI, LogicConceptMatchType> fullMatch(Set<URI> source, Set<URI> target) { Metrics.get().increment("iServeSetMatchFunction.fullMatch"); Table<URI, URI, MatchResult> result = this.matcher.match(source, target); Table<URI, URI, LogicConceptMatchType> transformed = HashBasedTable.create(); for (Table.Cell<URI, URI, MatchResult> cell : result.cellSet()) { transformed.put(cell.getRowKey(), cell.getColumnKey(), (LogicConceptMatchType) cell.getValue().getMatchType()); }/*from ww w. j a va 2 s.co m*/ return new MatchTable<URI, LogicConceptMatchType>(transformed); }
From source file:org.opendaylight.groupbasedpolicy.util.SubjectResolverUtils.java
private static Policy resolvePolicy(Tenant contractTenant, Contract contract, Policy merge, Table<EndpointConstraint, EndpointConstraint, List<Subject>> subjectMap) { Table<EndpointConstraint, EndpointConstraint, List<RuleGroup>> ruleMap = HashBasedTable.create(); if (merge != null) { ruleMap.putAll(merge.getRuleMap()); }// w ww. j av a 2 s . c o m for (Cell<EndpointConstraint, EndpointConstraint, List<Subject>> entry : subjectMap.cellSet()) { List<RuleGroup> rules = new ArrayList<>(); EndpointConstraint consEpConstraint = entry.getRowKey(); EndpointConstraint provEpConstraint = entry.getColumnKey(); List<RuleGroup> oldrules = ruleMap.get(consEpConstraint, provEpConstraint); if (oldrules != null) { rules.addAll(oldrules); } for (Subject s : entry.getValue()) { if (s.getRule() == null) continue; RuleGroup rg = new RuleGroup(s.getRule(), s.getOrder(), contractTenant, contract, s.getName()); rules.add(rg); } Collections.sort(rules); ruleMap.put(consEpConstraint, provEpConstraint, Collections.unmodifiableList(rules)); } return new Policy(ruleMap); }
From source file:org.sonar.server.measure.ws.ComponentTreeDataLoader.java
/** * Conditions for best value measure://w ww. j a va 2s.co m * <ul> * <li>component is a production file or test file</li> * <li>metric is optimized for best value</li> * </ul> */ private static void addBestValuesToMeasures(Table<String, MetricDto, Measure> measuresByComponentUuidAndMetric, List<ComponentDto> components, List<MetricDto> metrics) { List<MetricDtoWithBestValue> metricDtosWithBestValueMeasure = metrics.stream() .filter(MetricDtoFunctions.isOptimizedForBestValue()).map(new MetricDtoToMetricDtoWithBestValue()) .collect(MoreCollectors.toList(metrics.size())); if (metricDtosWithBestValueMeasure.isEmpty()) { return; } Stream<ComponentDto> componentsEligibleForBestValue = components.stream().filter(IsFileComponent.INSTANCE); componentsEligibleForBestValue.forEach(component -> { for (MetricDtoWithBestValue metricWithBestValue : metricDtosWithBestValueMeasure) { if (measuresByComponentUuidAndMetric.get(component.uuid(), metricWithBestValue.getMetric()) == null) { measuresByComponentUuidAndMetric.put(component.uuid(), metricWithBestValue.getMetric(), Measure.createFromMeasureDto(metricWithBestValue.getBestValue())); } } }); }