Apache Lucene open-source search software
SOLR-5261: fix javabin block indexing back compat
Yonik Seeleyf4c6a05206a8
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java b/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.javaindex cd5ae826ec6..c23d0455dba 100644--- a/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java+++ b/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java@@ -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 byteTAG_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) {