public DocumentDataContainerEnumerator_IndexScan( int untrimmedCount, DriverRowData rowData, DocumentDataContainer dataContainer, IReadOnlyList <FieldMetadata> fields, int countOfMainFields, SortIndex sortIndex, bool descending) : base(untrimmedCount, rowData, dataContainer, fields, countOfMainFields) { if (sortIndex == null) { throw new ArgumentNullException("sortIndex"); } // note that we ignore value of sortIndex.IsValid here // that's because invalidation of index only happens when the data is stale // we only check state of an index and optionally update it in the beginning of processing pipeline if (sortIndex.OrderData == null || sortIndex.OrderData.Length > untrimmedCount) { throw new ArgumentException("Index on column is in invalid state", "sortIndex"); } m_sortIndex = sortIndex; m_descending = descending; PositionInIndex = descending ? m_sortIndex.ValidDocCount : -1; ReadStructureAndTakeLocks(); }
public SortIndexManager(DocumentDataContainer documentStore) { if (documentStore == null) { throw new ArgumentNullException("documentStore"); } m_documentStore = documentStore; m_fieldIdToIndexHandle = new ConcurrentDictionary <int, int>(); if (m_documentStore.FieldIdToColumnStore.Count != m_documentStore.DocDesc.Fields.Length) { throw new Exception("Internal error: fieldid->colstore map and array of fields in document descriptor have different lengths"); } m_fieldIndexes = new SortIndex[m_documentStore.FieldIdToColumnStore.Count]; for (var ordinal = 0; ordinal < m_fieldIndexes.Length; ordinal++) { m_fieldIndexes[ordinal] = new SortIndex(); m_fieldIdToIndexHandle[m_documentStore.DocDesc.Fields[ordinal]] = ordinal; } }
internal void UpdateIndex(int fieldId, SortIndex index, int count) { if (!index.IsValid) { var columnStore = m_documentStore.RequireColumnStore(fieldId); var method = typeof(SortIndex).GetMethod("Update").MakeGenericMethod(columnStore.ElementType); m_documentStore.StructureLock.EnterWriteLock(); try { method.Invoke(index, new object[] { columnStore, m_documentStore.ValidDocumentsBitmap, count }); } catch (TargetInvocationException e) { throw e.InnerException; } finally { m_documentStore.StructureLock.ExitWriteLock(); } } }