1 23 24 package org.continuent.sequoia.controller.cache.result; 25 26 import java.util.Collection ; 27 import java.util.Iterator ; 28 29 import org.continuent.sequoia.controller.cache.result.entries.AbstractResultCacheEntry; 30 import org.continuent.sequoia.controller.cache.result.schema.CacheDatabaseTable; 31 import org.continuent.sequoia.controller.requests.AbstractRequest; 32 import org.continuent.sequoia.controller.requests.ParsingGranularities; 33 import org.continuent.sequoia.controller.requests.SelectRequest; 34 import org.continuent.sequoia.controller.requests.UpdateRequest; 35 36 47 public class ResultCacheTable extends ResultCache 48 { 49 55 public ResultCacheTable(int maxEntries, int pendingTimeout) 56 { 57 super(maxEntries, pendingTimeout); 58 parsingGranularity = ParsingGranularities.TABLE; 59 } 60 61 64 protected void processAddToCache(AbstractResultCacheEntry qe) 65 { 66 SelectRequest request = qe.getRequest(); 67 Collection from = request.getFrom(); 68 if (from == null) 69 return; 70 for (Iterator i = from.iterator(); i.hasNext();) 71 cdbs.getTable((String ) i.next()).addCacheEntry(qe); 72 } 73 74 77 public boolean isUpdateNecessary(UpdateRequest request) 78 { 79 return true; 80 } 81 82 85 protected void processWriteNotify(AbstractRequest request) 86 { 87 for (Iterator iter = request.getSemantic().getWriteSet().iterator(); iter 88 .hasNext();) 89 { 90 String tableName = (String ) iter.next(); 91 CacheDatabaseTable cdt = cdbs.getTable(tableName); 92 93 if (cdt != null) 94 cdt.invalidateAll(); 95 else 96 { 97 logger.warn("Table " + tableName 98 + " not found in cache schema. Flushing whole cache."); 99 flushCache(); 100 } 101 } 102 } 103 104 107 public String getName() 108 { 109 return "table"; 110 } 111 } | Popular Tags |