Investigating ... looks like an error expecting specific iteration of a Map.
: Date: Wed, 19 Jan 2011 01:19:59 +0100 : From: Uwe Schindler <[email protected]> : Reply-To: [email protected] : To: [email protected] : Subject: RE: svn commit: r1060589 - in /lucene/dev/branches/branch_3x/solr: ./ : src/java/org/apache/solr/response/ src/test/org/apache/solr/request/ : src/test/org/apache/solr/response/ : : Hi Hoss, : : for some reason this test always fails here in JRE 1.5.22, windows 64bit - I have no idea why it fails: : : [junit] Testsuite: org.apache.solr.response.TestPHPSerializedResponseWriter : [junit] Testcase: testSolrDocuments(org.apache.solr.response.TestPHPSerializedResponseWriter): Caused an ERROR : [junit] expected:<...cs";a:2:{i:0;a:6:{s:[5:"data2";i:42;s:5:"data4";a:2:{s:7:"data4.1";s:5:"hello";s:7:"data4.2";s:7:"hashmap"; : }s:5:"data5";a:3:{i:0;s:7:"data5.1";i:1;s:7:"data5.2";i:2;s:7:"data5.3";}s:5:"data3";b:1;s:5:"data1";s:5:"hello";s:2:"id";s:1:"1"];} : i:1;a:1:{s:2:"id";...> but was:<...cs";a:2:{i:0;a:6:{s:[2:"id";s:1:"1";s:5:"data1";s:5:"hello";s:5:"data4";a:2:{s:7:"data4.2";s:7:"h : ashmap";s:7:"data4.1";s:5:"hello";}s:5:"data5";a:3:{i:0;s:7:"data5.1";i:1;s:7:"data5.2";i:2;s:7:"data5.3";}s:5:"data2";i:42;s:5:"dat : a3";b:1];}i:1;a:1:{s:2:"id";...> : [junit] at org.apache.solr.response.TestPHPSerializedResponseWriter.testSolrDocuments(TestPHPSerializedResponseWriter.java:9 : 7) : [junit] at org.apache.lucene.util.LuceneTestCase$LuceneTestCaseRunner.runChild(LuceneTestCase.java:1007) : [junit] at org.apache.lucene.util.LuceneTestCase$LuceneTestCaseRunner.runChild(LuceneTestCase.java:939) : [junit] : [junit] : [junit] Tests run: 2, Failures: 0, Errors: 1, Time elapsed: 0,92 sec : [junit] : [junit] ------------- Standard Error ----------------- : [junit] NOTE: reproduce with: ant test -Dtestcase=TestPHPSerializedResponseWriter -Dtestmethod=testSolrDocuments -Dtests.seed=-4 : 471053174879366440:3010158564746321131 : [junit] NOTE: test params are: locale=es_ES, timezone=SystemV/HST10 : [junit] NOTE: all tests run in this JVM: : [junit] [EchoParamsTest, MinimalSchemaTest, TestSolrCoreProperties, LengthFilterTest, TestChineseTokenizerFactory, TestEnglishMi : nimalStemFilterFactory, TestGermanStemFilterFactory, TestItalianLightStemFilterFactory, TestPatternReplaceCharFilter, TestPortuguese : StemFilterFactory, TestStandardFactories, TestTurkishLowerCaseFilterFactory, SolrExampleBinaryTest, LargeVolumeEmbeddedTest, TestSol : rProperties, SolrDocumentTest, TestJavaBinCodec, ResourceLoaderTest, TestLegacyMergeSchedulerPolicyConfig, SpellCheckerRequestHandle : rTest, SpellCheckComponentTest, TestPHPSerializedResponseWriter] : [junit] NOTE: Windows 7 6.1 amd64/Sun Microsystems Inc. 1.5.0_22 (64-bit)/cpus=2,threads=2,free=159377304,total=186777600 : [junit] ------------- ---------------- --------------- : [junit] TEST org.apache.solr.response.TestPHPSerializedResponseWriter FAILED : : ----- : Uwe Schindler : H.-H.-Meier-Allee 63, D-28213 Bremen : http://www.thetaphi.de : eMail: [email protected] : : : > -----Original Message----- : > From: [email protected] [mailto:[email protected]] : > Sent: Tuesday, January 18, 2011 10:45 PM : > To: [email protected] : > Subject: svn commit: r1060589 - in /lucene/dev/branches/branch_3x/solr: ./ : > src/java/org/apache/solr/response/ src/test/org/apache/solr/request/ : > src/test/org/apache/solr/response/ : > : > Author: hossman : > Date: Tue Jan 18 21:44:33 2011 : > New Revision: 1060589 : > : > URL: http://svn.apache.org/viewvc?rev=1060589&view=rev : > Log: : > SOLR-2307: merge trunk r1060585 : > : > Added: : > : > lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/response/T : > estPHPSerializedResponseWriter.java : > - copied unchanged from r1060585, : > lucene/dev/trunk/solr/src/test/org/apache/solr/response/TestPHPSerialize : > dResponseWriter.java : > Modified: : > lucene/dev/branches/branch_3x/solr/ (props changed) : > lucene/dev/branches/branch_3x/solr/CHANGES.txt : > : > lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/response/P : > HPSerializedResponseWriter.java : > : > lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/request/JSO : > NWriterTest.java : > : > Modified: lucene/dev/branches/branch_3x/solr/CHANGES.txt : > URL: : > http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/CHAN : > GES.txt?rev=1060589&r1=1060588&r2=1060589&view=diff : > ========================================================== : > ==================== : > --- lucene/dev/branches/branch_3x/solr/CHANGES.txt (original) : > +++ lucene/dev/branches/branch_3x/solr/CHANGES.txt Tue Jan 18 21:44:33 : > +++ 2011 : > @@ -467,6 +467,10 @@ Bug Fixes : > * SOLR-2261: fix velocity template layout.vm that referred to an older : > version of jquery. (Eric Pugh via rmuir) : > : > +* SOLR-2307: fix bug in PHPSerializedResponseWriter (wt=phps) when : > + dealing with SolrDocumentList objects -- ie: sharded queries. : > + (Antonio Verni via hossman) : > + : > : > Other Changes : > ---------------------- : > : > Modified: : > lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/response/P : > HPSerializedResponseWriter.java : > URL: : > http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/jav : > a/org/apache/solr/response/PHPSerializedResponseWriter.java?rev=106058 : > 9&r1=1060588&r2=1060589&view=diff : > ========================================================== : > ==================== : > --- : > lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/response/P : > HPSerializedResponseWriter.java (original) : > +++ : > lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/response : > +++ /PHPSerializedResponseWriter.java Tue Jan 18 21:44:33 2011 : > @@ -31,7 +31,8 @@ import org.apache.solr.schema.SchemaFiel import : > org.apache.solr.search.DocIterator; : > import org.apache.solr.search.DocList; : > import org.apache.solr.search.SolrIndexSearcher; : > - : > +import org.apache.solr.common.SolrDocument; : > +import org.apache.solr.common.SolrDocumentList; : > /** : > * A description of the PHP serialization format can be found here: : > * http://www.hurring.com/scott/code/perl/serialize/ : > @@ -200,6 +201,96 @@ class PHPSerializedWriter extends JSONWr : > } : > : > @Override : > + public void writeSolrDocument(String name, SolrDocument doc, : > Set<String> returnFields, Map pseudoFields) throws IOException { : > + HashMap <String,Object> single = new HashMap<String, Object>(); : > + HashMap <String,Object> multi = new HashMap<String, Object>(); : > + int pseudoSize = pseudoFields != null ? pseudoFields.size() : 0; : > + : > + for (String fname : doc.getFieldNames()) { : > + if(returnFields != null && !returnFields.contains(fname)){ : > + continue; : > + } : > + : > + Object val = doc.getFieldValue(fname); : > + SchemaField sf = schema.getFieldOrNull(fname); : > + if (sf != null && sf.multiValued()) { : > + multi.put(fname, val); : > + }else{ : > + single.put(fname, val); : > + } : > + } : > + : > + writeMapOpener(single.size() + multi.size() + pseudoSize); : > + for(String fname: single.keySet()){ : > + Object val = single.get(fname); : > + writeKey(fname, true); : > + writeVal(fname, val); : > + } : > + : > + for(String fname: multi.keySet()){ : > + writeKey(fname, true); : > + : > + Object val = multi.get(fname); : > + if (!(val instanceof Collection)) { : > + // should never be reached if multivalued fields are stored as a : > Collection : > + // so I'm assuming a size of 1 just to wrap the single value : > + writeArrayOpener(1); : > + writeVal(fname, val); : > + writeArrayCloser(); : > + }else{ : > + writeVal(fname, val); : > + } : > + } : > + : > + if (pseudoSize > 0) { : > + writeMap(null,pseudoFields,true, false); : > + } : > + writeMapCloser(); : > + } : > + : > + : > + @Override : > + public void writeSolrDocumentList(String name, SolrDocumentList docs, : > Set<String> fields, Map otherFields) throws IOException { : > + boolean includeScore=false; : > + if (fields!=null) { : > + includeScore = fields.contains("score"); : > + if (fields.size()==0 || (fields.size()==1 && includeScore) || : > fields.contains("*")) { : > + fields=null; // null means return all stored fields : > + } : > + } : > + : > + int sz = docs.size(); : > + : > + writeMapOpener(includeScore ? 4 : 3); : > + : > + writeKey("numFound",false); : > + writeLong(null,docs.getNumFound()); : > + : > + writeKey("start",false); : > + writeLong(null,docs.getStart()); : > + : > + if (includeScore && docs.getMaxScore() != null) { : > + writeKey("maxScore",false); : > + writeFloat(null,docs.getMaxScore()); : > + } : > + : > + writeKey("docs",false); : > + : > + writeArrayOpener(sz); : > + for (int i=0; i<sz; i++) { : > + writeKey(i, false); : > + writeSolrDocument(null, docs.get(i), fields, otherFields); : > + } : > + writeArrayCloser(); : > + : > + if (otherFields !=null) { : > + writeMap(null, otherFields, true, false); : > + } : > + writeMapCloser(); : > + } : > + : > + : > + @Override : > public void writeArray(String name, Object[] val) throws IOException { : > writeMapOpener(val.length); : > for(int i=0; i < val.length; i++) { : > : > Modified: : > lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/request/JSO : > NWriterTest.java : > URL: : > http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/tes : > t/org/apache/solr/request/JSONWriterTest.java?rev=1060589&r1=1060588& : > r2=1060589&view=diff : > ========================================================== : > ==================== : > --- : > lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/request/JSO : > NWriterTest.java (original) : > +++ : > lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/request/ : > +++ JSONWriterTest.java Tue Jan 18 21:44:33 2011 : > @@ -62,24 +62,9 @@ public class JSONWriterTest extends Solr : > buf = new StringWriter(); : > w.write(buf, req, rsp); : > assertEquals(buf.toString(), "{\"data1\":\"NaN\",\"data2\":\"- : > Infinity\",\"data3\":\"Infinity\"}"); : > - : > - } : > - : > - @Test : > - public void testPHPS() throws IOException { : > - SolrQueryRequest req = req("dummy"); : > - SolrQueryResponse rsp = new SolrQueryResponse(); : > - QueryResponseWriter w = new PHPSerializedResponseWriter(); : > - : > - StringWriter buf = new StringWriter(); : > - rsp.add("data1", "hello"); : > - rsp.add("data2", 42); : > - rsp.add("data3", true); : > - w.write(buf, req, rsp); : > - assertEquals(buf.toString(), : > "a:3:{s:5:\"data1\";s:5:\"hello\";s:5:\"data2\";i:42;s:5:\"data3\";b:1;}"); : > + req.close(); : > } : > : > - @Test : > public void testJSON() throws IOException { : > SolrQueryRequest req = req("wt","json","json.nl","arrarr"); : > SolrQueryResponse rsp = new SolrQueryResponse(); @@ -93,7 +78,7 @@ : > public class JSONWriterTest extends Solr : > : > w.write(buf, req, rsp); : > assertEquals(buf.toString(), "{\"nl\":[[\"data1\",\"hello\"],[null,42]]}"); : > - : > + req.close(); : > } : > : > } : > : : : : --------------------------------------------------------------------- : To unsubscribe, e-mail: [email protected] : For additional commands, e-mail: [email protected] : -Hoss --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
