-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: Indexing Performance
PostPosted: Thu Mar 12, 2009 10:03 pm 
Newbie

Joined: Fri Mar 06, 2009 11:22 am
Posts: 16
I have an application that persists data using hibernate to a database which I am now trying to switch to Hibernate Search. Everything seems to index just fine but the overhead of indexing the data is about 5x the overhead incurred during a regular insert (~250ms vs ~50ms). Given this situation I am looking for a way to save the information to the database and have it indexed by a separate process. Is there any documentation on how to go about doing this?

My first guess is that I could implement a custom listener which then delegates to a worker thread who simply does indexing so not to cause the delay to the database. I would think that this is a common issue however and possibly a solution already exists.

Any thoughts on this would be appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 13, 2009 4:28 am 
Pro
Pro

Joined: Wed Oct 03, 2007 2:31 pm
Posts: 205
Can't you set the configuration for indexing async? The hibernate search documentation provides information on doing indexing on seperate processes. Alternatively look at the Hibernate Search in Action book. It's very good and gives you tons of info.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 13, 2009 8:41 am 
Newbie

Joined: Fri Mar 06, 2009 11:22 am
Posts: 16
this is exactly what I was looking for. When I enable this property
Code:
<property name="hibernate.search.worker.execution">async</property>


I get the following error when doing an insert:

Code:
1641 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - cleaning up connection pool: jdbc:derby://localhost:1527/Events;create=true
Exception in thread "pool-3-thread-1" org.apache.lucene.store.AlreadyClosedException: this Directory is closed
   at org.apache.lucene.store.Directory.ensureOpen(Directory.java:220)
   at org.apache.lucene.store.FSDirectory.list(FSDirectory.java:320)
   at org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:533)
   at org.apache.lucene.index.SegmentInfos.read(SegmentInfos.java:272)
   at org.apache.lucene.index.IndexWriter.init(IndexWriter.java:1088)
   at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:686)
   at org.hibernate.search.backend.Workspace.getIndexWriter(Workspace.java:180)
   at org.hibernate.search.backend.impl.lucene.PerDPQueueProcessor.performWriterWorks(PerDPQueueProcessor.java:104)
   at org.hibernate.search.backend.impl.lucene.PerDPQueueProcessor.run(PerDPQueueProcessor.java:88)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
   at java.lang.Thread.run(Thread.java:619)



my code is very simple and is essentially the following:

Code:
       Session session = HibernateUtil.getSessionFactory().getCurrentSession();
       long startTime = Calendar.getInstance().getTimeInMillis();
       
       session.beginTransaction();

   //code to create entity....
   Entity e = new Entity();
        session.persist(e);
       
        session.getTransaction().commit();
        long endCreate = Calendar.getInstance().getTimeInMillis();
       
        System.out.println("Create and Store time " + (endCreate - startTime));
        HibernateUtil.getSessionFactory().close();


Any ideas why this is happening?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 13, 2009 11:25 am 
Pro
Pro

Joined: Wed Oct 03, 2007 2:31 pm
Posts: 205
Hmm.. this is strange as I am running my code in async mode as well.
Are you still getting this problem? I'll try to have a look at my stuff and i'll get back to you.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 13, 2009 11:26 am 
Pro
Pro

Joined: Wed Oct 03, 2007 2:31 pm
Posts: 205
Hmm.. this is strange as I am running my code in async mode as well with no problems. I had some issues when using lucene natively.

Are you still getting this problem? I'll try to have a look at my stuff and i'll get back to you.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 13, 2009 1:31 pm 
Newbie

Joined: Fri Mar 06, 2009 11:22 am
Posts: 16
Yep, still getting the problem and I have not seen any others with the issue through google.

I am only getting this problem when running outside of JBoss...in JBoss I do not see the issue.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.