List of usage examples for java.util LinkedHashMap keySet
public Set<K> keySet()
From source file:org.apache.hadoop.hive.ql.exec.MapredLocalTask.java
public int executeFromChildJVM(DriverContext driverContext) { // check the local work if (work == null) { return -1; }//from w ww . j a v a2 s. c o m memoryMXBean = ManagementFactory.getMemoryMXBean(); long startTime = System.currentTimeMillis(); console.printInfo( Utilities.now() + "\tStarting to launch local task to process map join;\tmaximum memory = " + memoryMXBean.getHeapMemoryUsage().getMax()); fetchOperators = new HashMap<String, FetchOperator>(); Map<FetchOperator, JobConf> fetchOpJobConfMap = new HashMap<FetchOperator, JobConf>(); execContext.setJc(job); // set the local work, so all the operator can get this context execContext.setLocalWork(work); boolean inputFileChangeSenstive = work.getInputFileChangeSensitive(); try { initializeOperators(fetchOpJobConfMap); // for each big table's bucket, call the start forward if (inputFileChangeSenstive) { for (LinkedHashMap<String, ArrayList<String>> bigTableBucketFiles : work.getBucketMapjoinContext() .getAliasBucketFileNameMapping().values()) { for (String bigTableBucket : bigTableBucketFiles.keySet()) { startForward(inputFileChangeSenstive, bigTableBucket); } } } else { startForward(inputFileChangeSenstive, null); } long currentTime = System.currentTimeMillis(); long elapsed = currentTime - startTime; console.printInfo( Utilities.now() + "\tEnd of local task; Time Taken: " + Utilities.showTime(elapsed) + " sec."); } catch (Throwable e) { if (e instanceof OutOfMemoryError || (e instanceof HiveException && e.getMessage().equals("RunOutOfMeomoryUsage"))) { // Don't create a new object if we are already out of memory return 3; } else { l4j.error("Hive Runtime Error: Map local work failed"); e.printStackTrace(); return 2; } } return 0; }
From source file:org.openmeetings.servlet.outputhandler.Install.java
private Template getStep2Template(HttpServletRequest httpServletRequest, Context ctx, String lang) throws Exception { String header = httpServletRequest.getHeader("Accept-Language"); String[] headerList = header != null ? header.split(",") : new String[0]; String headCode = headerList.length > 0 ? headerList[0] : "en"; String filePath = getServletContext().getRealPath("/") + ImportInitvalues.languageFolderName; LinkedHashMap<Integer, LinkedHashMap<String, Object>> allLanguagesAll = getImportInitvalues() .getLanguageFiles(filePath); LinkedHashMap<Integer, String> allLanguages = new LinkedHashMap<Integer, String>(); //first iteration for preferred language Integer prefKey = -1;/*from w w w .j av a 2 s . co m*/ String prefName = null; for (Integer key : allLanguagesAll.keySet()) { String langName = (String) allLanguagesAll.get(key).get("name"); String langCode = (String) allLanguagesAll.get(key).get("code"); if (langCode != null) { if (headCode.equals(langCode)) { prefKey = key; prefName = langName; break; } else if (headCode.startsWith(langCode)) { prefKey = key; prefName = langName; } } } allLanguages.put(prefKey, prefName); for (Integer key : allLanguagesAll.keySet()) { String langName = (String) allLanguagesAll.get(key).get("name"); if (key != prefKey) { allLanguages.put(key, langName); } } LinkedHashMap<String, String> allFonts = new LinkedHashMap<String, String>(); allFonts.put("TimesNewRoman", "TimesNewRoman"); allFonts.put("Verdana", "Verdana"); allFonts.put("Arial", "Arial"); List<OmTimeZone> omTimeZoneList = getImportInitvalues().getTimeZones(filePath); Template tpl = super.getTemplate("install_step1_" + lang + ".vm"); ctx.put("allLanguages", allLanguages); ctx.put("allFonts", allFonts); ctx.put("allTimeZones", ImportHelper.getAllTimeZones(omTimeZoneList)); StringWriter writer = new StringWriter(); tpl.merge(ctx, writer); return tpl; }
From source file:com.aliyun.odps.graph.local.LocalGraphJobRunner.java
private void processInput(TableInfo tableInfo) throws IOException, OdpsException { LOG.info("Processing input: " + tableInfo); String projName = tableInfo.getProjectName(); if (projName == null) { projName = SessionState.get().getOdps().getDefaultProject(); }/*from w w w. ja va 2 s.co m*/ String tblName = tableInfo.getTableName(); String[] readCols = tableInfo.getCols(); // ?MR?? LinkedHashMap<String, String> expectPartsHashMap = tableInfo.getPartSpec(); PartitionSpec expectParts = null; if (expectPartsHashMap != null && expectPartsHashMap.size() > 0) { StringBuffer sb = new StringBuffer(); for (String key : expectPartsHashMap.keySet()) { if (sb.length() > 0) { sb.append(","); } sb.append(key + "=" + expectPartsHashMap.get(key)); } expectParts = new PartitionSpec(sb.toString()); } // ?Table Scheme??? if (!wareHouse.existsTable(projName, tblName) || wareHouse.getDownloadMode() == DownloadMode.ALWAYS) { DownloadUtils.downloadTableSchemeAndData(odps, tableInfo, wareHouse.getLimitDownloadRecordCount(), wareHouse.getInputColumnSeperator()); if (!wareHouse.existsTable(projName, tblName)) { throw new OdpsException("download table from remote host failure"); } } // ////warehouse _scheme_????//// TableMeta whTblMeta = wareHouse.getTableMeta(projName, tblName); Column[] whReadFields = LocalRunUtils.getInputTableFields(whTblMeta, readCols); List<PartitionSpec> whParts = wareHouse.getPartitions(projName, tblName); // ////////////////////// if (whParts.size() > 0) { // partitioned table for (PartitionSpec partSpec : whParts) { // ? if (!match(expectParts, partSpec)) { continue; } File whSrcDir = wareHouse.getPartitionDir(whTblMeta.getProjName(), whTblMeta.getTableName(), partSpec); // add input split only when src dir has data file if (LocalRunUtils.listDataFiles(whSrcDir).size() > 0) { // ??warehouse File tempDataDir = jobDirecotry.getInputDir( wareHouse.getRelativePath(whTblMeta.getProjName(), whTblMeta.getTableName(), partSpec)); File tempSchemeDir = jobDirecotry.getInputDir( wareHouse.getRelativePath(whTblMeta.getProjName(), whTblMeta.getTableName(), null)); wareHouse.copyTable(whTblMeta.getProjName(), whTblMeta.getTableName(), partSpec, readCols, tempSchemeDir, wareHouse.getLimitDownloadRecordCount(), wareHouse.getInputColumnSeperator()); for (File file : LocalRunUtils.listDataFiles(tempDataDir)) { inputs.add(new InputSplit(file, whReadFields, 0L, file.length(), tableInfo)); } } } } else { // not partitioned table if (tableInfo.getPartSpec() != null && tableInfo.getPartSpec().size() > 0) { throw new IOException(ExceptionCode.ODPS_0720121 + "table " + projName + "." + tblName + " is not partitioned table"); } File whSrcDir = wareHouse.getTableDir(whTblMeta.getProjName(), whTblMeta.getTableName()); if (LocalRunUtils.listDataFiles(whSrcDir).size() > 0) { // ??warehouse File tempDataDir = jobDirecotry.getInputDir( wareHouse.getRelativePath(whTblMeta.getProjName(), whTblMeta.getTableName(), null)); File tempSchemeDir = tempDataDir; wareHouse.copyTable(whTblMeta.getProjName(), whTblMeta.getTableName(), null, readCols, tempSchemeDir, wareHouse.getLimitDownloadRecordCount(), wareHouse.getInputColumnSeperator()); for (File file : LocalRunUtils.listDataFiles(tempDataDir)) { inputs.add(new InputSplit(file, whReadFields, 0L, file.length(), tableInfo)); } } } }
From source file:com.hp.alm.ali.idea.model.HorizonStrategy.java
@Override public EntityQuery preProcess(EntityQuery query) { EntityQuery clone = super.preProcess(query); if (!clone.getColumns().isEmpty()) { if ("release-backlog-item".equals(query.getEntityType())) { clone.addColumn("entity-type", 1); clone.addColumn("entity-id", 1); clone.addColumn("blocked", 1); } else if ("defect".equals(query.getEntityType()) || "requirement".equals(query.getEntityType())) { clone.addColumn("release-backlog-item.id", 1); clone.addColumn("release-backlog-item.blocked", 1); LinkedHashMap<String, SortOrder> order = clone.getOrder(); if (containsAny(order.keySet(), orderMap.keySet())) { remapOrder(order, orderMap); clone.setOrder(order);/*w ww . ja v a2 s .c o m*/ } } else if ("project-task".equals(query.getEntityType())) { clone.addColumn("release-backlog-item-id", 1); } // workspace support: add workspace condition and retrieve field if ("defect".equals(query.getEntityType()) || "requirement".equals(query.getEntityType()) || "release-backlog-item".equals(query.getEntityType()) || "build-type".equals(query.getEntityType()) || "release".equals(query.getEntityType())) { clone.addColumn("product-group-id", 1); try { Integer.valueOf(clone.getValue("id")); } catch (NumberFormatException e) { // unless query is made against particular item, add workspace condition clone.setValue("product-group-id", String.valueOf(workspaceConfiguration.getWorkspaceId())); clone.setPropertyResolved("product-group-id", true); } } // until build instances support workspaces we need to use cross-filter if ("build-instance".equals(query.getEntityType())) { try { Integer.valueOf(clone.getValue("id")); } catch (NumberFormatException e) { // unless query is made against particular item, add workspace condition clone.setValue("build-type.product-group-id", String.valueOf(workspaceConfiguration.getWorkspaceId())); clone.setPropertyResolved("build-type.product-group-id", true); } } } return clone; }
From source file:com.hp.alm.ali.idea.model.HorizonStrategy.java
private void remapOrder(LinkedHashMap<String, SortOrder> order, Map<String, String> orderMap) { ArrayList<String> list = new ArrayList<String>(order.keySet()); for (String key : list) { SortOrder value = order.remove(key); String newKey = orderMap.get(key); if (newKey != null) { order.put(newKey, value);/*from w w w .jav a 2s .co m*/ } else { order.put(key, value); } } }
From source file:org.fao.fenix.wds.web.rest.crowdprices.CrowdPricesDataRESTService.java
private String createGeoJsonDisabled(List<List<String>> table) { String s = "{ \"type\":\"FeatureCollection\",\"features\":["; int i = 0;/*from ww w .ja va 2 s . c o m*/ LinkedHashMap<String, List<List<String>>> markets = getCrowdPricesPoints(table); for (String marketname : markets.keySet()) { String popupcontent = "<b>" + marketname + "</b><br> No available data for that market in the current selection"; String lat = ""; String lon = ""; for (List<String> row : markets.get(marketname)) { lon = row.get(1); lat = row.get(2); } // System.out.println("popup: " + popupcontent); s += "{\"type\":\"Feature\",\"properties\":{\"iconurl\":\"images/marker-icon-disabled.png\"," + "\"name\":\"Countrys\"," + "\"popupContent\":\"" + popupcontent + " \"},\"geometry\":{\"type\":\"Point\",\"coordinates\":[" + lon + "," + lat + "]}}"; if (i < markets.size() - 1) { s += ","; } i++; } s += "]}"; return s; }
From source file:de.ingrid.importer.udk.strategy.v1.IDCStrategy1_0_4.java
protected void updateSysList() throws Exception { if (log.isInfoEnabled()) { log.info("Updating sys_list..."); }// w w w . j a va 2 s.c o m // --------------------------- int lstId = 6100; if (log.isInfoEnabled()) { log.info("Updating syslist " + lstId + " (INSPIRE Themen fr Verschlagwortung)..."); } // clean up, to guarantee no old values ! sqlStr = "DELETE FROM sys_list where lst_id = " + lstId; jdbc.executeUpdate(sqlStr); // german syslist LinkedHashMap<Integer, String> newSyslist6100_de = UtilsInspireThemes.inspireThemes_de; // english syslist LinkedHashMap<Integer, String> newSyslist6100_en = UtilsInspireThemes.inspireThemes_en; Iterator<Integer> itr = newSyslist6100_de.keySet().iterator(); while (itr.hasNext()) { int key = itr.next(); // german version jdbc.executeUpdate( "INSERT INTO sys_list (id, lst_id, entry_id, lang_id, name, maintainable, is_default) VALUES (" + getNextId() + ", " + lstId + ", " + key + ", 'de', '" + newSyslist6100_de.get(key) + "', 0, 'N')"); // english version jdbc.executeUpdate( "INSERT INTO sys_list (id, lst_id, entry_id, lang_id, name, maintainable, is_default) VALUES (" + getNextId() + ", " + lstId + ", " + key + ", 'en', '" + newSyslist6100_en.get(key) + "', 0, 'N')"); } // --------------------------- lstId = 527; if (log.isInfoEnabled()) { log.info("Updating syslist " + lstId + " (ISO)Themenkategorie-Codeliste (ISO B.5.27 MD_TopicCategoryCode)..."); } // clean up, to guarantee no old values ! sqlStr = "DELETE FROM sys_list where lst_id = " + lstId; jdbc.executeUpdate(sqlStr); // german syslist LinkedHashMap<Integer, String> newSyslist527_de = new LinkedHashMap<Integer, String>(); newSyslist527_de.put(1, "Landwirtschaft"); newSyslist527_de.put(2, "Biologie"); newSyslist527_de.put(3, "Grenzen"); newSyslist527_de.put(4, "Atmosphre"); newSyslist527_de.put(5, "Wirtschaft"); newSyslist527_de.put(6, "Hhenangaben"); newSyslist527_de.put(7, "Umwelt"); newSyslist527_de.put(8, "Geowissenschaften"); newSyslist527_de.put(9, "Gesundheitswesen"); newSyslist527_de.put(10, "Oberflchenbeschreibung"); newSyslist527_de.put(11, "Militr und Aufklrung"); newSyslist527_de.put(12, "Binnengewsser"); newSyslist527_de.put(13, "Ortsangaben"); newSyslist527_de.put(14, "Meere"); newSyslist527_de.put(15, "Planungsunterlagen, Kataster"); newSyslist527_de.put(16, "Gesellschaft"); newSyslist527_de.put(17, "Bauwerke"); newSyslist527_de.put(18, "Verkehrswesen"); newSyslist527_de.put(19, "Ver- und Entsorgung, Kommunikation"); // english syslist LinkedHashMap<Integer, String> newSyslist527_en = new LinkedHashMap<Integer, String>(); newSyslist527_en.put(1, "farming"); newSyslist527_en.put(2, "biota"); newSyslist527_en.put(3, "boundaries"); newSyslist527_en.put(4, "climatologyMeteorologyAtmosphere"); newSyslist527_en.put(5, "economy"); newSyslist527_en.put(6, "elevation"); newSyslist527_en.put(7, "environment"); newSyslist527_en.put(8, "geoscientificInformation"); newSyslist527_en.put(9, "health"); newSyslist527_en.put(10, "imageryBaseMapsEarthCover"); newSyslist527_en.put(11, "intelligenceMilitary"); newSyslist527_en.put(12, "inlandWaters"); newSyslist527_en.put(13, "location"); newSyslist527_en.put(14, "oceans"); newSyslist527_en.put(15, "planningCadastre"); newSyslist527_en.put(16, "society"); newSyslist527_en.put(17, "structure"); newSyslist527_en.put(18, "transportation"); newSyslist527_en.put(19, "utilitiesCommunication"); itr = newSyslist527_de.keySet().iterator(); while (itr.hasNext()) { int key = itr.next(); // german version jdbc.executeUpdate( "INSERT INTO sys_list (id, lst_id, entry_id, lang_id, name, maintainable, is_default) VALUES (" + getNextId() + ", " + lstId + ", " + key + ", 'de', '" + newSyslist527_de.get(key) + "', 0, 'N')"); // english version jdbc.executeUpdate( "INSERT INTO sys_list (id, lst_id, entry_id, lang_id, name, maintainable, is_default) VALUES (" + getNextId() + ", " + lstId + ", " + key + ", 'en', '" + newSyslist527_en.get(key) + "', 0, 'N')"); } if (log.isInfoEnabled()) { log.info("Updating sys_list... done"); } }
From source file:controller.ViewPackageController.java
@RequestMapping(value = "/createOrder", method = RequestMethod.GET) public String createOrder(HttpServletRequest req, ModelMap mm, Authentication authen) { try {//from ww w .jav a2 s . c o m LinkedHashMap<OderDetail, Requirement> orderSession = null; orderSession = (LinkedHashMap<OderDetail, Requirement>) req.getSession().getAttribute("orderSession"); if (orderSession == null) { mm.put("msg", "No Package choosed"); return "createOrder"; } else { Set<OderDetail> listOrderDetail = new HashSet<>(); Set<Requirement> listRequirement = new HashSet<>(); listOrderDetail = orderSession.keySet(); for (Requirement rq : orderSession.values()) { if (rq != null) { listRequirement.add(rq); } } Customer customer = cusModel.find(authen.getName(), "username", false).get(0); customer.setRequirements(listRequirement); Calendar c = Calendar.getInstance(); c.add(Calendar.MONTH, 1); Order order = null; int orderID = orderModel.getOrderIDByCustomerNonActive(customer.getCustomerId()); if (orderID == 0) { order = new Order(customer, new Date(), c.getTime(), Byte.valueOf("0"), null); orderModel.addOrUpdate(order); } else { order = orderModel.getByID(orderID); } Set<OderDetail> listDetailTmp = order.getOderDetails(); for (OderDetail od : listOrderDetail) { od.setId(new OderDetailId(order.getOderId(), od.getPackages().getPackageId())); for (OderDetail tmp : listDetailTmp) { if (od.getPackages().getPackageId() == tmp.getPackages().getPackageId()) { od.setQuantity(od.getQuantity() + 1); break; } } } order.setOderDetails(listOrderDetail); orderModel.addOrUpdate(order); cusModel.addOrUpdate(customer); req.getSession().setAttribute("orderSession", null); mm.put("msg", "Order Created"); } } catch (Exception ex) { mm.put("msg", ex.getMessage()); } return "createOrder"; }
From source file:org.fao.fenix.wds.web.rest.crowdprices.CrowdPricesDataRESTService.java
private String createGeoJson(List<List<String>> table) { String s = "{ \"type\":\"FeatureCollection\",\"features\":["; int i = 0;//from w w w . j av a 2 s .co m LinkedHashMap<String, List<List<String>>> markets = getCrowdPricesPoints(table); for (String marketname : markets.keySet()) { String popupcontent = "<b>" + marketname + "</b><br>"; String lat = ""; String lon = ""; for (List<String> row : markets.get(marketname)) { popupcontent += row.get(1).replace("_", " ") + " - " + row.get(2) + " " + " " + row.get(3).replace("_", " ") + "/" + row.get(4).replace("_", " ") + "<br>"; lon = row.get(5); lat = row.get(6); } // System.out.println("popup: " + popupcontent); s += "{\"type\":\"Feature\",\"properties\":{\"iconurl\":\"images/marker-icon.png\"," + "\"name\":\"Countrys\"," + // s += "{\"type\":\"Feature\",\"properties\":{\"iconurl\":\"http://fenixapps.fao.org/repository/js/leaflet/0.5.1/images/marker-icon-disabled.png\"," + "\"name\":\"Countrys\"," + "\"popupContent\":\"" + popupcontent + " \"},\"geometry\":{\"type\":\"Point\",\"coordinates\":[" + lon + "," + lat + "]}}"; if (i < markets.size() - 1) { s += ","; } i++; } s += "]}"; return s; }
From source file:com.fortify.bugtracker.common.src.context.AbstractSourceContextGenerator.java
private void updateQueryBuilderWithConfiguredNamePatterns(Context initialContext, Q queryBuilder) { LinkedHashMap<Pattern, Context> namePatternToContextMap = getConfig().getNamePatternToCLIOptionsMap(); if (MapUtils.isNotEmpty(namePatternToContextMap)) { JSONMapFilterNamePatterns filter = new JSONMapFilterNamePatterns(MatchMode.INCLUDE, namePatternToContextMap.keySet()); addNonNullFilterListener(filter, getFilterListenerForConfiguredNamePatterns(initialContext)); queryBuilder.preProcessor(filter); }/* ww w .j av a 2 s. c o m*/ }