List of usage examples for com.google.common.collect Maps newHashMap
public static <K, V> HashMap<K, V> newHashMap(Map<? extends K, ? extends V> map)
From source file:com.palantir.atlasdb.transaction.impl.Transactions.java
/** * For tables that provide write-write conflict detection, touch is a useful tool. * Touch will ensure that the value you read from a table wasn't modified by any concurrent * transactions.//from ww w .jav a 2 s . com * <p> * If a cell is deleted, it also ensures that no concurrent transactions have written a value * to that cell. * <p> * Note: If two concurrent transactions both touch the same cell, only one of them will * complete successfully and the other will retry. This means touch allows a read to have * "serializable" semantics, but it is at the cost of a write. If we find that we rely heavily * on touch and it causes a lot of contention, we should consider implementing serializable * isolation. */ public static void touchCells(Transaction t, String tableName, Set<Cell> cells) { Map<Cell, byte[]> results = Maps.newHashMap(t.get(tableName, cells)); for (Cell cell : cells) { if (!results.containsKey(cell)) { results.put(cell, PtBytes.EMPTY_BYTE_ARRAY); } } t.put(tableName, results); }
From source file:com.cloudera.exhibit.core.composite.UpdatableExhibitDescriptor.java
public UpdatableExhibitDescriptor(ExhibitDescriptor base) { super(base.attributes(), Maps.newHashMap(base.frames())); }
From source file:org.elasticsearch.test.cache.recycler.MockPageCacheRecycler.java
public static void ensureAllPagesAreReleased() throws Exception { final Map<Object, Throwable> masterCopy = Maps.newHashMap(ACQUIRED_PAGES); if (!masterCopy.isEmpty()) { // not empty, we might be executing on a shared cluster that keeps on obtaining // and releasing pages, lets make sure that after a reasonable timeout, all master // copy (snapshot) have been released boolean success = ElasticsearchTestCase.awaitBusy(new Predicate<Object>() { @Override/*www .ja va 2 s.co m*/ public boolean apply(Object input) { return Sets.intersection(masterCopy.keySet(), ACQUIRED_PAGES.keySet()).isEmpty(); } }); if (!success) { masterCopy.keySet().retainAll(ACQUIRED_PAGES.keySet()); ACQUIRED_PAGES.keySet().removeAll(masterCopy.keySet()); // remove all existing master copy we will report on if (!masterCopy.isEmpty()) { final Throwable t = masterCopy.entrySet().iterator().next().getValue(); throw new RuntimeException(masterCopy.size() + " pages have not been released", t); } } } }
From source file:org.terasology.rendering.nui.skin.UISkinData.java
public UISkinData(Map<String, UIStyleFamily> families) { skinFamilies = Maps.newHashMap(families); }
From source file:org.apache.shindig.gadgets.http.HttpResponseMetadataHelper.java
/** * Return a copy of input response with additional metadata values. * @param response source response/* w w w.j a v a2s . c o m*/ * @param values added metadata values * @return copy of source response with updated metadata */ public static HttpResponse updateMetadata(HttpResponse response, Map<String, String> values) { Map<String, String> metadata = Maps.newHashMap(response.getMetadata()); // metadata.putAll(values); for (Map.Entry<String, String> val : values.entrySet()) { metadata.put(val.getKey(), val.getValue()); } return new HttpResponseBuilder(response).setMetadata(metadata).create(); }
From source file:org.carrot2.util.simplexml.SessionInitStrategy.java
public SessionInitStrategy(Strategy delegate, Map<Object, Object> sessionValues) { this.delegate = delegate; this.sessionValues = Maps.newHashMap(sessionValues); }
From source file:net.sourceforge.docfetcher.model.index.file.MapValueDiff.java
protected final void doRun() { Map<K, V> rightCopy = Maps.newHashMap(right); for (Map.Entry<K, V> leftEntry : left.entrySet()) { if (isStopped()) return; K leftKey = leftEntry.getKey();//from w w w. ja va 2s . c o m V leftValue = leftEntry.getValue(); V rightValue = rightCopy.remove(leftKey); if (rightValue != null) handleBoth(leftValue, rightValue); else handleOnlyLeft(leftValue); } for (V rightValue : rightCopy.values()) { if (isStopped()) return; handleOnlyRight(rightValue); } }