Project

General

Profile

Revision 3146

Added by Chris Jones over 14 years ago

As part of a patch fix for:

http://bugzilla.ecoinformatics.org/show_bug.cgi?id=2469

I've changed DocumentImpl.java in three locations:

buildIndex()
traverseParents()
updatePathIndex()

This patch modifies updatePathIndex() by changing the pathsFound input
parameter to a HashMap from a Vector. The HashMap stores PathIndexEntry
objects that represent each row to be inserted into the xml_path_index table.
The HashMap prevents nodeids from the current node from being offset with
the data from adjacent nodes under certain circumstances, which was happening
while a Vector was being used to store paths found for indexing. See the next
two patches for more info.

View differences:

src/edu/ucsb/nceas/metacat/DocumentImpl.java
1508 1508
     * @param pathList the hash of paths to insert
1509 1509
     * @throws SQLException if there is an error inserting into the db
1510 1510
     */
1511
    private void updatePathIndex(DBConnection conn, NodeRecord currentNode, Vector pathList)
1511
    private void updatePathIndex(DBConnection conn, HashMap pathsFound)
1512 1512
    	throws SQLException {
1513
    	  // Increase usage count for the connection
1514
        conn.increaseUsageCount(1);
1515
        
1513 1516
        // Create an insert statement to reuse for all of the path
1514 1517
        // insertions
1515 1518
        PreparedStatement pstmt = conn.prepareStatement("INSERT INTO "
1516
                + "xml_path_index (docid, path, nodedata, "
1519
                + "xml_path_index (nodeid, docid, path, nodedata, "
1517 1520
                + "nodedatanumerical, parentnodeid)"
1518
                + " VALUES (?, ?, ?, ?, ?)");
1519
        pstmt.setString(1, docid);
1521
                + " VALUES (?, ?, ?, ?, ?, ?)");
1522
        
1520 1523
        // Step through the hashtable and insert each of the path values
1521
        Iterator it = pathList.iterator();
1524
        Iterator it = pathsFound.values().iterator();
1522 1525
         while (it.hasNext()) {
1523
        	 String path = (String)it.next();
1524
        	 logMetacat.debug("Inserting: "+ path);
1525
        	 pstmt.setString(2, path);
1526
        	 pstmt.setString(3, currentNode.getNodeData());
1527
        	 pstmt.setFloat(4, currentNode.getNodeDataNumerical());
1528
        	 pstmt.setLong(5, currentNode.getParentNodeId());    
1529
        	 pstmt.execute();        	
1526
        	 PathIndexEntry entry = (PathIndexEntry)it.next();
1527

  
1528
           pstmt.setLong(1, entry.nodeId);
1529
           pstmt.setString(2,entry.docid);
1530
        	 pstmt.setString(3, entry.path);
1531
        	 pstmt.setString(4, entry.nodeData);
1532
        	 pstmt.setFloat(5, entry.nodeDataNumerical);
1533
        	 pstmt.setLong(6, entry.parentId);    
1534
        	 pstmt.execute();       	
1530 1535
        }
1531 1536
        // Close the database statement
1532 1537
        pstmt.close();

Also available in: Unified diff