public LRUStringConverter(int size) { cache = Collections.synchronizedMap(new LRUMap(size)); }
public Map makeEmptyMap() { return new LRUMap(); }
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")); }
RFileWriter(FileSKVWriter fileSKVWriter, int visCacheSize) { this.writer = fileSKVWriter; this.validVisibilities = new LRUMap(visCacheSize); }
Iterator it = null; LRUMap map = new LRUMap(2); assertEquals(0, map.size()); assertEquals(false, map.isFull());
private VisibilityFilter(SortedKeyValueIterator<Key,Value> iterator, Authorizations authorizations, byte[] defaultVisibility) { super(iterator); this.ve = new VisibilityEvaluator(authorizations); this.authorizations = authorizations; this.defaultVisibility = new ArrayByteSequence(defaultVisibility); this.cache = new LRUMap(1000); }
@Override public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException { super.init(source, options, env); validateOptions(options); this.filterInvalid = Boolean.parseBoolean(options.get(FILTER_INVALID_ONLY)); if (!filterInvalid) { String auths = options.get(AUTHS); Authorizations authObj = auths == null || auths.isEmpty() ? new Authorizations() : new Authorizations(auths.getBytes(UTF_8)); this.ve = new VisibilityEvaluator(authObj); } this.cache = new LRUMap(1000); }
@Override public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException { super.init(source, options, env); scanning = IteratorScope.scan.equals(env.getIteratorScope()); if (scanning) { String auths = options.get(AUTH_OPT); if (auths != null && !auths.isEmpty()) { ve = new VisibilityEvaluator(new Authorizations(auths.getBytes(UTF_8))); visibleCache = new LRUMap(100); } } if (options.containsKey(MAX_BUFFER_SIZE_OPT)) { maxBufferSize = ConfigurationTypeHelper .getFixedMemoryAsBytes(options.get(MAX_BUFFER_SIZE_OPT)); } else { maxBufferSize = DEFAULT_MAX_BUFFER_SIZE; } parsedVisibilitiesCache = new LRUMap(100); }
Map cache = new LRUMap(100000); Set<Path> processing = new HashSet<>(); ExecutorService threadPool = Executors.newFixedThreadPool(16);
@Override public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) { TransformingIterator copy; try { copy = getClass().newInstance(); } catch (Exception e) { throw new RuntimeException(e); } copy.setSource(getSource().deepCopy(env)); copy.scanning = scanning; copy.keyPos = keyPos; copy.keys.addAll(keys); copy.seekRange = (seekRange == null) ? null : new Range(seekRange); copy.seekColumnFamilies = (seekColumnFamilies == null) ? null : new HashSet<>(seekColumnFamilies); copy.seekColumnFamiliesInclusive = seekColumnFamiliesInclusive; copy.ve = ve; if (visibleCache != null) { copy.visibleCache = new LRUMap(visibleCache.maxSize()); copy.visibleCache.putAll(visibleCache); } if (parsedVisibilitiesCache != null) { copy.parsedVisibilitiesCache = new LRUMap(parsedVisibilitiesCache.maxSize()); copy.parsedVisibilitiesCache.putAll(parsedVisibilitiesCache); } copy.maxBufferSize = maxBufferSize; return copy; }
public void testInternalState_getEntry_int() { if (isPutAddSupported() == false || isPutChangeSupported() == false) return; SingleHashCode one = new SingleHashCode("1"); SingleHashCode two = new SingleHashCode("2"); SingleHashCode three = new SingleHashCode("3"); SingleHashCode four = new SingleHashCode("4"); SingleHashCode five = new SingleHashCode("5"); SingleHashCode six = new SingleHashCode("6"); LRUMap map = new LRUMap(3, 1.0f); int hashIndex = map.hashIndex(map.hash(one), 4); map.put(one, "A"); map.put(two, "B"); map.put(three, "C"); assertEquals(one, map.getEntry(0).key); assertEquals(two, map.getEntry(1).key); assertEquals(three, map.getEntry(2).key); try { map.getEntry(-1); fail(); } catch (IndexOutOfBoundsException ex) {} try { map.getEntry(3); fail(); } catch (IndexOutOfBoundsException ex) {} }
public void testLRUMultiKeyMap() { MultiKeyMap map = MultiKeyMap.decorate(new LRUMap(2)); map.put(I1, I2, "1-2"); map.put(I1, I3, "1-3"); assertEquals(2, map.size()); map.put(I1, I4, "1-4"); assertEquals(2, map.size()); assertEquals(true, map.containsKey(I1, I3)); assertEquals(true, map.containsKey(I1, I4)); assertEquals(false, map.containsKey(I1, I2)); MultiKeyMap cloned = (MultiKeyMap) map.clone(); assertEquals(2, map.size()); assertEquals(true, cloned.containsKey(I1, I3)); assertEquals(true, cloned.containsKey(I1, I4)); assertEquals(false, cloned.containsKey(I1, I2)); cloned.put(I1, I5, "1-5"); assertEquals(2, cloned.size()); assertEquals(true, cloned.containsKey(I1, I4)); assertEquals(true, cloned.containsKey(I1, I5)); }
@SuppressWarnings("unused") public void setSecondLevelCache(final Cache secondLevelCache) { this.secondLevelCache = secondLevelCache; uncacheableKeys = new LRUMap(1000); }
public FishEyeCacheImpl(int revCacheSize, int csCacheSize, AuthenticationContext authenticationContext) { this.authenticationContext = authenticationContext; if (revCacheSize > 0 && csCacheSize > 0) { revCache = Collections.synchronizedMap(new LRUMap(revCacheSize)); csCache = Collections.synchronizedMap(new LRUMap(csCacheSize)); } else { cacheDisabled = true; } }
@SuppressWarnings("unused") public void setSecondLevelCache(final Optional<Cache> secondLevelCacheOptional) { if (secondLevelCacheOptional.isPresent()) { this.secondLevelCache = secondLevelCacheOptional.get(); uncacheableKeys = new LRUMap(1000); } }
/** * @see PrincipalProvider#init(java.util.Properties) */ public synchronized void init(Properties options) { if (initialized) { throw new IllegalStateException("already initialized"); } int maxSize = Integer.parseInt(options.getProperty(MAXSIZE_KEY, "1000")); cache = new LRUMap(maxSize); includeNegative = Boolean.parseBoolean(options.getProperty(NEGATIVE_ENTRY_KEY, "false")); initialized = true; }
@Override protected Map<String, CacheEntry> initialValue(){ // Bug 51942 - this map may be used from multiple threads @SuppressWarnings("unchecked") // LRUMap is not generic currently Map<String, CacheEntry> map = new LRUMap(getMaxSize()); return Collections.synchronizedMap(map); } };
SingleHashCode six = new SingleHashCode("6"); LRUMap map = new LRUMap(3, 1.0f); int hashIndex = map.hashIndex(map.hash(one), 4); map.put(one, "A");
public GraphTransformerResolver() { this.readWriteLock = new ReentrantReadWriteLock(); this.graph = new TransformationGraph(); lookupStrategyTransformation = new TransformationGraphLookupStrategy(graph); converterFilter = new CompositeConverterFilter(new TransformationLengthConverterFilter(), new PriorityWeightingConverterFilter(), new NameConverterFilter()); cache = new LRUMap(); }
public GraphTransformerResolver() { this.readWriteLock = new ReentrantReadWriteLock(); this.graph = new SynchronizedTransformationGraph(); lookupStrategyTransformation = new TransformationGraphLookupStrategy(graph); converterFilter = new CompositeConverterFilter(new TypeMatchingVertexesFilter(), new TransformationLengthConverterFilter(), new PriorityWeightingConverterFilter(), new NameConverterFilter()); cache = new LRUMap(); }