[hibernate-dev] [OGM] Ogm mass indexer, how to convert Tuple/EntityKey to Entity/Id?

Emmanuel Bernard emmanuel at hibernate.org
Mon Mar 4 12:02:24 EST 2013

On 4 mars 2013, at 17:39, Sanne Grinovero <sanne at hibernate.org> wrote:

> On 4 March 2013 16:20, Emmanuel Bernard <emmanuel at hibernate.org> wrote:
>> I already gave what I knew on how to load an entity from a tuple (which
>> isn't much) but we can try and dig together. Something I thought about
>> is that ORM probably has a mechanism to load an entity from a resultset
>> via the query parser. And that probably looks also like the second half
>> of OgmLoader.load. We could look at this part and see if we can make an
>> OGM version of it. We never had the need before as we never had query
>> support (the way SQL does it).
> I would also need to study the ORM code, but to add a high level observation,
> the methods currently defined by the GridDialect are focusing on
> loading from well known key instances,
> there is nothing to makes us able to scan/inspect for all values.
> In other words: even if we wanted to load keys first, we don't have definitions
> of functions from raw->primary key instances either.

I understand that. I'm not denying the need for the method. 

>> On the visitor vs Iterator approach, I still don't see how implementing
>> an Iterator on a map / reduce backend would be harder than the visitor
>> but maybe I'm missing something.
>>    class IteratorAsStream {
>>        final Query someMapReduceQuery = ...;
>>        public Object next() {
>>            if (!someMapReduceQuery.started()) {
>>                // execute and collect results in parallel
>>                someMapReduceQuery.execute();
>>            }
>>            Object result = someMapReduce.getNextOrBlock();
>>            return result;
>>        }
>>    }
> That could work to *load* all entities in parallel, but I'd like to
> process the entities in parallel as well.
> And I'd rather not force the GridDialect implementors to write some
> Hibernate Search specific code,
> so to break out we need some form of "Execute X on each": a closure or a lambda.

I can't see how the visitor model helps in your processing of entities in parallel. To me both approaches are strictly equivalent. Care to show some pseudo-code?

More information about the hibernate-dev mailing list