Hibernate SVN: r19130 - in search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend: impl and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2010-03-29 18:35:23 -0400 (Mon, 29 Mar 2010)
New Revision: 19130
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/AddLuceneWork.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/DeleteLuceneWork.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/WorkQueue.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java
Log:
cleanup code after doubly-applied patch
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/AddLuceneWork.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/AddLuceneWork.java 2010-03-29 15:26:12 UTC (rev 19129)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/AddLuceneWork.java 2010-03-29 22:35:23 UTC (rev 19130)
@@ -66,7 +66,7 @@
@Override
public String toString() {
- return "Add LuceneWork: " + this.getEntityClass().getSimpleName() + "#" + this.getIdInString();
+ return "AddLuceneWork: " + this.getEntityClass().getName() + "#" + this.getIdInString();
}
}
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/DeleteLuceneWork.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/DeleteLuceneWork.java 2010-03-29 15:26:12 UTC (rev 19129)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/DeleteLuceneWork.java 2010-03-29 22:35:23 UTC (rev 19130)
@@ -44,6 +44,7 @@
@Override
public String toString() {
- return "Delete LuceneWork: " + this.getEntityClass().getSimpleName() + "#" + this.getIdInString();
+ return "DeleteLuceneWork: " + this.getEntityClass().getName() + "#" + this.getIdInString();
}
+
}
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/WorkQueue.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/WorkQueue.java 2010-03-29 15:26:12 UTC (rev 19129)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/WorkQueue.java 2010-03-29 22:35:23 UTC (rev 19130)
@@ -55,12 +55,10 @@
this(10);
}
-
public void add(Work work) {
queue.add(work);
}
-
public List<Work> getQueue() {
return queue;
}
@@ -73,14 +71,6 @@
public List<LuceneWork> getSealedQueue() {
if (sealedQueue == null) throw new AssertionFailure("Access a Sealed WorkQueue which has not been sealed");
- if (log.isTraceEnabled()) {
- StringBuilder sb = new StringBuilder();
- for (LuceneWork lw : sealedQueue) {
- sb.append( lw.toString() );
- sb.append( "\n" );
- }
- log.trace( "sending sealedQueue to backend: \n" + sb.toString() );
- }
return sealedQueue;
}
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java 2010-03-29 15:26:12 UTC (rev 19129)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java 2010-03-29 22:35:23 UTC (rev 19130)
@@ -275,13 +275,13 @@
public void performWorks(WorkQueue workQueue) {
List<LuceneWork> sealedQueue = workQueue.getSealedQueue();
- if ( log.isDebugEnabled() ) {
+ if ( log.isTraceEnabled() ) {
StringBuilder sb = new StringBuilder( "Lucene WorkQueue to send to backend: \n\t" );
for ( LuceneWork lw : sealedQueue ) {
sb.append( lw.toString() );
sb.append( "\n\t" );
}
- log.debug( sb.toString() );
+ log.trace( sb.toString() );
}
Runnable processor = backendQueueProcessorFactory.getProcessor( sealedQueue );
if ( sync ) {
14 years, 8 months
Hibernate SVN: r19129 - search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-03-29 11:26:12 -0400 (Mon, 29 Mar 2010)
New Revision: 19129
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java
Log:
HSEARCH-481 clean import
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java 2010-03-29 15:25:11 UTC (rev 19128)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java 2010-03-29 15:26:12 UTC (rev 19129)
@@ -27,11 +27,9 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
-import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
@@ -39,11 +37,10 @@
import org.hibernate.Hibernate;
import org.hibernate.annotations.common.AssertionFailure;
-import org.hibernate.search.backend.AddLuceneWork;
-import org.hibernate.search.backend.DeleteLuceneWork;
-import org.hibernate.util.StringHelper;
import org.hibernate.search.Environment;
+import org.hibernate.search.backend.AddLuceneWork;
import org.hibernate.search.backend.BackendQueueProcessorFactory;
+import org.hibernate.search.backend.DeleteLuceneWork;
import org.hibernate.search.backend.LuceneWork;
import org.hibernate.search.backend.QueueingProcessor;
import org.hibernate.search.backend.Work;
@@ -56,11 +53,12 @@
import org.hibernate.search.backend.impl.jms.JMSBackendQueueProcessorFactory;
import org.hibernate.search.backend.impl.lucene.LuceneBackendQueueProcessorFactory;
import org.hibernate.search.batchindexing.Executors;
+import org.hibernate.search.engine.DocumentBuilderContainedEntity;
import org.hibernate.search.engine.DocumentBuilderIndexedEntity;
import org.hibernate.search.engine.SearchFactoryImplementor;
-import org.hibernate.search.engine.DocumentBuilderContainedEntity;
import org.hibernate.search.util.LoggerFactory;
import org.hibernate.search.util.PluginLoader;
+import org.hibernate.util.StringHelper;
/**
* Batch work until {@link #performWorks} is called.
14 years, 8 months
Hibernate SVN: r19128 - search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-03-29 11:25:11 -0400 (Mon, 29 Mar 2010)
New Revision: 19128
Modified:
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/RecursiveGraphTest.java
Log:
HSEARCH-476 clean test
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/RecursiveGraphTest.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/RecursiveGraphTest.java 2010-03-29 15:19:10 UTC (rev 19127)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/RecursiveGraphTest.java 2010-03-29 15:25:11 UTC (rev 19128)
@@ -104,7 +104,7 @@
for (Fieldable field : (List<Fieldable>)doc.getFields()) {
sb.append( field.name() ).append( ":" ).append( field.stringValue() ).append( " " );
}
- System.out.println( sb.toString() );
+ //System.out.println( sb.toString() );
}
}
finally {
14 years, 8 months
Hibernate SVN: r19127 - search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-03-29 11:19:10 -0400 (Mon, 29 Mar 2010)
New Revision: 19127
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java
Log:
HSEARCH-481 In a given sealed queue, only apply the same add/delete operation once (the first delete and the last add)
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java 2010-03-29 15:06:45 UTC (rev 19126)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java 2010-03-29 15:19:10 UTC (rev 19127)
@@ -24,15 +24,23 @@
*/
package org.hibernate.search.backend.impl;
+import java.io.Serializable;
import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
+import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.hibernate.Hibernate;
+import org.hibernate.annotations.common.AssertionFailure;
+import org.hibernate.search.backend.AddLuceneWork;
+import org.hibernate.search.backend.DeleteLuceneWork;
import org.hibernate.util.StringHelper;
import org.hibernate.search.Environment;
import org.hibernate.search.backend.BackendQueueProcessorFactory;
@@ -140,9 +148,98 @@
*/
processWorkByLayer( queue, initialSize, luceneQueue, Layer.FIRST );
processWorkByLayer( queue, initialSize, luceneQueue, Layer.SECOND );
- workQueue.setSealedQueue( luceneQueue );
+ workQueue.setSealedQueue( optimize( luceneQueue ) );
}
+ private List<LuceneWork> optimize(List<LuceneWork> luceneQueue) {
+ /*
+ * for a given entity id and entity type,
+ * keep the latest AddLuceneWork and the first DeleteLuceneWork
+ * in the queue.
+ *
+ * To do that, keep a list of indexes that need to be removed from the list
+ */
+ final int size = luceneQueue.size();
+ List<Integer> toDelete = new ArrayList<Integer>( size );
+ Map<DuplicatableWork, Integer> workByPosition = new HashMap<DuplicatableWork, Integer>( size );
+ for ( int index = 0 ; index < size; index++ ) {
+ LuceneWork work = luceneQueue.get( index );
+ if ( work instanceof AddLuceneWork ) {
+ DuplicatableWork dupWork = new DuplicatableWork( work );
+ final Integer oldIndex = workByPosition.get( dupWork );
+ if ( oldIndex != null ) {
+ toDelete.add(oldIndex);
+ workByPosition.put( dupWork, index );
+ }
+ workByPosition.put( dupWork, index );
+ }
+ else if ( work instanceof DeleteLuceneWork ) {
+ DuplicatableWork dupWork = new DuplicatableWork( work );
+ final Integer oldIndex = workByPosition.get( dupWork );
+ if ( oldIndex != null ) {
+ toDelete.add(index);
+ }
+ else {
+ workByPosition.put( dupWork, index );
+ }
+ }
+ }
+ List<LuceneWork> result = new ArrayList<LuceneWork>( size - toDelete.size() );
+ for ( int index = 0 ; index < size; index++ ) {
+ if ( ! toDelete.contains( index ) ) {
+ result.add( luceneQueue.get( index ) );
+ }
+ }
+ return result;
+ }
+
+ private static class DuplicatableWork {
+ private final Class<? extends LuceneWork> workType;
+ private final Serializable id;
+ private final Class<?> entityType;
+
+ public DuplicatableWork(LuceneWork work) {
+ workType = work.getClass();
+ if ( ! ( AddLuceneWork.class.isAssignableFrom( workType ) || DeleteLuceneWork.class.isAssignableFrom( workType ) ) ) {
+ throw new AssertionFailure( "Should not be used for lucene work type: " + workType );
+ }
+ id = work.getId();
+ entityType = work.getEntityClass();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if ( this == o ) {
+ return true;
+ }
+ if ( o == null || getClass() != o.getClass() ) {
+ return false;
+ }
+
+ DuplicatableWork that = ( DuplicatableWork ) o;
+
+ if ( !entityType.equals( that.entityType ) ) {
+ return false;
+ }
+ if ( !id.equals( that.id ) ) {
+ return false;
+ }
+ if ( !workType.equals( that.workType ) ) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = workType.hashCode();
+ result = 31 * result + id.hashCode();
+ result = 31 * result + entityType.hashCode();
+ return result;
+ }
+ }
+
private <T> void processWorkByLayer(List<Work> queue, int initialSize, List<LuceneWork> luceneQueue, Layer layer) {
for ( int i = 0; i < initialSize; i++ ) {
@SuppressWarnings("unchecked")
14 years, 8 months
Hibernate SVN: r19126 - in search/trunk/hibernate-search/src: main/java/org/hibernate/search/engine and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-03-29 11:06:45 -0400 (Mon, 29 Mar 2010)
New Revision: 19126
Added:
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/Event.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/ParentOfBirthEvent.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/Person.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/RecursiveGraphTest.java
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/AddLuceneWork.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/DeleteLuceneWork.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/WorkQueue.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/DocumentBuilderContainedEntity.java
Log:
HSEARCH-476 entities found while processing containedIn / IndexedDmbedded and without id will trigger an even down the road => ignore
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/AddLuceneWork.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/AddLuceneWork.java 2010-03-28 22:48:08 UTC (rev 19125)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/AddLuceneWork.java 2010-03-29 15:06:45 UTC (rev 19126)
@@ -66,7 +66,7 @@
@Override
public String toString() {
- return "AddLuceneWork: " + this.getEntityClass().getName() + "#" + this.getIdInString();
+ return "Add LuceneWork: " + this.getEntityClass().getSimpleName() + "#" + this.getIdInString();
}
}
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/DeleteLuceneWork.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/DeleteLuceneWork.java 2010-03-28 22:48:08 UTC (rev 19125)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/DeleteLuceneWork.java 2010-03-29 15:06:45 UTC (rev 19126)
@@ -44,7 +44,6 @@
@Override
public String toString() {
- return "DeleteLuceneWork: " + this.getEntityClass().getName() + "#" + this.getIdInString();
+ return "Delete LuceneWork: " + this.getEntityClass().getSimpleName() + "#" + this.getIdInString();
}
-
}
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/WorkQueue.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/WorkQueue.java 2010-03-28 22:48:08 UTC (rev 19125)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/WorkQueue.java 2010-03-29 15:06:45 UTC (rev 19126)
@@ -29,11 +29,16 @@
import java.util.Collections;
import org.hibernate.annotations.common.AssertionFailure;
+import org.hibernate.search.util.LoggerFactory;
+import org.slf4j.Logger;
/**
* @author Emmanuel Bernard
*/
public class WorkQueue {
+
+ private static final Logger log = LoggerFactory.make();
+
private List<Work> queue;
private List<LuceneWork> sealedQueue;
@@ -66,9 +71,16 @@
return subQueue;
}
-
public List<LuceneWork> getSealedQueue() {
if (sealedQueue == null) throw new AssertionFailure("Access a Sealed WorkQueue which has not been sealed");
+ if (log.isTraceEnabled()) {
+ StringBuilder sb = new StringBuilder();
+ for (LuceneWork lw : sealedQueue) {
+ sb.append( lw.toString() );
+ sb.append( "\n" );
+ }
+ log.trace( "sending sealedQueue to backend: \n" + sb.toString() );
+ }
return sealedQueue;
}
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/DocumentBuilderContainedEntity.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/DocumentBuilderContainedEntity.java 2010-03-28 22:48:08 UTC (rev 19125)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/DocumentBuilderContainedEntity.java 2010-03-29 15:06:45 UTC (rev 19126)
@@ -721,7 +721,14 @@
private <T> void addWorkForEmbeddedValue(T value, List<LuceneWork> queue, Class<T> valueClass,
DocumentBuilderIndexedEntity<T> builderIndexedEntity, SearchFactoryImplementor searchFactoryImplementor) {
Serializable id = ( Serializable ) ReflectionHelper.getMemberValue( value, builderIndexedEntity.idGetter );
- builderIndexedEntity.addWorkToQueue( valueClass, value, id, WorkType.UPDATE, queue, searchFactoryImplementor );
+ if ( id != null) {
+ builderIndexedEntity.addWorkToQueue( valueClass, value, id, WorkType.UPDATE, queue, searchFactoryImplementor );
+ }
+ else {
+ //this is an indexed entity that is not yet persisted but should be reached by cascade
+ // and thus raise an Hibernate Core event leading to its indexing by Hibernate Search
+ // => no need to do anything here
+ }
}
public Analyzer getAnalyzer() {
Added: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/Event.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/Event.java (rev 0)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/Event.java 2010-03-29 15:06:45 UTC (rev 19126)
@@ -0,0 +1,76 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.scratch;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
+import org.hibernate.search.annotations.ContainedIn;
+import org.hibernate.search.annotations.IndexedEmbedded;
+
+@Entity
+public class Event implements Serializable {
+
+ private Long id;
+ private Set<ParentOfBirthEvent> parentsOf = new HashSet<ParentOfBirthEvent>();
+ private Set<Person> children = new HashSet<Person>();
+
+ @Id
+ @GeneratedValue
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ @IndexedEmbedded
+ @OneToMany(mappedBy = "event")
+ public Set<ParentOfBirthEvent> getParentsOf() {
+ return parentsOf;
+ }
+
+ public void setParentsOf(Set<ParentOfBirthEvent> parentsOf) {
+ this.parentsOf = parentsOf;
+ }
+
+ @ContainedIn
+ @OneToMany(mappedBy = "birthEvent")
+ public Set<Person> getChildren() {
+ return children;
+ }
+
+ public void setChildren(Set<Person> children) {
+ this.children = children;
+ }
+
+}
Added: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/ParentOfBirthEvent.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/ParentOfBirthEvent.java (rev 0)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/ParentOfBirthEvent.java 2010-03-29 15:06:45 UTC (rev 19126)
@@ -0,0 +1,82 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.scratch;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+
+import org.hibernate.search.annotations.ContainedIn;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.IndexedEmbedded;
+
+@Entity
+@Indexed
+public class ParentOfBirthEvent {
+
+ private Long id;
+ private Person parent;
+ private Event event;
+
+ public ParentOfBirthEvent(Person parent, Event event) {
+ this.parent = parent;
+ this.event = event;
+ }
+
+ @Id
+ @DocumentId
+ @GeneratedValue
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ @IndexedEmbedded
+ @ManyToOne
+ public Person getParent() {
+ return parent;
+ }
+
+ public void setParent(Person parent) {
+ this.parent = parent;
+ }
+
+ @ContainedIn
+ @ManyToOne(cascade=CascadeType.ALL)
+ public Event getEvent() {
+ return event;
+ }
+
+ public void setEvent(Event event) {
+ this.event = event;
+ }
+
+}
Added: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/Person.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/Person.java (rev 0)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/Person.java 2010-03-29 15:06:45 UTC (rev 19126)
@@ -0,0 +1,100 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.scratch;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+
+import org.hibernate.search.annotations.ContainedIn;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.IndexedEmbedded;
+import org.hibernate.search.annotations.Store;
+
+@Entity
+@Indexed
+public class Person implements Serializable {
+
+ private Long id;
+ private Set<ParentOfBirthEvent> parentOfBirthEvents;
+ private Event birthEvent;
+ private String name;
+
+ public Person() {
+ birthEvent = new Event();
+ birthEvent.getChildren().add( this );
+ parentOfBirthEvents = new HashSet<ParentOfBirthEvent>();
+ }
+
+ @DocumentId
+ @Id
+ @GeneratedValue
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ @ContainedIn
+ @OneToMany(cascade = { CascadeType.ALL })
+ public Set<ParentOfBirthEvent> getParentOfBirthEvents() {
+ return parentOfBirthEvents;
+ }
+
+ public void setParentOfBirthEvents(Set<ParentOfBirthEvent> parentOfBirthEvents) {
+ this.parentOfBirthEvents = parentOfBirthEvents;
+ }
+
+ @IndexedEmbedded(depth = 4)
+ @ManyToOne(cascade = { CascadeType.ALL }, optional = false)
+ public Event getBirthEvent() {
+ return birthEvent;
+ }
+
+ public void setBirthEvent(Event birthEvent) {
+ this.birthEvent = birthEvent;
+ }
+
+ @Field(store=Store.YES)
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
Added: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/RecursiveGraphTest.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/RecursiveGraphTest.java (rev 0)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/scratch/RecursiveGraphTest.java 2010-03-29 15:06:45 UTC (rev 19126)
@@ -0,0 +1,115 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.scratch;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Fieldable;
+import org.apache.lucene.index.CorruptIndexException;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.MatchAllDocsQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.ScoreDoc;
+import org.apache.lucene.search.TopDocs;
+import org.hibernate.Session;
+import org.hibernate.search.test.SearchTestCase;
+
+public class RecursiveGraphTest extends SearchTestCase {
+
+ public void testCreateParentAndChild() throws Exception {
+ Person[] people = new Person[2];
+ Person parent = new Person();
+ parent.setName( "parent" );
+ Person child = new Person();
+ child.setName( "child" );
+ connectChildToParent(child, parent);
+ people[0] = parent;
+ people[1] = child;
+ savePeople( people );
+ showIndexContentsForType( Person.class );
+ assertEquals( 2, getDocumentNbr( Person.class ) );
+ }
+
+ private void connectChildToParent(Person child, Person parent) {
+ Event birthEvent = child.getBirthEvent();
+ child.setBirthEvent(birthEvent);
+ ParentOfBirthEvent parentOfBirthEvent = new ParentOfBirthEvent(parent, child.getBirthEvent());
+ parent.getParentOfBirthEvents().add(parentOfBirthEvent);
+ }
+
+ public void savePeople(Person... people) {
+ for (Person person : people) {
+ if (person==null) continue;
+ Session s = getSessions().openSession();
+ s.getTransaction().begin();
+ s.save( person );
+ s.getTransaction().commit();
+ s.close();
+ }
+ }
+
+ @Override
+ protected Class<?>[] getMappings() {
+ return new Class[]{
+ Event.class,
+ Person.class,
+ ParentOfBirthEvent.class
+ };
+ }
+
+ private int getDocumentNbr(Class type) throws Exception {
+ IndexReader reader = IndexReader.open( getDirectory( type ), false );
+ try {
+ return reader.numDocs();
+ }
+ finally {
+ reader.close();
+ }
+ }
+
+ private void showIndexContentsForType(Class type) throws CorruptIndexException, IOException {
+ IndexSearcher searcher = new IndexSearcher( getDirectory( type ), false );
+ try {
+ Query q = new MatchAllDocsQuery();
+ TopDocs docs = searcher.search( q, null, 100 );
+ ScoreDoc[] scoreDocs = docs.scoreDocs;
+ for (ScoreDoc sd : scoreDocs) {
+ Document doc = searcher.doc( sd.doc );
+ StringBuilder sb = new StringBuilder();
+ for (Fieldable field : (List<Fieldable>)doc.getFields()) {
+ sb.append( field.name() ).append( ":" ).append( field.stringValue() ).append( " " );
+ }
+ System.out.println( sb.toString() );
+ }
+ }
+ finally {
+ searcher.close();
+ }
+ }
+
+}
14 years, 8 months
Hibernate SVN: r19125 - in search/trunk: hibernate-search and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2010-03-28 18:48:08 -0400 (Sun, 28 Mar 2010)
New Revision: 19125
Modified:
search/trunk/hibernate-search-archetype/pom.xml
search/trunk/hibernate-search/pom.xml
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/analyzer/Article.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/analyzer/solr/Team.java
search/trunk/pom.xml
Log:
HSEARCH-454 Upgrade Solr dependencies (Gustavo Fernandes)
Modified: search/trunk/hibernate-search/pom.xml
===================================================================
--- search/trunk/hibernate-search/pom.xml 2010-03-28 19:07:14 UTC (rev 19124)
+++ search/trunk/hibernate-search/pom.xml 2010-03-28 22:48:08 UTC (rev 19125)
@@ -59,10 +59,6 @@
</dependency>
<dependency>
<groupId>org.apache.solr</groupId>
- <artifactId>solr-common</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.solr</groupId>
<artifactId>solr-core</artifactId>
</dependency>
<dependency>
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/analyzer/Article.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/analyzer/Article.java 2010-03-28 19:07:14 UTC (rev 19124)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/analyzer/Article.java 2010-03-28 22:48:08 UTC (rev 19125)
@@ -31,10 +31,10 @@
import javax.persistence.Id;
import javax.persistence.OneToMany;
-import org.apache.solr.analysis.EnglishPorterFilterFactory;
import org.apache.solr.analysis.GermanStemFilterFactory;
import org.apache.solr.analysis.LowerCaseFilterFactory;
import org.apache.solr.analysis.StandardTokenizerFactory;
+import org.apache.solr.analysis.SnowballPorterFilterFactory;
import org.hibernate.search.annotations.AnalyzerDef;
import org.hibernate.search.annotations.AnalyzerDefs;
@@ -43,6 +43,7 @@
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
+import org.hibernate.search.annotations.Parameter;
import org.hibernate.search.annotations.Store;
import org.hibernate.search.annotations.TokenFilterDef;
import org.hibernate.search.annotations.TokenizerDef;
@@ -57,8 +58,9 @@
tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class),
filters = {
@TokenFilterDef(factory = LowerCaseFilterFactory.class),
- @TokenFilterDef(factory = EnglishPorterFilterFactory.class
- )
+ @TokenFilterDef(factory = SnowballPorterFilterFactory.class, params = {
+ @Parameter(name = "language", value = "English")
+ })
}),
@AnalyzerDef(name = "de",
tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class),
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/analyzer/solr/Team.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/analyzer/solr/Team.java 2010-03-28 19:07:14 UTC (rev 19124)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/analyzer/solr/Team.java 2010-03-28 22:48:08 UTC (rev 19125)
@@ -150,7 +150,7 @@
filters = {
@TokenFilterDef(factory = PhoneticFilterFactory.class, params = {
@Parameter(name = "encoder", value = "Metaphone"),
- @Parameter(name = "inject", value = "true")
+ @Parameter(name = "inject", value = "false")
})
})
})
Modified: search/trunk/hibernate-search-archetype/pom.xml
===================================================================
--- search/trunk/hibernate-search-archetype/pom.xml 2010-03-28 19:07:14 UTC (rev 19124)
+++ search/trunk/hibernate-search-archetype/pom.xml 2010-03-28 22:48:08 UTC (rev 19125)
@@ -32,10 +32,6 @@
</dependency>
<dependency>
<groupId>org.apache.solr</groupId>
- <artifactId>solr-common</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.solr</groupId>
<artifactId>solr-core</artifactId>
<exclusions>
<exclusion>
@@ -43,10 +39,6 @@
<artifactId>commons-httpclient</artifactId>
</exclusion>
<exclusion>
- <groupId>org.apache.solr</groupId>
- <artifactId>solr-solrj</artifactId>
- </exclusion>
- <exclusion>
<groupId>woodstox</groupId>
<artifactId>wstx-asl</artifactId>
</exclusion>
Modified: search/trunk/pom.xml
===================================================================
--- search/trunk/pom.xml 2010-03-28 19:07:14 UTC (rev 19124)
+++ search/trunk/pom.xml 2010-03-28 22:48:08 UTC (rev 19125)
@@ -144,6 +144,11 @@
<version>${slf4jVersion}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.solr</groupId>
+ <artifactId>solr-core</artifactId>
+ <version>1.4.0</version>
+ </dependency>
</dependencies>
<dependencyManagement>
@@ -196,13 +201,8 @@
</dependency>
<dependency>
<groupId>org.apache.solr</groupId>
- <artifactId>solr-common</artifactId>
- <version>1.3.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.solr</groupId>
<artifactId>solr-core</artifactId>
- <version>1.3.0</version>
+ <version>1.4.0</version>
<optional>true</optional>
<exclusions>
<exclusion>
@@ -210,10 +210,6 @@
<artifactId>commons-httpclient</artifactId>
</exclusion>
<exclusion>
- <groupId>org.apache.solr</groupId>
- <artifactId>solr-solrj</artifactId>
- </exclusion>
- <exclusion>
<groupId>woodstox</groupId>
<artifactId>wstx-asl</artifactId>
</exclusion>
14 years, 8 months
Hibernate SVN: r19124 - search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/query.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2010-03-28 15:07:14 -0400 (Sun, 28 Mar 2010)
New Revision: 19124
Modified:
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/query/MultiClassesQueryLoaderTest.java
Log:
HSEARCH-322 Review MultiClassesQueryLoader - no problems, just added an extra test
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/query/MultiClassesQueryLoaderTest.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/query/MultiClassesQueryLoaderTest.java 2010-03-28 18:35:44 UTC (rev 19123)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/query/MultiClassesQueryLoaderTest.java 2010-03-28 19:07:14 UTC (rev 19124)
@@ -38,6 +38,7 @@
/**
* @author Emmanuel Bernard
+ * @author Sanne Grinovero
*/
public class MultiClassesQueryLoaderTest extends SearchTestCase {
@@ -61,10 +62,44 @@
List result = hibQuery.list();
assertEquals( "Should have returned no author", 0, result.size() );
- for (Object o : s.createCriteria( Object.class ).list()) {
- s.delete( o );
- }
+ tx.commit();
+ s.close();
+ }
+
+ public void testObjectTypeFiltering() throws Exception {
+ Session sess = openSession();
+ Transaction tx = sess.beginTransaction();
+ Author author = new Author();
+ author.setName( "Moo Cow" );
+ Music music = new Music();
+ music.addAuthor( author );
+ music.setTitle( "The moo moo mooing under the stars" );
+ Book book = new Book();
+ book.setBody( "This is the story of the Moo Cow, who sang the moo moo moo at night" );
+ book.setId( 1 );
+ sess.persist( book );
+ sess.persist( author );
+ sess.persist( music );
+ tx.commit();
+ sess.clear();
+ FullTextSession s = Search.getFullTextSession( sess );
+ tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( getTargetLuceneVersion(), "title", SearchTestCase.keywordAnalyzer );
+ Query query = parser.parse( "name:moo OR title:moo OR body:moo" );
+ FullTextQuery hibQuery = s.createFullTextQuery( query, Music.class );
+ List result = hibQuery.list();
+ assertEquals( "Should match the music only", 1, result.size() );
+ hibQuery = s.createFullTextQuery( query, Author.class, Music.class );
+ result = hibQuery.list();
+ assertEquals( "Should match the author and music only", 2, result.size() );
+ hibQuery = s.createFullTextQuery( query, Author.class, Music.class, Book.class );
+ result = hibQuery.list();
+ assertEquals( "Should match the author, music and book", 3, result.size() );
+ hibQuery = s.createFullTextQuery( query );
+ result = hibQuery.list();
+ assertEquals( "Should match all types", 3, result.size() );
+
tx.commit();
s.close();
}
@@ -72,7 +107,9 @@
protected Class<?>[] getMappings() {
return new Class[] {
Author.class,
- Music.class
+ Music.class,
+ Book.class
};
}
+
}
14 years, 8 months
Hibernate SVN: r19123 - in search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend: impl and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2010-03-28 14:35:44 -0400 (Sun, 28 Mar 2010)
New Revision: 19123
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/AddLuceneWork.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/DeleteLuceneWork.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/OptimizeLuceneWork.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/PurgeAllLuceneWork.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java
Log:
HSEARCH-432 Add logging to trace the WorkQueue before being processed
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/AddLuceneWork.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/AddLuceneWork.java 2010-03-28 15:48:54 UTC (rev 19122)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/AddLuceneWork.java 2010-03-28 18:35:44 UTC (rev 19123)
@@ -63,5 +63,10 @@
public <T> T getWorkDelegate(final WorkVisitor<T> visitor) {
return visitor.getDelegate( this );
}
+
+ @Override
+ public String toString() {
+ return "AddLuceneWork: " + this.getEntityClass().getName() + "#" + this.getIdInString();
+ }
}
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/DeleteLuceneWork.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/DeleteLuceneWork.java 2010-03-28 15:48:54 UTC (rev 19122)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/DeleteLuceneWork.java 2010-03-28 18:35:44 UTC (rev 19123)
@@ -42,4 +42,9 @@
return visitor.getDelegate( this );
}
+ @Override
+ public String toString() {
+ return "DeleteLuceneWork: " + this.getEntityClass().getName() + "#" + this.getIdInString();
+ }
+
}
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/OptimizeLuceneWork.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/OptimizeLuceneWork.java 2010-03-28 15:48:54 UTC (rev 19122)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/OptimizeLuceneWork.java 2010-03-28 18:35:44 UTC (rev 19123)
@@ -45,4 +45,9 @@
return visitor.getDelegate( this );
}
+ @Override
+ public String toString() {
+ return "OptimizeLuceneWork: " + this.getEntityClass().getName();
+ }
+
}
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/PurgeAllLuceneWork.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/PurgeAllLuceneWork.java 2010-03-28 15:48:54 UTC (rev 19122)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/PurgeAllLuceneWork.java 2010-03-28 18:35:44 UTC (rev 19123)
@@ -44,4 +44,9 @@
return visitor.getDelegate( this );
}
+ @Override
+ public String toString() {
+ return "PurgeAllLuceneWork: " + this.getEntityClass().getName();
+ }
+
}
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java 2010-03-28 15:48:54 UTC (rev 19122)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java 2010-03-28 18:35:44 UTC (rev 19123)
@@ -179,7 +179,16 @@
}
public void performWorks(WorkQueue workQueue) {
- Runnable processor = backendQueueProcessorFactory.getProcessor( workQueue.getSealedQueue() );
+ List<LuceneWork> sealedQueue = workQueue.getSealedQueue();
+ if ( log.isDebugEnabled() ) {
+ StringBuilder sb = new StringBuilder( "Lucene WorkQueue to send to backend: \n\t" );
+ for ( LuceneWork lw : sealedQueue ) {
+ sb.append( lw.toString() );
+ sb.append( "\n\t" );
+ }
+ log.debug( sb.toString() );
+ }
+ Runnable processor = backendQueueProcessorFactory.getProcessor( sealedQueue );
if ( sync ) {
processor.run();
}
14 years, 8 months
Hibernate SVN: r19122 - core/trunk/core/src/main/java/org/hibernate/dialect.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-03-28 11:48:54 -0400 (Sun, 28 Mar 2010)
New Revision: 19122
Modified:
core/trunk/core/src/main/java/org/hibernate/dialect/IngresDialect.java
Log:
HHH-4998 org.hibernate.test.hql.ASTParserLoadingTest failure running testStr with Ingres
Modified: core/trunk/core/src/main/java/org/hibernate/dialect/IngresDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/IngresDialect.java 2010-03-28 14:39:15 UTC (rev 19121)
+++ core/trunk/core/src/main/java/org/hibernate/dialect/IngresDialect.java 2010-03-28 15:48:54 UTC (rev 19122)
@@ -41,9 +41,10 @@
* <li> Only supports simple constants or columns on the left side of an IN, making (1,2,3) in (...) or (<subselect>) in (...) non-supported.
* <li> Supports only 39 digits in decimal.
* <li> Explicitly set USE_GET_GENERATED_KEYS property to false.
+ * <li> Perform string casts to varchar; removes space padding.
* </ul>
*
- * @author Ian Booth, Bruce Lunsford, Max Rydahl Andersen
+ * @author Ian Booth, Bruce Lunsford, Max Rydahl Andersen, Raymond Fan
*/
public class IngresDialect extends Dialect {
@@ -139,6 +140,10 @@
registerFunction( "uuid_from_char", new StandardSQLFunction( "uuid_from_char", Hibernate.BYTE ) );
registerFunction( "uuid_to_char", new StandardSQLFunction( "uuid_to_char", Hibernate.STRING ) );
registerFunction( "year", new StandardSQLFunction( "year", Hibernate.INTEGER ) );
+ // Casting to char of numeric values introduces space padding up to the
+ // maximum width of a value for that return type. Casting to varchar
+ // does not introduce space padding.
+ registerFunction( "str", new SQLFunctionTemplate(Hibernate.STRING, "cast(?1 as varchar)") );
// Ingres driver supports getGeneratedKeys but only in the following
// form:
// The Ingres DBMS returns only a single table key or a single object
14 years, 8 months
Hibernate SVN: r19121 - in search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend: impl/lucene and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2010-03-28 10:39:15 -0400 (Sun, 28 Mar 2010)
New Revision: 19121
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/Workspace.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/lucene/PerDPQueueProcessor.java
Log:
HSEARCH-474 Ensure IndexWriter is closed on errors in backend
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/Workspace.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/Workspace.java 2010-03-28 14:33:37 UTC (rev 19120)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/Workspace.java 2010-03-28 14:39:15 UTC (rev 19121)
@@ -214,4 +214,26 @@
return entitiesInDirectory;
}
+ /**
+ * Forces release of Directory lock. Should be used only to cleanup as error recovery.
+ */
+ public synchronized void forceLockRelease() {
+ log.warn( "going to force release of the IndexWriter lock" );
+ try {
+ try {
+ if ( writer != null ) {
+ writer.close();
+ log.trace( "IndexWriter closed" );
+ }
+ }
+ finally {
+ writer = null; //make sure to send a faulty writer into garbage
+ IndexWriter.unlock( directoryProvider.getDirectory() );
+ }
+ }
+ catch (IOException ioe) {
+ throw new SearchException( "IOException while attempting to force release the Directory Lock", ioe );
+ }
+ }
+
}
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/lucene/PerDPQueueProcessor.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/lucene/PerDPQueueProcessor.java 2010-03-28 14:33:37 UTC (rev 19120)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/lucene/PerDPQueueProcessor.java 2010-03-28 14:39:15 UTC (rev 19121)
@@ -87,17 +87,28 @@
return;
}
log.debug( "Opening an IndexWriter for update" );
- IndexWriter indexWriter = workspace.getIndexWriter( batchmode );
try {
- for (LuceneWork lw : workOnWriter) {
- lw.getWorkDelegate( worker ).performWork( lw, indexWriter );
+ IndexWriter indexWriter = workspace.getIndexWriter( batchmode );
+ try {
+ for ( LuceneWork lw : workOnWriter ) {
+ lw.getWorkDelegate( worker ).performWork( lw, indexWriter );
+ }
+ workspace.commitIndexWriter();
+ performOptimizations();
}
- workspace.commitIndexWriter();
- performOptimizations();
+ finally {
+ if ( ! exclusiveIndexUsage ) workspace.closeIndexWriter();
+ }
}
- finally {
- if ( ! exclusiveIndexUsage )
+ catch (Throwable tw) {
+ //needs to be attempted even for out of memory errors, therefore we catch Throwable
+ log.error( "Unexpected error in Lucene Backend: ", tw );
+ try {
workspace.closeIndexWriter();
+ }
+ finally {
+ workspace.forceLockRelease();
+ }
}
}
14 years, 8 months