Utf8Generator source code

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Utf8Generator source code

dpilato
Hi there,


I'm getting a NullPointerException while playing with Json Converter.
I would try to find out what's going on but I can not find the source code of the involved class.

Could you please tell me where I can find the source of org.elasticsearch.common.jackson.impl.Utf8Generator ?

I can't find it in GitHub...

Here is an extract of stacktrace...

java.lang.NullPointerException
        at org.elasticsearch.common.jackson.impl.Utf8Generator._verifyValueWrite(Utf8Generator.java:940)
        at org.elasticsearch.common.jackson.impl.Utf8Generator.writeBoolean(Utf8Generator.java:889)
        at org.elasticsearch.common.xcontent.json.JsonXContentGenerator.writeBoolean(JsonXContentGenerator.java:107)
        at org.elasticsearch.common.xcontent.XContentBuilder.value(XContentBuilder.java:786)

Thanks for your help,
David
Reply | Threaded
Open this post in threaded view
|

Re: Utf8Generator source code

kimchy
Administrator
Its jackson code which gets embedded in elasticsearch. How do you create the builder?

On Friday, March 4, 2011 at 8:49 PM, dpilato wrote:

Hi there,


I'm getting a NullPointerException while playing with Json Converter.
I would try to find out what's going on but I can not find the source code
of the involved class.

Could you please tell me where I can find the source of
org.elasticsearch.common.jackson.impl.Utf8Generator ?

I can't find it in GitHub...

Here is an extract of stacktrace...

java.lang.NullPointerException
        at
org.elasticsearch.common.jackson.impl.Utf8Generator._verifyValueWrite(Utf8Generator.java:940)
        at
org.elasticsearch.common.jackson.impl.Utf8Generator.writeBoolean(Utf8Generator.java:889)
        at
org.elasticsearch.common.xcontent.json.JsonXContentGenerator.writeBoolean(JsonXContentGenerator.java:107)
        at
org.elasticsearch.common.xcontent.XContentBuilder.value(XContentBuilder.java:786)

Thanks for your help,
David

--
View this message in context: http://elasticsearch-users.115913.n3.nabble.com/Utf8Generator-source-code-tp2635014p2635014.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: Utf8Generator source code

dpilato
kimchy wrote
Its jackson code which gets embedded in elasticsearch. How do you create the builder?
Thanks. I suppose I will find it here.

I will post my code on Monday. It's a recursive way to build JSon index query.

I'm working on a simple gateway to push Entities from Hibernate to Elastic. I will push the code to the community in a few days.

Take care,
David.
Reply | Threaded
Open this post in threaded view
|

Re: Utf8Generator source code

