incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r951095 - in /incubator/lcf/trunk/modules/framework: core/org/apache/lcf/core/database/ core/org/apache/lcf/core/interfaces/ crawler-ui/ pull-agent/org/apache/lcf/crawler/jobs/ pull-agent/org/apache/lcf/crawler/repository/
Date Thu, 03 Jun 2010 18:20:54 GMT
Author: kwright
Date: Thu Jun  3 18:20:53 2010
New Revision: 951095

URL: http://svn.apache.org/viewvc?rev=951095&view=rev
Log:
Get reports working with Derby, as well as OFFSETs.

Modified:
    incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/BaseTable.java
    incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/DBInterfaceDerby.java
    incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/DBInterfaceMySQL.java
    incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/DBInterfacePostgreSQL.java
    incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/interfaces/IDBInterface.java
    incubator/lcf/trunk/modules/framework/crawler-ui/documentstatus.jsp
    incubator/lcf/trunk/modules/framework/crawler-ui/simplereport.jsp
    incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/jobs/HopCount.java
    incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/jobs/JobManager.java
    incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/jobs/JobQueue.java
    incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/jobs/Jobs.java
    incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/repository/RepositoryHistoryManager.java

Modified: incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/BaseTable.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/BaseTable.java?rev=951095&r1=951094&r2=951095&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/BaseTable.java
(original)
+++ incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/BaseTable.java
Thu Jun  3 18:20:53 2010
@@ -283,14 +283,27 @@ public class BaseTable
     return CacheKeyFactory.makeTableKey(null,tableName,dbInterface.getDatabaseName());
   }
 
-  /** Construct a limit clause.
-  * This method constructs a limit clause in the proper manner for the database in question.
-  *@param limit is the limit number.
+  /** Construct a regular-expression match clause.
+  * This method builds both the text part of a regular-expression match.
+  *@param column is the column specifier string.
+  *@param regularExpression is the properly-quoted regular expression string, or "?" if a
parameterized value is to be used.
+  *@param caseInsensitive is true of the regular expression match is to be case insensitive.
+  *@return the query chunk needed, not padded with spaces on either side.
+  */
+  public String constructRegexpClause(String column, String regularExpression, boolean caseInsensitive)
+  {
+    return dbInterface.constructRegexpClause(column,regularExpression,caseInsensitive);
+  }
+  
+  /** Construct an offset/limit clause.
+  * This method constructs an offset/limit clause in the proper manner for the database in
question.
+  *@param offset is the starting offset number.
+  *@param limit is the limit of result rows to return.
   *@return the proper clause, with no padding spaces on either side.
   */
-  public String constructLimitClause(int limit)
+  public String constructOffsetLimitClause(int offset, int limit)
   {
-    return dbInterface.constructLimitClause(limit);
+    return dbInterface.constructOffsetLimitClause(offset,limit);
   }
 
   /** Quote a sql string.

Modified: incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/DBInterfaceDerby.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/DBInterfaceDerby.java?rev=951095&r1=951094&r2=951095&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/DBInterfaceDerby.java
(original)
+++ incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/DBInterfaceDerby.java
Thu Jun  3 18:20:53 2010
@@ -373,7 +373,7 @@ public class DBInterfaceDerby extends Da
   protected static String mapType(String inputType)
   {
     if (inputType.equalsIgnoreCase("longtext"))
-      return "clob";
+      return "CLOB";
     return inputType;
   }
 
@@ -771,14 +771,37 @@ public class DBInterfaceDerby extends Da
     }
   }
 
-  /** Construct a limit clause.
-  * This method constructs a limit clause in the proper manner for the database in question.
-  *@param limit is the limit number.
+  /** Construct a regular-expression match clause.
+  * This method builds both the text part of a regular-expression match.
+  *@param column is the column specifier string.
+  *@param regularExpression is the properly-quoted regular expression string, or "?" if a
parameterized value is to be used.
+  *@param caseInsensitive is true of the regular expression match is to be case insensitive.
+  *@return the query chunk needed, not padded with spaces on either side.
+  */
+  public String constructRegexpClause(String column, String regularExpression, boolean caseInsensitive)
+  {
+    // MHL to invoke a stored procedure
+    return column + " LIKE " + regularExpression;
+  }
+
+  /** Construct an offset/limit clause.
+  * This method constructs an offset/limit clause in the proper manner for the database in
question.
+  *@param offset is the starting offset number.
+  *@param limit is the limit of result rows to return.
   *@return the proper clause, with no padding spaces on either side.
   */
