Revision 1297
Added by Jing Tao over 22 years ago
src/edu/ucsb/nceas/metacat/DBQuery.java | ||
---|---|---|
234 | 234 |
QuerySpecification qspec = new QuerySpecification(xmlquery, |
235 | 235 |
parserName, |
236 | 236 |
util.getOption("accNumSeparator")); |
237 |
//System.out.println(qspec.printSQL(useXMLIndex)); |
|
238 |
pstmt = dbconn.prepareStatement( qspec.printSQL(useXMLIndex) ); |
|
237 |
String query = qspec.printSQL(useXMLIndex); |
|
238 |
MetaCatUtil.debugMessage("query: "+query, 30); |
|
239 |
//System.out.println(qspec.printSQL(useXMLIndex)); |
|
240 |
double startTime = System.currentTimeMillis()/1000; |
|
241 |
pstmt = dbconn.prepareStatement(query); |
|
239 | 242 |
|
240 | 243 |
// Execute the SQL query using the JDBC connection |
241 | 244 |
pstmt.execute(); |
242 | 245 |
ResultSet rs = pstmt.getResultSet(); |
246 |
double queryExecuteTime =System.currentTimeMillis()/1000; |
|
247 |
MetaCatUtil.debugMessage("Time for execute query: "+ |
|
248 |
(queryExecuteTime -startTime), 30); |
|
243 | 249 |
boolean tableHasRows = rs.next(); |
244 | 250 |
while (tableHasRows) |
245 | 251 |
{ |
246 | 252 |
docid = rs.getString(1).trim(); |
247 |
if ( !hasPermission(user, groups, docid) ) { |
|
253 |
long checkTimeStart = System.currentTimeMillis(); |
|
254 |
boolean permit =hasPermission(user, groups, docid); |
|
255 |
long checkTimeEnd = System.currentTimeMillis(); |
|
256 |
MetaCatUtil.debugMessage("check permission time: "+ |
|
257 |
(checkTimeEnd - checkTimeStart), 30); |
|
258 |
if ( !permit ) { |
|
248 | 259 |
// Advance to the next record in the cursor |
249 | 260 |
tableHasRows = rs.next(); |
250 | 261 |
continue; |
251 | 262 |
} |
263 |
|
|
252 | 264 |
docname = rs.getString(2); |
253 | 265 |
doctype = rs.getString(3); |
254 | 266 |
createDate = rs.getString(4); |
... | ... | |
377 | 389 |
} |
378 | 390 |
rs.close(); |
379 | 391 |
pstmt.close(); |
392 |
double docListTime =System.currentTimeMillis()/1000; |
|
393 |
MetaCatUtil.debugMessage("prepare docid list time: " |
|
394 |
+(docListTime-queryExecuteTime), 30); |
|
380 | 395 |
|
381 | 396 |
if (qspec.containsExtendedSQL()) |
382 | 397 |
{ |
... | ... | |
393 | 408 |
if (doclist.length() > 0) { |
394 | 409 |
doclist.deleteCharAt(doclist.length()-1); //remove the last comma |
395 | 410 |
//pstmt.close(); |
396 |
pstmt = dbconn.prepareStatement(qspec.printExtendedSQL( |
|
397 |
doclist.toString())); |
|
411 |
double extendedQueryStart = System.currentTimeMillis()/1000; |
|
412 |
String extendedQuery = qspec.printExtendedSQL(doclist.toString()); |
|
413 |
MetaCatUtil.debugMessage("Extended query: "+ extendedQuery, 30); |
|
414 |
pstmt = dbconn.prepareStatement(extendedQuery); |
|
398 | 415 |
//increase dbconnection usage count |
399 | 416 |
dbconn.increaseUsageCount(1); |
400 | 417 |
pstmt.execute(); |
401 | 418 |
rs = pstmt.getResultSet(); |
419 |
double extendedQueryEnd = System.currentTimeMillis()/1000; |
|
420 |
MetaCatUtil.debugMessage("Time for execute extended query: " |
|
421 |
+(extendedQueryEnd-extendedQueryStart), 30); |
|
402 | 422 |
tableHasRows = rs.next(); |
403 | 423 |
while(tableHasRows) |
404 | 424 |
{ |
405 | 425 |
docid = rs.getString(1).trim(); |
406 |
if ( !hasPermission(user, groups, docid) ) { |
|
426 |
//if ( !hasPermission(user, groups, docid) ) {
|
|
407 | 427 |
// Advance to the next record in the cursor |
408 |
tableHasRows = rs.next(); |
|
409 |
continue; |
|
410 |
} |
|
428 |
//tableHasRows = rs.next();
|
|
429 |
//continue;
|
|
430 |
//}
|
|
411 | 431 |
fieldname = rs.getString(2); |
412 | 432 |
fielddata = rs.getString(3); |
413 | 433 |
|
... | ... | |
430 | 450 |
docListResult.put(docid, document.toString()); |
431 | 451 |
} |
432 | 452 |
} |
453 |
double docListResultEnd = System.currentTimeMillis()/1000; |
|
454 |
MetaCatUtil.debugMessage("Time for prepare doclistresult after"+ |
|
455 |
" execute extended query: " |
|
456 |
+(docListResultEnd-extendedQueryEnd), 30); |
|
433 | 457 |
} |
434 | 458 |
rs.close(); |
435 | 459 |
} |
... | ... | |
437 | 461 |
|
438 | 462 |
//this loop adds the relation data to the resultdoc |
439 | 463 |
//this code might be able to be added to the backtracking code above |
464 |
double startRelation = System.currentTimeMillis()/1000; |
|
440 | 465 |
Enumeration docidkeys = docListResult.keys(); |
441 | 466 |
while(docidkeys.hasMoreElements()) |
442 | 467 |
{ |
... | ... | |
482 | 507 |
rs.close(); |
483 | 508 |
pstmt.close(); |
484 | 509 |
} |
510 |
double endRelation = System.currentTimeMillis()/1000; |
|
511 |
MetaCatUtil.debugMessage("Time for adding relation to docListResult: "+ |
|
512 |
(endRelation-startRelation), 30); |
|
485 | 513 |
|
486 | 514 |
} catch (SQLException e) { |
487 | 515 |
System.err.println("SQL Error in DBQuery.findDocuments: " + |
... | ... | |
546 | 574 |
while (tableHasRows) |
547 | 575 |
{ |
548 | 576 |
result.add(rs.getString(1)); |
549 |
System.out.println(rs.getString(1)); |
|
577 |
//System.out.println(rs.getString(1));
|
|
550 | 578 |
tableHasRows = rs.next(); |
551 | 579 |
} |
552 | 580 |
} |
Also available in: Unified diff
Delete the code for permission checking in execute extened query. It was redundant. Add some debug message for displaying search time.