上文说由DataImporter类进一步处理,DataImporter类的简要代码如下
/***********************************************************************
* Module: DataImporter.java
* Author: Administrator
* Purpose: Defines the Class DataImporter
***********************************************************************/
import java.util.*;
/** @pdOid 6bcd8340-c69a-4f17-b886-2c530258bdb6 */
public class DataImporter {
/** @param key
* @param name
* @param ctx
* @pdOid f7657de8-0309-4376-895f-ee6d10261de2 */
DataSource getDataSourceInstance(DataConfig.Entity key, String name, Context ctx) {
DataSource dataSrc = new JdbcDataSource();
return DataSource;
}
/** @param reqParams
* @param sw
* @pdOid d62e4f04-48dc-485b-bb00-be1a56117e92 */
void runCmd(RequestParams reqParams, SolrWriter sw) {
doFullImport(sw,reqParams);
doDeltaImport(sw,reqParams);
}
/** @pdOid bd4adb15-5fad-4770-a57e-3443bf440533 */
public DocBuilder docBuilder;
/** @param writer
* @param requestParams
* @pdOid 8743a461-6a20-44ad-bd75-d1cdfd97ede0 */
public void doFullImport(SolrWriter writer, RequestParams requestParams) {
docBuilder = new DocBuilder(this, writer, propWriter, requestParams);
docBuilder.execute();
}
/** @param writer
* @param requestParams
* @pdOid a43ada26-0d41-4b02-ba66-a22a4a369a46 */
public void doDeltaImport(SolrWriter writer, RequestParams requestParams) {
docBuilder = new DocBuilder(this, writer, propWriter, requestParams);
docBuilder.execute();
}
* Module: DataImporter.java
* Author: Administrator
* Purpose: Defines the Class DataImporter
***********************************************************************/
import java.util.*;
/** @pdOid 6bcd8340-c69a-4f17-b886-2c530258bdb6 */
public class DataImporter {
/** @param key
* @param name
* @param ctx
* @pdOid f7657de8-0309-4376-895f-ee6d10261de2 */
DataSource getDataSourceInstance(DataConfig.Entity key, String name, Context ctx) {
DataSource dataSrc = new JdbcDataSource();
return DataSource;
}
/** @param reqParams
* @param sw
* @pdOid d62e4f04-48dc-485b-bb00-be1a56117e92 */
void runCmd(RequestParams reqParams, SolrWriter sw) {
doFullImport(sw,reqParams);
doDeltaImport(sw,reqParams);
}
/** @pdOid bd4adb15-5fad-4770-a57e-3443bf440533 */
public DocBuilder docBuilder;
/** @param writer
* @param requestParams
* @pdOid 8743a461-6a20-44ad-bd75-d1cdfd97ede0 */
public void doFullImport(SolrWriter writer, RequestParams requestParams) {
docBuilder = new DocBuilder(this, writer, propWriter, requestParams);
docBuilder.execute();
}
/** @param writer
* @param requestParams
* @pdOid a43ada26-0d41-4b02-ba66-a22a4a369a46 */
public void doDeltaImport(SolrWriter writer, RequestParams requestParams) {
docBuilder = new DocBuilder(this, writer, propWriter, requestParams);
docBuilder.execute();
}
}
其中runCmd方法根据请求参数决定调用自身的doFullImport(sw,reqParams); 方法或doDeltaImport(sw,reqParams);方法,分别对应全部导入和增量导入
DataImporter类持有对DocBuilder 的引用,具体的InputDocument的创建由DocBuilder 类实现