Thanks James:

This looks promising.  I¹ll repost when I¹ve had a chance to implement
this.  -scott


On 3/18/16, 10:44 AM, "McKinley, James T" <james.mckin...@cengage.com>
wrote:

>We use Kryo to pass query objects between hosts:
>
>https://github.com/EsotericSoftware/kryo
>
>We initially had some trouble with it creating dynamic classes and
>running out of PermGen space but we got around that using an ObjectPool:
>
>http://commons.apache.org/proper/commons-pool/api-1.6/org/apache/commons/p
>ool/impl/StackObjectPool.html
>
>I've not looked at the project recently, we're using version 2.21 and
>there's a 3.0.0 now, so they may have solved the issues we had and made
>things nicer, but here's how we're doing it with 2.21:
>
>To serialize:
>
>static private ObjectPool<Kryo> pool = new StackObjectPool<Kryo>(new
>KryoFactory(), 75, 75);
>
>ByteArrayOutputStream baos = new ByteArrayOutputStream();
>Output output = new Output(baos);
>kryo = pool.borrowObject();
>kryo.writeClassAndObject(output, query);
>pool.returnObject(kryo);
>output.close();
>String base64EncodedSerializedObject =
>Base64.encodeBytes(baos.toByteArray());
>
>Where query is a Lucene Query object (I've left out the error handling
>for brevity).
>
>To deserialize:
>
>ByteArrayInputStream bais = new
>ByteArrayInputStream(Base64.decode(encodedQuery));
>Input input = new Input(bais);
>kryo = pool.borrowObject();
>deserializedQueryObject = (Query) kryo.readClassAndObject(input);
>pool.returnObject(kryo);
>input.close();
>
>Hope that might help.
>
>Jim
>
>________________________________________
>From: Bauer, Herbert S. (Scott) <bauer.sc...@mayo.edu>
>Sent: 18 March 2016 10:02
>To: java-user@lucene.apache.org
>Subject: Serializing Queries
>
>Has anyone in this group solved the problem of serializing complex
>boolean queries (Some of our clauses have span and other query types)?
>Our Java RMI depends upon being able to do so.   I have seen posts that
>say you can just parse the string representation but apparently that only
>works on simple query representations.     I¹m looking at the CoreParser
>and it¹s supporting xml parsing capabilities with an eye toward
>Marshalling the boolean query into a DOM object and unmarshalling it on
>the server side using some of the support implied by the CoreParser and
>related classes.  -scott
>---------------------------------------------------------------------
>To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
>For additional commands, e-mail: java-user-h...@lucene.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to