Changeset 4829
- Timestamp:
- Mar 23, 2009, 3:28:03 PM (13 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/clients/web/net/sf/basedb/clients/web/ExperimentExplorer.java
r4815 r4829 36 36 import javax.servlet.jsp.PageContext; 37 37 38 import net.sf.basedb.util.StaticCache; 38 39 import net.sf.basedb.util.Values; 39 40 import net.sf.basedb.clients.web.formatter.FormatterFactory; 40 41 import net.sf.basedb.clients.web.taglib.table.TableColumn; 41 42 import net.sf.basedb.core.AnnotationType; 43 import net.sf.basedb.core.Application; 42 44 import net.sf.basedb.core.BaseException; 43 45 import net.sf.basedb.core.BioAssay; … … 848 850 } 849 851 852 @SuppressWarnings("unchecked") 850 853 private void initReporterCache(DbControl dc) 851 854 { … … 854 857 if (posCache == null) 855 858 { 856 Select spotPos = Dynamic.select(VirtualTable.SPOT, VirtualColumn.POSITION); 857 DynamicSpotQuery posQuery = bas.getSpotData(); 858 posQuery.select(spotPos); 859 posQuery.order(Orders.asc(Expressions.selected(spotPos))); 860 posQuery.setDistinct(true); 861 DynamicResultIterator it = posQuery.iterate(dc); 862 List<Integer> posList = new ArrayList<Integer>(bas.getNumReporters()); 863 try 864 { 865 while (it.hasNext()) 859 StaticCache staticCache = Application.getStaticCache(); 860 String cacheKey = "explorer/bioassayset." + bas.getId() + "/poslist.ser"; 861 List<Integer> posList = (List<Integer>)staticCache.load(cacheKey, 100); 862 if (posList == null) 863 { 864 Select spotPos = Dynamic.select(VirtualTable.SPOT, VirtualColumn.POSITION); 865 DynamicSpotQuery posQuery = bas.getSpotData(); 866 posQuery.select(spotPos); 867 posQuery.order(Orders.asc(Expressions.selected(spotPos))); 868 posQuery.setDistinct(true); 869 DynamicResultIterator it = posQuery.iterate(dc); 870 posList = new ArrayList<Integer>(bas.getNumReporters()); 871 try 866 872 { 867 posList.add(it.next().getInt(1)); 873 while (it.hasNext()) 874 { 875 posList.add(it.next().getInt(1)); 876 } 877 staticCache.store(cacheKey, posList, 100); 868 878 } 869 }870 catch (SQLException ex)871 {872 throw new BaseException(ex);873 }874 finally875 {876 it.close();879 catch (SQLException ex) 880 { 881 throw new BaseException(ex); 882 } 883 finally 884 { 885 it.close(); 886 } 877 887 } 878 888 posCache = new int[posList.size()]; -
trunk/src/core/net/sf/basedb/core/VirtualColumn.java
r4817 r4829 92 92 !INDEXED, !NULLABLE, PRIMARY_KEY); 93 93 94 /**95 This column stores the (indexed) data cube position coordinate.96 */97 public static final VirtualColumn INDEXED_POSITION =98 new VirtualColumn("position", "position", Hibernate.INTEGER, 0,99 INDEXED, !NULLABLE, PRIMARY_KEY);100 101 94 /** 102 95 This column stores the data cube filter number. -
trunk/src/core/net/sf/basedb/core/VirtualTable.java
r4817 r4829 57 57 VirtualColumn.LAYER, 58 58 VirtualColumn.COLUMN, 59 VirtualColumn. INDEXED_POSITION59 VirtualColumn.POSITION 60 60 ) 61 61 { -
trunk/src/core/net/sf/basedb/util/StaticCache.java
r4827 r4829 53 53 with the any of the {@link #read(String, int)} or {@link #write(String, InputStream, int)} 54 54 methods and their variants. It can also be used to store any {@link Serializable} 55 object with {@link #store(String, Serializable, int)} and {@link #load(String, int)}.55 object with {@link #store(String, Object, int)} and {@link #load(String, int)}. 56 56 <p> 57 57 … … 305 305 306 306 @param key The cache key 307 @param object The object to store in the cache 307 @param object The object to store in the cache, it must be a 308 {@link Serializable} object 308 309 @param timeout A timeout in milliseconds to wait for a write lock 309 310 on the requested cache entry 310 311 @return TRUE if the object could be stored, FALSE otherwise 311 312 */ 312 public boolean store(String key, Serializable object, int timeout) 313 throws IOException 313 public boolean store(String key, Object object, int timeout) 314 314 { 315 315 if (disabled) return false; 316 316 OutputStream out = null; 317 boolean stored = false; 317 318 try 318 319 { … … 323 324 oos.writeObject(object); 324 325 oos.flush(); 325 } 326 stored = true; 327 } 328 } 329 catch (IOException ex) 330 { 331 log.warn("Could not store cached entry: " + key, ex); 326 332 } 327 333 finally 328 334 { 329 if (out != null) out.close(); 330 } 331 return true; 335 if (out != null) 336 { 337 try 338 { 339 out.close(); 340 } 341 catch (IOException ex) 342 {} 343 } 344 } 345 return stored; 332 346 } 333 347 … … 341 355 exists or if a read lock couldn't be aquired 342 356 */ 343 public Serializable load(String key, int timeout) 344 throws IOException 357 public Object load(String key, int timeout) 345 358 { 346 359 if (disabled) return null; … … 363 376 } 364 377 } 378 catch (IOException ex) 379 { 380 log.warn("Could not load cached entry: " + key, ex); 381 } 365 382 finally 366 383 { 367 if (in != null) in.close(); 384 if (in != null) 385 { 386 try 387 { 388 in.close(); 389 } 390 catch (IOException ex) 391 {} 392 } 368 393 } 369 394 return object;
Note: See TracChangeset
for help on using the changeset viewer.