lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Digy (JIRA)" <j...@apache.org>
Subject [jira] Updated: (LUCENENET-170) BooleanClause serialization fails owing to issues with serializing Occur object
Date Sat, 24 Jan 2009 14:59:02 GMT

     [ https://issues.apache.org/jira/browse/LUCENENET-170?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Digy updated LUCENENET-170:
---------------------------

    Attachment:     (was: Parameter.patch)

> 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.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.


Mime
View raw message