public void testClone() { LRUMap map = new LRUMap(10); map.put("1", "1"); Map cloned = (Map) map.clone(); assertEquals(map.size(), cloned.size()); assertSame(map.get("1"), cloned.get("1")); }
@Override protected boolean accept(Key k, Value v) { ByteSequence testVis = k.getColumnVisibilityData(); if (testVis.length() == 0 && defaultVisibility.length() == 0) return true; else if (testVis.length() == 0) testVis = defaultVisibility; Boolean b = (Boolean) cache.get(testVis); if (b != null) return b; try { Boolean bb = ve.evaluate(new ColumnVisibility(testVis.toArray())); cache.put(testVis, bb); return bb; } catch (VisibilityParseException e) { log.error("VisibilityParseException with visibility of Key: {}", k, e); return false; } catch (BadArgumentException e) { log.error("BadArgumentException with visibility of Key: {}", k, e); return false; } }
/** * Append the key and value to the last locality group that was started. If no locality group was * started, then the default group will automatically be started. * * @param key * This key must be greater than or equal to the last key appended. For non-default * locality groups, the keys column family must be one of the column families specified * when calling startNewLocalityGroup(). Must be non-null. * @param val * value to append, must be non-null. * * @throws IllegalArgumentException * This is thrown when data is appended out of order OR when the key contains a invalid * visibility OR when a column family is not valid for a locality group. */ public void append(Key key, Value val) throws IOException { if (!startedLG) { startDefaultLocalityGroup(); } Boolean wasChecked = (Boolean) validVisibilities.get(key.getColumnVisibilityData()); if (wasChecked == null) { byte[] cv = key.getColumnVisibilityData().toArray(); new ColumnVisibility(cv); validVisibilities.put(new ArrayByteSequence(Arrays.copyOf(cv, cv.length)), Boolean.TRUE); } writer.append(key, val); }
/** * Returns cached snapshot or null if no snapshot is currently cached for the given * ObjectId. */ public synchronized DataRow getCachedSnapshot(ObjectId oid) { return (DataRow) snapshots.get(oid); }
/** * Returns cached snapshot or null if no snapshot is currently cached for the given * ObjectId. */ public synchronized DataRow getCachedSnapshot(ObjectId oid) { return (DataRow) snapshots.get(oid); }
/** * Returns a list of previously cached snapshots. */ public synchronized List getCachedSnapshots(String key) { if (key == null) { return null; } return (List) snapshotLists.get(key); }
/** * Returns a list of previously cached snapshots. */ public synchronized List getCachedSnapshots(String key) { if (key == null) { return null; } return (List) snapshotLists.get(key); }
public NewtResponse get (int taxid) { return (NewtResponse) lru.get (taxid+""); }
public QueryMasterTask getQueryMasterTask(QueryId queryId, boolean includeFinished) { QueryMasterTask queryMasterTask = queryMasterTasks.get(queryId); if (queryMasterTask != null) { return queryMasterTask; } else { if (includeFinished) { synchronized (finishedQueryMasterTasksCache) { return (QueryMasterTask) finishedQueryMasterTasksCache.get(queryId); } } else { return null; } } }
public QueryMasterTask getQueryMasterTask(QueryId queryId, boolean includeFinished) { QueryMasterTask queryMasterTask = queryMasterTasks.get(queryId); if (queryMasterTask != null) { return queryMasterTask; } else { if (includeFinished) { synchronized (finishedQueryMasterTasksCache) { return (QueryMasterTask) finishedQueryMasterTasksCache.get(queryId); } } else { return null; } } }
public static IdRef<?> getCursor(String cursor) { return (IdRef<?>) cursors.get(cursor); }
protected boolean accept(ColumnVisibility visibility) { Boolean b = (Boolean) cache.get(visibility); if (b != null) return b; try { Boolean bb = ve.evaluate(visibility); cache.put(visibility, bb); return bb; } catch (VisibilityParseException | BadArgumentException e) { log.error("Parse Error", e); return false; } } }
private static void transactionLog(String tx, Type operationType, IdRef<?> id, Object object, Object previousObject) { if (tx == null) { return; } MockTransaction mockTransaction = (MockTransaction) transactions.get(tx); mockTransaction.add(operationType, id, object, previousObject); }
private static InetAddress getCachedMisconfiguredHost(String host, int port) { synchronized (misconfiguredHosts) { if (misconfiguredHosts.isEmpty()) { return null; } removeStaleCachedMisconfiguredHosts(); MisconfiguredHostCacheEntry entry = (MisconfiguredHostCacheEntry) misconfiguredHosts.get(host + port); if (entry != null) { return entry.getAddress(); } return null; } }
public JoinEdge getCachedOrNewJoinEdge(JoinSpec joinSpec, JoinVertex left, JoinVertex right) { Pair<JoinVertex,JoinVertex> cacheKey = new Pair<>(left, right); if (edgeCache.containsKey(cacheKey)) { return (JoinEdge) edgeCache.get(cacheKey); } else { return cacheEdge(new JoinEdge(joinSpec, left, right)); } }
public JoinEdge getCachedOrNewJoinEdge(JoinSpec joinSpec, JoinVertex left, JoinVertex right) { Pair<JoinVertex,JoinVertex> cacheKey = new Pair<JoinVertex, JoinVertex>(left, right); if (edgeCache.containsKey(cacheKey)) { return (JoinEdge) edgeCache.get(cacheKey); } else { return cacheEdge(new JoinEdge(joinSpec, left, right)); } }
public static void rollback(String tx) { MockTransaction mockTransaction = (MockTransaction) transactions.get(tx); mockTransaction.rollback(); transactions.remove(tx); }