mirror of https://github.com/apache/lucene.git
SOLR-5261: fix javabin block indexing back compat
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1525732 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
764c248064
commit
f4c6a05206
|
@ -62,7 +62,6 @@ public class JavaBinCodec {
|
|||
END = 15,
|
||||
|
||||
SOLRINPUTDOC = 16,
|
||||
SOLRINPUTDOC_CHILDS = 17,
|
||||
|
||||
// types that combine tag + length (or other info) in a single byte
|
||||
TAG_AND_LEN = (byte) (1 << 5),
|
||||
|
@ -359,36 +358,32 @@ public class JavaBinCodec {
|
|||
|
||||
public SolrInputDocument readSolrInputDocument(DataInputInputStream dis) throws IOException {
|
||||
int sz = readVInt(dis);
|
||||
dis.readByte(); // skip childDocuments tag
|
||||
int childsSize = readVInt(dis);
|
||||
float docBoost = (Float)readVal(dis);
|
||||
SolrInputDocument sdoc = new SolrInputDocument();
|
||||
sdoc.setDocumentBoost(docBoost);
|
||||
for (int i = 0; i < sz; i++) {
|
||||
float boost = 1.0f;
|
||||
String fieldName;
|
||||
Object boostOrFieldName = readVal(dis);
|
||||
if (boostOrFieldName instanceof Float) {
|
||||
boost = (Float)boostOrFieldName;
|
||||
Object obj = readVal(dis); // could be a boost, a field name, or a child document
|
||||
if (obj instanceof Float) {
|
||||
boost = (Float)obj;
|
||||
fieldName = (String)readVal(dis);
|
||||
} else if (obj instanceof SolrInputDocument) {
|
||||
sdoc.addChildDocument((SolrInputDocument)obj);
|
||||
continue;
|
||||
} else {
|
||||
fieldName = (String)boostOrFieldName;
|
||||
fieldName = (String)obj;
|
||||
}
|
||||
Object fieldVal = readVal(dis);
|
||||
sdoc.setField(fieldName, fieldVal, boost);
|
||||
}
|
||||
for (int i = 0; i < childsSize; i++) {
|
||||
dis.readByte(); // skip solrinputdoc tag
|
||||
SolrInputDocument child = readSolrInputDocument(dis);
|
||||
sdoc.addChildDocument(child);
|
||||
}
|
||||
return sdoc;
|
||||
}
|
||||
|
||||
public void writeSolrInputDocument(SolrInputDocument sdoc) throws IOException {
|
||||
writeTag(SOLRINPUTDOC, sdoc.size());
|
||||
List<SolrInputDocument> children = sdoc.getChildDocuments();
|
||||
writeTag(SOLRINPUTDOC_CHILDS, children==null ? 0 : children.size());
|
||||
int sz = sdoc.size() + (children==null ? 0 : children.size());
|
||||
writeTag(SOLRINPUTDOC, sz);
|
||||
writeFloat(sdoc.getDocumentBoost());
|
||||
for (SolrInputField inputField : sdoc.values()) {
|
||||
if (inputField.getBoost() != 1.0f) {
|
||||
|
|
Loading…
Reference in New Issue