コード例 #1
0
        /// <summary>
        /// Reads the data. (allows faster custom serialization for better performance in TraceLab)
        /// </summary>
        /// <param name="reader">The reader.</param>
        public void ReadData(System.IO.BinaryReader reader)
        {
            int dataversion = reader.ReadInt32();

            if (dataversion != TLTermEntry.version)
            {
                throw new InvalidOperationException("Binary reader did not correct version data. Data corrupted. Potentially IRawSerializable not implemented correctly");
            }
            else
            {
                m_term = reader.ReadString();
                m_numberOfArtifactsContainingTerm = reader.ReadInt32();
                m_totalFrequencyAcrossArtifacts   = reader.ReadInt32();
                m_weight = reader.ReadDouble();
                int postingsCount = reader.ReadInt32();

                //reset both collections
                m_postings       = new PostingsCollection();
                m_postingsLookup = new Dictionary <string, TLPosting>();

                for (int i = 0; i < postingsCount; ++i)
                {
                    TLPosting posting = new TLPosting();
                    posting.ReadData(reader);
                    AddPosting(posting);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Allows adding new posting to the termEntry.
        /// </summary>
        /// <exception cref="System.ArgumentException">if posting is null</exception>
        private void AddPosting(TLPosting posting)
        {
            if (posting == null)
            {
                throw new ArgumentException("The posting cannot be null");
            }

            PostingsLookup.Add(posting.ArtifactId, posting);
            m_postings.Add(posting);
        }
コード例 #3
0
 /// <summary>
 /// Generates an object from its XML representation.
 /// </summary>
 /// <param name="reader">The XmlReader stream from which the object is deserialized. </param>
 public void ReadXml(System.Xml.XmlReader reader)
 {
     version = int.Parse(reader.GetAttribute("Version"));
     Term    = reader.GetAttribute("Term");
     NumberOfArtifactsContainingTerm = int.Parse(reader.GetAttribute("NoOfArtsWithTerm"));
     TotalFrequencyAcrossArtifacts   = int.Parse(reader.GetAttribute("TotalFrequency"));
     Weight = double.Parse(reader.GetAttribute("Weight"));
     reader.Read();
     while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
     {
         TLPosting posting = new TLPosting();
         posting.ReadXml(reader);
         AddPosting(posting);
     }
     //read to the next
     reader.Read();
 }
コード例 #4
0
        /// <summary>
        /// Allows adding new posting to the termEntry.
        /// </summary>
        /// <param name="artifactId">artifact id</param>
        /// <param name="frequency">frequency of the term in the given artifact</param>
        /// <param name="weight">local weight of the term in the posting</param>
        /// <returns>created posting</returns>
        /// <exception cref="System.ArgumentException">if documentId is null or empty; or if frequency is less than 0</exception>
        public TLPosting AddPosting(string artifactId, int frequency, double weight)
        {
            if (artifactId == null || artifactId == "")
            {
                throw new ArgumentException("The documentId cannot be empty or null");
            }
            if (frequency <= 0)
            {
                throw new ArgumentException("Frequency has to be greater than 0.");
            }

            TLPosting posting = new TLPosting(artifactId, frequency, weight);

            PostingsLookup.Add(artifactId, posting);
            m_postings.Add(posting);

            return(posting);
        }
コード例 #5
0
        /// <summary>
        /// Reads the data. (allows faster custom serialization for better performance in TraceLab)
        /// </summary>
        /// <param name="reader">The reader.</param>
        public void ReadData(System.IO.BinaryReader reader)
        {
            int dataversion = reader.ReadInt32();
            if (dataversion != TLTermEntry.version)
            {
                throw new InvalidOperationException("Binary reader did not correct version data. Data corrupted. Potentially IRawSerializable not implemented correctly");
            }
            else
            {
                m_term = reader.ReadString();
                m_numberOfArtifactsContainingTerm = reader.ReadInt32();
                m_totalFrequencyAcrossArtifacts = reader.ReadInt32();
                m_weight = reader.ReadDouble();
                int postingsCount = reader.ReadInt32();

                //reset both collections
                m_postings = new PostingsCollection();
                m_postingsLookup = new Dictionary<string, TLPosting>();

                for (int i = 0; i < postingsCount; ++i)
                {
                    TLPosting posting = new TLPosting();
                    posting.ReadData(reader);
                    AddPosting(posting);
                }
            }
        }
コード例 #6
0
 /// <summary>
 /// Generates an object from its XML representation.
 /// </summary>
 /// <param name="reader">The XmlReader stream from which the object is deserialized. </param>
 public void ReadXml(System.Xml.XmlReader reader)
 {
     version = int.Parse(reader.GetAttribute("Version"));
     Term = reader.GetAttribute("Term");
     NumberOfArtifactsContainingTerm = int.Parse(reader.GetAttribute("NoOfArtsWithTerm"));
     TotalFrequencyAcrossArtifacts = int.Parse(reader.GetAttribute("TotalFrequency"));
     Weight = double.Parse(reader.GetAttribute("Weight"));
     reader.Read();
     while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
     {
         TLPosting posting = new TLPosting();
         posting.ReadXml(reader);
         AddPosting(posting);
     }
     //read to the next
     reader.Read();
 }
コード例 #7
0
        /// <summary>
        /// Allows adding new posting to the termEntry.
        /// </summary>
        /// <exception cref="System.ArgumentException">if posting is null</exception>
        private void AddPosting(TLPosting posting)
        {
            if (posting == null)
                throw new ArgumentException("The posting cannot be null");

            PostingsLookup.Add(posting.ArtifactId, posting);
            m_postings.Add(posting);
        }
コード例 #8
0
        /// <summary>
        /// Allows adding new posting to the termEntry.
        /// </summary>
        /// <param name="artifactId">artifact id</param>
        /// <param name="frequency">frequency of the term in the given artifact</param>
        /// <param name="weight">local weight of the term in the posting</param>
        /// <returns>created posting</returns>
        /// <exception cref="System.ArgumentException">if documentId is null or empty; or if frequency is less than 0</exception>
        public TLPosting AddPosting(string artifactId, int frequency, double weight)
        {
            if (artifactId == null || artifactId == "")
                throw new ArgumentException("The documentId cannot be empty or null");
            if (frequency <= 0)
                throw new ArgumentException("Frequency has to be greater than 0.");

            TLPosting posting = new TLPosting(artifactId, frequency, weight);
            PostingsLookup.Add(artifactId, posting);
            m_postings.Add(posting);

            return posting;

        }
コード例 #9
0
 /// <summary>
 /// Compares two specified TLTermEntry objects and returns an integer that indicates their relative position in the sort order.
 /// </summary>
 /// <param name="x">The first TLTermEntry to compare. </param>
 /// <param name="y">The second TLTermEntry to compare. </param>
 /// <returns>A 32-bit signed integer that indicates the lexical relationship between the two comparands.</returns>
 public int Compare(TLPosting x, TLPosting y)
 {
     return((new CaseInsensitiveComparer()).Compare(x.ArtifactId, y.ArtifactId));
 }
コード例 #10
0
 /// <summary>
 /// Compares two specified TLTermEntry objects and returns an integer that indicates their relative position in the sort order.
 /// </summary>
 /// <param name="x">The first TLTermEntry to compare. </param>
 /// <param name="y">The second TLTermEntry to compare. </param>
 /// <returns>A 32-bit signed integer that indicates the lexical relationship between the two comparands.</returns>
 public int Compare(TLPosting x, TLPosting y)
 {
     return ((new CaseInsensitiveComparer()).Compare(x.ArtifactId, y.ArtifactId));
 }