Author: kwright
Date: Thu Dec 13 08:45:16 2012
New Revision: 1421138
URL: http://svn.apache.org/viewvc?rev=1421138&view=rev
Log:
Clean up the hinting part of CONNECTORS-584. Should not be a functional change.
Modified:
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceMySQL.java
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IDBInterface.java
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobQueue.java
Modified:
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceMySQL.java
URL:
http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceMySQL.java?rev=1421138&r1=1421137&r2=1421138&view=diff
==============================================================================
---
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceMySQL.java
(original)
+++
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceMySQL.java
Thu Dec 13 08:45:16 2012
@@ -921,13 +921,27 @@ public class DBInterfaceMySQL extends Da
/** Construct index hint clause.
* On most databases this returns an empty string, but on MySQL this returns
* a USE INDEX hint. It requires the name of an index.
- *@param indexName is the name of an index.
+ *@param tableName is the table the index is from.
+ *@param description is the description of an index, which is expected to
exist.
*@return the query chunk that should go between the table names and the WHERE
* clause.
*/
- public String constructIndexHintClause(String indexName)
+ public String constructIndexHintClause(String tableName, IndexDescription
description)
+ throws ManifoldCFException
{
- return "FORCE INDEX ("+indexName+") ";
+ // Figure out what index it is
+ Map indexes = getTableIndexes(tableName,null,null);
+ Iterator iter = indexes.keySet().iterator();
+ while (iter.hasNext())
+ {
+ String indexName = (String)iter.next();
+ IndexDescription id = (IndexDescription)indexes.get(indexName);
+ if (id.equals(description))
+ {
+ return "FORCE INDEX ("+indexName+")";
+ }
+ }
+ throw new ManifoldCFException("Expected index description "+description+"
not found");
}
/** Construct a cast to a double value.
Modified:
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java
URL:
http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java?rev=1421138&r1=1421137&r2=1421138&view=diff
==============================================================================
---
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java
(original)
+++
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java
Thu Dec 13 08:45:16 2012
@@ -486,11 +486,13 @@ public abstract class Database
/** Construct index hint clause.
* On most databases this returns an empty string, but on MySQL this returns
* a USE INDEX hint. It requires the name of an index.
- *@param indexName is the name of an index.
+ *@param tableName is the table the index is from.
+ *@param description is the description of an index, which is expected to
exist.
*@return the query chunk that should go between the table names and the WHERE
* clause.
*/
- public String constructIndexHintClause(String indexName)
+ public String constructIndexHintClause(String tableName, IndexDescription
description)
+ throws ManifoldCFException
{
return "";
}
Modified:
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IDBInterface.java
URL:
http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IDBInterface.java?rev=1421138&r1=1421137&r2=1421138&view=diff
==============================================================================
---
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IDBInterface.java
(original)
+++
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IDBInterface.java
Thu Dec 13 08:45:16 2012
@@ -257,11 +257,13 @@ public interface IDBInterface
/** Construct index hint clause.
* On most databases this returns an empty string, but on MySQL this returns
* a USE INDEX hint. It requires the name of an index.
- *@param indexName is the name of an index.
+ *@param tableName is the table the index is from.
+ *@param description is the description of an index, which is expected to
exist.
*@return the query chunk that should go between the table names and the WHERE
* clause.
*/
- public String constructIndexHintClause(String indexName);
+ public String constructIndexHintClause(String tableName, IndexDescription
description)
+ throws ManifoldCFException;
/** Construct ORDER-BY clause meant for reading from an index.
* Supply the field names belonging to the index, in order.
Modified:
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java
URL:
http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java?rev=1421138&r1=1421137&r2=1421138&view=diff
==============================================================================
---
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java
(original)
+++
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java
Thu Dec 13 08:45:16 2012
@@ -2104,7 +2104,7 @@ public class JobManager implements IJobM
sb.append(jobQueue.docPriorityField).append(",").append(jobQueue.jobIDField).append(",")
.append(jobQueue.docHashField).append(",").append(jobQueue.docIDField)
.append(" FROM ").append(jobQueue.getTableName())
- .append(" t0
").append(database.constructIndexHintClause(jobQueue.getGetNextDocumentsIndex())).append("WHERE
");
+ .append(" t0 ").append(jobQueue.getGetNextDocumentsIndexHint()).append("
WHERE ");
sb.append(database.buildConjunctionClause(list,new ClauseDescription[]{
//new UnitaryClause(jobQueue.docPriorityField,">=",new Long(0L)),
@@ -2160,7 +2160,7 @@ public class JobManager implements IJobM
.append(jobQueue.failTimeField).append(",t0.")
.append(jobQueue.failCountField).append(",t0.")
.append(jobQueue.prioritySetField).append(" FROM
").append(jobQueue.getTableName())
- .append(" t0
").append(database.constructIndexHintClause(jobQueue.getGetNextDocumentsIndex())).append("WHERE
");
+ .append(" t0 ").append(jobQueue.getGetNextDocumentsIndexHint()).append("
WHERE ");
sb.append(database.buildConjunctionClause(list,new ClauseDescription[]{
//new UnitaryClause("t0."+jobQueue.docPriorityField,">=",new Long(0L)),
Modified:
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobQueue.java
URL:
http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobQueue.java?rev=1421138&r1=1421137&r2=1421138&view=diff
==============================================================================
---
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobQueue.java
(original)
+++
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobQueue.java
Thu Dec 13 08:45:16 2012
@@ -154,8 +154,8 @@ public class JobQueue extends org.apache
/** Thread context */
protected IThreadContext threadContext;
- /** Cached getNextDocuments order-by index name */
- protected String getNextDocumentsIndex = null;
+ /** Cached getNextDocuments order-by index hint */
+ protected String getNextDocumentsIndexHint = null;
/** Constructor.
*@param database is the database handle.
@@ -269,33 +269,18 @@ public class JobQueue extends org.apache
}
}
- /** Get the 'getNextDocuments' index name.
+ /** Get the 'getNextDocuments' index hint.
*/
- public String getGetNextDocumentsIndex()
+ public String getGetNextDocumentsIndexHint()
throws ManifoldCFException
{
- if (getNextDocumentsIndex == null)
+ if (getNextDocumentsIndexHint == null)
{
// Figure out what index it is
- IndexDescription docpriorityIndex = new IndexDescription(false,new
String[]{docPriorityField,statusField,checkActionField,checkTimeField});
- Map indexes = getTableIndexes(null,null);
- Iterator iter = indexes.keySet().iterator();
- while (iter.hasNext())
- {
- String indexName = (String)iter.next();
- IndexDescription id = (IndexDescription)indexes.get(indexName);
- if (id.equals(docpriorityIndex))
- {
- getNextDocumentsIndex = indexName;
- break;
- }
- }
- // Derby doesn't actually allow us to get index columns, so
- // for Derby, we return null.
- //if (getNextDocumentsIndex == null)
- // throw new ManifoldCFException("Can't find getnextdocuments index");
+ getNextDocumentsIndexHint =
getDBInterface().constructIndexHintClause(getTableName(),
+ new IndexDescription(false,new
String[]{docPriorityField,statusField,checkActionField,checkTimeField}));
}
- return getNextDocumentsIndex;
+ return getNextDocumentsIndexHint;
}
/** Analyze job tables due to major event */