-  public String constructLimitClause(int limit)
+  public String constructOffsetLimitClause(int offset, int limit)
   {
-    return "";
+    StringBuffer sb = new StringBuffer();
+    if (offset != 0)
+      sb.append("OFFSET ").append(Integer.toString(offset)).append(" ROWS");
+    if (limit != -1)
+    {
+      if (offset != 0)
+        sb.append(" ");
+      sb.append("FETCH NEXT ").append(Integer.toString(limit)).append(" ROWS ONLY");
+    }
+    return sb.toString();
   }
 
   /** Quote a sql string.

Modified: incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/DBInterfaceMySQL.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/DBInterfaceMySQL.java?rev=951095&r1=951094&r2=951095&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/DBInterfaceMySQL.java
(original)
+++ incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/DBInterfaceMySQL.java
Thu Jun  3 18:20:53 2010
@@ -574,14 +574,37 @@ public class DBInterfaceMySQL extends Da
     return executeQuery(query,params,cacheKeys,null,queryClass,true,maxResults,resultSpec,returnLimit);
   }
 
-  /** Construct a limit clause.
-  * This method constructs a limit clause in the proper manner for the database in question.
-  *@param limit is the limit number.
+  /** Construct a regular-expression match clause.
+  * This method builds both the text part of a regular-expression match.
+  *@param column is the column specifier string.
+  *@param regularExpression is the properly-quoted regular expression string, or "?" if a
parameterized value is to be used.
+  *@param caseInsensitive is true of the regular expression match is to be case insensitive.
+  *@return the query chunk needed, not padded with spaces on either side.
+  */
+  public String constructRegexpClause(String column, String regularExpression, boolean caseInsensitive)
+  {
+    // MHL - do what MySQL requires, whatever that is...
+    return column + " LIKE " + regularExpression;
+  }
+
+  /** Construct an offset/limit clause.
+  * This method constructs an offset/limit clause in the proper manner for the database in
question.
+  *@param offset is the starting offset number.
+  *@param limit is the limit of result rows to return.
   *@return the proper clause, with no padding spaces on either side.
   */
-  public String constructLimitClause(int limit)
+  public String constructOffsetLimitClause(int offset, int limit)
   {
-    return "LIMIT "+Integer.toString(limit);
+    StringBuffer sb = new StringBuffer();
+    if (offset != 0)
+      sb.append("OFFSET ").append(Integer.toString(offset));
+    if (limit != -1)
+    {
+      if (offset != 0)
+        sb.append(" ");
+      sb.append("LIMIT ").append(Integer.toString(limit));
+    }
+    return sb.toString();
   }
 
   /** Quote a sql string.

Modified: incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/DBInterfacePostgreSQL.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/DBInterfacePostgreSQL.java?rev=951095&r1=951094&r2=951095&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/DBInterfacePostgreSQL.java
(original)
+++ incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/database/DBInterfacePostgreSQL.java
Thu Jun  3 18:20:53 2010
@@ -801,14 +801,36 @@ public class DBInterfacePostgreSQL exten
     }
   }
 
-  /** Construct a limit clause.
-  * This method constructs a limit clause in the proper manner for the database in question.
-  *@param limit is the limit number.
+  /** Construct a regular-expression match clause.
+  * This method builds both the text part of a regular-expression match.
+  *@param column is the column specifier string.
+  *@param regularExpression is the properly-quoted regular expression string, or "?" if a
parameterized value is to be used.
+  *@param caseInsensitive is true of the regular expression match is to be case insensitive.
+  *@return the query chunk needed, not padded with spaces on either side.
+  */
+  public String constructRegexpClause(String column, String regularExpression, boolean caseInsensitive)
+  {
+    return column + "~" + (caseInsensitive?"*":"") + regularExpression;
+  }
+
+  /** Construct an offset/limit clause.
+  * This method constructs an offset/limit clause in the proper manner for the database in
question.
+  *@param offset is the starting offset number.
+  *@param limit is the limit of result rows to return.
   *@return the proper clause, with no padding spaces on either side.
   */
