public int add(int key, int value) { return _add(key, value, MODE.LAST); }
public int put(int key, int value) { return _put(key, value, MODE.LAST); }
protected void rehash() { int oldCapacity = table.length; IntIntLinkedEntry oldMap[] = table; int newCapacity = oldCapacity * 2 + 1; IntIntLinkedEntry newMap[] = new IntIntLinkedEntry[newCapacity]; threshold = (int) (newCapacity * loadFactor); table = newMap; for (int i = oldCapacity; i-- > 0;) { IntIntLinkedEntry old = oldMap[i]; while (old != null) { IntIntLinkedEntry e = old; old = old.hash_next; int key = e.key; int index = hash(key) % newCapacity; e.hash_next = newMap[index]; newMap[index] = e; } } }
private synchronized int _put(int key, int value, MODE m) { IntIntLinkedEntry tab[] = table; int index = hash(key) % tab.length; for (IntIntLinkedEntry e = tab[index]; e != null; e = e.hash_next) { if (CompareUtil.equals(e.key, key)) { case FORCE_FIRST: if (header.link_next != e) { unchain(e); chain(header, header.link_next, e); unchain(e); chain(header.link_prev, header, e); int v = remove(k); overflowed(k, v); int v = remove(k); overflowed(k, v); rehash(); tab = table; index = hash(key) % tab.length; case FORCE_FIRST: case FIRST: chain(header, header.link_next, e); break; case FORCE_LAST: case LAST:
public synchronized void sort(Comparator<IntIntLinkedEntry> c){ ArrayList<IntIntLinkedEntry> list = new ArrayList<IntIntLinkedEntry>(this.size()); Enumeration<IntIntLinkedEntry> en = this.entries(); while(en.hasMoreElements()){ list.add(en.nextElement()); } Collections.sort(list, c); this.clear(); for(int i = 0 ; i<list.size() ; i++){ IntIntLinkedEntry e = list.get(i); this.put(e.getKey(), e.getValue()); } } }
private static int getSqlHash(String sql) { if (sql.length() < 100) return HashUtil.hash(sql); int id = sql.hashCode(); int hash = sqlHash.get(id); if (hash == 0) { hash = HashUtil.hash(sql); sqlHash.put(id, hash); } return hash; } private static IntLinkedSet sqlText = new IntLinkedSet().setMax(10000);
public String toFormatString() { StringBuffer buf = new StringBuffer(); Enumeration it = entries(); buf.append("{\n"); while (it.hasMoreElements()) { IntIntLinkedEntry e = (IntIntLinkedEntry) it.nextElement(); buf.append("\t").append(e.getKey() + "=" + e.getValue()).append("\n"); } buf.append("}"); return buf.toString(); }
private synchronized int _add(int key, int value, MODE m) { IntIntLinkedEntry tab[] = table; int index = hash(key) % tab.length; for (IntIntLinkedEntry e = tab[index]; e != null; e = e.hash_next) { if (CompareUtil.equals(e.key, key)) { case FORCE_FIRST: if (header.link_next != e) { unchain(e); chain(header, header.link_next, e); unchain(e); chain(header.link_prev, header, e); int v = remove(k); overflowed(k, v); int v = remove(k); overflowed(k, v); rehash(); tab = table; index = hash(key) % tab.length; case FORCE_FIRST: case FIRST: chain(header, header.link_next, e); break; case FORCE_LAST: case LAST:
public synchronized void sort(Comparator<IntIntLinkedEntry> c){ ArrayList<IntIntLinkedEntry> list = new ArrayList<IntIntLinkedEntry>(this.size()); Enumeration<IntIntLinkedEntry> en = this.entries(); while(en.hasMoreElements()){ list.add(en.nextElement()); } Collections.sort(list, c); this.clear(); for(int i = 0 ; i<list.size() ; i++){ IntIntLinkedEntry e = list.get(i); this.put(e.getKey(), e.getValue()); } } }
private static int getSqlHash(String sql) { if (sql.length() < 100) return HashUtil.hash(sql); int id = sql.hashCode(); int hash = sqlHash.get(id); if (hash == 0) { hash = HashUtil.hash(sql); sqlHash.put(id, hash); } return hash; } private static IntLinkedSet sqlText = new IntLinkedSet().setMax(10000);
public String toFormatString() { StringBuffer buf = new StringBuffer(); Enumeration it = entries(); buf.append("{\n"); while (it.hasMoreElements()) { IntIntLinkedEntry e = (IntIntLinkedEntry) it.nextElement(); buf.append("\t").append(e.getKey() + "=" + e.getValue()).append("\n"); } buf.append("}"); return buf.toString(); }
private synchronized int _put(int key, int value, MODE m) { IntIntLinkedEntry tab[] = table; int index = hash(key) % tab.length; for (IntIntLinkedEntry e = tab[index]; e != null; e = e.hash_next) { if (CompareUtil.equals(e.key, key)) { case FORCE_FIRST: if (header.link_next != e) { unchain(e); chain(header, header.link_next, e); unchain(e); chain(header.link_prev, header, e); int v = remove(k); overflowed(k, v); int v = remove(k); overflowed(k, v); rehash(); tab = table; index = hash(key) % tab.length; case FORCE_FIRST: case FIRST: chain(header, header.link_next, e); break; case FORCE_LAST: case LAST:
public synchronized void sort(Comparator<IntIntLinkedEntry> c){ ArrayList<IntIntLinkedEntry> list = new ArrayList<IntIntLinkedEntry>(this.size()); Enumeration<IntIntLinkedEntry> en = this.entries(); while(en.hasMoreElements()){ list.add(en.nextElement()); } Collections.sort(list, c); this.clear(); for(int i = 0 ; i<list.size() ; i++){ IntIntLinkedEntry e = list.get(i); this.put(e.getKey(), e.getValue()); } } }
public void process(XLogPack p) { if (conf.summary_enabled == false) return; // service summary SummaryData d = getSummaryMap(serviceMaster, p.service); d.count++; d.elapsed += p.elapsed; if (p.error != 0) { d.error_cnt++; } d.cpu += p.cpu; d.mem += p.kbytes; // ip summary if (IPUtil.isOK(p.ipaddr) && p.ipaddr[0] != 0 && p.ipaddr[0] != 127) { int ip = DataInputX.toInt(p.ipaddr, 0); ipMaster.put(ip, ipMaster.get(ip) + 1); } // user-agent summary if (p.userAgent != 0) { uaMaster.put(p.userAgent, uaMaster.get(p.userAgent) + 1); } }