public void Should_save_null() { var map = new ObjIntHashMap(30); map.Put(null, 1); Assert.That(map.Get(null), Is.EqualTo(1)); }
public void Should_return_saved_values() { var map = new ObjIntHashMap(30); for (int i = 0; i < 20; i++) { map.Put("Sym_" + i, i); } for (int i = 0; i < 30; i++) { Assert.That(map.Get("Sym_" + i), Is.EqualTo(i < 20 ? i : MetadataConstants.SYMBOL_NOT_FOUND_VALUE)); } }
public void Should_clear_prev_values() { var map = new ObjIntHashMap(30); for (int i = 0; i < 20; i++) { map.Put("Sym_" + i, i); } map.Clear(); for (int i = 0; i < 20; i++) { Assert.That(map.Get("Sym_" + i), Is.EqualTo(MetadataConstants.SYMBOL_NOT_FOUND_VALUE)); } }
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); }
public int GetRowID(string key) { return(_cache2.Get(key)); }