You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Uwe Schindler <uw...@thetaphi.de> on 2014/02/22 10:01:50 UTC
RE: svn commit: r1570793 - in /lucene/dev/trunk/solr/solrj/src: java/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java test-files/solrj/updateReq_4_5.bin test/org/apache/solr/client/solrj/request/TestUpdateRequestCodec.java
Hi,
your commit is likely to fail when we start to restructure directory layouts. Tests should (whenever possible) always use the classpath to find the files in test-files (which is part of the classpath).
Attached is a patch with the "recommended way". I suggest to fix this. ExternalPaths.SOURCE_HOME is unused in Solr test, the constant is just a relict and only used internally on setup of test infrastructure. Real tests should not use it.
There are more usages of this constant in test with "absolute" paths (including "contrib/foobar/src/test-files" to the contrib modules, I will open issue to fix those.
Uwe
-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de
> -----Original Message-----
> From: noble@apache.org [mailto:noble@apache.org]
> Sent: Saturday, February 22, 2014 7:19 AM
> To: commits@lucene.apache.org
> Subject: svn commit: r1570793 - in /lucene/dev/trunk/solr/solrj/src:
> java/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java
> test-files/solrj/updateReq_4_5.bin
> test/org/apache/solr/client/solrj/request/TestUpdateRequestCodec.java
>
> Author: noble
> Date: Sat Feb 22 06:19:16 2014
> New Revision: 1570793
>
> URL: http://svn.apache.org/r1570793
> Log:
> SOLR-5762 broke backward compatibility of Javabin format
>
> Added:
> lucene/dev/trunk/solr/solrj/src/test-files/solrj/updateReq_4_5.bin (with
> props)
> Modified:
>
> lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/Ja
> vaBinUpdateRequestCodec.java
>
> lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/request/T
> estUpdateRequestCodec.java
>
> Modified:
> lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/Ja
> vaBinUpdateRequestCodec.java
> URL:
> http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apa
> che/solr/client/solrj/request/JavaBinUpdateRequestCodec.java?rev=157079
> 3&r1=1570792&r2=1570793&view=diff
> ==========================================================
> ====================
> ---
> lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/Ja
> vaBinUpdateRequestCodec.java (original)
> +++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/re
> +++ quest/JavaBinUpdateRequestCodec.java Sat Feb 22 06:19:16 2014
> @@ -184,7 +184,13 @@ public class JavaBinUpdateRequestCodec {
> delByIdMap = (Map<String,Map<String,Object>>)
> namedList[0].get("delByIdMap");
> delByQ = (List<String>) namedList[0].get("delByQ");
> doclist = (List) namedList[0].get("docs");
> - docMap = (List<Entry<SolrInputDocument,Map<Object,Object>>>)
> namedList[0].get("docsMap");
> + Object docsMapObj = namedList[0].get("docsMap");
> +
> + if (docsMapObj instanceof Map) {//SOLR-5762
> + docMap = new ArrayList(((Map)docsMapObj).entrySet());
> + } else {
> + docMap = (List<Entry<SolrInputDocument, Map<Object, Object>>>)
> docsMapObj;
> + }
>
>
> // we don't add any docs, because they were already processed
>
> Added: lucene/dev/trunk/solr/solrj/src/test-files/solrj/updateReq_4_5.bin
> URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test-
> files/solrj/updateReq_4_5.bin?rev=1570793&view=auto
> ==========================================================
> ====================
> Binary file - no diff available.
>
> Modified:
> lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/request/T
> estUpdateRequestCodec.java
> URL:
> http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apa
> che/solr/client/solrj/request/TestUpdateRequestCodec.java?rev=1570793&r
> 1=1570792&r2=1570793&view=diff
> ==========================================================
> ====================
> ---
> lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/request/T
> estUpdateRequestCodec.java (original)
> +++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/re
> +++ quest/TestUpdateRequestCodec.java Sat Feb 22 06:19:16 2014
> @@ -18,6 +18,9 @@ package org.apache.solr.client.solrj.req
>
> import java.io.ByteArrayInputStream;
> import java.io.ByteArrayOutputStream;
> +import java.io.File;
> +import java.io.FileInputStream;
> +import java.io.FileOutputStream;
> import java.io.IOException;
> import java.util.ArrayList;
> import java.util.Collection;
> @@ -31,6 +34,7 @@ import junit.framework.Assert; import
> org.apache.lucene.util.LuceneTestCase;
> import org.apache.solr.common.SolrInputDocument;
> import org.apache.solr.common.SolrInputField;
> +import org.apache.solr.util.ExternalPaths;
> import org.junit.Test;
>
> /**
> @@ -160,6 +164,75 @@ public class TestUpdateRequestCodec exte
>
>
>
> + public void testBackCompat4_5() throws IOException {
> +
> + UpdateRequest updateRequest = new UpdateRequest();
> + updateRequest.deleteById("*:*");
> + updateRequest.deleteById("id:5");
> + updateRequest.deleteByQuery("2*");
> + updateRequest.deleteByQuery("1*");
> + updateRequest.setParam("a", "b");
> + SolrInputDocument doc = new SolrInputDocument();
> + doc.addField("id", 1);
> + doc.addField("desc", "one", 2.0f);
> + doc.addField("desc", "1");
> + updateRequest.add(doc);
> +
> + doc = new SolrInputDocument();
> + doc.addField("id", 2);
> + doc.setDocumentBoost(10.0f);
> + doc.addField("desc", "two", 3.0f);
> + doc.addField("desc", "2");
> + updateRequest.add(doc);
> +
> + doc = new SolrInputDocument();
> + doc.addField("id", 3);
> + doc.addField("desc", "three", 3.0f);
> + doc.addField("desc", "3");
> + updateRequest.add(doc);
> +
> + doc = new SolrInputDocument();
> + Collection<String> foobar = new HashSet<String>();
> + foobar.add("baz1");
> + foobar.add("baz2");
> + doc.addField("foobar",foobar);
> + updateRequest.add(doc);
> +
> + updateRequest.deleteById("2");
> + updateRequest.deleteByQuery("id:3");
> +
> +
> +
> + FileInputStream is = new FileInputStream(new
> File(ExternalPaths.SOURCE_HOME, "solrj/src/test-
> files/solrj/updateReq_4_5.bin"));
> + UpdateRequest updateUnmarshalled = new
> JavaBinUpdateRequestCodec().unmarshal(is, new
> JavaBinUpdateRequestCodec.StreamingUpdateHandler() {
> + @Override
> + public void update(SolrInputDocument document, UpdateRequest req,
> Integer commitWithin, Boolean override) {
> + if(commitWithin == null ){
> + req.add(document);
> + }
> + System.err.println("Doc" + document + "
> ,commitWithin:"+commitWithin+ " , override:"+ override);
> + }
> + });
> +
> + System.err.println(updateUnmarshalled.getDocumentsMap());
> + System.err.println(updateUnmarshalled.getDocuments());
> +
> + for (int i = 0; i < updateRequest.getDocuments().size(); i++) {
> + SolrInputDocument inDoc = updateRequest.getDocuments().get(i);
> + SolrInputDocument outDoc =
> updateUnmarshalled.getDocuments().get(i);
> + compareDocs("doc#"+i, inDoc, outDoc);
> + }
> + Assert.assertEquals(updateUnmarshalled.getDeleteById().get(0) ,
> + updateRequest.getDeleteById().get(0));
> + Assert.assertEquals(updateUnmarshalled.getDeleteQuery().get(0) ,
> + updateRequest.getDeleteQuery().get(0));
> +
> + assertEquals("b", updateUnmarshalled.getParams().get("a"));
> + is.close();
> + }
> +
> +
> +
> private void compareDocs(String m,
> SolrInputDocument expectedDoc,
> SolrInputDocument actualDoc) {
RE: svn commit: r1570793 - in /lucene/dev/trunk/solr/solrj/src: java/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java test-files/solrj/updateReq_4_5.bin test/org/apache/solr/client/solrj/request/TestUpdateRequestCodec.java
Posted by Uwe Schindler <uw...@thetaphi.de>.
You might not have seen it, I attached a patch to my original mail fixing the issue. I may commit this together with my remaining fixes at other places using “absolute” paths.
Uwe
-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
<http://www.thetaphi.de/> http://www.thetaphi.de
eMail: uwe@thetaphi.de
From: Noble Paul നോബിള് नोब्ळ् [mailto:noble.paul@gmail.com]
Sent: Saturday, February 22, 2014 10:53 AM
To: Lucene Dev
Subject: RE: svn commit: r1570793 - in /lucene/dev/trunk/solr/solrj/src: java/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java test-files/solrj/updateReq_4_5.bin test/org/apache/solr/client/solrj/request/TestUpdateRequestCodec.java
Sure.
let's change the location one we identify the right place.
I hope we don't need to block 4.7 for this
On 22 Feb 2014 14:32, "Uwe Schindler" <uw...@thetaphi.de> wrote:
Hi,
your commit is likely to fail when we start to restructure directory layouts. Tests should (whenever possible) always use the classpath to find the files in test-files (which is part of the classpath).
Attached is a patch with the "recommended way". I suggest to fix this. ExternalPaths.SOURCE_HOME is unused in Solr test, the constant is just a relict and only used internally on setup of test infrastructure. Real tests should not use it.
There are more usages of this constant in test with "absolute" paths (including "contrib/foobar/src/test-files" to the contrib modules, I will open issue to fix those.
Uwe
-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de
> -----Original Message-----
> From: noble@apache.org [mailto:noble@apache.org]
> Sent: Saturday, February 22, 2014 7:19 AM
> To: commits@lucene.apache.org
> Subject: svn commit: r1570793 - in /lucene/dev/trunk/solr/solrj/src:
> java/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java
> test-files/solrj/updateReq_4_5.bin
> test/org/apache/solr/client/solrj/request/TestUpdateRequestCodec.java
>
> Author: noble
> Date: Sat Feb 22 06:19:16 2014
> New Revision: 1570793
>
> URL: http://svn.apache.org/r1570793
> Log:
> SOLR-5762 broke backward compatibility of Javabin format
>
> Added:
> lucene/dev/trunk/solr/solrj/src/test-files/solrj/updateReq_4_5.bin (with
> props)
> Modified:
>
> lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/Ja
> vaBinUpdateRequestCodec.java
>
> lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/request/T
> estUpdateRequestCodec.java
>
> Modified:
> lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/Ja
> vaBinUpdateRequestCodec.java
> URL:
> http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apa
> che/solr/client/solrj/request/JavaBinUpdateRequestCodec.java?rev=157079
> 3&r1=1570792&r2=1570793&view=diff
> ==========================================================
> ====================
> ---
> lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/Ja
> vaBinUpdateRequestCodec.java (original)
> +++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/re
> +++ quest/JavaBinUpdateRequestCodec.java Sat Feb 22 06:19:16 2014
> @@ -184,7 +184,13 @@ public class JavaBinUpdateRequestCodec {
> delByIdMap = (Map<String,Map<String,Object>>)
> namedList[0].get("delByIdMap");
> delByQ = (List<String>) namedList[0].get("delByQ");
> doclist = (List) namedList[0].get("docs");
> - docMap = (List<Entry<SolrInputDocument,Map<Object,Object>>>)
> namedList[0].get("docsMap");
> + Object docsMapObj = namedList[0].get("docsMap");
> +
> + if (docsMapObj instanceof Map) {//SOLR-5762
> + docMap = new ArrayList(((Map)docsMapObj).entrySet());
> + } else {
> + docMap = (List<Entry<SolrInputDocument, Map<Object, Object>>>)
> docsMapObj;
> + }
>
>
> // we don't add any docs, because they were already processed
>
> Added: lucene/dev/trunk/solr/solrj/src/test-files/solrj/updateReq_4_5.bin
> URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test-
> files/solrj/updateReq_4_5.bin?rev=1570793&view=auto
> ==========================================================
> ====================
> Binary file - no diff available.
>
> Modified:
> lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/request/T
> estUpdateRequestCodec.java
> URL:
> http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apa
> che/solr/client/solrj/request/TestUpdateRequestCodec.java?rev=1570793&r
> 1=1570792&r2=1570793&view=diff
> ==========================================================
> ====================
> ---
> lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/request/T
> estUpdateRequestCodec.java (original)
> +++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/re
> +++ quest/TestUpdateRequestCodec.java Sat Feb 22 06:19:16 2014
> @@ -18,6 +18,9 @@ package org.apache.solr.client.solrj.req
>
> import java.io.ByteArrayInputStream;
> import java.io.ByteArrayOutputStream;
> +import java.io.File;
> +import java.io.FileInputStream;
> +import java.io.FileOutputStream;
> import java.io.IOException;
> import java.util.ArrayList;
> import java.util.Collection;
> @@ -31,6 +34,7 @@ import junit.framework.Assert; import
> org.apache.lucene.util.LuceneTestCase;
> import org.apache.solr.common.SolrInputDocument;
> import org.apache.solr.common.SolrInputField;
> +import org.apache.solr.util.ExternalPaths;
> import org.junit.Test;
>
> /**
> @@ -160,6 +164,75 @@ public class TestUpdateRequestCodec exte
>
>
>
> + public void testBackCompat4_5() throws IOException {
> +
> + UpdateRequest updateRequest = new UpdateRequest();
> + updateRequest.deleteById("*:*");
> + updateRequest.deleteById("id:5");
> + updateRequest.deleteByQuery("2*");
> + updateRequest.deleteByQuery("1*");
> + updateRequest.setParam("a", "b");
> + SolrInputDocument doc = new SolrInputDocument();
> + doc.addField("id", 1);
> + doc.addField("desc", "one", 2.0f);
> + doc.addField("desc", "1");
> + updateRequest.add(doc);
> +
> + doc = new SolrInputDocument();
> + doc.addField("id", 2);
> + doc.setDocumentBoost(10.0f);
> + doc.addField("desc", "two", 3.0f);
> + doc.addField("desc", "2");
> + updateRequest.add(doc);
> +
> + doc = new SolrInputDocument();
> + doc.addField("id", 3);
> + doc.addField("desc", "three", 3.0f);
> + doc.addField("desc", "3");
> + updateRequest.add(doc);
> +
> + doc = new SolrInputDocument();
> + Collection<String> foobar = new HashSet<String>();
> + foobar.add("baz1");
> + foobar.add("baz2");
> + doc.addField("foobar",foobar);
> + updateRequest.add(doc);
> +
> + updateRequest.deleteById("2");
> + updateRequest.deleteByQuery("id:3");
> +
> +
> +
> + FileInputStream is = new FileInputStream(new
> File(ExternalPaths.SOURCE_HOME, "solrj/src/test-
> files/solrj/updateReq_4_5.bin"));
> + UpdateRequest updateUnmarshalled = new
> JavaBinUpdateRequestCodec().unmarshal(is, new
> JavaBinUpdateRequestCodec.StreamingUpdateHandler() {
> + @Override
> + public void update(SolrInputDocument document, UpdateRequest req,
> Integer commitWithin, Boolean override) {
> + if(commitWithin == null ){
> + req.add(document);
> + }
> + System.err.println("Doc" + document + "
> ,commitWithin:"+commitWithin+ " , override:"+ override);
> + }
> + });
> +
> + System.err.println(updateUnmarshalled.getDocumentsMap());
> + System.err.println(updateUnmarshalled.getDocuments());
> +
> + for (int i = 0; i < updateRequest.getDocuments().size(); i++) {
> + SolrInputDocument inDoc = updateRequest.getDocuments().get(i);
> + SolrInputDocument outDoc =
> updateUnmarshalled.getDocuments().get(i);
> + compareDocs("doc#"+i, inDoc, outDoc);
> + }
> + Assert.assertEquals(updateUnmarshalled.getDeleteById().get(0) ,
> + updateRequest.getDeleteById().get(0));
> + Assert.assertEquals(updateUnmarshalled.getDeleteQuery().get(0) ,
> + updateRequest.getDeleteQuery().get(0));
> +
> + assertEquals("b", updateUnmarshalled.getParams().get("a"));
> + is.close();
> + }
> +
> +
> +
> private void compareDocs(String m,
> SolrInputDocument expectedDoc,
> SolrInputDocument actualDoc) {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org
RE: svn commit: r1570793 - in /lucene/dev/trunk/solr/solrj/src: java/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java test-files/solrj/updateReq_4_5.bin test/org/apache/solr/client/solrj/request/TestUpdateRequestCodec.java
Posted by Uwe Schindler <uw...@thetaphi.de>.
Hi,
No thats fine, does not block 4.7. I am currently fixing the remaining stuff in code recently donated that also violated this (especially the analytics module + mapreduce)
I will open issue and fix your’s, too.
Uwe
-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
<http://www.thetaphi.de/> http://www.thetaphi.de
eMail: uwe@thetaphi.de
From: Noble Paul നോബിള് नोब्ळ् [mailto:noble.paul@gmail.com]
Sent: Saturday, February 22, 2014 10:53 AM
To: Lucene Dev
Subject: RE: svn commit: r1570793 - in /lucene/dev/trunk/solr/solrj/src: java/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java test-files/solrj/updateReq_4_5.bin test/org/apache/solr/client/solrj/request/TestUpdateRequestCodec.java
Sure.
let's change the location one we identify the right place.
I hope we don't need to block 4.7 for this
On 22 Feb 2014 14:32, "Uwe Schindler" <uw...@thetaphi.de> wrote:
Hi,
your commit is likely to fail when we start to restructure directory layouts. Tests should (whenever possible) always use the classpath to find the files in test-files (which is part of the classpath).
Attached is a patch with the "recommended way". I suggest to fix this. ExternalPaths.SOURCE_HOME is unused in Solr test, the constant is just a relict and only used internally on setup of test infrastructure. Real tests should not use it.
There are more usages of this constant in test with "absolute" paths (including "contrib/foobar/src/test-files" to the contrib modules, I will open issue to fix those.
Uwe
-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de
> -----Original Message-----
> From: noble@apache.org [mailto:noble@apache.org]
> Sent: Saturday, February 22, 2014 7:19 AM
> To: commits@lucene.apache.org
> Subject: svn commit: r1570793 - in /lucene/dev/trunk/solr/solrj/src:
> java/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java
> test-files/solrj/updateReq_4_5.bin
> test/org/apache/solr/client/solrj/request/TestUpdateRequestCodec.java
>
> Author: noble
> Date: Sat Feb 22 06:19:16 2014
> New Revision: 1570793
>
> URL: http://svn.apache.org/r1570793
> Log:
> SOLR-5762 broke backward compatibility of Javabin format
>
> Added:
> lucene/dev/trunk/solr/solrj/src/test-files/solrj/updateReq_4_5.bin (with
> props)
> Modified:
>
> lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/Ja
> vaBinUpdateRequestCodec.java
>
> lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/request/T
> estUpdateRequestCodec.java
>
> Modified:
> lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/Ja
> vaBinUpdateRequestCodec.java
> URL:
> http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apa
> che/solr/client/solrj/request/JavaBinUpdateRequestCodec.java?rev=157079
> 3&r1=1570792&r2=1570793&view=diff
> ==========================================================
> ====================
> ---
> lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/Ja
> vaBinUpdateRequestCodec.java (original)
> +++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/re
> +++ quest/JavaBinUpdateRequestCodec.java Sat Feb 22 06:19:16 2014
> @@ -184,7 +184,13 @@ public class JavaBinUpdateRequestCodec {
> delByIdMap = (Map<String,Map<String,Object>>)
> namedList[0].get("delByIdMap");
> delByQ = (List<String>) namedList[0].get("delByQ");
> doclist = (List) namedList[0].get("docs");
> - docMap = (List<Entry<SolrInputDocument,Map<Object,Object>>>)
> namedList[0].get("docsMap");
> + Object docsMapObj = namedList[0].get("docsMap");
> +
> + if (docsMapObj instanceof Map) {//SOLR-5762
> + docMap = new ArrayList(((Map)docsMapObj).entrySet());
> + } else {
> + docMap = (List<Entry<SolrInputDocument, Map<Object, Object>>>)
> docsMapObj;
> + }
>
>
> // we don't add any docs, because they were already processed
>
> Added: lucene/dev/trunk/solr/solrj/src/test-files/solrj/updateReq_4_5.bin
> URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test-
> files/solrj/updateReq_4_5.bin?rev=1570793&view=auto
> ==========================================================
> ====================
> Binary file - no diff available.
>
> Modified:
> lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/request/T
> estUpdateRequestCodec.java
> URL:
> http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apa
> che/solr/client/solrj/request/TestUpdateRequestCodec.java?rev=1570793&r
> 1=1570792&r2=1570793&view=diff
> ==========================================================
> ====================
> ---
> lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/request/T
> estUpdateRequestCodec.java (original)
> +++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/re
> +++ quest/TestUpdateRequestCodec.java Sat Feb 22 06:19:16 2014
> @@ -18,6 +18,9 @@ package org.apache.solr.client.solrj.req
>
> import java.io.ByteArrayInputStream;
> import java.io.ByteArrayOutputStream;
> +import java.io.File;
> +import java.io.FileInputStream;
> +import java.io.FileOutputStream;
> import java.io.IOException;
> import java.util.ArrayList;
> import java.util.Collection;
> @@ -31,6 +34,7 @@ import junit.framework.Assert; import
> org.apache.lucene.util.LuceneTestCase;
> import org.apache.solr.common.SolrInputDocument;
> import org.apache.solr.common.SolrInputField;
> +import org.apache.solr.util.ExternalPaths;
> import org.junit.Test;
>
> /**
> @@ -160,6 +164,75 @@ public class TestUpdateRequestCodec exte
>
>
>
> + public void testBackCompat4_5() throws IOException {
> +
> + UpdateRequest updateRequest = new UpdateRequest();
> + updateRequest.deleteById("*:*");
> + updateRequest.deleteById("id:5");
> + updateRequest.deleteByQuery("2*");
> + updateRequest.deleteByQuery("1*");
> + updateRequest.setParam("a", "b");
> + SolrInputDocument doc = new SolrInputDocument();
> + doc.addField("id", 1);
> + doc.addField("desc", "one", 2.0f);
> + doc.addField("desc", "1");
> + updateRequest.add(doc);
> +
> + doc = new SolrInputDocument();
> + doc.addField("id", 2);
> + doc.setDocumentBoost(10.0f);
> + doc.addField("desc", "two", 3.0f);
> + doc.addField("desc", "2");
> + updateRequest.add(doc);
> +
> + doc = new SolrInputDocument();
> + doc.addField("id", 3);
> + doc.addField("desc", "three", 3.0f);
> + doc.addField("desc", "3");
> + updateRequest.add(doc);
> +
> + doc = new SolrInputDocument();
> + Collection<String> foobar = new HashSet<String>();
> + foobar.add("baz1");
> + foobar.add("baz2");
> + doc.addField("foobar",foobar);
> + updateRequest.add(doc);
> +
> + updateRequest.deleteById("2");
> + updateRequest.deleteByQuery("id:3");
> +
> +
> +
> + FileInputStream is = new FileInputStream(new
> File(ExternalPaths.SOURCE_HOME, "solrj/src/test-
> files/solrj/updateReq_4_5.bin"));
> + UpdateRequest updateUnmarshalled = new
> JavaBinUpdateRequestCodec().unmarshal(is, new
> JavaBinUpdateRequestCodec.StreamingUpdateHandler() {
> + @Override
> + public void update(SolrInputDocument document, UpdateRequest req,
> Integer commitWithin, Boolean override) {
> + if(commitWithin == null ){
> + req.add(document);
> + }
> + System.err.println("Doc" + document + "
> ,commitWithin:"+commitWithin+ " , override:"+ override);
> + }
> + });
> +
> + System.err.println(updateUnmarshalled.getDocumentsMap());
> + System.err.println(updateUnmarshalled.getDocuments());
> +
> + for (int i = 0; i < updateRequest.getDocuments().size(); i++) {
> + SolrInputDocument inDoc = updateRequest.getDocuments().get(i);
> + SolrInputDocument outDoc =
> updateUnmarshalled.getDocuments().get(i);
> + compareDocs("doc#"+i, inDoc, outDoc);
> + }
> + Assert.assertEquals(updateUnmarshalled.getDeleteById().get(0) ,
> + updateRequest.getDeleteById().get(0));
> + Assert.assertEquals(updateUnmarshalled.getDeleteQuery().get(0) ,
> + updateRequest.getDeleteQuery().get(0));
> +
> + assertEquals("b", updateUnmarshalled.getParams().get("a"));
> + is.close();
> + }
> +
> +
> +
> private void compareDocs(String m,
> SolrInputDocument expectedDoc,
> SolrInputDocument actualDoc) {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org
RE: svn commit: r1570793 - in /lucene/dev/trunk/solr/solrj/src:
java/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java
test-files/solrj/updateReq_4_5.bin test/org/apache/solr/client/solrj/request/TestUpdateRequestCodec.java
Posted by Noble Paul നോബിള് नोब्ळ् <no...@gmail.com>.
Sure.
let's change the location one we identify the right place.
I hope we don't need to block 4.7 for this
On 22 Feb 2014 14:32, "Uwe Schindler" <uw...@thetaphi.de> wrote:
> Hi,
>
> your commit is likely to fail when we start to restructure directory
> layouts. Tests should (whenever possible) always use the classpath to find
> the files in test-files (which is part of the classpath).
> Attached is a patch with the "recommended way". I suggest to fix this.
> ExternalPaths.SOURCE_HOME is unused in Solr test, the constant is just a
> relict and only used internally on setup of test infrastructure. Real tests
> should not use it.
>
> There are more usages of this constant in test with "absolute" paths
> (including "contrib/foobar/src/test-files" to the contrib modules, I will
> open issue to fix those.
>
> Uwe
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
>
>
> > -----Original Message-----
> > From: noble@apache.org [mailto:noble@apache.org]
> > Sent: Saturday, February 22, 2014 7:19 AM
> > To: commits@lucene.apache.org
> > Subject: svn commit: r1570793 - in /lucene/dev/trunk/solr/solrj/src:
> > java/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java
> > test-files/solrj/updateReq_4_5.bin
> > test/org/apache/solr/client/solrj/request/TestUpdateRequestCodec.java
> >
> > Author: noble
> > Date: Sat Feb 22 06:19:16 2014
> > New Revision: 1570793
> >
> > URL: http://svn.apache.org/r1570793
> > Log:
> > SOLR-5762 broke backward compatibility of Javabin format
> >
> > Added:
> > lucene/dev/trunk/solr/solrj/src/test-files/solrj/updateReq_4_5.bin
> (with
> > props)
> > Modified:
> >
> >
> lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/Ja
> > vaBinUpdateRequestCodec.java
> >
> >
> lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/request/T
> > estUpdateRequestCodec.java
> >
> > Modified:
> >
> lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/Ja
> > vaBinUpdateRequestCodec.java
> > URL:
> >
> http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apa
> > che/solr/client/solrj/request/JavaBinUpdateRequestCodec.java?rev=157079
> > 3&r1=1570792&r2=1570793&view=diff
> > ==========================================================
> > ====================
> > ---
> >
> lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/Ja
> > vaBinUpdateRequestCodec.java (original)
> > +++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/re
> > +++ quest/JavaBinUpdateRequestCodec.java Sat Feb 22 06:19:16 2014
> > @@ -184,7 +184,13 @@ public class JavaBinUpdateRequestCodec {
> > delByIdMap = (Map<String,Map<String,Object>>)
> > namedList[0].get("delByIdMap");
> > delByQ = (List<String>) namedList[0].get("delByQ");
> > doclist = (List) namedList[0].get("docs");
> > - docMap = (List<Entry<SolrInputDocument,Map<Object,Object>>>)
> > namedList[0].get("docsMap");
> > + Object docsMapObj = namedList[0].get("docsMap");
> > +
> > + if (docsMapObj instanceof Map) {//SOLR-5762
> > + docMap = new ArrayList(((Map)docsMapObj).entrySet());
> > + } else {
> > + docMap = (List<Entry<SolrInputDocument, Map<Object, Object>>>)
> > docsMapObj;
> > + }
> >
> >
> > // we don't add any docs, because they were already processed
> >
> > Added: lucene/dev/trunk/solr/solrj/src/test-files/solrj/updateReq_4_5.bin
> > URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test-
> > files/solrj/updateReq_4_5.bin?rev=1570793&view=auto
> > ==========================================================
> > ====================
> > Binary file - no diff available.
> >
> > Modified:
> >
> lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/request/T
> > estUpdateRequestCodec.java
> > URL:
> >
> http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apa
> > che/solr/client/solrj/request/TestUpdateRequestCodec.java?rev=1570793&r
> > 1=1570792&r2=1570793&view=diff
> > ==========================================================
> > ====================
> > ---
> >
> lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/request/T
> > estUpdateRequestCodec.java (original)
> > +++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/re
> > +++ quest/TestUpdateRequestCodec.java Sat Feb 22 06:19:16 2014
> > @@ -18,6 +18,9 @@ package org.apache.solr.client.solrj.req
> >
> > import java.io.ByteArrayInputStream;
> > import java.io.ByteArrayOutputStream;
> > +import java.io.File;
> > +import java.io.FileInputStream;
> > +import java.io.FileOutputStream;
> > import java.io.IOException;
> > import java.util.ArrayList;
> > import java.util.Collection;
> > @@ -31,6 +34,7 @@ import junit.framework.Assert; import
> > org.apache.lucene.util.LuceneTestCase;
> > import org.apache.solr.common.SolrInputDocument;
> > import org.apache.solr.common.SolrInputField;
> > +import org.apache.solr.util.ExternalPaths;
> > import org.junit.Test;
> >
> > /**
> > @@ -160,6 +164,75 @@ public class TestUpdateRequestCodec exte
> >
> >
> >
> > + public void testBackCompat4_5() throws IOException {
> > +
> > + UpdateRequest updateRequest = new UpdateRequest();
> > + updateRequest.deleteById("*:*");
> > + updateRequest.deleteById("id:5");
> > + updateRequest.deleteByQuery("2*");
> > + updateRequest.deleteByQuery("1*");
> > + updateRequest.setParam("a", "b");
> > + SolrInputDocument doc = new SolrInputDocument();
> > + doc.addField("id", 1);
> > + doc.addField("desc", "one", 2.0f);
> > + doc.addField("desc", "1");
> > + updateRequest.add(doc);
> > +
> > + doc = new SolrInputDocument();
> > + doc.addField("id", 2);
> > + doc.setDocumentBoost(10.0f);
> > + doc.addField("desc", "two", 3.0f);
> > + doc.addField("desc", "2");
> > + updateRequest.add(doc);
> > +
> > + doc = new SolrInputDocument();
> > + doc.addField("id", 3);
> > + doc.addField("desc", "three", 3.0f);
> > + doc.addField("desc", "3");
> > + updateRequest.add(doc);
> > +
> > + doc = new SolrInputDocument();
> > + Collection<String> foobar = new HashSet<String>();
> > + foobar.add("baz1");
> > + foobar.add("baz2");
> > + doc.addField("foobar",foobar);
> > + updateRequest.add(doc);
> > +
> > + updateRequest.deleteById("2");
> > + updateRequest.deleteByQuery("id:3");
> > +
> > +
> > +
> > + FileInputStream is = new FileInputStream(new
> > File(ExternalPaths.SOURCE_HOME, "solrj/src/test-
> > files/solrj/updateReq_4_5.bin"));
> > + UpdateRequest updateUnmarshalled = new
> > JavaBinUpdateRequestCodec().unmarshal(is, new
> > JavaBinUpdateRequestCodec.StreamingUpdateHandler() {
> > + @Override
> > + public void update(SolrInputDocument document, UpdateRequest req,
> > Integer commitWithin, Boolean override) {
> > + if(commitWithin == null ){
> > + req.add(document);
> > + }
> > + System.err.println("Doc" + document + "
> > ,commitWithin:"+commitWithin+ " , override:"+ override);
> > + }
> > + });
> > +
> > + System.err.println(updateUnmarshalled.getDocumentsMap());
> > + System.err.println(updateUnmarshalled.getDocuments());
> > +
> > + for (int i = 0; i < updateRequest.getDocuments().size(); i++) {
> > + SolrInputDocument inDoc = updateRequest.getDocuments().get(i);
> > + SolrInputDocument outDoc =
> > updateUnmarshalled.getDocuments().get(i);
> > + compareDocs("doc#"+i, inDoc, outDoc);
> > + }
> > + Assert.assertEquals(updateUnmarshalled.getDeleteById().get(0) ,
> > + updateRequest.getDeleteById().get(0));
> > + Assert.assertEquals(updateUnmarshalled.getDeleteQuery().get(0) ,
> > + updateRequest.getDeleteQuery().get(0));
> > +
> > + assertEquals("b", updateUnmarshalled.getParams().get("a"));
> > + is.close();
> > + }
> > +
> > +
> > +
> > private void compareDocs(String m,
> > SolrInputDocument expectedDoc,
> > SolrInputDocument actualDoc) {
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
RE: svn commit: r1570793 - in /lucene/dev/trunk/solr/solrj/src: java/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java test-files/solrj/updateReq_4_5.bin test/org/apache/solr/client/solrj/request/TestUpdateRequestCodec.java
Posted by Uwe Schindler <uw...@thetaphi.de>.
Alternatively you can use SolrTestCaseJ4.getFile() if you really need a file. In that case, an input stream was enough, so this is the simplier variant.
-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de
> -----Original Message-----
> From: Uwe Schindler [mailto:uwe@thetaphi.de]
> Sent: Saturday, February 22, 2014 10:02 AM
> To: dev@lucene.apache.org
> Subject: RE: svn commit: r1570793 - in /lucene/dev/trunk/solr/solrj/src:
> java/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java
> test-files/solrj/updateReq_4_5.bin
> test/org/apache/solr/client/solrj/request/TestUpdateRequestCodec.java
>
> Hi,
>
> your commit is likely to fail when we start to restructure directory layouts.
> Tests should (whenever possible) always use the classpath to find the files in
> test-files (which is part of the classpath).
> Attached is a patch with the "recommended way". I suggest to fix this.
> ExternalPaths.SOURCE_HOME is unused in Solr test, the constant is just a
> relict and only used internally on setup of test infrastructure. Real tests
> should not use it.
>
> There are more usages of this constant in test with "absolute" paths
> (including "contrib/foobar/src/test-files" to the contrib modules, I will open
> issue to fix those.
>
> Uwe
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
>
>
> > -----Original Message-----
> > From: noble@apache.org [mailto:noble@apache.org]
> > Sent: Saturday, February 22, 2014 7:19 AM
> > To: commits@lucene.apache.org
> > Subject: svn commit: r1570793 - in /lucene/dev/trunk/solr/solrj/src:
> > java/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.ja
> > va
> > test-files/solrj/updateReq_4_5.bin
> > test/org/apache/solr/client/solrj/request/TestUpdateRequestCodec.java
> >
> > Author: noble
> > Date: Sat Feb 22 06:19:16 2014
> > New Revision: 1570793
> >
> > URL: http://svn.apache.org/r1570793
> > Log:
> > SOLR-5762 broke backward compatibility of Javabin format
> >
> > Added:
> > lucene/dev/trunk/solr/solrj/src/test-files/solrj/updateReq_4_5.bin
> (with
> > props)
> > Modified:
> >
> > lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/requ
> > est/Ja
> > vaBinUpdateRequestCodec.java
> >
> > lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/requ
> > est/T
> > estUpdateRequestCodec.java
> >
> > Modified:
> > lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/requ
> > est/Ja
> > vaBinUpdateRequestCodec.java
> > URL:
> > http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/
> > apa
> >
> che/solr/client/solrj/request/JavaBinUpdateRequestCodec.java?rev=15707
> > 9
> > 3&r1=1570792&r2=1570793&view=diff
> >
> ==========================================================
> > ====================
> > ---
> > lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/requ
> > est/Ja vaBinUpdateRequestCodec.java (original)
> > +++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/
> > +++ re quest/JavaBinUpdateRequestCodec.java Sat Feb 22 06:19:16 2014
> > @@ -184,7 +184,13 @@ public class JavaBinUpdateRequestCodec {
> > delByIdMap = (Map<String,Map<String,Object>>)
> > namedList[0].get("delByIdMap");
> > delByQ = (List<String>) namedList[0].get("delByQ");
> > doclist = (List) namedList[0].get("docs");
> > - docMap = (List<Entry<SolrInputDocument,Map<Object,Object>>>)
> > namedList[0].get("docsMap");
> > + Object docsMapObj = namedList[0].get("docsMap");
> > +
> > + if (docsMapObj instanceof Map) {//SOLR-5762
> > + docMap = new ArrayList(((Map)docsMapObj).entrySet());
> > + } else {
> > + docMap = (List<Entry<SolrInputDocument, Map<Object, Object>>>)
> > docsMapObj;
> > + }
> >
> >
> > // we don't add any docs, because they were already processed
> >
> > Added:
> > lucene/dev/trunk/solr/solrj/src/test-files/solrj/updateReq_4_5.bin
> > URL:
> > http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test-
> > files/solrj/updateReq_4_5.bin?rev=1570793&view=auto
> >
> ==========================================================
> > ====================
> > Binary file - no diff available.
> >
> > Modified:
> > lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/requ
> > est/T
> > estUpdateRequestCodec.java
> > URL:
> > http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/
> > apa
> >
> che/solr/client/solrj/request/TestUpdateRequestCodec.java?rev=1570793&
> > r
> > 1=1570792&r2=1570793&view=diff
> >
> ==========================================================
> > ====================
> > ---
> > lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/requ
> > est/T
> > estUpdateRequestCodec.java (original)
> > +++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/
> > +++ re quest/TestUpdateRequestCodec.java Sat Feb 22 06:19:16 2014
> > @@ -18,6 +18,9 @@ package org.apache.solr.client.solrj.req
> >
> > import java.io.ByteArrayInputStream;
> > import java.io.ByteArrayOutputStream;
> > +import java.io.File;
> > +import java.io.FileInputStream;
> > +import java.io.FileOutputStream;
> > import java.io.IOException;
> > import java.util.ArrayList;
> > import java.util.Collection;
> > @@ -31,6 +34,7 @@ import junit.framework.Assert; import
> > org.apache.lucene.util.LuceneTestCase;
> > import org.apache.solr.common.SolrInputDocument;
> > import org.apache.solr.common.SolrInputField;
> > +import org.apache.solr.util.ExternalPaths;
> > import org.junit.Test;
> >
> > /**
> > @@ -160,6 +164,75 @@ public class TestUpdateRequestCodec exte
> >
> >
> >
> > + public void testBackCompat4_5() throws IOException {
> > +
> > + UpdateRequest updateRequest = new UpdateRequest();
> > + updateRequest.deleteById("*:*");
> > + updateRequest.deleteById("id:5");
> > + updateRequest.deleteByQuery("2*");
> > + updateRequest.deleteByQuery("1*");
> > + updateRequest.setParam("a", "b");
> > + SolrInputDocument doc = new SolrInputDocument();
> > + doc.addField("id", 1);
> > + doc.addField("desc", "one", 2.0f);
> > + doc.addField("desc", "1");
> > + updateRequest.add(doc);
> > +
> > + doc = new SolrInputDocument();
> > + doc.addField("id", 2);
> > + doc.setDocumentBoost(10.0f);
> > + doc.addField("desc", "two", 3.0f);
> > + doc.addField("desc", "2");
> > + updateRequest.add(doc);
> > +
> > + doc = new SolrInputDocument();
> > + doc.addField("id", 3);
> > + doc.addField("desc", "three", 3.0f);
> > + doc.addField("desc", "3");
> > + updateRequest.add(doc);
> > +
> > + doc = new SolrInputDocument();
> > + Collection<String> foobar = new HashSet<String>();
> > + foobar.add("baz1");
> > + foobar.add("baz2");
> > + doc.addField("foobar",foobar);
> > + updateRequest.add(doc);
> > +
> > + updateRequest.deleteById("2");
> > + updateRequest.deleteByQuery("id:3");
> > +
> > +
> > +
> > + FileInputStream is = new FileInputStream(new
> > File(ExternalPaths.SOURCE_HOME, "solrj/src/test-
> > files/solrj/updateReq_4_5.bin"));
> > + UpdateRequest updateUnmarshalled = new
> > JavaBinUpdateRequestCodec().unmarshal(is, new
> > JavaBinUpdateRequestCodec.StreamingUpdateHandler() {
> > + @Override
> > + public void update(SolrInputDocument document, UpdateRequest
> > + req,
> > Integer commitWithin, Boolean override) {
> > + if(commitWithin == null ){
> > + req.add(document);
> > + }
> > + System.err.println("Doc" + document + "
> > ,commitWithin:"+commitWithin+ " , override:"+ override);
> > + }
> > + });
> > +
> > + System.err.println(updateUnmarshalled.getDocumentsMap());
> > + System.err.println(updateUnmarshalled.getDocuments());
> > +
> > + for (int i = 0; i < updateRequest.getDocuments().size(); i++) {
> > + SolrInputDocument inDoc = updateRequest.getDocuments().get(i);
> > + SolrInputDocument outDoc =
> > updateUnmarshalled.getDocuments().get(i);
> > + compareDocs("doc#"+i, inDoc, outDoc);
> > + }
> > + Assert.assertEquals(updateUnmarshalled.getDeleteById().get(0) ,
> > + updateRequest.getDeleteById().get(0));
> > + Assert.assertEquals(updateUnmarshalled.getDeleteQuery().get(0) ,
> > + updateRequest.getDeleteQuery().get(0));
> > +
> > + assertEquals("b", updateUnmarshalled.getParams().get("a"));
> > + is.close();
> > + }
> > +
> > +
> > +
> > private void compareDocs(String m,
> > SolrInputDocument expectedDoc,
> > SolrInputDocument actualDoc) {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org