-  public String constructLimitClause(int limit)
+  public String constructOffsetLimitClause(int offset, int limit)
   {
-    return "LIMIT "+Integer.toString(limit);
+    StringBuffer sb = new StringBuffer();
+    if (offset != 0)
+      sb.append("OFFSET ").append(Integer.toString(offset));
+    if (limit != -1)
+    {
+      if (offset != 0)
+        sb.append(" ");
+      sb.append("LIMIT ").append(Integer.toString(limit));
+    }
+    return sb.toString();
   }
 
   /** Quote a sql string.

Modified: incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/interfaces/IDBInterface.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/interfaces/IDBInterface.java?rev=951095&r1=951094&r2=951095&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/interfaces/IDBInterface.java
(original)
+++ incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/interfaces/IDBInterface.java
Thu Jun  3 18:20:53 2010
@@ -273,12 +273,22 @@ public interface IDBInterface
     int maxResults, ResultSpecification resultSpec, ILimitChecker returnLimit)
     throws LCFException;
 
-  /** Construct a limit clause.
-  * This method constructs a limit clause in the proper manner for the database in question.
-  *@param limit is the limit number.
+  /** Construct a regular-expression match clause.
+  * This method builds both the text part of a regular-expression match.
+  *@param column is the column specifier string.
+  *@param regularExpression is the properly-quoted regular expression string, or "?" if a
parameterized value is to be used.
+  *@param caseInsensitive is true of the regular expression match is to be case insensitive.
+  *@return the query chunk needed, not padded with spaces on either side.
+  */
+  public String constructRegexpClause(String column, String regularExpression, boolean caseInsensitive);
+  
+  /** Construct an offset/limit clause.
+  * This method constructs an offset/limit clause in the proper manner for the database in
question.
+  *@param offset is the starting offset number.
+  *@param limit is the limit of result rows to return.
   *@return the proper clause, with no padding spaces on either side.
   */
