Exemplo n.º 1
0
        public void CanReadWrittenBlobRecord()
        {
            var tableFile = RandomFilename;
            var schema    = new Schema();

            schema.AddBlobField("field", 40);
            _tableInfo = new TableInfo(tableFile, schema);

            _recordFile = new RecordFile(_tableInfo, _transaction);
            _recordFile.MoveToRID(new RID(0, 0));
            _recordFile.SetBlob("field", new byte[] { 1, 2, 3, 4, 5 });
            _recordFile.Close();

            _transaction.Commit();

            var cm    = new ConcurrencyManager();
            var newTr = new Transaction(_dispatcher, _bufferManager, cm, _fileManager, _logManager);

            var rf = new RecordFile(_tableInfo, newTr);

            rf.MoveToRID(new RID(0, 0));
            var value = rf.GetBlob("field");

            Assert.AreEqual(new byte[] { 1, 2, 3, 4, 5 }, value);
        }
Exemplo n.º 2
0
        public Constant GetValue(string fieldName)
        {
            var type = _schema.FieldType(fieldName);

            switch (type)
            {
            case FieldType.Bool:
                return(new Constant <bool>(_recordFile.GetBool(fieldName)));

            case FieldType.Byte:
                return(new Constant <byte>(_recordFile.GetByte(fieldName)));

            case FieldType.Integer:
                return(new Constant <int>(_recordFile.GetInt(fieldName)));

            case FieldType.Blob:
                return(new Constant <byte[]>(_recordFile.GetBlob(fieldName)));

            case FieldType.Date:
                return(new Constant <DateTime>(_recordFile.GetDate(fieldName)));
            }

            return(null);
        }