You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by "Digy (JIRA)" <ji...@apache.org> on 2009/01/24 16:34:59 UTC
[jira] Issue Comment Edited: (LUCENENET-170) BooleanClause
serialization fails owing to issues with serializing Occur object
[ https://issues.apache.org/jira/browse/LUCENENET-170?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12666942#action_12666942 ]
digydigy edited comment on LUCENENET-170 at 1/24/09 7:33 AM:
---------------------------------------------------------
Another patch which is more close to the Lucene's Java version.
It mimics the behaviour of "readResolve" in Java.
DIGY
was (Author: digydigy):
Another patch which is more close the Lucene's Java version.
It mimics the behaviour of "readResolve" in Java.
DIGY
> BooleanClause serialization fails owing to issues with serializing Occur object
> -------------------------------------------------------------------------------
>
> Key: LUCENENET-170
> URL: https://issues.apache.org/jira/browse/LUCENENET-170
> Project: Lucene.Net
> Issue Type: Bug
> Reporter: Moray McConnachie
> Attachments: Parameter v2.patch, Parameter.patch
>
>
> Essentially when you serialize a BooleanClause you lose all Occurs objects, so you cannot meaningfully serialize and deserialize BooleanQuery s with multiple clauses unless they all use the default Occur.SHOULD
> I suspect this bug extends to all objects depending on Parameter object, making it impossible to serialize and deserialize objects which include members inheriting from Parameter.
> I don't know enough about how the Parameter object ought to work or is used elsewhere to attempt a fix. I have a hack which works for my app by intercepting Serialize and Deserialize and serializing the occur member of BooleanClause to a string and Deserializing it the same way, but this is deeply suboptimal.
> Here is some test code for a Console application. Sorry about the formatting, this bug tracker seems not to like it too much.
> If the two queries don't match the bug is still in evidence.
> ----
> {{
> using System;\\
> using System.Collections.Generic;\\
> using System.IO;\\
> using System.Linq;\\
> using System.Runtime.Serialization.Formatters.Binary;\\
> using System.Text;\\
> using Lucene.Net.Search;\\
> namespace TestSerialization
> {
> class Program
> {
> static void Main(string[] args)
> {
> //build our sample query
> BooleanQuery queryPreSerialized = new BooleanQuery();
> queryPreSerialized.Add(new TermQuery(new Lucene.Net.Index.Term("country","Russia")),BooleanClause.Occur.MUST);
> queryPreSerialized.Add(new TermQuery(new Lucene.Net.Index.Term("country","France")),BooleanClause.Occur.MUST);
> Console.WriteLine("Query pre serialisation: " + queryPreSerialized.ToString());
> //now serialize it
> BinaryFormatter serializer = new BinaryFormatter();
> MemoryStream memoryStream = new MemoryStream();
> serializer.Serialize(memoryStream, queryPreSerialized);
> //now deserialize
> memoryStream.Seek(0, SeekOrigin.Begin);
> BooleanQuery queryPostSerialized = (BooleanQuery)serializer.Deserialize(memoryStream);
> Console.WriteLine("Query post deserialization: "+ queryPostSerialized.ToString());
> if (!queryPreSerialized.Equals(queryPostSerialized))
> Console.WriteLine("Serialized and deserialized do not match - down to issues with the way Parameter objects (in BooleanClause.Occur are maintained");
> memoryStream.Close();
> Console.WriteLine("press enter to close");
> Console.Read();
> }\\
> }\\
> }\\
> }}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.