public static SimpleDateFormat getDateFormat(CommandContext context, String format) { SimpleDateFormat result = null; if (context != null) { if (context.globalState.dateFormatCache == null) { context.globalState.dateFormatCache = new LRUCache<String, SimpleDateFormat>(32); } else { result = context.globalState.dateFormatCache.get(format); } } if (result == null) { result = new SimpleDateFormat(format); //TODO: could be locale sensitive if (context != null) { context.globalState.dateFormatCache.put(format, result); } } return result; }
/** * Returns the IndexBlock (containing words) with the given number. */ protected IndexBlock getIndexBlock(int blockNum) throws IOException { Integer key= new Integer(blockNum); Block block= (Block) blockCache.get(key); if (block != null && block instanceof IndexBlock) return (IndexBlock) block; IndexBlock indexBlock= new GammaCompressedIndexBlock(IIndexConstants.BLOCK_SIZE); indexBlock.read(raf, blockNum); blockCache.put(key, indexBlock); return indexBlock; }
cacheKey.add(key); this.cache.put(cacheKey, tb); removeBuffer = false; this.currentTuples += tb.getRowCount(); while (this.currentTuples > maxTuples && !cache.isEmpty()) { Iterator<Map.Entry<List<?>, TupleBuffer>> i = this.cache.entrySet().iterator(); Map.Entry<List<?>, TupleBuffer> entry = i.next(); TupleBuffer buffer = entry.getValue(); if (buffer.getRowCount() <= 2) { this.smallCache.put(entry.getKey(), buffer); } else { buffer.remove(); TupleBuffer cachedResult = cache.get(cacheKey); if (cachedResult == null) { cachedResult = smallCache.get(cacheKey);
/** * @see IndexInput#clearCache() */ public void clearCache() { blockCache= new LRUCache(CACHE_SIZE); }
protected boolean removeEldestEntry(Map.Entry<java.util.List<?>,TupleBuffer> eldest) { if (super.removeEldestEntry(eldest)) { if (spillOver != null && eldest.getValue().getRowCount() <= 2) { spillOver.put(eldest.getKey(), eldest.getValue()); } else { eldest.getValue().remove(); } return true; } return false; }
public Boolean isAccessible(AbstractMetadataRecord record) { if (this.globalState.accessible == null) { return null; } return this.globalState.accessible.get(record); }
public static Pattern getPattern(String newPattern, String originalPattern, int flags) throws ExpressionEvaluationException { List<?> key = Arrays.asList(newPattern, flags); Pattern p = patternCache.get(key); if (p == null) { try { p = Pattern.compile(newPattern, Pattern.DOTALL); patternCache.put(key, p); } catch(PatternSyntaxException e) { throw new ExpressionEvaluationException(QueryPlugin.Event.TEIID30448, e, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30448, new Object[]{originalPattern, e.getMessage()})); } } return p; }
cacheKey.add(key); this.cache.put(cacheKey, tb); removeBuffer = false; this.currentTuples += tb.getRowCount(); while (this.currentTuples > maxTuples && !cache.isEmpty()) { Iterator<Map.Entry<List<?>, TupleBuffer>> i = this.cache.entrySet().iterator(); Map.Entry<List<?>, TupleBuffer> entry = i.next(); TupleBuffer buffer = entry.getValue(); if (buffer.getRowCount() <= 2) { this.smallCache.put(entry.getKey(), buffer); } else { buffer.remove(); TupleBuffer cachedResult = cache.get(cacheKey); if (cachedResult == null) { cachedResult = smallCache.get(cacheKey);
/** * @see IndexInput#clearCache() */ public void clearCache() { blockCache= new LRUCache(CACHE_SIZE); }
protected boolean removeEldestEntry(Map.Entry<java.util.List<?>,TupleBuffer> eldest) { if (super.removeEldestEntry(eldest)) { if (spillOver != null && eldest.getValue().getRowCount() <= 2) { spillOver.put(eldest.getKey(), eldest.getValue()); } else { eldest.getValue().remove(); } return true; } return false; }
public Boolean isAccessible(AbstractMetadataRecord record) { if (this.globalState.accessible == null) { return null; } return this.globalState.accessible.get(record); }
public static SimpleDateFormat getDateFormat(CommandContext context, String format) { SimpleDateFormat result = null; if (context != null) { if (context.globalState.dateFormatCache == null) { context.globalState.dateFormatCache = new LRUCache<String, SimpleDateFormat>(32); } else { result = context.globalState.dateFormatCache.get(format); } } if (result == null) { result = new SimpleDateFormat(format); //TODO: could be locale sensitive if (context != null) { context.globalState.dateFormatCache.put(format, result); } } return result; }
/** * Returns the FileListBlock with the given number. */ protected FileListBlock getFileListBlock(int blockNum) throws IOException { Integer key= new Integer(blockNum); Block block= (Block) blockCache.get(key); if (block != null && block instanceof FileListBlock) return (FileListBlock) block; FileListBlock fileListBlock= new FileListBlock(IIndexConstants.BLOCK_SIZE); fileListBlock.read(raf, blockNum); blockCache.put(key, fileListBlock); return fileListBlock; }
cacheKey.add(key); this.cache.put(cacheKey, tb); removeBuffer = false; this.currentTuples += tb.getRowCount(); while (this.currentTuples > maxTuples && !cache.isEmpty()) { Iterator<Map.Entry<List<?>, TupleBuffer>> i = this.cache.entrySet().iterator(); Map.Entry<List<?>, TupleBuffer> entry = i.next(); TupleBuffer buffer = entry.getValue(); if (buffer.getRowCount() <= 2) { this.smallCache.put(entry.getKey(), buffer); } else { buffer.remove(); TupleBuffer cachedResult = cache.get(cacheKey); if (cachedResult == null) { cachedResult = smallCache.get(cacheKey);
public BlocksIndexInput(VDBResource inputFile) { this.indexFile= inputFile; blockCache= new LRUCache(CACHE_SIZE); }