public LazyField(FieldsReader enclosingInstance, System.String name, Field.Store store, Field.Index index, Field.TermVector termVector, int toRead, long pointer, bool isBinary):base(name, store, index, termVector) { InitBlock(enclosingInstance); this.toRead = toRead; this.pointer = pointer; this.isBinary = isBinary; if (isBinary) binaryLength = toRead; lazy = true; }
private void AddField(Document doc, FieldInfo fi, bool binary, bool compressed, bool tokenize) { //we have a binary stored field, and it may be compressed if (binary) { int toRead = fieldsStream.ReadVInt(); byte[] b = new byte[toRead]; fieldsStream.ReadBytes(b, 0, b.Length); if (compressed) doc.Add(new Field(fi.name, Uncompress(b), Field.Store.COMPRESS)); else doc.Add(new Field(fi.name, b, Field.Store.YES)); } else { Field.Store store = Field.Store.YES; Field.Index index = GetIndexType(fi, tokenize); Field.TermVector termVector = GetTermVectorType(fi); AbstractField f; if (compressed) { store = Field.Store.COMPRESS; int toRead = fieldsStream.ReadVInt(); byte[] b = new byte[toRead]; fieldsStream.ReadBytes(b, 0, b.Length); f = new Field(fi.name, false, System.Text.Encoding.GetEncoding("UTF-8").GetString(Uncompress(b)), store, index, termVector); f.SetOmitTermFreqAndPositions(fi.omitTermFreqAndPositions); f.SetOmitNorms(fi.omitNorms); } else { f = new Field(fi.name, false, fieldsStream.ReadString(), store, index, termVector); f.SetOmitTermFreqAndPositions(fi.omitTermFreqAndPositions); f.SetOmitNorms(fi.omitNorms); } doc.Add(f); } }
/// <summary> Creates a field for numeric values with the specified /// <code>precisionStep</code>. The instance is not yet initialized with /// a numeric value, before indexing a document containing this field, /// set a value using the various set<em>???</em>Value() methods. /// </summary> /// <param name="name">the field name /// </param> /// <param name="precisionStep">the used <a href="../search/NumericRangeQuery.html#precisionStepDesc">precision step</a> /// </param> /// <param name="store">if the field should be stored in plain text form /// (according to <code>toString(value)</code> of the used data type) /// </param> /// <param name="index">if the field should be indexed using {@link NumericTokenStream} /// </param> public NumericField(System.String name, int precisionStep, Field.Store store, bool index):base(name, store, index?Field.Index.ANALYZED_NO_NORMS:Field.Index.NO, Field.TermVector.NO) { SetOmitTermFreqAndPositions(true); tokenStream = new NumericTokenStream(precisionStep); }
/// <summary> Creates a field for numeric values using the default <code>precisionStep</code> /// {@link NumericUtils#PRECISION_STEP_DEFAULT} (4). The instance is not yet initialized with /// a numeric value, before indexing a document containing this field, /// set a value using the various set<em>???</em>Value() methods. /// </summary> /// <param name="name">the field name /// </param> /// <param name="store">if the field should be stored in plain text form /// (according to <code>toString(value)</code> of the used data type) /// </param> /// <param name="index">if the field should be indexed using {@link NumericTokenStream} /// </param> public NumericField(System.String name, Field.Store store, bool index):this(name, NumericUtils.PRECISION_STEP_DEFAULT, store, index) { }
protected internal AbstractField(System.String name, Field.Store store, Field.Index index, Field.TermVector termVector) { if (name == null) throw new System.NullReferenceException("name cannot be null"); this.name = StringHelper.Intern(name); // field names are interned if (store == Field.Store.YES) { this.isStored = true; this.isCompressed = false; } else if (store == Field.Store.COMPRESS) { this.isStored = true; this.isCompressed = true; } else if (store == Field.Store.NO) { this.isStored = false; this.isCompressed = false; } else { throw new System.ArgumentException("unknown store parameter " + store); } if (index == Field.Index.NO) { this.isIndexed = false; this.isTokenized = false; } else if (index == Field.Index.ANALYZED) { this.isIndexed = true; this.isTokenized = true; } else if (index == Field.Index.NOT_ANALYZED) { this.isIndexed = true; this.isTokenized = false; } else if (index == Field.Index.NOT_ANALYZED_NO_NORMS) { this.isIndexed = true; this.isTokenized = false; this.omitNorms = true; } else if (index == Field.Index.ANALYZED_NO_NORMS) { this.isIndexed = true; this.isTokenized = true; this.omitNorms = true; } else { throw new System.ArgumentException("unknown index parameter " + index); } this.isBinary = false; SetStoreTermVector(termVector); }
protected internal virtual void SetStoreTermVector(Field.TermVector termVector) { if (termVector == Field.TermVector.NO) { this.storeTermVector = false; this.storePositionWithTermVector = false; this.storeOffsetWithTermVector = false; } else if (termVector == Field.TermVector.YES) { this.storeTermVector = true; this.storePositionWithTermVector = false; this.storeOffsetWithTermVector = false; } else if (termVector == Field.TermVector.WITH_POSITIONS) { this.storeTermVector = true; this.storePositionWithTermVector = true; this.storeOffsetWithTermVector = false; } else if (termVector == Field.TermVector.WITH_OFFSETS) { this.storeTermVector = true; this.storePositionWithTermVector = false; this.storeOffsetWithTermVector = true; } else if (termVector == Field.TermVector.WITH_POSITIONS_OFFSETS) { this.storeTermVector = true; this.storePositionWithTermVector = true; this.storeOffsetWithTermVector = true; } else { throw new System.ArgumentException("unknown termVector parameter " + termVector); } }