예제 #1
0
        public void Should_save_null()
        {
            var map = new ObjIntHashMap(30);

            map.Put(null, 1);
            Assert.That(map.Get(null), Is.EqualTo(1));
        }
예제 #2
0
        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));
            }
        }
예제 #3
0
        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));
            }
        }
예제 #4
0
        public void Should_lookup_values()
        {
            // TODO
            var map = new ObjIntHashMap(1024);

            for (int i = 0; i < 2048; i++)
            {
                map.Put("Sym_" + i, i);
            }

            for (int i = 0; i < 2048; i++)
            {
                var    expected = "Sym_" + i;
                string actual;
                map.LookupValue(i, out actual);
                Assert.That(actual, Is.EqualTo(expected), "iteration " + i);
            }
        }
예제 #5
0
        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);
        }
예제 #6
0
 public void SetRowID(string key, int value)
 {
     _cache2.Put(key, value);
 }