org.apache.manifoldcf.crawler.jobs
Class HopCount.DocumentNode

java.lang.Object
  extended by org.apache.manifoldcf.crawler.jobs.HopCount.DocumentNode
Enclosing class:
HopCount

protected static class HopCount.DocumentNode
extends java.lang.Object

This class keeps track of the data associated with a node in the hash map. This basically includes the following: - the document identifier - the 'question' that was asked, which has the form (link type, maximum distance) - possibly the 'answer' to the question, which is either ">(maximum distance)", or a number. - references to the nodes which care about this answer, if they are still queued. - summary of the information we've gathered from children so far (if answer not known yet) - references to the children of this node that can affect the answer, including link details (if answer not known yet)


Field Summary
protected  HopCount.Answer bestPossibleAnswer
          The best (lowest) possible answer value for this node.
protected  java.util.Map childReferences
          Child node references.
protected  int databaseAnswerValue
          This is the original answer (if any), which is the current value in the database
protected  java.lang.Long databaseRow
          The original database row, if any
protected  boolean isComplete
          Answer complete flag.
protected  java.util.Map parentsWhoCare
          Parent nodes who care (i.e.
protected  HopCount.Question question
          The question.
protected  HopCount.Answer startingAnswer
          The answer, as calculated up to the level of all the completed children, which will not include incomplete child references of this node.
protected  HopCount.Answer trialAnswer
          The current best answer.
protected  boolean writeNeeded
          This flag is meaningful only if the complete flag is set.
 
Constructor Summary
HopCount.DocumentNode(HopCount.Question question)
          Create a document node.
 
Method Summary
 void addChild(HopCount.NodeReference childRef)
          Add a child reference.
 void addParent(HopCount.DocumentNode parent)
          Add a parent who should be notified if this node's answer changes.
 void clearChildReferences()
          Clear child references.
 void clearWriteNeeded()
          Clear the 'write needed' flag, to prevent another write.
 HopCount.Answer getBestPossibleAnswer()
          Get best possible answer
 java.util.Iterator getCurrentChildren()
          Iterate through current children.
 java.util.Iterator getCurrentParents()
          Iterate through all current parents.
 java.lang.Long getDatabaseRow()
          Get the database row
 int getDatabaseValue()
          Get the database answer value
 int getFinalAnswer()
          Get an answer that's final.
 HopCount.Question getQuestion()
          Get the question.
 HopCount.Answer getStartingAnswer()
          Get the starting (base) answer.
 HopCount.Answer getTrialAnswer()
          Get the current best answer.
 boolean hasChildren()
          Check if there are children.
 boolean isAnswerComplete()
          Check if the answer is complete.
 boolean isAnswerNeeded()
          Check if answer is still needed.
 boolean isComplete()
          Check if the node is complete, given the question it represents.
 boolean isWriteNeeded()
          Check if a write of the answer is needed to the database
 void makeComplete()
          Mark the node as being "complete", with a write needed.
 void makeCompleteNoWrite()
          Mark the answer as being "complete", and not needing a write.
 void removeChild(HopCount.NodeReference childRef)
          Remove a child reference.
 void removeParent(HopCount.DocumentNode parent)
          Remove a parent.
 void reset()
          Reset back to an "unknown" state.
 void setBestPossibleAnswer(HopCount.Answer answer)
          Set best possible answer
 void setSource(java.lang.Long rowID, int answerValue)
          Set the database row and answer value
 void setStartingAnswer(HopCount.Answer answer)
          Set the starting (base) answer.
 void setTrialAnswer(HopCount.Answer answer)
          Set the answer for this node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

question

protected HopCount.Question question
The question.


databaseAnswerValue

protected int databaseAnswerValue
This is the original answer (if any), which is the current value in the database


databaseRow

protected java.lang.Long databaseRow
The original database row, if any


startingAnswer

protected HopCount.Answer startingAnswer
The answer, as calculated up to the level of all the completed children, which will not include incomplete child references of this node. This is a starting point for every reassessment of this node's current answer. It is adjust only when additional children are noted as being complete.


trialAnswer

protected HopCount.Answer trialAnswer
The current best answer. This takes into account the current status of all the child nodes. If the node is not complete, then the answer must be viewed as being less than or equal to this value.


bestPossibleAnswer

protected HopCount.Answer bestPossibleAnswer
The best (lowest) possible answer value for this node. This value is calculated based on the known child link structure of a node, and can only increase. The value will start low (at 0) and will climb as more knowledge is gained, as the children's best possible answer value increases upon re-evaluation. When the trial answer (above) reaches a value equal to the best possible value, then the node will be immediately marked as "complete", and further processing will be considered unnecessary. As far as dependencies are concerned, the bestPossibleAnswer includes dependencies that have gone into its assessment. These dependencies represent what would need to be changed to invalidate the answer as it stands. (Invalidation means that a smaller best possible answer would be possible, so only add dependencies would need consideration.)


isComplete

protected boolean isComplete
Answer complete flag. Will be set to true only if the value of "trialAnswer" is deemed final.


writeNeeded

protected boolean writeNeeded
This flag is meaningful only if the complete flag is set.


parentsWhoCare

protected java.util.Map parentsWhoCare
Parent nodes who care (i.e. are still queued). This map contains DocumentNode objects.


childReferences

protected java.util.Map childReferences
Child node references. This is a reference to an actual document node object which has a parent reference back to this one. If the child node is modified, there is an obligation to cause the parent node to be re-evaluated. The re-evaluation process examines all child nodes and may adjust the status of the trial answer, and may indeed even remove the reference to the child. This map contains NodeReference objects.

Constructor Detail

HopCount.DocumentNode

public HopCount.DocumentNode(HopCount.Question question)
Create a document node. This will happen only if there is no comparable one already in the hash.

Method Detail

getQuestion

public HopCount.Question getQuestion()
Get the question.


reset

public void reset()
Reset back to an "unknown" state.


clearChildReferences

public void clearChildReferences()
Clear child references.


hasChildren

public boolean hasChildren()
Check if there are children.


getFinalAnswer

public int getFinalAnswer()
Get an answer that's final. Returns "unknown" if the current answer is incomplete.


isAnswerComplete

public boolean isAnswerComplete()
Check if the answer is complete. Returns true if the answer is complete.


isComplete

public boolean isComplete()
Check if the node is complete, given the question it represents.


isWriteNeeded

public boolean isWriteNeeded()
Check if a write of the answer is needed to the database


isAnswerNeeded

public boolean isAnswerNeeded()
Check if answer is still needed.


getBestPossibleAnswer

public HopCount.Answer getBestPossibleAnswer()
Get best possible answer


setBestPossibleAnswer

public void setBestPossibleAnswer(HopCount.Answer answer)
Set best possible answer


getTrialAnswer

public HopCount.Answer getTrialAnswer()
Get the current best answer.


setTrialAnswer

public void setTrialAnswer(HopCount.Answer answer)
Set the answer for this node.


getStartingAnswer

public HopCount.Answer getStartingAnswer()
Get the starting (base) answer.


setStartingAnswer

public void setStartingAnswer(HopCount.Answer answer)
Set the starting (base) answer.


makeComplete

public void makeComplete()
Mark the node as being "complete", with a write needed.


makeCompleteNoWrite

public void makeCompleteNoWrite()
Mark the answer as being "complete", and not needing a write.


addParent

public void addParent(HopCount.DocumentNode parent)
Add a parent who should be notified if this node's answer changes. The parent is responsible for figuring out when this reference should be removed.


clearWriteNeeded

public void clearWriteNeeded()
Clear the 'write needed' flag, to prevent another write.


addChild

public void addChild(HopCount.NodeReference childRef)
Add a child reference.

Parameters:
childRef - is the child node reference to add.

removeChild

public void removeChild(HopCount.NodeReference childRef)
Remove a child reference.

Parameters:
childRef - is the child node reference to remove.

removeParent

public void removeParent(HopCount.DocumentNode parent)
Remove a parent. This method will get called when the parent's answer no longer can be affected by this child's answer (probably because the child's answer has become complete).


getCurrentParents

public java.util.Iterator getCurrentParents()
Iterate through all current parents. This is an iterator over DocumentNode objects.


getCurrentChildren

public java.util.Iterator getCurrentChildren()
Iterate through current children. This is an iterator over NodeReference objects.


setSource

public void setSource(java.lang.Long rowID,
                      int answerValue)
Set the database row and answer value


getDatabaseRow

public java.lang.Long getDatabaseRow()
Get the database row


getDatabaseValue

public int getDatabaseValue()
Get the database answer value