You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by cp...@apache.org on 2016/09/26 13:29:07 UTC

[1/3] lucene-solr:master: TestSmileRequest to import response.SmileWriterTest instead of (deprecated) request.SmileWriterTest predecessor. Then remove (three) deprecated/relocated tests. (Follow-ons from SOLR-9538 itself.)

Repository: lucene-solr
Updated Branches:
  refs/heads/master be4233cb5 -> 7a6567e4a


TestSmileRequest to import response.SmileWriterTest instead of (deprecated) request.SmileWriterTest predecessor. Then remove (three) deprecated/relocated tests. (Follow-ons from SOLR-9538 itself.)


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/7a6567e4
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/7a6567e4
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/7a6567e4

Branch: refs/heads/master
Commit: 7a6567e4a66451a2b4b7cba5e6b8373ad200ea8e
Parents: d6d4f34
Author: Christine Poerschke <cp...@apache.org>
Authored: Mon Sep 26 12:39:18 2016 +0100
Committer: Christine Poerschke <cp...@apache.org>
Committed: Mon Sep 26 13:38:26 2016 +0100

----------------------------------------------------------------------
 .../org/apache/solr/request/JSONWriterTest.java | 140 ----------
 .../apache/solr/request/SmileWriterTest.java    | 257 -------------------
 .../solr/request/TestBinaryResponseWriter.java  | 106 --------
 .../apache/solr/search/TestSmileRequest.java    |   2 +-
 4 files changed, 1 insertion(+), 504 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7a6567e4/solr/core/src/test/org/apache/solr/request/JSONWriterTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/request/JSONWriterTest.java b/solr/core/src/test/org/apache/solr/request/JSONWriterTest.java
