protected LuceneDocumentConverterBase( Index index, ICollection <IndexField> fields, bool indexImplicitNull, bool indexEmptyEntries, int numberOfBaseFields, string keyFieldName = null, bool storeValue = false, string storeValueFieldName = Constants.Documents.Indexing.Fields.ReduceKeyValueFieldName) { _index = index ?? throw new ArgumentNullException(nameof(index)); var dictionary = new Dictionary <string, IndexField>(fields.Count, default(OrdinalStringStructComparer)); foreach (var field in fields) { dictionary[field.Name] = field; } _fields = dictionary; _indexImplicitNull = indexImplicitNull; _indexEmptyEntries = indexEmptyEntries; _numberOfBaseFields = numberOfBaseFields; _keyFieldName = keyFieldName ?? (storeValue ? Constants.Documents.Indexing.Fields.ReduceKeyHashFieldName : Constants.Documents.Indexing.Fields.DocumentIdFieldName); _storeValue = storeValue; _storeValueField = new Field(storeValueFieldName, new byte[0], 0, 0, Field.Store.YES); Scope = new ConversionScope(this); }
protected LuceneDocumentConverterBase(ICollection<IndexField> fields, bool indexImplicitNull, bool indexEmptyEntries, bool reduceOutput) { var dictionary = new Dictionary<string, IndexField>(fields.Count, default(OrdinalStringStructComparer)); foreach (var field in fields) dictionary[field.Name] = field; _fields = dictionary; _indexImplicitNull = indexImplicitNull; _indexEmptyEntries = indexEmptyEntries; _reduceOutput = reduceOutput; Scope = new ConversionScope(this); }
static byte[] ToArray(ConversionScope scope, Stream stream, out int length) { length = (int)(stream.Length - stream.Position); var buffer = scope.RentArray(length); using (var ms = new MemoryStream(buffer)) { stream.CopyTo(ms); return(buffer); } }