Examples of LuceneWork


Examples of org.hibernate.search.backend.LuceneWork

      int queueSize = workList.size();
      LOG.info("Performing " + queueSize + " lucene works");

      for (int i = 0; i < queueSize; i++) {
        LuceneWork work = workList.get(i);
        try {
          long time = 0;
          if (LOG.isLoggable(Level.INFO)) {
            String entity = work.getEntityClass().toString();
            LOG.info("Performing lucene work for " + entity);
            time = System.currentTimeMillis();
          }

          Transaction transaction = datastoreService.beginTransaction();
          try {
            work.getWorkDelegate(getVisitor()).performWork(work, indexWriter, monitor);
            transaction.commit();
          } finally {
            if (transaction.isActive())
              transaction.rollback();
          }

          if (LOG.isLoggable(Level.INFO)) {
            String entity = work.getEntityClass().toString();
            LOG.info("Performed lucene work for " + entity + " in " + (System.currentTimeMillis() - time) + " ms");
          }
        } catch (Exception e) {
          someFailureHappened = true;
          errorContextBuilder.errorThatOccurred(e.getCause());
View Full Code Here

Examples of org.hibernate.search.backend.LuceneWork

     */
    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);
View Full Code Here

Examples of org.hibernate.search.backend.LuceneWork

    Class<?> entityClass = ClassLoaderHelper.classForName(
        entityClassName,
        LuceneWorkHydrator.class,
        "entity class"
    );
    LuceneWork result = new DeleteLuceneWork(
        id,
        objectIdInString( entityClass, id ),
        entityClass
    );
    results.add( result );
View Full Code Here

Examples of org.hibernate.search.backend.LuceneWork

    Class<?> entityClass = ClassLoaderHelper.classForName(
        entityClassName,
        LuceneWorkHydrator.class,
        "entity class"
    );
    LuceneWork result = new AddLuceneWork(
        id,
        objectIdInString( entityClass, id ),
        entityClass,
        getLuceneDocument(),
        fieldToAnalyzerMap
View Full Code Here

Examples of org.hibernate.search.backend.LuceneWork

    Class<?> entityClass = ClassLoaderHelper.classForName(
        entityClassName,
        LuceneWorkHydrator.class,
        "entity class"
    );
    LuceneWork result = new UpdateLuceneWork(
        id,
        objectIdInString( entityClass, id ),
        entityClass,
        getLuceneDocument(),
        fieldToAnalyzerMap
View Full Code Here

Examples of org.hibernate.search.backend.LuceneWork

    doc.add( field );
    field = new Field( "id", "1", Field.Store.YES, Field.Index.NOT_ANALYZED );
    doc.add( field );
    field = new Field( "logo", shirt.getLogo(), Field.Store.NO, Field.Index.ANALYZED );
    doc.add( field );
    LuceneWork luceneWork = new AddLuceneWork(
        shirt.getId(), String.valueOf( shirt.getId() ), shirt.getClass(), doc
    );
    List<LuceneWork> queue = new ArrayList<LuceneWork>();
    queue.add( luceneWork );
    return queue;
View Full Code Here

Examples of org.hibernate.search.backend.LuceneWork

    Class<?> entityClass = ClassLoaderHelper.classForName(
        entityClassName,
        "entity class",
        searchFactory.getServiceManager()
    );
    LuceneWork result = new DeleteLuceneWork(
        id,
        objectIdInString( entityClass, id, conversionContext ),
        entityClass
    );
    results.add( result );
View Full Code Here

Examples of org.hibernate.search.backend.LuceneWork

    Class<?> entityClass = ClassLoaderHelper.classForName(
        entityClassName,
        "entity class",
        searchFactory.getServiceManager()
    );
    LuceneWork result = new AddLuceneWork(
        id,
        objectIdInString( entityClass, id, conversionContext ),
        entityClass,
        getLuceneDocument(),
        fieldToAnalyzerMap
View Full Code Here

Examples of org.hibernate.search.backend.LuceneWork

    Class<?> entityClass = ClassLoaderHelper.classForName(
        entityClassName,
        "entity class",
        searchFactory.getServiceManager()
    );
    LuceneWork result = new UpdateLuceneWork(
        id,
        objectIdInString( entityClass, id, conversionContext ),
        entityClass,
        getLuceneDocument(),
        fieldToAnalyzerMap
View Full Code Here

Examples of org.hibernate.search.backend.LuceneWork

    final int queueSize = workList.size();
    final ExecutorService executor = resources.getWorkersExecutor();
    final Future<LuceneWork>[] submittedTasks = new Future[ queueSize ];

    for ( int i = 0; i < queueSize; i++ ) {
      LuceneWork luceneWork = workList.get( i );
      SingleTaskRunnable task = new SingleTaskRunnable( luceneWork, resources, indexWriter, monitor );
      submittedTasks[i] = executor.submit( task, luceneWork );
    }

    boolean allTasksSuccessful = true;

    // now wait for all tasks being completed before releasing our lock
    // (this thread waits even in async backend mode)
    for ( int i = 0; i < queueSize; i++ ) {
      Future<LuceneWork> task = submittedTasks[i];
      try {
        LuceneWork work = task.get();
        errorContextBuilder.workCompleted( work );
      }
      catch (ExecutionException e) {
        errorContextBuilder.addWorkThatFailed( workList.get( i ) );
        errorContextBuilder.errorThatOccurred( e.getCause() );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.