From lucene-net-dev-return-1839-apmail-incubator-lucene-net-dev-archive=incubator.apache.org@incubator.apache.org Sat Jan 24 14:57:31 2009 Return-Path: Delivered-To: apmail-incubator-lucene-net-dev-archive@locus.apache.org Received: (qmail 38047 invoked from network); 24 Jan 2009 14:57:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 24 Jan 2009 14:57:31 -0000 Received: (qmail 17409 invoked by uid 500); 24 Jan 2009 14:57:31 -0000 Delivered-To: apmail-incubator-lucene-net-dev-archive@incubator.apache.org Received: (qmail 17375 invoked by uid 500); 24 Jan 2009 14:57:31 -0000 Mailing-List: contact lucene-net-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: lucene-net-dev@incubator.apache.org Delivered-To: mailing list lucene-net-dev@incubator.apache.org Received: (qmail 17364 invoked by uid 99); 24 Jan 2009 14:57:31 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 24 Jan 2009 06:57:31 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 24 Jan 2009 14:57:20 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 8785E234C485 for ; Sat, 24 Jan 2009 06:56:59 -0800 (PST) Message-ID: <1774671387.1232809019539.JavaMail.jira@brutus> Date: Sat, 24 Jan 2009 06:56:59 -0800 (PST) From: "Digy (JIRA)" To: lucene-net-dev@incubator.apache.org Subject: [jira] Updated: (LUCENENET-170) BooleanClause serialization fails owing to issues with serializing Occur object In-Reply-To: <1666071423.1232744399575.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/LUCENENET-170?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Digy updated LUCENENET-170: --------------------------- Attachment: 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, 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.