Changeset 2497
- Timestamp:
- Aug 8, 2006, 3:43:08 PM (17 years ago)
- Location:
- trunk/src/core/net/sf/basedb
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/data/FeatureData.java
r2314 r2497 128 128 /** 129 129 Get the reporter of the feature. 130 This property is mapped in the hibernate-properties- AbstractFeatureData.xml file since130 This property is mapped in the hibernate-properties-FeatureData.xml file since 131 131 it must be mapped with a cascade="evict" which is not supported by XDoclet. 132 132 */ -
trunk/src/core/net/sf/basedb/core/query/Hql.java
r2304 r2497 272 272 273 273 /** 274 Same as <code>leftJoin(null, propert, joinedAlias, null )</code>275 @see #leftJoin(String, String, String, Restriction )274 Same as <code>leftJoin(null, propert, joinedAlias, null, false)</code> 275 @see #leftJoin(String, String, String, Restriction, boolean) 276 276 */ 277 277 public static Join leftJoin(String property, String joinedAlias) 278 278 throws InvalidDataException 279 279 { 280 return leftJoin(null, property, joinedAlias, null );280 return leftJoin(null, property, joinedAlias, null, false); 281 281 } 282 282 … … 304 304 </pre> 305 305 306 <p> 307 The <code>fetch</code> parameter is used to fetch the joined data in the 308 same query. This is useful to 309 avoid subsequent queries to the database when you know that you are 310 going to access the joined items in your code. If you are joining a 311 collection the {@link Query#setFirstResult(int)} and {@link Query#setMaxResults(int)} 312 shouldn't be used since the join will create multiple rows for the same 313 root item. 314 315 @param alias The alias to resolve the property against, or null to resolve the 316 property against the root entity 317 @param property The property name of the associated entity (required) 318 @param joinedAlias The alias to give the joined entity (required) 319 @param on Optional extra restriction that is used in the <code>ON</code> clause 320 of the generated query 321 @param fetch If the joined items should be prefetched or not 322 @return A join query element 323 @throws InvalidDataException If the property or joined alias parameter 324 are null or if any of the parameters contains invalid characters 325 */ 326 public static Join leftJoin(String alias, String property, String joinedAlias, Restriction on, boolean fetch) 327 throws InvalidDataException 328 { 329 if (property == null) throw new InvalidUseOfNullException("property"); 330 if (joinedAlias == null) throw new InvalidUseOfNullException("alias"); 331 if (!PROPERTY_REGEXP.matcher(property).matches()) 332 { 333 throw new InvalidDataException("Property '"+property+"' has one or more invalid characters. Only a-z, A-Z, 0-9 and . is allowed."); 334 } 335 if (alias != null && !ALIAS_REGEXP.matcher(alias).matches()) 336 { 337 throw new InvalidDataException("Alias '"+alias+"' has one or more invalid characters. Only a-z, A-Z and 0-9 is allowed."); 338 } 339 if (!ALIAS_REGEXP.matcher(joinedAlias).matches()) 340 { 341 throw new InvalidDataException("Alias '"+joinedAlias+"' has one or more invalid characters. Only a-z, A-Z and 0-9 is allowed."); 342 } 343 return new HqlLeftJoin(alias, property, joinedAlias, on, fetch); 344 } 345 346 /** 347 Same as <code>rightJoin(null, propert, joinedAlias, null)</code> 348 @see #rightJoin(String, String, String, Restriction) 349 */ 350 public static Join rightJoin(String property, String joinedAlias) 351 throws InvalidDataException 352 { 353 return rightJoin(null, property, joinedAlias, null); 354 } 355 356 /** 357 Create a right join query element. A right join selects all items 358 from the joined association even if they don't have an associated item in 359 the root entity. The property must reference an association to another 360 item or collection of values. 361 306 362 @param alias The alias to resolve the property against, or null to resolve the 307 363 property against the root entity … … 314 370 are null or if any of the parameters contains invalid characters 315 371 */ 316 public static Join leftJoin(String alias, String property, String joinedAlias, Restriction on)372 public static Join rightJoin(String alias, String property, String joinedAlias, Restriction on) 317 373 throws InvalidDataException 318 374 { … … 331 387 throw new InvalidDataException("Alias '"+joinedAlias+"' has one or more invalid characters. Only a-z, A-Z and 0-9 is allowed."); 332 388 } 333 return new HqlLeftJoin(alias, property, joinedAlias, on);334 }335 336 /**337 Same as <code>rightJoin(null, propert, joinedAlias, null)</code>338 @see #rightJoin(String, String, String, Restriction)339 */340 public static Join rightJoin(String property, String joinedAlias)341 throws InvalidDataException342 {343 return rightJoin(null, property, joinedAlias, null);344 }345 346 /**347 Create a right join query element. A right join selects all items348 from the joined association even if they don't have an associated item in349 the root entity. The property must reference an association to another350 item or collection of values.351 352 @param alias The alias to resolve the property against, or null to resolve the353 property against the root entity354 @param property The property name of the associated entity (required)355 @param joinedAlias The alias to give the joined entity (required)356 @param on Optional extra restriction that is used in the <code>ON</code> clause357 of the generated query358 @return A join query element359 @throws InvalidDataException If the property or joined alias parameter360 are null or if any of the parameters contains invalid characters361 */362 public static Join rightJoin(String alias, String property, String joinedAlias, Restriction on)363 throws InvalidDataException364 {365 if (property == null) throw new InvalidUseOfNullException("property");366 if (joinedAlias == null) throw new InvalidUseOfNullException("alias");367 if (!PROPERTY_REGEXP.matcher(property).matches())368 {369 throw new InvalidDataException("Property '"+property+"' has one or more invalid characters. Only a-z, A-Z, 0-9 and . is allowed.");370 }371 if (alias != null && !ALIAS_REGEXP.matcher(alias).matches())372 {373 throw new InvalidDataException("Alias '"+alias+"' has one or more invalid characters. Only a-z, A-Z and 0-9 is allowed.");374 }375 if (!ALIAS_REGEXP.matcher(joinedAlias).matches())376 {377 throw new InvalidDataException("Alias '"+joinedAlias+"' has one or more invalid characters. Only a-z, A-Z and 0-9 is allowed.");378 }379 389 return new HqlRightJoin(alias, property, joinedAlias, on); 380 390 } -
trunk/src/core/net/sf/basedb/core/query/HqlLeftJoin.java
r2304 r2497 47 47 private final String joinedAlias; 48 48 private final Restriction on; 49 private final boolean fetch; 49 50 50 HqlLeftJoin(String alias, String property, String joinedAlias, Restriction on )51 HqlLeftJoin(String alias, String property, String joinedAlias, Restriction on, boolean fetch) 51 52 { 52 53 assert property != null : "property == null"; … … 56 57 this.joinedAlias = joinedAlias; 57 58 this.on = on; 59 this.fetch = fetch; 58 60 } 59 61 … … 67 69 if (query.getQueryType() == QueryType.HQL) 68 70 { 69 return "LEFT JOIN "+(alias == null ? query.getRootAlias() : alias) + "." + property + " " + joinedAlias + 71 return "LEFT JOIN " + (fetch && !query.isCounting() ? "FETCH " : "") + 72 (alias == null ? query.getRootAlias() : alias) + "." + property + " " + joinedAlias + 70 73 (on == null ? "" : " WITH " + on.toQl(query, dc)); 71 74 } -
trunk/src/core/net/sf/basedb/util/IntensityCalculatorUtil.java
r2492 r2497 24 24 package net.sf.basedb.util; 25 25 26 import net.sf.basedb.core.DataQuery; 26 27 import net.sf.basedb.core.DbControl; 28 import net.sf.basedb.core.Item; 27 29 import net.sf.basedb.core.RawDataType; 28 30 import net.sf.basedb.core.ArrayDesign; … … 46 48 import net.sf.basedb.core.data.RawData; 47 49 import net.sf.basedb.core.data.ReporterData; 50 import net.sf.basedb.core.query.Hql; 48 51 import net.sf.basedb.core.query.Selects; 49 52 import net.sf.basedb.core.query.Select; … … 275 278 progress.display(10, "Generating spot intensities (0 done)..."); 276 279 } 280 281 /* 282 long total = -System.nanoTime(); 283 long calc = 0; 284 long data = 0; 285 long cnew = 0; 286 long chit = 0; 287 long batt = 0; 288 long brep = 0; 289 long braw = 0; 290 */ 291 277 292 for (RawBioAssay rba : rawBioAssays) 278 293 { … … 286 301 287 302 // Load raw data for current raw bioassay 288 DataResultIterator<RawData> rawData = rba.getRawData().iterate(dc); 303 DataQuery<RawData> rawQuery = rba.getRawData(); 304 rawQuery.join(Hql.leftJoin(null, "reporter", Item.REPORTER.getAlias(), null, true)); 305 if (rba.getArrayDesign() != null) 306 { 307 rawQuery.join(Hql.leftJoin(null, "feature", Item.REPORTER.getAlias(), null, true)); 308 } 309 310 DataResultIterator<RawData> rawData = rawQuery.iterate(dc); 311 //data -= System.nanoTime(); 289 312 while (rawData.hasNext()) 290 313 { … … 292 315 int position = rd.getPosition(); 293 316 ReporterData reporter = rd.getReporter(); 317 //data += System.nanoTime(); 294 318 295 319 // Calculate intensities 320 //calc -= System.nanoTime(); 296 321 float[] intensities = iCalc.calculateIntensities(rd); 322 //calc += System.nanoTime(); 323 297 324 if (intensities != null) 298 325 { … … 300 327 if (positionCache.containsKey(position)) 301 328 { 329 //chit -= System.nanoTime(); 302 330 // A mapping already exists, check if same reporter 303 331 ReporterData cached = positionCache.get(position); 304 if ((reporter == null && cached != null) || (reporter != null && !reporter.equals(cached))) 332 int reporterId = reporter == null ? 0 : reporter.getId(); 333 int cachedId = cached == null ? 0 : cached.getId(); 334 if (reporterId != cachedId) 305 335 { 306 336 // Same position but different reporter, must assign different position … … 330 360 positionCache.put(position, reporter); 331 361 } 362 //chit += System.nanoTime(); 332 363 } 333 364 else 334 365 { 335 366 // New position, insert reporter mapping 367 //brep -= System.nanoTime(); 336 368 posBatcher.insert(position, reporter); 369 //brep += System.nanoTime(); 370 //cnew -= System.nanoTime(); 337 371 positionCache.put(position, reporter); 372 //cnew += System.nanoTime(); 338 373 } 374 //braw -= System.nanoTime(); 339 375 // Insert mapping to raw data spot 340 376 rawBatcher.insert(column, position, rd); 377 //braw += System.nanoTime(); 341 378 // Insert intensities 379 //batt -= System.nanoTime(); 342 380 spotBatcher.insert(column, position, intensities); 381 //batt += System.nanoTime(); 343 382 } 344 383 if (progress != null) … … 351 390 } 352 391 } 353 } 392 //data -= System.nanoTime(); 393 } 394 //data += System.nanoTime(); 354 395 } 355 396 if (progress != null) progress.display(100, "Generating spot intensities ("+totalSpots+" done)...\n"); 356 397 398 //total += System.nanoTime(); 399 400 /* 401 System.out.println("Total time: " + (total / 1000000) + " ms"); 402 System.out.println("Intensity : " + (calc / 1000000) + " ms"); 403 System.out.println("Load data : " + (data / 1000000) + " ms"); 404 System.out.println("New pos : " + (cnew / 1000000) + " ms"); 405 System.out.println("Cached pos: " + (chit / 1000000) + " ms"); 406 System.out.println("Batch data: " + (batt / 1000000) + " ms"); 407 System.out.println("Batch rep : " + (brep / 1000000) + " ms"); 408 System.out.println("Batch raw : " + (braw / 1000000) + " ms"); 409 */ 410 357 411 // Close batchers and clean up 358 412 positionCache.clear();
Note: See TracChangeset
for help on using the changeset viewer.