Re: structure.getChildren(token,parent) returns nothing here is the story

Dorel bruno <[email protected]> Tue, 03 Apr 2007 10:31:19 +0200
Newsgroups gmane.comp.jakarta.slide.devel
Message-ID <[email protected]>
Martin van den Bemt a écrit :

Sorry but I can't send you a pacth because I 've modified Slide's kernel 
code to impléments some new capabilities :
with my version I can :

setup "stopWords" in lucene (english or french) (I've sent the code to 
aslam bari  see the slide-users archive)
setup mergeFactor , min and max files ... in lucene (I 've sent the 
source code to bugzilla)

we notice a very strange behavior with RDBMSadapters The global 
performances slow down when the number of documents grows up
we made some change to correct this behavior .

Now, the changes are too intricate to send you a patch  because  if you  
run tests  (or unit tests)  unsuccessfully I can't tell you which 
modification make the test wrong (and it may be due to an unpredictable  
side effect)

So have a look to my code of course you can criticize  it I will take 
into account your remarks,   for my own I think the XXXXRDBMSAdapters  
are  not  commented  at all so I can make a huge mistake when I modify 
this code


Regards

B DOREL



> Would be nice if you can send a patch instead of attaching.. Also it's best to attach it to an issue
> so we don't forget about it..
> Activity is picking up from people who are able to commit, so I don't think this will end up in the
> trash.. Since there is a lack of unit tests it could take a bit of time till we investigated the
> patch though..
>
> Thanx for the effort !
>
> Mvgr,
> Martin
>
> Dorel bruno wrote:
>   
>> Suite of my last message
>>
>>
>> Hi all
>>
>> I've Found the bug concerning the GetChildren method the story is :
>> I use a version of PostgresRDBMSAdapter (which extends
>> StrandardRDBMSAdapter) which doesn't redefine the
>> clearBinding(Connection connection, Uri uri, Set UpdatedBindings)so the
>> Set of updatedBindings is ignored (see StrandardRDBMSAdapter) to avoid a
>> complete clear instaed of a "smart" clear (just the updated
>> bindings)I've written this method using the MySQL example and joined to
>> this mail the result source This works in my project.
>>
>> Enjoy !(in fact I'm sure you gonna push it in your favorite trash as
>> usually)
>>
>>
>> Regards
>>
>> B DOREL
>>
>>
>>
>>
>>
>>
>> Digging in the slide's code I have troubles with  the
>> StrandardRDBMSAdapter class
>>
>> The method storeObject use the bindings attribute to fill the Binding
>> table it seems OK
>>
>> The method retrieveObject use binding table to fill the children
>> attribute  This explain why getChildren returns nothing
>>
>>
>> Is it a bugg ? does anybody can explain me how this class works? The
>> source code of this class is so well commented ! 2 lines of comments
>> composed with three words each
>>
>> Regards
>>
>>
>>
>> B DOREL
>>
>>
>>
>>
>>
>>
>>
>> Hi all
>>
>> I have a trouble using structure.getChildren(token,parentNode) : this
>> method return an enumeration with 0 elements, but,  when I build the
>> structure I use the
>> node.addChild  method to set up children. To check it, I use a Postgres
>> JCDBA : I  list  the  parent_binding table evrythig is correct  and I
>> can see parents and children links in the tree structure.
>>
>> Is there any known bugs  or patch concerning the getChildren method ?
>>
>> From an other hand , I get spam messages with links to pornographics
>> sites :
>> subject   [Jakarta-slide  Wiki] Update of "FrontPage" by
>> AntoineLevyLambert   sender : Apache Wiki
>>
>> I suppose (I'm sure)  Antoine is a nice  buddy  and  he has never  sent
>> this message  just be aware of  it !
>>
>> Regards
>>
>> B DOREL
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>> ---------------------------------------------------------------------------------------
>>
>> Orange vous informe que cet  e-mail a ete controle par l'anti-virus mail.
>> Aucun virus connu a ce jour par nos services n'a ete detecte.
>>
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>> ---------------------------------------------------------------------------------------
>>
>> Orange vous informe que cet  e-mail a ete controle par l'anti-virus mail.
>> Aucun virus connu a ce jour par nos services n'a ete detecte.
>>
>>
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> /*
>>  * $Header: /home/cvspublic/jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/PostgresRDBMSAdapter.java,v 1.20 2005/06/13 12:35:07 unico Exp $
>>  * $Revision: 1.20 $
>>  * $Date: 2005/06/13 12:35:07 $
>>  *
>>  * ====================================================================
>>  *
>>  * Copyright 1999-2005 The Apache Software Foundation 
>>  *
>>  * Licensed under the Apache License, Version 2.0 (the "License");
>>  * you may not use this file except in compliance with the License.
>>  * You may obtain a copy of the License at
>>  *
>>  *     http://www.apache.org/licenses/LICENSE-2.0
>>  *
>>  * Unless required by applicable law or agreed to in writing, software
>>  * distributed under the License is distributed on an "AS IS" BASIS,
>>  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>>  * See the License for the specific language governing permissions and
>>  * limitations under the License.
>>  *
>>  */
>>
>> package org.apache.slide.store.impl.rdbms;
>>
>> import java.sql.Connection;
>> import java.sql.PreparedStatement;
>> import java.sql.ResultSet;
>> import java.sql.SQLException;
>> import java.util.Iterator;
>> import java.util.Set;
>>
>> import org.apache.slide.common.Service;
>> import org.apache.slide.common.ServiceAccessException;
>> import org.apache.slide.common.Uri;
>> import org.apache.slide.content.NodeRevisionDescriptor;
>> import org.apache.slide.content.NodeRevisionNumber;
>> import org.apache.slide.lock.LockTokenNotFoundException;
>> import org.apache.slide.lock.NodeLock;
>> import org.apache.slide.security.NodePermission;
>> import org.apache.slide.structure.ObjectNode;
>> import org.apache.slide.structure.ObjectNotFoundException;
>> import org.apache.slide.util.logger.Logger;
>>
>> /**
>>  * Adapter for Postgres 7.3/7.4.
>>  * 
>>  * The delete statements differ from StandardRDBMSAdapter
>>  * as Postgres does not understand "DELETE table FROM ...".
>>  *  
>>  * The Postgres driver for version 7.4.1 will alway load
>>  * the content into memory. This will be a problem for 
>>  * large documents.
>>  * 
>>  * @version $Revision: 1.20 $
>>  */
>>
>> public class PostgresRDBMSAdapter extends StandardRDBMSAdapter implements SequenceAdapter {
>>
>> 	protected static String LOG_CHANNEL =
>> 		PostgresRDBMSAdapter.class.getName();
>>
>>     protected static String normalizeSequenceName(String sequenceName) {
>>         return sequenceName.replace('-', '_').toUpperCase() + "_SEQ";
>>     }
>>
>> 	public PostgresRDBMSAdapter(Service service, Logger logger) {
>> 		super(service, logger);
>> 	}
>>
>> 	public void removeObject(Connection connection, Uri uri, ObjectNode object)
>> 		throws ServiceAccessException, ObjectNotFoundException {
>> 		PreparedStatement statement = null;
>> 		try {
>>
>> 			clearBinding(connection, uri);
>>
>> 			// delete links
>> 			try {
>> 				statement =
>> 					connection.prepareStatement(
>> 						"delete from LINKS where LINKS.URI_ID = URI.URI_ID and URI.URI_STRING = ?");
>> 				statement.setString(1, uri.toString());
>> 				statement.executeUpdate();
>> 			} finally {
>> 				close(statement);
>> 			}
>> 			// delete version history
>> 			// FIXME: Is this true??? Should the version history be removed if the object is removed???
>> 			try {
>> 				statement =
>> 					connection.prepareStatement(
>> 						"delete from VERSION_HISTORY  where VERSION_HISTORY.URI_ID = URI.URI_ID and URI.URI_STRING = ?");
>> 				statement.setString(1, uri.toString());
>> 				statement.executeUpdate();
>> 			} finally {
>> 				close(statement);
>> 			}
>> 			// delete version
>> 			try {
>> 				statement =
>> 					connection.prepareStatement(
>> 						"delete from VERSION where VERSION.URI_ID = URI.URI_ID and URI.URI_STRING = ?");
>> 				statement.setString(1, uri.toString());
>> 				statement.executeUpdate();
>> 			} finally {
>> 				close(statement);
>> 			}
>> 			// delete the object itself
>> 			try {
>> 				statement =
>> 					connection.prepareStatement(
>> 						"delete from OBJECT  where OBJECT.URI_ID = URI.URI_ID and URI.URI_STRING = ?");
>> 				statement.setString(1, uri.toString());
>> 				statement.executeUpdate();
>> 			} finally {
>> 				close(statement);
>> 			}
>> 			// finally delete the uri
>> 			try {
>> 				statement =
>> 					connection.prepareStatement(
>> 						"delete from URI where URI_STRING = ?");
>> 				statement.setString(1, uri.toString());
>> 				statement.executeUpdate();
>> 			} finally {
>> 				close(statement);
>> 			}
>> 		} catch (SQLException e) {
>> 			getLogger().log(e, LOG_CHANNEL, Logger.ERROR);
>> 			throw new ServiceAccessException(service, e);
>> 		}
>> 	}
>>
>> 	public void removeRevisionContent(
>> 		Connection connection,
>> 		Uri uri,
>> 		NodeRevisionDescriptor revisionDescriptor)
>> 		throws ServiceAccessException {
>> 		try {
>> 			PreparedStatement statement = null;
>> 			try {
>> 				statement =
>> 					connection.prepareStatement(
>> 						"delete from VERSION_CONTENT where VERSION_CONTENT.VERSION_ID = VERSION_HISTORY.VERSION_ID and VERSION_HISTORY.REVISION_NO = ? and VERSION_HISTORY.URI_ID=URI.URI_ID AND URI.URI_STRING=?");
>> 				statement.setString(
>> 					1,
>> 					revisionDescriptor.getRevisionNumber().toString());
>> 				statement.setString(2, uri.toString());
>> 				statement.executeUpdate();
>> 			} finally {
>> 				close(statement);
>> 			}
>> 		} catch (Exception e) {
>> 			getLogger().log(e, LOG_CHANNEL, Logger.ERROR);
>> 			throw new ServiceAccessException(service, e);
>> 		}
>> 	}
>>
>> 	public void removeRevisionDescriptor(
>> 		Connection connection,
>> 		Uri uri,
>> 		NodeRevisionNumber revisionNumber)
>> 		throws ServiceAccessException {
>> 		PreparedStatement statement = null;
>> 		try {
>> 			try {
>> 				statement =
>> 					connection.prepareStatement(
>> 						"delete from VERSION_LABELS where VERSION_LABELS.VERSION_ID = VERSION_HISTORY.VERSION_ID and VERSION_HISTORY.REVISION_NO = ? and VERSION_HISTORY.URI_ID = URI.URI_ID AND URI.URI_STRING = ?");
>> 				statement.setString(1, revisionNumber.toString());
>> 				statement.setString(2, uri.toString());
>> 				statement.executeUpdate();
>> 			} finally {
>> 				close(statement);
>> 			}
>> 			try {
>> 				statement =
>> 					connection.prepareStatement(
>> 						"delete from PROPERTIES where PROPERTIES.VERSION_ID = VERSION_HISTORY.VERSION_ID and VERSION_HISTORY.REVISION_NO = ? and VERSION_HISTORY.URI_ID = URI.URI_ID AND URI.URI_STRING = ?");
>> 				statement.setString(1, revisionNumber.toString());
>> 				statement.setString(2, uri.toString());
>> 				statement.executeUpdate();
>> 			} finally {
>> 				close(statement);
>> 			}
>> 		} catch (SQLException e) {
>> 			getLogger().log(e, LOG_CHANNEL, Logger.ERROR);
>> 			throw new ServiceAccessException(service, e);
>> 		}
>> 	}
>>
>>     public void removeRevisionDescriptors(Connection connection, Uri uri) throws ServiceAccessException {
>>         PreparedStatement statement = null;
>>         try {
>>             
>>             statement =
>>                 connection.prepareStatement(
>>                 "delete from VERSION_PREDS where VERSION_PREDS.VERSION_ID = VERSION_HISTORY.VERSION_ID and VERSION_HISTORY.URI_ID = URI.URI_ID and URI.URI_STRING = ?");
>>             statement.setString(1, uri.toString());
>>             statement.executeUpdate();
>>         } catch (SQLException e) {
>>             throw createException(e, uri.toString());
>>         } finally {
>>             close(statement);
>>         }
>>     }
>>
>> 	public void removeLock(Connection connection, Uri uri, NodeLock lock)
>> 		throws ServiceAccessException, LockTokenNotFoundException {
>> 		PreparedStatement statement = null;
>> 		try {
>> 			try {
>> 				statement =
>> 					connection.prepareStatement(
>> 						"delete from LOCKS where LOCK_ID = URI.URI_ID and URI.URI_STRING=?");
>> 				statement.setString(1, lock.getLockId());
>> 				statement.executeUpdate();
>> 			} finally {
>> 				close(statement);
>> 			}
>> 			try {
>> 				statement =
>> 					connection.prepareStatement(
>> 						"delete from URI where URI_STRING=?");
>> 				statement.setString(1, lock.getLockId());
>>             statement.executeUpdate();
>> 			} finally {
>> 				close(statement);
>> 			}
>> 		} catch (SQLException e) {
>> 			getLogger().log(e, LOG_CHANNEL, Logger.ERROR);
>> 			throw new ServiceAccessException(service, e);
>> 		}
>> 	}
>>
>>     public void revokePermission(Connection connection, Uri uri, NodePermission permission)
>>     throws ServiceAccessException {
>>         if (permission == null) return;
>>         final StringBuffer sql = new StringBuffer("delete from PERMISSIONS where (OBJECT_ID, SUBJECT_ID, ACTION_ID) IN" +
>>                 " (SELECT ou.URI_ID, su.URI_ID, au.URI_ID FROM URI ou, URI su, URI au WHERE ou.URI_STRING = ? and su.URI_STRING = ? and au.URI_STRING = ?)");
>> 		PreparedStatement statement = null;
>> 		try {
>>             final NodeRevisionNumber revisionNumber = permission.getRevisionNumber();
>>             // generate proper sql based on content of revision number
>>             if (revisionNumber != null) {
>>                 sql.append(" and VERSION_NO = ?");
>>             } else {
>>                 sql.append(" and VERSION_NO IS NULL");
>>             }
>>             statement = connection.prepareStatement(sql.toString());
>>             statement.setString(1, uri.toString());
>>             statement.setString(2, permission.getSubjectUri());
>>             statement.setString(3, permission.getActionUri());
>>             if (revisionNumber != null) {
>>                 statement.setString(4, revisionNumber.toString());
>>             }
>>             statement.executeUpdate();
>> 		} catch (SQLException e) {
>>             throw createException(e, uri.toString());
>> 		} finally {
>> 			close(statement);
>> 		}
>> 	}
>>
>> 	public void revokePermissions(Connection connection, Uri uri)
>> 		throws ServiceAccessException {
>> 		PreparedStatement statement = null;
>> 		try {
>> 			statement =
>> 				connection.prepareStatement(
>> 					"delete from PERMISSIONS where PERMISSIONS.OBJECT_ID = URI.URI_ID and URI.URI_STRING = ?");
>> 			statement.setString(1, uri.toString());
>> 			statement.executeUpdate();
>> 		} catch (SQLException e) {
>> 			getLogger().log(e, LOG_CHANNEL, Logger.ERROR);
>> 			throw new ServiceAccessException(service, e);
>> 		} finally {
>> 			close(statement);
>> 		}
>> 	}
>>
>>     protected void clearBinding(Connection connection, Uri uri, Set updatedBindings)
>>        throws ServiceAccessException, ObjectNotFoundException, SQLException {
>>        PreparedStatement statement = null;
>>
>>        // clear this uri from having bindings and being bound 
>>        int bsize = updatedBindings.size();
>>        //If there are bindings to update, only remove those from the database
>>        if (bsize > 0) {
>>
>>            try {
>>                String bindings = "(";
>>                for (int i = 1; i < bsize; i++)
>>                    bindings = bindings + "?,";
>>                bindings = bindings + "?)";
>>                statement =
>>                    connection.prepareStatement(
>>                        "delete from BINDING where URI.URI_ID = BINDING.CHILD_UURI_ID and URI.URI_STRING IN "
>>                            + bindings);
>>
>>                Iterator iter = updatedBindings.iterator();
>>                for (int i = 1; iter.hasNext(); i++) {
>>                    String next = iter.next().toString();
>>                    statement.setString(i, next);
>>                }
>>                statement.executeUpdate();
>>            } finally {
>>                close(statement);
>>            }
>>
>>            try {
>>                statement =
>>                  connection.prepareStatement(
>>                     "delete from PARENT_BINDING where PARENT_BINDING.URI_ID = URI.URI_ID and URI.URI_STRING = ?");
>>                statement.setString(1, uri.toString());
>>                statement.executeUpdate();
>>            } finally {
>>                close(statement);
>>            }
>>        } else {
>>            //otherwise remove all related to the uri
>>            clearBinding(connection, uri);
>>        }
>>
>>     }
>>
>> 	protected void clearBinding(Connection connection, Uri uri)
>> 		throws ServiceAccessException, ObjectNotFoundException, SQLException {
>> 		PreparedStatement statement = null;
>>
>> 		// clear this uri from having bindings and being bound 
>>
>> 		// getLogger().log("Clear bindings for " + uri.toString(),LOG_CHANNEL,Logger.INFO);  
>>
>> 		try {
>> 			statement =
>> 				connection.prepareStatement(
>> 					"delete from BINDING where (BINDING.URI_ID = URI.URI_ID and URI.URI_STRING = ?) ");
>> 			//or (BINDING.CHILD_UURI_ID = URI.URI_ID and URI.URI_STRING = ?");
>> 			statement.setString(1, uri.toString());
>> 			//statement.setString(2, uri.toString());
>> 			statement.executeUpdate();
>> 		} finally {
>> 			close(statement);
>> 		}
>>
>> 		try {
>> 			statement =
>> 				connection.prepareStatement(
>> 					"delete from PARENT_BINDING where PARENT_BINDING.URI_ID = URI.URI_ID and URI.URI_STRING = ?");
>> 			//  or PARENT_BINDING.PARENT_UURI_ID = URI.URI_ID and URI.URI_STRING = ?");
>> 			statement.setString(1, uri.toString());
>> 			//statement.setString(2, uri.toString());
>> 			statement.executeUpdate();
>> 		} finally {
>> 			close(statement);
>> 		}
>> 	}
>>
>>     public boolean isSequenceSupported(Connection conn) {
>>         return true;
>>     }
>>
>>     public boolean createSequence(Connection conn, String sequenceName) throws ServiceAccessException {
>>
>>         String query = "CREATE SEQUENCE " + normalizeSequenceName(sequenceName);
>>
>>         PreparedStatement statement = null;
>>
>>         try {
>>             statement = conn.prepareStatement(query);
>>             statement.executeUpdate();
>>             return true;
>>         } catch (SQLException e) {
>>             throw new ServiceAccessException(service, e);
>>         } finally {
>>             close(statement);
>>         }
>>
>>     }
>>
>>     public long nextSequenceValue(Connection conn, String sequenceName) throws ServiceAccessException {
>>         String selectQuery = "SELECT nextval('" + normalizeSequenceName(sequenceName)+"');";
>>
>>         PreparedStatement selectStatement = null;
>>         ResultSet res = null;
>>
>>         try {
>>             selectStatement = conn.prepareStatement(selectQuery);
>>             res = selectStatement.executeQuery();
>>             if (!res.next()) {
>>                 throw new ServiceAccessException(service, "Could not increment sequence " + sequenceName);
>>             }
>>             long value = res.getLong(1);
>>             return value;
>>         } catch (SQLException e) {
>>             throw new ServiceAccessException(service, e);
>>         } finally {
>>             close(selectStatement, res);
>>         }
>>     }
>>
>>     public boolean sequenceExists(Connection conn, String sequenceName) throws ServiceAccessException {
>>
>>         PreparedStatement selectStatement = null;
>>         ResultSet res = null;
>>
>>         try {
>>             selectStatement = conn.prepareStatement("SELECT * FROM " + normalizeSequenceName(sequenceName));
>>             res = selectStatement.executeQuery();
>>             return true;
>>         } catch (SQLException e) {
>>             return false;
>>         } finally {
>>             close(selectStatement, res);
>>         }
>>     }
>>     
>>     protected String convertRevisionNumberToComparable(String revisioNumber) {
>>         return "cast(split_part("
>>             + revisioNumber
>>             + ", '.', 1) as numeric), cast(split_part("
>>             + revisioNumber
>>             + ", '.', 2) as numeric)";
>>     }
>>
>> }
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
> ---------------------------------------------------------------------------------------
> Orange vous informe que cet  e-mail a ete controle par l'anti-virus mail. 
> Aucun virus connu a ce jour par nos services n'a ete detecte.
>
>
>
>
>