Ejemplo n.º 1
0
        public IRollback Commit(PartitionTxData pd)
        {
            if (!_isStorageInitialized)
            {
                return(null);
            }

            // Set respective append offset.
            // Some serializers can skip null fields.
            var count = pd.NextRowID;

            for (int i = 0; i < _columnStorage.OpenFileCount; i++)
            {
                var file = _columnStorage.GetOpenedFileByID(i);
                if (file != null)
                {
                    var column = _metadata.GetColumnByID(file.ColumnID);
                    var size   = StorageSizeUtils.GetRecordSize(column, file.DataType);
                    if (size > 0)
                    {
                        pd.AppendOffset[file.FileID] = count * size;
                    }
                }
            }
            return(_txSupport.Commit(pd));
        }
 private static IColumnMetadata GetTimestamp(IJournalMetadata metadata)
 {
     if (!metadata.TimestampColumnID.HasValue)
     {
         return(null);
     }
     return(metadata.GetColumnByID(metadata.TimestampColumnID.Value));
 }
Ejemplo n.º 3
0
        public T?GetNullable <T>(long rowId, int columnIndex) where T : struct
        {
            int  partitionID = RowIDUtil.ToPartitionIndex(rowId);
            long localRowID  = RowIDUtil.ToLocalRowID(rowId);

            if (_columnMaps != null)
            {
                columnIndex = _columnMaps[columnIndex];
            }
            var nullable  = _metadata.GetColumnByID(columnIndex).Nullable;
            var nullIndex = _metadata.GetColumnByID(columnIndex).NullIndex;

            if (nullable && _bitSetColIndex != -1)
            {
                if (partitionID == _lastPartitionID)
                {
                    byte[] bitset = ((IBitsetColumn)_lastPartitionReader.ReadColumn(_bitSetColIndex))
                                    .GetValue(localRowID, _tx.ReadCache);

                    if (new ByteArray(bitset).IsSet(nullIndex))
                    {
                        return(default(T?));
                    }
                }
                else if (UpdatePartitionGetIsNull(partitionID, localRowID, nullIndex))
                {
                    return(default(T?));
                }
            }

            if (partitionID == _lastPartitionID)
            {
                return(((ITypedColumn <T>)_lastPartitionReader.ReadColumn(columnIndex)).Get(localRowID, _tx.ReadCache));
            }

            return(UpdatePartition <T>(partitionID, localRowID, columnIndex));
        }