-  public String constructLimitClause(int limit);
+  public String constructOffsetLimitClause(int offset, int limit);
   
   /** Quote a sql string.
   * This method quotes a sql string in the proper manner for the database in question.

Modified: incubator/lcf/trunk/modules/framework/crawler-ui/documentstatus.jsp
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/crawler-ui/documentstatus.jsp?rev=951095&r1=951094&r2=951095&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/framework/crawler-ui/documentstatus.jsp (original)
+++ incubator/lcf/trunk/modules/framework/crawler-ui/documentstatus.jsp Thu Jun  3 18:20:53
2010
@@ -398,7 +398,7 @@ if (maintenanceUnderway == false)
 
 		<table class="displaytable">
 		    <tr class="headerrow">
-			<td class="reportcolumnheader"><a href="javascript:void(0);" onclick='javascript:ColumnClick("identifier");'><nobr>Identifier</nobr></a></td>
+			<td class="reportcolumnheader"><nobr>Identifier</nobr></td>
 			<td class="reportcolumnheader"><a href="javascript:void(0);" onclick='javascript:ColumnClick("job");'><nobr>Job</nobr></a></td>
 			<td class="reportcolumnheader"><a href="javascript:void(0);" onclick='javascript:ColumnClick("state");'><nobr>State</nobr></a></td>
 			<td class="reportcolumnheader"><a href="javascript:void(0);" onclick='javascript:ColumnClick("status");'><nobr>Status</nobr></a></td>

Modified: incubator/lcf/trunk/modules/framework/crawler-ui/simplereport.jsp
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/crawler-ui/simplereport.jsp?rev=951095&r1=951094&r2=951095&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/framework/crawler-ui/simplereport.jsp (original)
+++ incubator/lcf/trunk/modules/framework/crawler-ui/simplereport.jsp Thu Jun  3 18:20:53
2010
@@ -683,11 +683,11 @@ if (maintenanceUnderway == false)
 		    <tr class="headerrow">
 			<td class="reportcolumnheader"><a href="javascript:void(0);" onclick='javascript:ColumnClick("starttime");'><nobr>Start
Time</nobr></a></td>
 			<td class="reportcolumnheader"><a href="javascript:void(0);" onclick='javascript:ColumnClick("activity");'><nobr>Activity</nobr></a></td>
-			<td class="reportcolumnheader"><a href="javascript:void(0);" onclick='javascript:ColumnClick("identifier");'><nobr>Identifier</nobr></a></td>
+			<td class="reportcolumnheader"><nobr>Identifier</nobr></td>
 			<td class="reportcolumnheader"><a href="javascript:void(0);" onclick='javascript:ColumnClick("resultcode");'><nobr>Result
Code</nobr></a></td>
 			<td class="reportcolumnheader"><a href="javascript:void(0);" onclick='javascript:ColumnClick("bytes");'><nobr>Bytes</nobr></a></td>
 			<td class="reportcolumnheader"><a href="javascript:void(0);" onclick='javascript:ColumnClick("elapsedtime");'><nobr>Time</nobr></a></td>
-			<td class="reportcolumnheader"><a href="javascript:void(0);" onclick='javascript:ColumnClick("resultdesc");'><nobr>Result
Description</nobr></a></td>
+			<td class="reportcolumnheader"><nobr>Result Description</nobr></td>
 		    </tr>
 <%
 		zz = 0;

Modified: incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/jobs/HopCount.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/jobs/HopCount.java?rev=951095&r1=951094&r2=951095&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/jobs/HopCount.java
(original)
+++ incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/jobs/HopCount.java
Thu Jun  3 18:20:53 2010
@@ -678,7 +678,7 @@ public class HopCount extends org.apache
     list.add(jobID);
     list.add(markToString(MARK_QUEUED));
     IResultSet set = performQuery("SELECT "+linkTypeField+","+parentIDHashField+" FROM "+
-      getTableName()+" WHERE "+jobIDField+"=? AND "+markForDeathField+"=? "+constructLimitClause(200)+"
FOR UPDATE",list,null,null,200);
+      getTableName()+" WHERE "+jobIDField+"=? AND "+markForDeathField+"=? "+constructOffsetLimitClause(0,200)+"
FOR UPDATE",list,null,null,200);
 
     // No more entries == we are done
     if (set.getRowCount() == 0)

Modified: incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/jobs/JobManager.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/jobs/JobManager.java?rev=951095&r1=951094&r2=951095&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/jobs/JobManager.java
(original)
+++ incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/jobs/JobManager.java
Thu Jun  3 18:20:53 2010
@@ -844,7 +844,7 @@ public class JobManager implements IJobM
           database.quoteSQLString(jobQueue.statusToString(jobQueue.STATUS_ACTIVENEEDRESCAN))+","+
           database.quoteSQLString(jobQueue.statusToString(jobQueue.STATUS_ACTIVENEEDRESCANPURGATORY))+","+
           database.quoteSQLString(jobQueue.statusToString(jobQueue.STATUS_BEINGDELETED))+
-          ")) "+database.constructLimitClause(maxCount),
+          ")) "+database.constructOffsetLimitClause(0,maxCount),
           null,null,null,maxCount,null);
 
         if (Logging.perf.isDebugEnabled())
@@ -1108,7 +1108,7 @@ public class JobManager implements IJobM
       .append(jobQueue.prioritySetField).append("<? AND ").append(jobQueue.statusField).append("
IN(")
       .append(database.quoteSQLString(jobQueue.statusToString(JobQueue.STATUS_COMPLETE))).append(",")
       .append(database.quoteSQLString(jobQueue.statusToString(JobQueue.STATUS_PURGATORY))).append(")")
-      .append(" ").append(database.constructLimitClause(n));
+      .append(" ").append(database.constructOffsetLimitClause(0,n));
     list.add(new Long(currentTime));
 
     IResultSet set = database.performQuery(sb.toString(),list,null,null,n,null);
@@ -1170,7 +1170,7 @@ public class JobManager implements IJobM
       .append(database.quoteSQLString(JobQueue.statusToString(jobQueue.STATUS_PENDINGPURGATORY))).append(")
AND (")
       .append(jobQueue.checkActionField).append(" IS NULL OR ")
       .append(jobQueue.checkActionField).append("=").append(database.quoteSQLString(jobQueue.actionToString(JobQueue.ACTION_RESCAN)))
-      .append(") ").append(database.constructLimitClause(n));
+      .append(") ").append(database.constructOffsetLimitClause(0,n));
     list.add(new Long(currentTime));
 
     // Analyze jobqueue tables unconditionally, since it's become much more sensitive in
8.3 than it used to be.
@@ -1334,7 +1334,7 @@ public class JobManager implements IJobM
       .append(database.quoteSQLString(jobQueue.statusToString(jobQueue.STATUS_ACTIVENEEDRESCANPURGATORY))).append(",")
       .append(database.quoteSQLString(jobQueue.statusToString(jobQueue.STATUS_BEINGDELETED)))
       .append("))");
-    sb.append(" ").append(database.constructLimitClause(n));
+    sb.append(" ").append(database.constructOffsetLimitClause(0,n));
 
     // Analyze jobqueue tables unconditionally, since it's become much more sensitive in
8.3 than it used to be.
     jobQueue.unconditionallyAnalyzeTables();
@@ -1721,7 +1721,7 @@ public class JobManager implements IJobM
       .append(jobQueue.checkActionField).append("=?")
       .append(") AND (")
       .append(jobQueue.statusField).append("=? OR ").append(jobQueue.statusField).append("=?)")
-      .append(" ORDER BY ").append(jobQueue.docPriorityField).append(" ASC ").append(database.constructLimitClause(1));
+      .append(" ORDER BY ").append(jobQueue.docPriorityField).append(" ASC ").append(database.constructOffsetLimitClause(0,1));
 
     list.add(currentTimeValue);
     list.add(jobQueue.actionToString(JobQueue.ACTION_RESCAN));
@@ -1837,7 +1837,7 @@ public class JobManager implements IJobM
 
       // Now we can tack the limit onto the query.  Before this point, remainingDocuments
would be crap
       int limitValue = vList.getRemainingDocuments();
-      sb.append(database.constructLimitClause(limitValue));
+      sb.append(database.constructOffsetLimitClause(0,limitValue));
 
       if (Logging.perf.isDebugEnabled())
       {
@@ -5069,7 +5069,7 @@ public class JobManager implements IJobM
             "("+jobQueue.jobIDField+"=? AND "+jobQueue.statusField+"=?) OR "+
             "("+jobQueue.jobIDField+"=? AND "+jobQueue.statusField+"=?) OR "+
             "("+jobQueue.jobIDField+"=? AND "+jobQueue.statusField+"=?) OR "+
-            "("+jobQueue.jobIDField+"=? AND "+jobQueue.statusField+"=?) "+database.constructLimitClause(1),list,null,null,1,null);
+            "("+jobQueue.jobIDField+"=? AND "+jobQueue.statusField+"=?) "+database.constructOffsetLimitClause(0,1),list,null,null,1,null);
 
           if (confirmSet.getRowCount() > 0)
             continue;
@@ -5210,7 +5210,7 @@ public class JobManager implements IJobM
             "("+jobQueue.jobIDField+"=? AND "+jobQueue.statusField+"=?) OR "+
             "("+jobQueue.jobIDField+"=? AND "+jobQueue.statusField+"=?) OR "+
             "("+jobQueue.jobIDField+"=? AND "+jobQueue.statusField+"=?) OR "+
-            "("+jobQueue.jobIDField+"=? AND "+jobQueue.statusField+"=?) "+database.constructLimitClause(1),list,null,null,1,null);
+            "("+jobQueue.jobIDField+"=? AND "+jobQueue.statusField+"=?) "+database.constructOffsetLimitClause(0,1),list,null,null,1,null);
 
           if (confirmSet.getRowCount() > 0)
             continue;
@@ -5298,7 +5298,7 @@ public class JobManager implements IJobM
             "("+jobQueue.jobIDField+"=? AND "+jobQueue.statusField+"=?) OR "+
             "("+jobQueue.jobIDField+"=? AND "+jobQueue.statusField+"=?) OR "+
             "("+jobQueue.jobIDField+"=? AND "+jobQueue.statusField+"=?) OR "+
-            "("+jobQueue.jobIDField+"=? AND "+jobQueue.statusField+"=?) "+database.constructLimitClause(1),list,null,null,1,null);
+            "("+jobQueue.jobIDField+"=? AND "+jobQueue.statusField+"=?) "+database.constructOffsetLimitClause(0,1),list,null,null,1,null);
 
           if (confirmSet.getRowCount() > 0)
             continue;
@@ -5397,7 +5397,7 @@ public class JobManager implements IJobM
           IResultSet confirmSet = database.performQuery("SELECT "+jobQueue.idField+" FROM
"+
             jobQueue.getTableName()+" WHERE "+
             "("+jobQueue.jobIDField+"=? AND "+jobQueue.statusField+"=?) OR "+
-            "("+jobQueue.jobIDField+"=? AND "+jobQueue.statusField+"=?) "+database.constructLimitClause(1),list,null,null,1,null);
+            "("+jobQueue.jobIDField+"=? AND "+jobQueue.statusField+"=?) "+database.constructOffsetLimitClause(0,1),list,null,null,1,null);
 
           if (confirmSet.getRowCount() > 0)
             continue;
@@ -5693,7 +5693,8 @@ public class JobManager implements IJobM
     // Build the query.
     Long currentTime = new Long(System.currentTimeMillis());
     StringBuffer sb = new StringBuffer("SELECT ");
-    sb.append("t0.").append(jobQueue.docIDField).append(" AS identifier,")
+    sb.append("t0.").append(jobQueue.idField).append(" AS id,")
+      .append("t0.").append(jobQueue.docIDField).append(" AS identifier,")
       .append("t1.").append(jobs.descriptionField).append(" AS job,")
       .append("CASE")
       .append(" WHEN ").append("t0.").append(jobQueue.statusField).append("=").append(database.quoteSQLString(jobQueue.statusToString(jobQueue.STATUS_PENDING))).append("
THEN 'Not yet processed'")
@@ -5775,7 +5776,8 @@ public class JobManager implements IJobM
       .append(" FROM ").append(jobQueue.getTableName()).append(" t0,").append(jobs.getTableName()).append("
t1 WHERE ")
       .append("t0.").append(jobQueue.jobIDField).append("=t1.").append(jobs.idField);
     addCriteria(sb,"t0.",connectionName,filterCriteria,true);
-    addOrdering(sb,new String[]{"identifier","job","state","status","scheduled","action","retrycount","retrylimit"},sortOrder);
+    // The intrinsic ordering is provided by the "id" column, and nothing else.
+    addOrdering(sb,new String[]{"id"},sortOrder);
     addLimits(sb,startRow,rowCount);
     return database.performQuery(sb.toString(),null,null,null,rowCount,null);
   }
@@ -5943,10 +5945,7 @@ public class JobManager implements IJobM
     if (identifierRegexp != null)
     {
       whereEmitted = emitClauseStart(sb,whereEmitted);
-      sb.append(fieldPrefix).append(jobQueue.docIDField).append("~");
-      if (identifierRegexp.isInsensitive())
-        sb.append("*");
-      sb.append(database.quoteSQLString(identifierRegexp.getRegexpString()));
+      sb.append(database.constructRegexpClause(fieldPrefix+jobQueue.docIDField,database.quoteSQLString(identifierRegexp.getRegexpString()),identifierRegexp.isInsensitive()));
     }
 
     Long nowTime = new Long(criteria.getNowTime());
@@ -6126,10 +6125,11 @@ public class JobManager implements IJobM
         if (i > 0)
           sb.append(",");
         sb.append(field);
-        if (j == 0)
-          sb.append(" DESC");
-        else
-          sb.append(" ASC");
+        sb.append(" DESC");
+        //if (j == 0)
+        //  sb.append(" DESC");
+        //else
+        //  sb.append(" ASC");
         i++;
       }
       j++;
@@ -6140,7 +6140,7 @@ public class JobManager implements IJobM
   */
   protected void addLimits(StringBuffer sb, int startRow, int maxRowCount)
   {
-    sb.append(" ").append(database.constructLimitClause(maxRowCount)).append(" OFFSET ").append(Integer.toString(startRow));
+    sb.append(" ").append(database.constructOffsetLimitClause(startRow,maxRowCount));
   }
 
 

