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

Emmanuel Bernard emmanuel at hibernate.org
Mon Mar 4 05:50:37 EST 2013


The mass indexer does not work at the resultset level so mixing tuples
and mass indexer seems wrong to me.

Have you considered something like

    Iterator<Tuple> getAllTuplesFrom(String... tableNames);

And then expose an Iterator<Object> (ie entities) to the mass indexer?
I mean we could make it work with your proposed consumer scheme but I
find it unnecessarily complex and it might make stream / flow style
processing impossible. I can be wrong but I'd like to see your arguments
first.

OgmLoader.getRowFromResultSet shows how to get a Object[] from a Tuple.
OgmLoader.getRow is at the heart of it.

But the process of initializing an entity involves several phases, so
the best bet is to look at OgmLoader.load and look at what happens
globally.

In the end, to answer your question, there is no method to do what
you want today, it's more or less the bottom half of OgmLoader.load.

What about associations BTW?

On Fri 2013-03-01 15:00, Davide D'Alto wrote:
> Hello,
> I'm trying to create a mass indexer that could work with OGM.
> The idea is to have a way to scan all the element of a certain type in
> the data store and index them, this way it would be possible to create
> an index starting from an existing populated data store.
> 
> The first prototype idea is to add a method to the GridDialect, something like:
> 
> GridDialect#forEachTuple(Consumer consumer, String... tableName)
> 
> Where the Consumer is an interface with a method Consumer#consume(Tuple tuple)
> 
> The consumer will execute the indexing of the found tuple.
> 
> The problem that I have now is how to convert the Tuple to the
> corresponding entity so that I can index it using hibernate search.
> An alternative idea would be to use the EntityKey and obtain the id
> instead of using the Tuple.
> 
> Is there a method somewhere that I can use to obtain an entity from a Tuple?
> 
> Thanks,
> Davide
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev


More information about the hibernate-dev mailing list