if (termsIndexDivisor != -1 && !sr.termsIndexLoaded()) { // If this reader was originally opened because we // needed to merge it, we didn't load the terms // index. But now, if the caller wants the terms // index (eg because it's doing deletes, or an NRT // reader is being opened) we ask the reader to // load its terms index. sr.loadTermsIndex(termsIndexDivisor); }
if (documentMerge) { //Update Dengshilong 2014-09-25 //here is where documentMerge and read FieldCache actually do //read fields and types from start parameters //for every field ,read value from FieldCache , //for numerical field use the correspond byte transform method to build a Field String fieldNamesStr = System .getProperty(Constant.DOCUMENT_MERGE_FIELDS); String typesStr = System .getProperty(Constant.DOCUMENT_MERGE_TYPES); String[] fieldNames = fieldNamesStr.split(","); String[] types = typesStr.split(","); for (; docCount < maxDoc; docCount++) { // NOTE: it's very important to first assign to doc then // pass it to // termVectorsWriter.addAllDocVectors; see LUCENE-1282 Document doc = reader.document(docCount, fieldSelectorMerge); Map typeMap = TypeUtil.TYPE_MAP; for (int i = 0; i < fieldNames.length; i++) { String fieldName = fieldNames[i]; String type = types[i]; Fieldable field = (Fieldable) doc .getFieldable(fieldName); if (field == null) { Types t = (Types) TypeUtil.TYPE_MAP.get(type); switch(t) { case INTEGER: int[] vi = FieldCache.DEFAULT.getInts(reader, fieldName); Field fi = new Field(fieldName, ByteUtil.toArr(vi[docCount]), Store.YES); doc.add(fi); break; case LONG: long[] vl = FieldCache.DEFAULT.getLongs(reader, fieldName); Field fl = new Field(fieldName, ByteUtil.toArr(vl[docCount]), Store.YES); doc.add(fl); break; case FLOAT: float[] vf = FieldCache.DEFAULT.getFloats(reader, fieldName); Field ff = new Field(fieldName, ByteUtil.toArr(vf[docCount]), Store.YES); doc.add(ff); break; case DOUBLE: double[] vd = FieldCache.DEFAULT.getDoubles(reader, fieldName); Field fd = new Field(fieldName, ByteUtil.toArr(vd[docCount]), Store.YES); doc.add(fd); break; } } else { continue; } }