Modified: incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/jobs/JobQueue.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/jobs/JobQueue.java?rev=951095&r1=951094&r2=951095&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/jobs/JobQueue.java
(original)
+++ incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/jobs/JobQueue.java
Thu Jun  3 18:20:53 2010
@@ -528,7 +528,7 @@ public class JobQueue extends org.apache
       quoteSQLString(statusToString(STATUS_ACTIVE))+","+
       quoteSQLString(statusToString(STATUS_ACTIVEPURGATORY))+","+
       quoteSQLString(statusToString(STATUS_ACTIVENEEDRESCAN))+","+
-      quoteSQLString(statusToString(STATUS_ACTIVENEEDRESCANPURGATORY))+") "+constructLimitClause(1),list,null,null,1);
+      quoteSQLString(statusToString(STATUS_ACTIVENEEDRESCANPURGATORY))+") "+constructOffsetLimitClause(0,1),list,null,null,1);
     return set.getRowCount() > 0;
   }
 

Modified: incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/jobs/Jobs.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/jobs/Jobs.java?rev=951095&r1=951094&r2=951095&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/jobs/Jobs.java
(original)
+++ incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/jobs/Jobs.java
Thu Jun  3 18:20:53 2010
@@ -1753,7 +1753,7 @@ public class Jobs extends org.apache.lcf
   {
     IResultSet set = performQuery("SELECT "+idField+" FROM "+getTableName()+" WHERE "+
       statusField+" IN ("+quoteSQLString(statusToString(STATUS_READYFORDELETE))+","+
-      quoteSQLString(statusToString(STATUS_SHUTTINGDOWN))+") "+constructLimitClause(1),
+      quoteSQLString(statusToString(STATUS_SHUTTINGDOWN))+") "+constructOffsetLimitClause(0,1),
       null,new StringSet(getJobStatusKey()),null,1);
     return set.getRowCount() > 0;
   }
