Hi robatsu,
the mass indexer needs to do the same thing: retrieve the tuple objects from the datastore convert them to entities and then index them.
In the method MondoDBDialect#forEachTuple(...) a com.mongodb.DBCollection is returned and then converted into a Tuple using:
Code:
DBCollection collection = db.getCollection( entityKeyMetadata.getTable() );
for ( DBObject dbObject : collection.find() ) {
consumer.consume( new Tuple( new MassIndexingMongoDBTupleSnapshot( dbObject, entityKeyMetadata ) ) );
}
To see how to obtain the metada you can check BatchIndexingWorkspace#metadata(...)
Code:
private EntityKeyMetadata metadata(SessionFactory sessionFactory, Class<?> indexedType) {
OgmEntityPersister persister = (OgmEntityPersister) ( (SessionFactoryImplementor) sessionFactory ).getEntityPersister( indexedType.getName() );
return new EntityKeyMetadata( persister.getTableName(), persister.getRootTableIdentifierColumnNames() );
}
At some point the consumer will convert the tuple into an enity, the logic is in the method TupleIndexer#entity(...):
Code:
private Object entity(Session session, Tuple tuple) {
OgmEntityPersister persister = (OgmEntityPersister) ( (SessionFactoryImplementor) sessionFactory ).getEntityPersister( indexedType.getName() );
OgmLoader loader = new OgmLoader( new OgmEntityPersister[] { persister } );
List<Tuple> tuples = new ArrayList<Tuple>();
tuples.add( tuple );
OgmLoadingContext ogmLoadingContext = new OgmLoadingContext();
ogmLoadingContext.setTuples( tuples );
List<Object> entities = loader.loadEntities( (SessionImplementor) session, LockOptions.NONE, ogmLoadingContext );
return entities.get( 0 );
}
I hope this can help.