Ejemplo n.º 1
0
        internal void  AddDocument(Document doc)
        {
            indexStream.WriteLong(fieldsStream.GetFilePointer());

            int storedCount = 0;

            foreach (Field field  in doc.Fields())
            {
                if (field.IsStored())
                {
                    storedCount++;
                }
            }
            fieldsStream.WriteVInt(storedCount);

            foreach (Field field in doc.Fields())
            {
                if (field.IsStored())
                {
                    fieldsStream.WriteVInt(fieldInfos.FieldNumber(field.Name()));

                    byte bits = 0;
                    if (field.IsTokenized())
                    {
                        bits |= 1;
                    }
                    fieldsStream.WriteByte(bits);

                    fieldsStream.WriteString(field.StringValue());
                }
            }
        }
 private void  MergeNorms()
 {
     for (int i = 0; i < fieldInfos.Size(); i++)
     {
         FieldInfo fi = fieldInfos.FieldInfo(i);
         if (fi.isIndexed)
         {
             OutputStream output = directory.CreateFile(segment + ".f" + i);
             try
             {
                 for (int j = 0; j < readers.Count; j++)
                 {
                     Monodoc.Lucene.Net.Index.IndexReader reader = (Monodoc.Lucene.Net.Index.IndexReader)readers[j];
                     byte[] input  = reader.Norms(fi.name);
                     int    maxDoc = reader.MaxDoc();
                     for (int k = 0; k < maxDoc; k++)
                     {
                         byte norm = input != null?input[k]:(byte)0;
                         if (!reader.IsDeleted(k))
                         {
                             output.WriteByte(norm);
                         }
                     }
                 }
             }
             finally
             {
                 output.Close();
             }
         }
     }
 }
Ejemplo n.º 3
0
 private void  WriteNorms(Document doc, System.String segment)
 {
     for (int n = 0; n < fieldInfos.Size(); n++)
     {
         FieldInfo fi = fieldInfos.FieldInfo(n);
         if (fi.isIndexed)
         {
             float        norm  = fieldBoosts[n] * similarity.LengthNorm(fi.name, fieldLengths[n]);
             OutputStream norms = directory.CreateFile(segment + ".f" + n);
             try
             {
                 norms.WriteByte(Monodoc.Lucene.Net.Search.Similarity.EncodeNorm(norm));
             }
             finally
             {
                 norms.Close();
             }
         }
     }
 }
Ejemplo n.º 4
0
 public void  Write(OutputStream output)
 {
     output.WriteVInt(Size());
     for (int i = 0; i < Size(); i++)
     {
         FieldInfo fi   = FieldInfo(i);
         byte      bits = (byte)(0x0);
         if (fi.isIndexed)
         {
             bits |= (byte)(0x1);
         }
         if (fi.storeTermVector)
         {
             bits |= (byte)(0x2);
         }
         output.WriteString(fi.name);
         //Was REMOVE
         //output.writeByte((byte)(fi.isIndexed ? 1 : 0));
         output.WriteByte(bits);
     }
 }
Ejemplo n.º 5
0
		public void  Write(OutputStream output)
		{
			output.WriteVInt(Size());
			for (int i = 0; i < Size(); i++)
			{
				FieldInfo fi = FieldInfo(i);
				byte bits = (byte) (0x0);
				if (fi.isIndexed)
					bits |= (byte) (0x1);
				if (fi.storeTermVector)
					bits |= (byte) (0x2);
				output.WriteString(fi.name);
				//Was REMOVE
				//output.writeByte((byte)(fi.isIndexed ? 1 : 0));
				output.WriteByte(bits);
			}
		}