deleted file mode 100644
index 7bb66c0..0000000
--- a/solr/core/src/test/org/apache/solr/request/JSONWriterTest.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.request;
-
-import java.io.IOException;
-import java.io.StringWriter;
-import java.nio.charset.StandardCharsets;
-import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.common.SolrDocument;
-import org.apache.solr.common.SolrDocumentList;
-import org.apache.solr.common.params.CommonParams;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.search.ReturnFields;
-import org.apache.solr.response.JSONResponseWriter;
-import org.apache.solr.response.PythonResponseWriter;
-import org.apache.solr.response.QueryResponseWriter;
-import org.apache.solr.response.RubyResponseWriter;
-import org.apache.solr.response.SolrQueryResponse;
-import org.apache.solr.search.SolrReturnFields;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/** Test some aspects of JSON/python writer output (very incomplete)
- * @Deprecated use {@link org.apache.solr.response.JSONWriterTest} instead
- *
- */
-@Deprecated
-public class JSONWriterTest extends SolrTestCaseJ4 {
-  @BeforeClass
-  public static void beforeClass() throws Exception {
-    initCore("solrconfig.xml","schema.xml");
-  }
-
-  private void jsonEq(String expected, String received) {
-    expected = expected.trim();
-    received = received.trim();
-    assertEquals(expected, received);
-  }
-  
-  @Test
-  public void testTypes() throws IOException {
-    SolrQueryRequest req = req("dummy");
-    SolrQueryResponse rsp = new SolrQueryResponse();
-    QueryResponseWriter w = new PythonResponseWriter();
-
-    StringWriter buf = new StringWriter();
-    rsp.add("data1", Float.NaN);
-    rsp.add("data2", Double.NEGATIVE_INFINITY);
-    rsp.add("data3", Float.POSITIVE_INFINITY);
-    w.write(buf, req, rsp);
-    jsonEq(buf.toString(), "{'data1':float('NaN'),'data2':-float('Inf'),'data3':float('Inf')}");
-
-    w = new RubyResponseWriter();
-    buf = new StringWriter();
-    w.write(buf, req, rsp);
-    jsonEq(buf.toString(), "{'data1'=>(0.0/0.0),'data2'=>-(1.0/0.0),'data3'=>(1.0/0.0)}");
-
-    w = new JSONResponseWriter();
-    buf = new StringWriter();
-    w.write(buf, req, rsp);
-    jsonEq(buf.toString(), "{\"data1\":\"NaN\",\"data2\":\"-Infinity\",\"data3\":\"Infinity\"}");
-    req.close();
-  }
-
-  @Test
-  public void testJSON() throws IOException {
-    SolrQueryRequest req = req("wt","json","json.nl","arrarr");
-    SolrQueryResponse rsp = new SolrQueryResponse();
-    JSONResponseWriter w = new JSONResponseWriter();
-
-    StringWriter buf = new StringWriter();
-    NamedList nl = new NamedList();
-    nl.add("data1", "he\u2028llo\u2029!");       // make sure that 2028 and 2029 are both escaped (they are illegal in javascript)
-    nl.add(null, 42);
-    rsp.add("nl", nl);
-
-    rsp.add("byte", Byte.valueOf((byte)-3));
-    rsp.add("short", Short.valueOf((short)-4));
-    rsp.add("bytes", "abc".getBytes(StandardCharsets.UTF_8));
-
-    w.write(buf, req, rsp);
-    jsonEq("{\"nl\":[[\"data1\",\"he\\u2028llo\\u2029!\"],[null,42]],\"byte\":-3,\"short\":-4,\"bytes\":\"YWJj\"}", buf.toString());
-    req.close();
-  }
-
-  @Test
-  public void testJSONSolrDocument() throws IOException {
-    SolrQueryRequest req = req(CommonParams.WT,"json",
-                               CommonParams.FL,"id,score");
-    SolrQueryResponse rsp = new SolrQueryResponse();
-    JSONResponseWriter w = new JSONResponseWriter();
-
-    ReturnFields returnFields = new SolrReturnFields(req);
-    rsp.setReturnFields(returnFields);
-
-    StringWriter buf = new StringWriter();
-
-    SolrDocument solrDoc = new SolrDocument();
-    solrDoc.addField("id", "1");
-    solrDoc.addField("subject", "hello2");
-    solrDoc.addField("title", "hello3");
-    solrDoc.addField("score", "0.7");
-
-    SolrDocumentList list = new SolrDocumentList();
-    list.setNumFound(1);
-    list.setStart(0);
-    list.setMaxScore(0.7f);
-    list.add(solrDoc);
-
-    rsp.addResponse(list);
-
-    w.write(buf, req, rsp);
-    String result = buf.toString();
-    assertFalse("response contains unexpected fields: " + result, 
-                result.contains("hello") || 
-                result.contains("\"subject\"") || 
-                result.contains("\"title\""));
-    assertTrue("response doesn't contain expected fields: " + result, 
-               result.contains("\"id\"") &&
-               result.contains("\"score\""));
-
-
-    req.close();
-  }
-  
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7a6567e4/solr/core/src/test/org/apache/solr/request/SmileWriterTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/request/SmileWriterTest.java b/solr/core/src/test/org/apache/solr/request/SmileWriterTest.java
deleted file mode 100644
index 3d34dc6..0000000
--- a/solr/core/src/test/org/apache/solr/request/SmileWriterTest.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.request;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringReader;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.BinaryNode;
-import com.fasterxml.jackson.databind.node.BooleanNode;
-import com.fasterxml.jackson.databind.node.NullNode;
-import com.fasterxml.jackson.databind.node.NumericNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.fasterxml.jackson.dataformat.smile.SmileFactory;
-import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.common.SolrDocument;
-import org.apache.solr.common.SolrDocumentList;
-import org.apache.solr.common.params.CommonParams;
-import org.apache.solr.common.params.ModifiableSolrParams;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.common.util.Utils;
-import org.apache.solr.response.SmileResponseWriter;
-import org.apache.solr.response.SolrQueryResponse;
-import org.apache.solr.search.ReturnFields;
-import org.apache.solr.search.SolrReturnFields;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.noggit.CharArr;
-import org.noggit.JSONParser;
-import org.noggit.JSONWriter;
-import org.noggit.ObjectBuilder;
-
-/** @Deprecated use {@link org.apache.solr.response.SmileWriterTest} instead.
- *
- */
-@Deprecated
-public class SmileWriterTest extends SolrTestCaseJ4 {
-  @BeforeClass
-  public static void beforeClass() throws Exception {
-    initCore("solrconfig.xml","schema.xml");
-  }
-
-  @Test
-  public void testTypes() throws IOException {
-    SolrQueryRequest req = req("dummy");
-    SolrQueryResponse rsp = new SolrQueryResponse();
-    rsp.add("data1", Float.NaN);
-    rsp.add("data2", Double.NEGATIVE_INFINITY);
-    rsp.add("data3", Float.POSITIVE_INFINITY);
-    SmileResponseWriter smileResponseWriter = new SmileResponseWriter();
-    ByteArrayOutputStream baos = new ByteArrayOutputStream();
-    smileResponseWriter.write(baos,req,rsp);
-    Map m = (Map) decodeSmile(new ByteArrayInputStream(baos.toByteArray()));
-    CharArr out = new CharArr();
-    JSONWriter jsonWriter = new JSONWriter(out, 2);
-    jsonWriter.setIndentSize(-1); // indentation by default
-    jsonWriter.write(m);
-    String s = new String(Utils.toUTF8(out), StandardCharsets.UTF_8);
-    assertEquals(s , "{\"data1\":NaN,\"data2\":-Infinity,\"data3\":Infinity}");
-
-    req.close();
-  }
-
-  @Test
-  public void testJSON() throws IOException {
-    SolrQueryRequest req = req("wt","json","json.nl","arrarr");
-    SolrQueryResponse rsp = new SolrQueryResponse();
-    SmileResponseWriter w = new SmileResponseWriter();
-
-    ByteArrayOutputStream buf = new ByteArrayOutputStream();
-    NamedList nl = new NamedList();
-    nl.add("data1", "he\u2028llo\u2029!");       // make sure that 2028 and 2029 are both escaped (they are illegal in javascript)
-    nl.add(null, 42);
-    rsp.add("nl", nl);
-
-    rsp.add("byte", Byte.valueOf((byte)-3));
-    rsp.add("short", Short.valueOf((short)-4));
-    String expected = "{\"nl\":[[\"data1\",\"he\\u2028llo\\u2029!\"],[null,42]],byte:-3,short:-4}";
-    w.write(buf, req, rsp);
-    Map m = (Map) decodeSmile(new ByteArrayInputStream(buf.toByteArray()));
-    Map o2 = (Map) new ObjectBuilder(new JSONParser(new StringReader(expected))).getObject();
-    assertEquals(Utils.toJSONString(m), Utils.toJSONString(o2));
-    req.close();
-  }
-
-  @Test
-  public void testJSONSolrDocument() throws IOException {
-    SolrQueryRequest req = req(CommonParams.WT,"json",
-        CommonParams.FL,"id,score");
-    SolrQueryResponse rsp = new SolrQueryResponse();
-    SmileResponseWriter w = new SmileResponseWriter();
-
-    ReturnFields returnFields = new SolrReturnFields(req);
-    rsp.setReturnFields(returnFields);
-
-    ByteArrayOutputStream buf = new ByteArrayOutputStream();
-
-    SolrDocument solrDoc = new SolrDocument();
-    solrDoc.addField("id", "1");
-    solrDoc.addField("subject", "hello2");
-    solrDoc.addField("title", "hello3");
-    solrDoc.addField("score", "0.7");
-
-    SolrDocumentList list = new SolrDocumentList();
-    list.setNumFound(1);
-    list.setStart(0);
-    list.setMaxScore(0.7f);
-    list.add(solrDoc);
-
-    rsp.addResponse(list);
-
-    w.write(buf, req, rsp);
-
-    byte[] bytes = buf.toByteArray();
-    Map m = (Map) decodeSmile(new ByteArrayInputStream(bytes));
-    m = (Map) m.get("response");
-    List l = (List) m.get("docs");
-    Map doc = (Map) l.get(0);
-    assertFalse(doc.containsKey("subject"));
-    assertFalse(doc.containsKey("title"));
-    assertTrue(doc.containsKey("id"));
-    assertTrue(doc.containsKey("score"));
-    req.close();
-  }
-
-
-  @Test
-  public void test10Docs() throws IOException {
-    SolrDocumentList l = new SolrDocumentList();
-    for(int i=0;i<10; i++){
-      l.add(sampleDoc(random(), i));
-    }
-
-    SolrQueryResponse response = new SolrQueryResponse();
-    response.getValues().add("results", l);
-    ByteArrayOutputStream baos = new ByteArrayOutputStream();
-    new SmileResponseWriter().write(baos, new LocalSolrQueryRequest(null, new ModifiableSolrParams()), response);
-
-    byte[] bytes = baos.toByteArray();
-    Map m = (Map) decodeSmile(new ByteArrayInputStream(bytes, 0, bytes.length));
-    m = (Map) m.get("results");
-    List lst = (List) m.get("docs");
-    assertEquals(lst.size(),10);
-    for (int i = 0; i < lst.size(); i++) {
-      m = (Map) lst.get(i);
-      SolrDocument d = new SolrDocument();
-      d.putAll(m);
-      compareSolrDocument(l.get(i), d);
-    }
-
-  }
-
-  public static SolrDocument sampleDoc(Random r, int bufnum) {
-    SolrDocument sdoc = new SolrDocument();
-    sdoc.put("id", "my_id_" + bufnum);
-    sdoc.put("author", str(r, 10 + r.nextInt(10)));
-    sdoc.put("address", str(r, 20 + r.nextInt(20)));
-    sdoc.put("license", str(r, 10));
-    sdoc.put("title", str(r, 5 + r.nextInt(10)));
-    sdoc.put("title_bin", str(r, 5 + r.nextInt(10)).getBytes(StandardCharsets.UTF_8));
-    sdoc.put("modified_dt", r.nextInt(1000000));
-    sdoc.put("creation_dt", r.nextInt(1000000));
-    sdoc.put("birthdate_dt", r.nextInt(1000000));
-    sdoc.put("clean", r.nextBoolean());
-    sdoc.put("dirty", r.nextBoolean());
-    sdoc.put("employed", r.nextBoolean());
-    sdoc.put("priority", r.nextInt(100));
-    sdoc.put("dependents", r.nextInt(6));
-    sdoc.put("level", r.nextInt(101));
-    sdoc.put("education_level", r.nextInt(10));
-    // higher level of reuse for string values
-    sdoc.put("state", "S"+r.nextInt(50));
-    sdoc.put("country", "Country"+r.nextInt(20));
-    sdoc.put("some_boolean", ""+r.nextBoolean());
-    sdoc.put("another_boolean", ""+r.nextBoolean());
-    return sdoc;
-  }
-  // common-case ascii
-  static String str(Random r, int sz) {
-    StringBuffer sb = new StringBuffer(sz);
-    for (int i=0; i<sz; i++) {
-      sb.append('\n' + r.nextInt(128-'\n'));
-    }
-    return sb.toString();
-  }
-
-
-  public static Object decodeSmile( InputStream is) throws IOException {
-    final SmileFactory smileFactory = new SmileFactory();
-    com.fasterxml.jackson.databind.ObjectMapper mapper = new  com.fasterxml.jackson.databind.ObjectMapper(smileFactory);
-    JsonNode jsonNode = mapper.readTree(is);
-    return getVal(jsonNode);
-  }
-
-
-  public static Object getVal(JsonNode value) {
-    if (value instanceof NullNode) {
-      return null;
-    }
-    if (value instanceof NumericNode) {
-      return ((NumericNode) value).numberValue();
-    }
-    if (value instanceof BooleanNode) {
-      ((BooleanNode) value).booleanValue();
-    }
-    if(value instanceof ObjectNode){
-      Iterator<Map.Entry<String, JsonNode>> it = ((ObjectNode)value).fields();
-      Map result = new LinkedHashMap<>();
-      while(it.hasNext()){
-        Map.Entry<String, JsonNode> e = it.next();
-        result.put(e.getKey(),getVal(e.getValue()));
-      }
-      return result;
-    }
-    if (value instanceof ArrayNode) {
-      ArrayList result =  new ArrayList();
-      Iterator<JsonNode> it = ((ArrayNode) value).elements();
-      while (it.hasNext()) {
-        result.add(getVal(it.next()));
-      }
-      return result;
-
-    }
-    if(value instanceof BinaryNode) {
-      return ((BinaryNode) value).binaryValue();
-    }
-
-    return value.textValue();
-  }
-
-
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7a6567e4/solr/core/src/test/org/apache/solr/request/TestBinaryResponseWriter.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/request/TestBinaryResponseWriter.java b/solr/core/src/test/org/apache/solr/request/TestBinaryResponseWriter.java
deleted file mode 100644
index 2a8531f..0000000
--- a/solr/core/src/test/org/apache/solr/request/TestBinaryResponseWriter.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.request;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.util.Locale;
-import java.util.Map;
-import java.util.UUID;
-
-import org.apache.solr.common.SolrDocument;
-import org.apache.solr.common.SolrDocumentList;
-import org.apache.solr.common.params.CommonParams;
-import org.apache.solr.common.util.JavaBinCodec;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.response.BinaryQueryResponseWriter;
-import org.apache.solr.response.BinaryResponseWriter.Resolver;
-import org.apache.solr.response.SolrQueryResponse;
-import org.apache.solr.search.SolrReturnFields;
-import org.apache.solr.util.AbstractSolrTestCase;
-import org.junit.BeforeClass;
-
-/**
- * Test for BinaryResponseWriter
- * @Deprecated use {@link org.apache.solr.response.TestBinaryResponseWriter} instead.
- *
- * @since solr 1.4
- */
-@Deprecated
-public class TestBinaryResponseWriter extends AbstractSolrTestCase {
-
-  
-  @BeforeClass
-  public static void beforeClass() throws Exception {
-    System.setProperty("enable.update.log", "false"); // schema12 doesn't support _version_
-    initCore("solrconfig.xml", "schema12.xml");
-  }
-
-  /**
-   * Tests known types implementation by asserting correct encoding/decoding of UUIDField
-   */
-  public void testUUID() throws Exception {
-    String s = UUID.randomUUID().toString().toLowerCase(Locale.ROOT);
-    assertU(adoc("id", "101", "uuid", s));
-    assertU(commit());
-    LocalSolrQueryRequest req = lrf.makeRequest("q", "*:*");
-    SolrQueryResponse rsp = h.queryAndResponse(req.getParams().get(CommonParams.QT), req);
-    BinaryQueryResponseWriter writer = (BinaryQueryResponseWriter) h.getCore().getQueryResponseWriter("javabin");
-    ByteArrayOutputStream baos = new ByteArrayOutputStream();
-    writer.write(baos, req, rsp);
-    NamedList res = (NamedList) new JavaBinCodec().unmarshal(new ByteArrayInputStream(baos.toByteArray()));
-    SolrDocumentList docs = (SolrDocumentList) res.get("response");
-    for (Object doc : docs) {
-      SolrDocument document = (SolrDocument) doc;
-      assertEquals("Returned object must be a string", "java.lang.String", document.getFieldValue("uuid").getClass().getName());
-      assertEquals("Wrong UUID string returned", s, document.getFieldValue("uuid"));
-    }
-
-    req.close();
-  }
-
-  public void testResolverSolrDocumentPartialFields() throws Exception {
-    LocalSolrQueryRequest req = lrf.makeRequest("q", "*:*",
-                                                "fl", "id,xxx,ddd_s"); 
-    SolrDocument in = new SolrDocument();
-    in.addField("id", 345);
-    in.addField("aaa_s", "aaa");
-    in.addField("bbb_s", "bbb");
-    in.addField("ccc_s", "ccc");
-    in.addField("ddd_s", "ddd");
-    in.addField("eee_s", "eee");    
-
-    Resolver r = new Resolver(req, new SolrReturnFields(req));
-    Object o = r.resolve(in, new JavaBinCodec());
-
-    assertNotNull("obj is null", o);
-    assertTrue("obj is not doc", o instanceof SolrDocument);
-
-    SolrDocument out = new SolrDocument();
-    for (Map.Entry<String, Object> e : in) {
-      if(r.isWritable(e.getKey())) out.put(e.getKey(),e.getValue());
-
-    }
-    assertTrue("id not found", out.getFieldNames().contains("id"));
-    assertTrue("ddd_s not found", out.getFieldNames().contains("ddd_s"));
-    assertEquals("Wrong number of fields found", 
-                 2, out.getFieldNames().size());
-    req.close();
-
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7a6567e4/solr/core/src/test/org/apache/solr/search/TestSmileRequest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/search/TestSmileRequest.java b/solr/core/src/test/org/apache/solr/search/TestSmileRequest.java
index 78760da..c6d72ee 100644
--- a/solr/core/src/test/org/apache/solr/search/TestSmileRequest.java
+++ b/solr/core/src/test/org/apache/solr/search/TestSmileRequest.java
@@ -30,7 +30,7 @@ import org.apache.solr.client.solrj.request.QueryRequest;
 import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.common.util.Utils;
-import org.apache.solr.request.SmileWriterTest;
+import org.apache.solr.response.SmileWriterTest;
 import org.apache.solr.search.json.TestJsonRequest;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;


[2/3] lucene-solr:master: Fix @link typo.

Posted by cp...@apache.org.
Fix @link typo.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/d6d4f347
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/d6d4f347
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/d6d4f347

Branch: refs/heads/master
Commit: d6d4f34757448e90bd3afc54de238353c12388ec
Parents: a8f4ef0
Author: Christine Poerschke <cp...@apache.org>
Authored: Mon Sep 26 12:37:04 2016 +0100
Committer: Christine Poerschke <cp...@apache.org>
Committed: Mon Sep 26 13:38:26 2016 +0100

----------------------------------------------------------------------
 lucene/core/src/java/org/apache/lucene/util/ByteBlockPool.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d6d4f347/lucene/core/src/java/org/apache/lucene/util/ByteBlockPool.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/util/ByteBlockPool.java b/lucene/core/src/java/org/apache/lucene/util/ByteBlockPool.java
index e575d87..1b71440 100644
--- a/lucene/core/src/java/org/apache/lucene/util/ByteBlockPool.java
+++ b/lucene/core/src/java/org/apache/lucene/util/ByteBlockPool.java
@@ -282,7 +282,7 @@ public final class ByteBlockPool {
 
   /** Fill the provided {@link BytesRef} with the bytes at the specified offset/length slice.
    *  This will avoid copying the bytes, if the slice fits into a single block; otherwise, it uses
-   *  the provided {@linkl BytesRefBuilder} to copy bytes over. */
+   *  the provided {@link BytesRefBuilder} to copy bytes over. */
   void setBytesRef(BytesRefBuilder builder, BytesRef result, long offset, int length) {
     result.length = length;
 


[3/3] lucene-solr:master: SOLR-9543: reduce code duplication in ReRankQParserPlugin.ReRankCollector.topDocs (part 2 of 2)

Posted by cp...@apache.org.
SOLR-9543: reduce code duplication in ReRankQParserPlugin.ReRankCollector.topDocs (part 2 of 2)


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/a8f4ef02
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/a8f4ef02
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/a8f4ef02

Branch: refs/heads/master
Commit: a8f4ef02edf83043fcf04db2a8c42832892aaa78
Parents: be4233c
Author: Christine Poerschke <cp...@apache.org>
Authored: Mon Sep 26 12:27:12 2016 +0100
Committer: Christine Poerschke <cp...@apache.org>
Committed: Mon Sep 26 13:38:26 2016 +0100

----------------------------------------------------------------------
 .../apache/solr/search/ReRankQParserPlugin.java | 52 ++++++--------------
 1 file changed, 15 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a8f4ef02/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java
index e4f00ee..a230170 100644
--- a/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java
@@ -268,45 +268,23 @@ public class ReRankQParserPlugin extends QParserPlugin {
           IntIntHashMap boostedDocs = QueryElevationComponent.getBoostDocs((SolrIndexSearcher)searcher, boostedPriority, requestContext);
 
           Arrays.sort(rescoredDocs.scoreDocs, new BoostedComp(boostedDocs, mainDocs.scoreDocs, rescoredDocs.getMaxScore()));
+        }
 
-          if(howMany == rescoredDocs.scoreDocs.length) {
-            return rescoredDocs; // Just return the rescoredDocs
-          } else if(howMany > rescoredDocs.scoreDocs.length) {
-            //We need to return more then we've reRanked, so create the combined page.
-            ScoreDoc[] scoreDocs = new ScoreDoc[howMany];
-            System.arraycopy(mainScoreDocs, 0, scoreDocs, 0, scoreDocs.length); //lay down the initial docs
-            System.arraycopy(rescoredDocs.scoreDocs, 0, scoreDocs, 0, rescoredDocs.scoreDocs.length);//overlay the re-ranked docs.
-            rescoredDocs.scoreDocs = scoreDocs;
-            return rescoredDocs;
-          } else {
-            //We've rescored more then we need to return.
-            ScoreDoc[] scoreDocs = new ScoreDoc[howMany];
-            System.arraycopy(rescoredDocs.scoreDocs, 0, scoreDocs, 0, howMany);
-            rescoredDocs.scoreDocs = scoreDocs;
-            return rescoredDocs;
-          }
-
+        if(howMany == rescoredDocs.scoreDocs.length) {
+          return rescoredDocs; // Just return the rescoredDocs
+        } else if(howMany > rescoredDocs.scoreDocs.length) {
+          //We need to return more then we've reRanked, so create the combined page.
+          ScoreDoc[] scoreDocs = new ScoreDoc[howMany];
+          System.arraycopy(mainScoreDocs, 0, scoreDocs, 0, scoreDocs.length); //lay down the initial docs
+          System.arraycopy(rescoredDocs.scoreDocs, 0, scoreDocs, 0, rescoredDocs.scoreDocs.length);//overlay the re-ranked docs.
+          rescoredDocs.scoreDocs = scoreDocs;
+          return rescoredDocs;
         } else {
-
-          if(howMany == rescoredDocs.scoreDocs.length) {
-            return rescoredDocs; // Just return the rescoredDocs
-          } else if(howMany > rescoredDocs.scoreDocs.length) {
-
-            //We need to return more then we've reRanked, so create the combined page.
-            ScoreDoc[] scoreDocs = new ScoreDoc[howMany];
-            //lay down the initial docs
-            System.arraycopy(mainScoreDocs, 0, scoreDocs, 0, scoreDocs.length);
-            //overlay the rescoreds docs
-            System.arraycopy(rescoredDocs.scoreDocs, 0, scoreDocs, 0, rescoredDocs.scoreDocs.length);
-            rescoredDocs.scoreDocs = scoreDocs;
-            return rescoredDocs;
-          } else {
-            //We've rescored more then we need to return.
-            ScoreDoc[] scoreDocs = new ScoreDoc[howMany];
-            System.arraycopy(rescoredDocs.scoreDocs, 0, scoreDocs, 0, howMany);
-            rescoredDocs.scoreDocs = scoreDocs;
-            return rescoredDocs;
-          }
+          //We've rescored more then we need to return.
+          ScoreDoc[] scoreDocs = new ScoreDoc[howMany];
+          System.arraycopy(rescoredDocs.scoreDocs, 0, scoreDocs, 0, howMany);
+          rescoredDocs.scoreDocs = scoreDocs;
+          return rescoredDocs;
         }
       } catch (Exception e) {
         throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);