private IEnumerable <long> CreateRange(int partitionIndex, long itemsCount) { for (long i = 0; i < itemsCount; i++) { yield return(RowIDUtil.ToRowID(partitionIndex, i)); } }
private List <long> GetLatestByIndexedSymbolByKeys(IEnumerable <PartitionRowIDRange> partitions, IReadTransactionContext tx) { var latestRowIDs = new List <long>(_keys.Count); foreach (var part in partitions) { var partition = tx.Read(part.PartitionID); int[] keysMap = new int[_keys.Count]; // Key mapping. for (int i = 0; i < _keys.Count; i++) { keysMap[i] = partition.GetSymbolKey(_column.ColumnID, _keys[i], tx); } var allFound = true; for (int i = 0; i < _keys.Count; i++) { if (latestRowIDs[i] == 0) { // Symbol D file key. var key = keysMap[i]; if (key != MetadataConstants.SYMBOL_NOT_FOUND_VALUE) { var rowIDs = partition.GetSymbolRowsByKey(_column.ColumnID, key, tx); foreach (var rowID in rowIDs) { if (rowID >= part.Low && rowID <= part.High) { // Stop search the key. latestRowIDs[i] = RowIDUtil.ToRowID(part.PartitionID, rowID); break; } } } else { // Stop search the invalid value. latestRowIDs[i] = MetadataConstants.SYMBOL_NOT_FOUND_VALUE; } } allFound &= latestRowIDs[i] != 0; } // Early partition scan termination. if (allFound) { break; } } return(latestRowIDs); }
private IEnumerable <long> TakeFromTo(PartitionRowIDRange part, IEnumerable <long> rowIds) { foreach (var rowId in rowIds) { if (rowId < part.Low) { yield break; } if (rowId <= part.High) { yield return(RowIDUtil.ToRowID(part.PartitionID, rowId)); } } }
private List <long> GetAllLatestByIndexedSymbolByKeys(IEnumerable <PartitionRowIDRange> partitions, IReadTransactionContext tx) { var allKeys = new ObjIntHashMap(); var latestRowIDs = new List <long>(); foreach (var part in partitions) { var partition = tx.Read(part.PartitionID); var symbolColumn = (ISymbolMapColumn)partition.ReadColumn(Column.ColumnID); // Key mapping. var partitionTxData = tx.GetPartitionTx(part.PartitionID); var distinctCount = symbolColumn.GetDistinctCount(partitionTxData); for (int i = 0; i < distinctCount; i++) { var key = i; var symbolValue = symbolColumn.GetKeyValue(key, partitionTxData); if (symbolValue == null) { key = MetadataConstants.NULL_SYMBOL_VALUE; } var existing = allKeys.Get(symbolValue); if (existing == MetadataConstants.SYMBOL_NOT_FOUND_VALUE) { var rowIDs = partition.GetSymbolRowsByKey(_column.ColumnID, key, tx); foreach (var rowID in rowIDs) { if (rowID >= part.Low && rowID <= part.High) { // Stop search the key. latestRowIDs.Add(RowIDUtil.ToRowID(part.PartitionID, rowID)); allKeys.Put(symbolValue, 1); break; } } } } } return(latestRowIDs); }
private IEnumerable <long> GetLatestFromDescending(IEnumerable <PartitionRowIDRange> partitions, IReadTransactionContext tx) { var latest = new HashSet <T>(); HashSet <T> contains = _keys != null ? new HashSet <T>(_keys) : null; foreach (var partition in partitions) { var readPartition = tx.Read(partition.PartitionID); var col = (ITypedColumn <T>)readPartition.ReadColumn(_column.ColumnID); for (long r = partition.High; r >= partition.Low; r--) { var val = col.Get(r, tx.ReadCache); if ((contains == null || contains.Contains(val)) && !latest.Contains(val)) { latest.Add(val); yield return(RowIDUtil.ToRowID(partition.PartitionID, r)); } } } }
private IEnumerable <long> IsPartitionMatch(IReadTransactionContext tx, PartitionRowIDRange part, IPartitionReader partition, ERowIDSortDirection sortDirection) { if (sortDirection == ERowIDSortDirection.Asc) { for (long rowId = part.Low; rowId <= part.High; rowId++) { if (IsMatch(partition, tx.ReadCache, rowId)) { yield return(RowIDUtil.ToRowID(part.PartitionID, rowId)); } } } else { for (long rowId = part.High; rowId >= part.Low; rowId--) { if (IsMatch(partition, tx.ReadCache, rowId)) { yield return(RowIDUtil.ToRowID(part.PartitionID, rowId)); } } } }