dpilato
In reply to this post by kimchy
kimchy wrote
Its jackson code which gets embedded in elasticsearch.
 Just a question (may be stupid because I don't know gradle) : why did you embed jars in Elastic (with jarjar) and not using directly other jars as dependencies ? Why did you rename package names of original jars ?

Elastic is really cool and you have done a great job on it.  I'm quite sure that it will be a major product in the next years.
Reply | Threaded
Open this post in threaded view
|

Re: Utf8Generator source code

kimchy
Administrator
The reason what its gets "jarjar'ed" is because of the problem of viral nature of depending on specific versions. Jackson is quite a popular library (rightly so!), and using elasticsearch should not bind users to a specific jackson in their app. This allows to more easily change versions of jackson in elasticsearch without backward comp. problems for users. Same applies for additional libraries like Guice, and mvel.

On Saturday, March 5, 2011 at 1:09 PM, dpilato wrote:


kimchy wrote:

Its jackson code which gets embedded in elasticsearch.

Just a question (may be stupid because I don't know gradle) : why did you
embed jars in Elastic (with jarjar) and not using directly other jars as
dependencies ? Why did you rename package names of original jars ?

Elastic is really cool and you have done a great job on it. I'm quite sure
that it will be a major product in the next years.

--
View this message in context: http://elasticsearch-users.115913.n3.nabble.com/Utf8Generator-source-code-tp2635014p2637649.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

RE: Utf8Generator source code

dpilato
In reply to this post by dpilato

Hi Kimchy,

 

 

I wrote a test case for the NPE in Utf8Generator.

 

https://githu b.com/da ctor

 

There is a JSonBuilderTest with two methods :

testSimpleEntityThatSuccess() build a JSon content that succeed.

testSimpleEntityThatFails() try to build the same JSon content using recursivity but it fails with the NPE.

 

I don’t understand the reason. Thanks for any help.

 

I’ve seen that Alois Cochard publish something about automatic entity mapping. I think that I’m going to use it instead of writing an analog code  ( https://github.com/aloiscochard/elasticsearch )

 

Are you going to integrate his code in elasticsearch repo (and in next releases) ?

<p class=Ms oNormal> ont-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> 

 

Thanks,

David.

Reply | Threaded
Open this post in threaded view
|

Re: RE: Utf8Generator source code

kimchy
Administrator
Its a bit hard to tell where the failure is, since it relies on your code that converts the object. If you can create a simple test case that fails with just the builder, it would help.

On Tuesday, March 8, 2011 at 10:31 AM, dpilato wrote:

<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><style><!-- /* Font Definitions */ @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} @font-face {font-family:Tahoma; panose-1:2 11 6 4 3 5 4 4 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0cm; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman","serif";} a:link, span.MsoHyperlink {mso-style-priority:99; color:blue; text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {mso-style-priority:99; color:purple; text-decoration:underline;} span.EmailStyle17 {mso-style-type:personal-reply; font-family:"Calibri","sans-serif"; color:#1F497D;} .MsoChpDefault {mso-style-type:export-only; font-family:"Calibri","sans-serif"; mso-fareast-language:EN-US;} @page WordSection1 {size:612.0pt 792.0pt; margin:70.85pt 70.85pt 70.85pt 70.85pt;} div.WordSection1 {page:WordSection1;} --></style></head><body lang=FR link=blue vlink=purple>

Hi Kimchy,

 

 

I wrote a test case for the NPE in Utf8Generator.

 

https://githu b.com/da ctor

 

There is a JSonBuilderTest with two methods :

testSimpleEntityThatSuccess() build a JSon content that succeed.

testSimpleEntityThatFails() try to build the same JSon content using recursivity but it fails with the NPE.

 

I don’t understand the reason. Thanks for any help.

 

I’ve seen that Alois Cochard publish something about automatic entity mapping. I think that I’m going to use it instead of writing an analog code  ( https://github.com/aloiscochard/elasticsearch )

 

Are you going to integrate his code in elasticsearch repo (and in next releases) ?

<p class=Ms oNormal> ont-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> 

 

Thanks,

David.

</body></html>

View this message in context: RE: Utf8Generator source code
Sent from the ElasticSearch Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: Utf8Generator source code

Matt Smalley
I got the same exception. In my case I wanted to index a parent
document and then the child document with the same client. Example:

<code>
Client client = this.elasticNode.client();
XContentBuilder builder = XContentFactory.jsonBuilder();
Map<String,Object> map;
IndexRequestBuilder irb

map = new HashMap<String,Object>();
map.put("foo", "foo");

client.prepareIndex("myindex", "mytype",
"1").setSource(builder.map(map).execute().actionGet();

map = new HashMap<String,Object>();
map.put("bar", "bar");

client.prepareIndex("myindex", "childtype", "1");
builder = XContentFactory.jsonBuilder();
irb = client.prepareIndex("myindex", "mytype", "1");
irb = irb.setParent("1");
irb = irb.setSource(builder.map(map);
irb = irb.execute().actionGet();
</code>

The NPE is thrown when we call prepareIndex the second time. Note that
removing the id allows that call to succeed, but then a subsequent
call fails (either setParent or setSource, I forget which.) I was able
to work around it by closing and recreating the client:

<code>
Client client = this.elasticNode.client();
XContentBuilder builder = XContentFactory.jsonBuilder();
Map<String,Object> map;
IndexRequestBuilder irb

map = new HashMap<String,Object>();
map.put("foo", "foo");

client.prepareIndex("myindex", "mytype",
"1").setSource(builder.map(map).execute().actionGet();
client.close();

map = new HashMap<String,Object>();
map.put("bar", "bar");

client = this.elasticNode.client();
client.prepareIndex("myindex", "childtype", "1");
builder = XContentFactory.jsonBuilder();
irb = client.prepareIndex("myindex", "mytype", "1");
irb = irb.setParent("1");
irb = irb.setSource(builder.map(map);
irb = irb.execute().actionGet();
client.close();
</code>

On Mar 8, 1:37 am, Shay Banon <[hidden email]> wrote:

> Its a bit hard to tell where the failure is, since it relies on your code that converts the object. If you can create a simple test case that fails with just the builder, it would help.On Tuesday, March 8, 2011 at 10:31 AM, dpilato wrote:
> > <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><style><!-- /* Font Definitions */ @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} @font-face {font-family:Tahoma; panose-1:2 11 6 4 3 5 4 4 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0cm; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman","serif";} a:link, span.MsoHyperlink {mso-style-priority:99; color:blue; text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {mso-style-priority:99; color:purple; text-decoration:underline;} span.EmailStyle17 {mso-style-type:personal-reply; font-family:"Calibri","sans-serif"; color:#1F497D;} .MsoChpDefault {mso-style-type:export-only; font-family:"Calibri","sans-serif"; mso-fareast-language:EN-US;} @page WordSection1 {
>
> size:612.0pt 792.0pt; margin:70.85pt 70.85pt 70.85pt 70.85pt;} div.WordSection1 {page:WordSection1;} --></style></head><body lang=FR link=blue vlink=purple>
>
>
>
>
>
>
>
> > Hi Kimchy,
>
> > I wrote a test case for the NPE in Utf8Generator.
>
> >https://github.com/da ctor
>
> > There is a JSonBuilderTest with two methods :
> > testSimpleEntityThatSuccess() build a JSon content that succeed.
> > testSimpleEntityThatFails() try to build the same JSon content using recursivity but it fails with the NPE.
>
> > I don’t understand the reason. Thanks for any help.
>
> > I’ve seen that Alois Cochard publish something about automatic entity mapping. I think that I’m going to use it instead of writing an analog code (https://github.com/aloiscochard/elasticsearch)
>
> > Are you going to integrate his code in elasticsearch repo (and in next releases) ?
> > <p class=Ms oNormal> ont-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>
>
> > Thanks,
> > David.
>
> > </body></html>
> >  View this message in context: RE: Utf8Generator source code
> >  Sent from the ElasticSearch Users mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: Utf8Generator source code

kimchy
Administrator
Can you create a test case for this? I can have a look.

On Thursday, April 7, 2011 at 12:39 AM, Matt Smalley wrote:

I got the same exception. In my case I wanted to index a parent
document and then the child document with the same client. Example:

<code>
Client client = this.elasticNode.client();
XContentBuilder builder = XContentFactory.jsonBuilder();
Map<String,Object> map;
IndexRequestBuilder irb

map = new HashMap<String,Object>();
map.put("foo", "foo");

client.prepareIndex("myindex", "mytype",
"1").setSource(builder.map(map).execute().actionGet();

map = new HashMap<String,Object>();
map.put("bar", "bar");

client.prepareIndex("myindex", "childtype", "1");
builder = XContentFactory.jsonBuilder();
irb = client.prepareIndex("myindex", "mytype", "1");
irb = irb.setParent("1");
irb = irb.setSource(builder.map(map);
irb = irb.execute().actionGet();
</code>

The NPE is thrown when we call prepareIndex the second time. Note that
removing the id allows that call to succeed, but then a subsequent
call fails (either setParent or setSource, I forget which.) I was able
to work around it by closing and recreating the client:

<code>
Client client = this.elasticNode.client();
XContentBuilder builder = XContentFactory.jsonBuilder();
Map<String,Object> map;
IndexRequestBuilder irb

map = new HashMap<String,Object>();
map.put("foo", "foo");

client.prepareIndex("myindex", "mytype",
"1").setSource(builder.map(map).execute().actionGet();
client.close();

map = new HashMap<String,Object>();
map.put("bar", "bar");

client = this.elasticNode.client();
client.prepareIndex("myindex", "childtype", "1");
builder = XContentFactory.jsonBuilder();
irb = client.prepareIndex("myindex", "mytype", "1");
irb = irb.setParent("1");
irb = irb.setSource(builder.map(map);
irb = irb.execute().actionGet();
client.close();
</code>

On Mar 8, 1:37 am, Shay Banon <shay.ba...@elasticsearch.com> wrote:
Its a bit hard to tell where the failure is, since it relies on your code that converts the object. If you can create a simple test case that fails with just the builder, it would help.On Tuesday, March 8, 2011 at 10:31 AM, dpilato wrote:
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><style><!-- /* Font Definitions */ @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} @font-face {font-family:Tahoma; panose-1:2 11 6 4 3 5 4 4 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0cm; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman","serif";} a:link, span.MsoHyperlink {mso-style-priority:99; color:blue; text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {mso-style-priority:99; color:purple; text-decoration:underline;} span.EmailStyle17 {mso-style-type:personal-reply; font-family:"Calibri","sans-serif"; color:#1F497D;} .MsoChpDefault {mso-style-type:export-only; font-family:"Calibri","sans-serif"; mso-fareast-language:EN-US;} @page WordSection1 {

size:612.0pt 792.0pt; margin:70.85pt 70.85pt 70.85pt 70.85pt;} div.WordSection1 {page:WordSection1;} --></style></head><body lang=FR link=blue vlink=purple>







Hi Kimchy,

I wrote a test case for the NPE in Utf8Generator.


There is a JSonBuilderTest with two methods :
testSimpleEntityThatSuccess() build a JSon content that succeed.
testSimpleEntityThatFails() try to build the same JSon content using recursivity but it fails with the NPE.

I don’t understand the reason. Thanks for any help.

I’ve seen that Alois Cochard publish something about automatic entity mapping. I think that I’m going to use it instead of writing an analog code (https://github.com/aloiscochard/elasticsearch)

Are you going to integrate his code in elasticsearch repo (and in next releases) ?
<p class=Ms oNormal> ont-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>

Thanks,
David.

</body></html>
 View this message in context: RE: Utf8Generator source code
 Sent from the ElasticSearch Users mailing list archive at Nabble.com.