@@ -1772,7 +1772,7 @@ public class Jobs extends org.apache.lcf
       statusField+" IN ("+
       quoteSQLString(statusToString(STATUS_ACTIVE)) + "," +
       quoteSQLString(statusToString(STATUS_ACTIVESEEDING)) +
-      ") "+constructLimitClause(1),null,new StringSet(getJobStatusKey()),null,1);
+      ") "+constructOffsetLimitClause(0,1),null,new StringSet(getJobStatusKey()),null,1);
     return set.getRowCount() > 0;
   }
 

Modified: incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/repository/RepositoryHistoryManager.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/repository/RepositoryHistoryManager.java?rev=951095&r1=951094&r2=951095&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/repository/RepositoryHistoryManager.java
(original)
+++ incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/repository/RepositoryHistoryManager.java
Thu Jun  3 18:20:53 2010
@@ -258,13 +258,15 @@ public class RepositoryHistoryManager ex
   {
     // Build the query.
     StringBuffer sb = new StringBuffer("SELECT ");
-    sb.append(activityTypeField).append(" AS activity,").append(startTimeField).append("
AS starttime,(")
+    sb.append(idField).append(" AS id,").append(activityTypeField).append(" AS activity,").append(startTimeField).append("
AS starttime,(")
       .append(endTimeField).append("-").append(startTimeField).append(")")
       .append(" AS elapsedtime,").append(resultCodeField).append(" AS resultcode,").append(resultDescriptionField)
       .append(" AS resultdesc,").append(dataSizeField).append(" AS bytes,").append(entityIdentifierField)
       .append(" AS identifier FROM ").append(getTableName());
     addCriteria(sb,"",connectionName,criteria,false);
-    addOrdering(sb,new String[]{"starttime","activity","elapsedtime","resultcode","resultdesc","bytes","identifier"},sort);
+    // Note well: We can't order by "identifier" in all databases, so in order to guarantee
order we use "id".  This will force a specific internal
+    // order for the OFFSET/LIMIT clause.  We include "starttime" because that's the default
ordering.
+    addOrdering(sb,new String[]{"starttime","id"},sort);
     addLimits(sb,startRow,maxRowCount);
     return performQuery(sb.toString(),null,null,null,maxRowCount);
   }
@@ -561,20 +563,14 @@ public class RepositoryHistoryManager ex
     if (entityMatch != null)
     {
       whereEmitted = emitClauseStart(sb,whereEmitted);
-      sb.append(fieldPrefix).append(entityIdentifierField).append("~");
-      if (entityMatch.isInsensitive())
-        sb.append("*");
-      sb.append(quoteSQLString(entityMatch.getRegexpString()));
+      sb.append(constructRegexpClause(fieldPrefix+entityIdentifierField,quoteSQLString(entityMatch.getRegexpString()),entityMatch.isInsensitive()));
     }
 
     RegExpCriteria resultCodeMatch = criteria.getResultCodeMatch();
     if (resultCodeMatch != null)
     {
       whereEmitted = emitClauseStart(sb,whereEmitted);
-      sb.append(fieldPrefix).append(resultCodeField).append("~");
-      if (resultCodeMatch.isInsensitive())
-        sb.append("*");
-      sb.append(quoteSQLString(resultCodeMatch.getRegexpString()));
+      sb.append(constructRegexpClause(fieldPrefix+resultCodeField,quoteSQLString(resultCodeMatch.getRegexpString()),resultCodeMatch.isInsensitive()));
     }
 
     return whereEmitted;
@@ -630,10 +626,12 @@ public class RepositoryHistoryManager ex
         if (i > 0)
           sb.append(",");
         sb.append(field);
-        if (j == 0)
-          sb.append(" DESC");
-        else
-          sb.append(" ASC");
+	// Always make it DESC order...
+	sb.append(" DESC");
+        //if (j == 0)
+	//  sb.append(" DESC");
+        //else
+        //  sb.append(" ASC");
         i++;
       }
       j++;
@@ -644,7 +642,7 @@ public class RepositoryHistoryManager ex
   */
   protected void addLimits(StringBuffer sb, int startRow, int maxRowCount)
   {
-    sb.append(" ").append(constructLimitClause(maxRowCount)).append(" OFFSET ").append(Integer.toString(startRow));
+    sb.append(" ").append(constructOffsetLimitClause(startRow,maxRowCount));
   }
 
 



Mime
View raw message