The brief code of the docbuilder class is as follows: Pass the context parameter to the constructor of the entityprocessorwrapper class, and then execute the init () method of entityprocessorwrapper to initialize the data source;
Then, call the entityprocessorwrapper method to obtain the data (all or incrementally import the data)
Public class docbuilder {
Private void dofulldump (){
Builddocument (getvariableresolver (), null, null, root, true, null );
}
Private void dodelta (){
Set <Map <string, Object> deletedkeys = new hashset <Map <string, Object> ();
Set <Map <string, Object> allpks = collectdelta (root, resolver, deletedkeys );
Builddocument (vri, null, MAP, root, true, null );
}
Private void builddocument (variableresolverimpl VR, docwrapper doc, Map <string, Object> PK, dataconfig. entity, Boolean isroot, contextimpl parentctx ){
Builddocument (VR, Doc, PK, entity, isroot, parentctx, entitiestodestroy );
}
Private void builddocument (variableresolverimpl VR, docwrapper doc, Map <string, Object> PK, dataconfig. entity, Boolean isroot, contextimpl parentctx, list <entityprocessorwrapper> entitiestodestroy ){
Entityprocessorwrapper entityprocessor = getentityprocessor (entity );
Contextimpl CTX = new contextimpl (entity, VR, null,
PK = NULL? Context. full_dump: context. delta_dump,
Session, parentctx, this );
Entityprocessor. INIT (CTX );
// Map <string, Object> Arow = entityprocessor. nextrow ();
// Other Code omitted
}
Private entityprocessorwrapper getentityprocessor (dataconfig. entity ){
Entityprocessor = new sqlentityprocessor ();
Return entity. processor = new entityprocessorwrapper (entityprocessor, this );
}
Dataimporter;
Public static final string last_index_time = "last_index_time ";
Public static final string index_start_time = "index_start_time ";
Public docbuilder (dataimporter, solrwriter, dihpropertieswriter propwriter, dataimporter. requestparams reqparams ){
This. dataimporter = dataimporter;
}
Public void execute (){
Dodelta ();
Dofulldump ();
}
Public set <Map <string, Object> collectdelta (dataconfig. entity, variableresolverimpl resolver, set <Map <string, Object> deletedrows ){
// Someone called abort
Entityprocessor = getentityprocessor (entity );
Contextimpl context1 = new contextimpl (entity, resolver, null, context. find_delta, session, null, this );
Entityprocessor. INIT (context1 );
Set <Map <string, Object> mymodifiedpks = new hashset <Map <string, Object> ();
// Map <string, Object> ROW = entityprocessor. nextmodifiedrowkey ();
Return mymodifiedpks;
}
}
The related class diagram is as follows: