Example #1
0
        public string GetString(long rowID, ReadContext readContext)
        {
            var symRowID = _data.ReadInt32(rowID * INT32_SIZE);

            if (symRowID == MetadataConstants.NULL_SYMBOL_VALUE)
            {
                return(null);
            }

#if DEBUG
            if (symRowID < 0)
            {
                throw new IndexOutOfRangeException(_data.Filename + "|" + PropertyName + "|" + rowID + "\n" +
                                                   ((CompositeRawFile)_data).GetAllUnsafePointers()
                                                   + "\n" + ((CompositeRawFile)_data).GetAllBufferPointers());
            }
#endif

            var    symbolCache = readContext.GetCache(_partitionID, _columnId, _capacity);
            string value;
            if (symbolCache.IsValueCached(symRowID, out value))
            {
                return(value);
            }

            value = _globalSymColumn.GetString(symRowID, readContext);
            symbolCache.SetRowID(value, symRowID);
            return(value);
        }
Example #2
0
        public IndexAddressColumn(IRawFile kData, int capacity, long recordCountHint)
        {
            _fileID      = kData.FileID;
            _partitionID = kData.PartitionID;
            int keycountHint = Math.Max(capacity, 1);

            // Nuber of records per keyblock
            // is a half of statistically expected
            // but minimum size is 10
            _rowBlockLenBitHint = (int)Math.Floor(Math.Log(Math.Max(recordCountHint / keycountHint / 2, 16), 2.0)) - 1;
            _rowBlockLenBitHint = Math.Max(_rowBlockLenBitHint, 4);
            int rowBlockLen = 1 << _rowBlockLenBitHint;

            _kData = kData;

            if (kData.GetAppendOffset() > 0)
            {
                rowBlockLen         = _kData.ReadInt32(ROW_BLOK_LEN_ADDRESS_OFFSET);
                _rowBlockLenBitHint = (int)Math.Log(rowBlockLen, 2);

                if (1 << _rowBlockLenBitHint != rowBlockLen)
                {
                    throw new NFSdbInvalidStateException("Row block length specified in file '{0}' equals " +
                                                         "{1}. Only power of 2 values are supported.",
                                                         _kData.Filename, rowBlockLen);
                }
            }
            else if (kData.Access == EFileAccess.ReadWrite)
            {
                kData.WriteInt64(0, rowBlockLen);                                    // 8
                kData.WriteInt64(KEY_BLOCK_ADDRESS_OFFSET, INITIAL_KEYBLOCK_OFFSET); // 8

                const int defaultKeyBlockSize = 0;
                kData.WriteInt64(INITIAL_KEYBLOCK_OFFSET, defaultKeyBlockSize); // 8
                kData.WriteInt64(INITIAL_KEYBLOCK_OFFSET + 8, 0);               // 8
                kData.SetAppendOffset(INITIAL_APPEND_OFFSET);
            }

            _rowBlockSize = rowBlockLen * 8 + 8;
        }
Example #3
0
 public int GetInt32(long rowID)
 {
     return(_storage.ReadInt32(rowID * _sizeBytes));
 }
Example #4
0
 private void Read(IRawFile item, int chunkCount, int chunkSize)
 {
     Enumerable.Range(0, chunkCount).Select(i => item.ReadInt32(i * chunkSize)).ToArray();
 }