List of usage examples for java.util HashMap size
int size
To view the source code for java.util HashMap size.
Click Source Link
From source file:net.sf.mpaxs.spi.server.HostRegister.java
/** * * @return//from ww w .j a va 2 s . c o m */ public String[] getHostIps() { HashMap<UUID, Host> allHosts = hosts.getAll(); String[] ret = new String[allHosts.size()]; int j = 0; for (UUID key : allHosts.keySet()) { ret[j] = allHosts.get(key).getIP(); j++; } return ret; }
From source file:ru.apertum.qsystem.reports.formirovators.AuthorizedClientsPeriodUsers.java
@Override public String validate(String driverClassName, String url, String username, String password, HttpRequest request, HashMap<String, String> params) { // ? /* w ww .ja v a2s. c o m*/ QLog.l().logger().trace("? \"" + params.toString() + "\"."); if (params.size() == 4) { // sd/ed/user_id/user Date sd, fd; String sdate, fdate, user; long user_id; try { //date = Uses.format_dd_MM_yyyy.parse(ss0[1]); sd = Uses.format_dd_MM_yyyy.parse(params.get("sd")); fd = Uses.format_dd_MM_yyyy.parse(params.get("ed")); sdate = (new java.text.SimpleDateFormat("yyyy-MM-dd")).format(sd); fdate = (new java.text.SimpleDateFormat("yyyy-MM-dd")).format(fd); user_id = Long.parseLong(params.get("user_id")); user = params.get("user"); } catch (ParseException | NumberFormatException ex) { return "<br> ! ? ? (..)."; } paramMap.put("sdate", sdate); paramMap.put("fdate", fdate); paramMap.put("sd", sd); paramMap.put("fd", fd); paramMap.put("user_id", user_id); paramMap.put("user", user); } else { return "<br> !"; } return null; }
From source file:com.ba.masters.room.BARoomAction.java
public ActionForward baGet(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { JSONObject json = new JSONObject(); BARoomDTO vo = new BARoomDTO(); try {/* w ww . j a v a2s . c om*/ logger.info(" get method starts here"); String roomId = request.getParameter("search"); HashMap hashMpRoomItemDet = BARoomFactory.getInstanceOfBARoomFactory().getRoomDtls(roomId); json.put("exception", ""); json.put("RoomDets", hashMpRoomItemDet); json.put("RoomExit", hashMpRoomItemDet.size()); // logger.warn("strCurrent PageNo ------------->"+objPageCount); } catch (Exception ex) { logger.error("The Exception is :" + ex); ex.printStackTrace(); json.put("exception", BAHandleAllException.exceptionHandler(ex)); } response.getWriter().write(json.toString()); return null; }
From source file:ru.apertum.qsystem.reports.formirovators.AuthorizedClientsPeriodServices.java
@Override public String validate(String driverClassName, String url, String username, String password, HttpRequest request, HashMap<String, String> params) { // ? /*from w w w. j a v a 2 s .co m*/ QLog.l().logger().trace("? \"" + params.toString() + "\"."); if (params.size() == 4) { // sd/ed/user_id/user Date sd, fd; String sdate; String fdate; long user_id; String user; try { //date = Uses.format_dd_MM_yyyy.parse(ss0[1]); sd = Uses.format_dd_MM_yyyy.parse(params.get("sd")); fd = Uses.format_dd_MM_yyyy.parse(params.get("ed")); sdate = (new java.text.SimpleDateFormat("yyyy-MM-dd")).format(sd); fdate = (new java.text.SimpleDateFormat("yyyy-MM-dd")).format(fd); user_id = Long.parseLong(params.get("user_id")); user = params.get("user"); } catch (ParseException | NumberFormatException ex) { return "<br> ! ? ? (..)."; } paramMap.put("sdate", sdate); paramMap.put("fdate", fdate); paramMap.put("sd", sd); paramMap.put("fd", fd); paramMap.put("user_id", user_id); paramMap.put("user", user); } else { return "<br> !"; } return null; }
From source file:Evaluator.StatCalculator.java
public double rmsCalc(HashMap<String, Double> kderunQidMap, HashMap<String, Double> aprunQidMap) { double sum = 0; Iterator it = kderunQidMap.keySet().iterator(); while (it.hasNext()) { String run = (String) it.next(); sum = (kderunQidMap.get(run) - aprunQidMap.get(run)) * (kderunQidMap.get(run) - aprunQidMap.get(run)); }/*from w w w . j av a 2s. c o m*/ sum /= kderunQidMap.size(); sum = Math.sqrt(sum); return sum; }
From source file:com.ba.masters.department.BADepartmentAction.java
/** * This is the Struts action method called on * http://.../actionPath?method=myAction2, where "method" is the value * specified in <action> element : ( <action parameter="method" .../> ) *//* w w w .j a va2 s . co m*/ public ActionForward baGet(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { JSONObject json = new JSONObject(); BADepartmentDTO vo = new BADepartmentDTO(); try { logger.info(" get method starts here"); String depId = request.getParameter("search"); HashMap hashMpDepartmentDet = BADepartmentFactory.getInstanceOfBaDepartmentFactory() .getDepartmentDtls(depId); json.put("exception", ""); json.put("DepartmentDets", hashMpDepartmentDet); json.put("DepartmentExit", hashMpDepartmentDet.size()); logger.warn("strCurrent PageNo ------------->" + objPageCount); } catch (Exception ex) { logger.error("The Exception is :" + ex); ex.printStackTrace(); json.put("exception", BAHandleAllException.exceptionHandler(ex)); } response.getWriter().write(json.toString()); return null; }
From source file:com.ba.masters.staff.BAStaffAction.java
public ActionForward baGet(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { JSONObject json = new JSONObject(); BAStaffDTO vo = new BAStaffDTO(); try {//w w w.ja v a 2s .co m logger.info(" get method starts here"); String staffId = request.getParameter("search"); HashMap hashMpStaffItemDet = BaStaffFactory.getInstanceOfBaStaffFactory().getStaffItemDtls(staffId); json.put("exception", ""); json.put("StaffItemDets", hashMpStaffItemDet); json.put("StaffItemExit", hashMpStaffItemDet.size()); logger.warn("strCurrent PageNo ------------->" + objPageCount); } catch (Exception ex) { logger.error("The Exception is :" + ex); ex.printStackTrace(); json.put("exception", BAHandleAllException.exceptionHandler(ex)); } response.getWriter().write(json.toString()); return null; }
From source file:com.ibm.bi.dml.runtime.controlprogram.parfor.RemoteDPParForMR.java
/** * Result file contains hierarchy of workerID-resultvar(incl filename). We deduplicate * on the workerID. Without JVM reuse each task refers to a unique workerID, so we * will not find any duplicates. With JVM reuse, however, each slot refers to a workerID, * and there are duplicate filenames due to partial aggregation and overwrite of fname * (the RemoteParWorkerMapper ensures uniqueness of those files independent of the * runtime implementation). //from w w w. j av a 2 s . co m * * @param job * @param fname * @return * @throws DMLRuntimeException */ @SuppressWarnings("deprecation") public static LocalVariableMap[] readResultFile(JobConf job, String fname) throws DMLRuntimeException, IOException { HashMap<Long, LocalVariableMap> tmp = new HashMap<Long, LocalVariableMap>(); FileSystem fs = FileSystem.get(job); Path path = new Path(fname); LongWritable key = new LongWritable(); //workerID Text value = new Text(); //serialized var header (incl filename) int countAll = 0; for (Path lpath : MatrixReader.getSequenceFilePaths(fs, path)) { SequenceFile.Reader reader = new SequenceFile.Reader(FileSystem.get(job), lpath, job); try { while (reader.next(key, value)) { //System.out.println("key="+key.get()+", value="+value.toString()); if (!tmp.containsKey(key.get())) tmp.put(key.get(), new LocalVariableMap()); Object[] dat = ProgramConverter.parseDataObject(value.toString()); tmp.get(key.get()).put((String) dat[0], (Data) dat[1]); countAll++; } } finally { if (reader != null) reader.close(); } } LOG.debug("Num remote worker results (before deduplication): " + countAll); LOG.debug("Num remote worker results: " + tmp.size()); //create return array return tmp.values().toArray(new LocalVariableMap[0]); }
From source file:edu.illinois.cs.cogcomp.transliteration.WikiTransliteration.java
/** * This finds all possible alignments between word1 and word2. * @param word1/* w w w . j ava 2 s . c om*/ * @param word2 * @param maxSubstringLength1 * @param maxSubstringLength2 * @param internTable * @param normalization * @return */ public static HashMap<Production, Double> FindAlignments(String word1, String word2, int maxSubstringLength1, int maxSubstringLength2, InternDictionary<String> internTable, NormalizationMode normalization) { HashMap<Production, Double> alignments = new HashMap<>(); // this populates the alignments hashmap. // FIXME: why not assign to alignments here? // FIXME: why is it boolean? Is the value ever false? What does it mean? HashSet<Production> memoizationtable = new HashSet<>(); FindAlignments(word1, word2, maxSubstringLength1, maxSubstringLength2, alignments, memoizationtable); // FIXME: probably don't need this? What about interning?? HashMap<Production, Double> result = new HashMap<>(alignments.size()); for (Production key : alignments.keySet()) { result.put(new Production(internTable.Intern(key.getFirst()), internTable.Intern(key.getSecond())), 1.0); } return Normalize(word1, word2, result, internTable, normalization); }
From source file:es.tid.fiware.rss.expenditureLimit.dao.impl.tests.DbeExpendLimitDaoTest.java
@Test public void testOrderedGetExpenditureLimitInfByUser() { BmService bmService = new BmService(); bmService.setNuServiceId(1);//from ww w. j a v a2 s . co m BmCurrency bmCurrency = new BmCurrency(); bmCurrency.setNuCurrencyId(1); BmObCountry bmObCountry = new BmObCountry(); bmObCountry.setId(new BmObCountryId(1, 1)); HashMap<String, List<DbeExpendLimit>> h = expLimitDao.getOrdExpLimitsForUserAppProvCurrencyObCountry( "userId01", bmService, "app123456", bmCurrency, bmObCountry); Assert.assertTrue("List founds", h != null && h.size() == 4); List<DbeExpendLimit> l = h.get(DbeExpendLimitDao.USER_APP_PROV_KEY); Assert.assertTrue("Especific elements founds", l != null && l.size() == 1); Iterator<DbeExpendLimit> it = l.iterator(); while (it.hasNext()) { DbeExpendLimit el = it.next(); if (!el.getId().getTxAppProviderId().equalsIgnoreCase("app123456")) { Assert.fail("Application provider invalid: " + el.getId().getTxAppProviderId()); } if (!el.getId().getTxEndUserId().equalsIgnoreCase("userId01")) { Assert.fail("User invalid: " + el.getId().getTxEndUserId()); } } l = h.get(DbeExpendLimitDao.USER_KEY); Assert.assertTrue("User elements founds", l != null && l.size() == 1); it = l.iterator(); while (it.hasNext()) { DbeExpendLimit el = it.next(); if (!el.getId().getTxAppProviderId().equalsIgnoreCase(DbeExpendLimitDao.NO_APP_PROVIDER_ID)) { Assert.fail("Application provider invalid: " + el.getId().getTxAppProviderId()); } if (!el.getId().getTxEndUserId().equalsIgnoreCase("userId01")) { Assert.fail("User invalid: " + el.getId().getTxEndUserId()); } } l = h.get(DbeExpendLimitDao.APP_PROV_KEY); Assert.assertTrue("App provider elements founds", l != null && l.size() == 1); it = l.iterator(); while (it.hasNext()) { DbeExpendLimit el = it.next(); if (!el.getId().getTxAppProviderId().equalsIgnoreCase("app123456")) { Assert.fail("Application provider invalid: " + el.getId().getTxAppProviderId()); } if (!el.getId().getTxEndUserId().equalsIgnoreCase(DbeExpendLimitDao.NO_USER_ID)) { Assert.fail("User invalid: " + el.getId().getTxEndUserId()); } } l = h.get(DbeExpendLimitDao.ALL_GENERIC_KEY); Assert.assertTrue("Generic elements founds", l != null && l.size() == 3); it = l.iterator(); while (it.hasNext()) { DbeExpendLimit el = it.next(); if (!el.getId().getTxAppProviderId().equalsIgnoreCase(DbeExpendLimitDao.NO_APP_PROVIDER_ID)) { Assert.fail("Application provider invalid: " + el.getId().getTxAppProviderId()); } if (!el.getId().getTxEndUserId().equalsIgnoreCase(DbeExpendLimitDao.NO_USER_ID)) { Assert.fail("User invalid: " + el.getId().getTxEndUserId()); } } }