Example usage for org.apache.commons.collections.map HashedMap get

List of usage examples for org.apache.commons.collections.map HashedMap get

Introduction

In this page you can find the example usage for org.apache.commons.collections.map HashedMap get.

Prototype

public Object get(Object key) 

Source Link

Document

Gets the value mapped to the key specified.

Usage

From source file:com.userweave.csv.AbstractModuleCsvConverter.java

@SuppressWarnings({ "rawtypes", "unchecked" })
protected List<AbstractCsvCell> getRowForSurveyExecution(HashedMap map, Object result) {
    List<AbstractCsvCell> row;

    // is there already a row?
    if (map.containsKey(result)) {
        row = (List<AbstractCsvCell>) map.get(result);
    } else {//from   w  w  w . ja  v a 2 s.co  m
        row = new LinkedList<AbstractCsvCell>();
        map.put(result, row);
    }

    return row;
}

From source file:herddb.model.Transaction.java

public LockHandle lookupLock(String tableName, Bytes key) {
    HashedMap ll = locks.get(tableName);
    if (ll == null || ll.isEmpty()) {
        return null;
    }/*  w  ww  . j  a v  a2 s.  co  m*/
    return (LockHandle) ll.get(key);
}

From source file:com.octo.captcha.engine.bufferedengine.BufferedEngineContainer.java

/**
 * Method launch by a scheduler to swap captcha from disk buffer to the memory buffer. The ratio of swaping for each
 * locale is defined in the configuration component.
 *///from w ww  .  j ava 2  s.com
public void swapCaptchasFromPersistentToVolatileMemory() {

    log.debug("entering swapCaptchasFromDiskBufferToMemoryBuffer()");

    MapIterator it = config.getLocaleRatio().mapIterator();

    //construct the map of swap size by locales;
    HashedMap captchasRatios = new HashedMap();
    while (it.hasNext()) {

        Locale locale = (Locale) it.next();
        double ratio = ((Double) it.getValue()).doubleValue();
        int ratioCount = (int) Math.round(config.getSwapSize().intValue() * ratio);

        //get the reminding size corresponding to the ratio
        int diff = (int) Math
                .round((config.getMaxVolatileMemorySize().intValue() - this.volatileBuffer.size()) * ratio);

        diff = diff < 0 ? 0 : diff;
        int toSwap = (diff < ratioCount) ? diff : ratioCount;

        captchasRatios.put(locale, new Integer(toSwap));
    }
    //get them from persistent buffer
    Iterator captchasRatiosit = captchasRatios.mapIterator();

    while (captchasRatiosit.hasNext() && !shutdownCalled) {
        Locale locale = (Locale) captchasRatiosit.next();
        int swap = ((Integer) captchasRatios.get(locale)).intValue();
        if (log.isDebugEnabled()) {
            log.debug("try to swap  " + swap + " Captchas from persistent to volatile memory with locale : "
                    + locale.toString());
        }

        Collection temp = this.persistentBuffer.removeCaptcha(swap, locale);

        this.volatileBuffer.putAllCaptcha(temp, locale);
        if (log.isDebugEnabled()) {
            log.debug("swaped  " + temp.size() + " Captchas from persistent to volatile memory with locale : "
                    + locale.toString());
        }
        //stats
        persistentMemoryHits += temp.size();
    }

    if (log.isDebugEnabled()) {
        log.debug("new volatil Buffer size : " + volatileBuffer.size());
    }
    // stats
    persistentToVolatileSwaps++;
}