Ejemplo n.º 1
0
 public ColumnSource[] GetPartitionColumns(int paritionID, IColumnStorage partitionStorage, PartitionConfig configOverride = null)
 {
     return(CreateColumnsFromColumnMetadata(_columns, partitionStorage, configOverride, paritionID));
 }
Ejemplo n.º 2
0
        private ColumnSource[] CreateColumnsFromColumnMetadata(IList <ColumnMetadata> columns,
                                                               IColumnStorage columnStorage, PartitionConfig configOverride, int partitionID)
        {
            var resultColumns = new ColumnSource[columns.Count];
            var recordHint    = _settings.RecordHint;

            if (configOverride != null)
            {
                columns    = ParseColumns(columns.Select(c => c.SerializerMetadata), configOverride.Columns);
                recordHint = configOverride.RecordHint;
            }

            int fileID = 0;

            for (int columnID = 0; columnID < columns.Count; columnID++)
            {
                var cType = columns[columnID];
                // Build.
                IColumn column;
                if (cType.ColumnType == EFieldType.String)
                {
                    // String.
                    var data  = columnStorage.GetFile(cType, fileID++, EDataType.Data, recordHint);
                    var index = columnStorage.GetFile(cType, fileID++, EDataType.Index, recordHint);
                    column = new StringColumn(data, index, cType.MaxSize, GetPropertyName(cType.FileName));
                }
                else if (cType.ColumnType == EFieldType.BitSet)
                {
                    var data = columnStorage.GetFile(cType, fileID++, EDataType.Data, recordHint);
                    column = new BitsetColumn(data, cType.MaxSize);
                }
                else if (cType.ColumnType == EFieldType.Symbol)
                {
                    var colData           = columnStorage.GetFile(cType, fileID++, EDataType.Data, recordHint);
                    var symData           = columnStorage.GetFile(cType, fileID++, EDataType.Symd, recordHint);
                    var symi              = columnStorage.GetFile(cType, fileID++, EDataType.Symi, recordHint);
                    var symk              = columnStorage.GetFile(cType, fileID++, EDataType.Symrk, recordHint);
                    var symr              = columnStorage.GetFile(cType, fileID++, EDataType.Symrr, recordHint);
                    int maxLen            = cType.MaxSize;
                    int distinctHintCount = cType.HintDistinctCount;
                    if (cType.Indexed)
                    {
                        var colDataK = columnStorage.GetFile(cType, fileID++, EDataType.Datak, recordHint);
                        var colDataR = columnStorage.GetFile(cType, fileID++, EDataType.Datar, recordHint);
                        column = new SymbolMapColumn(
                            columnID,
                            partitionID,
                            data: colData,
                            datak: colDataK,
                            datar: colDataR,
                            symd: symData,
                            symi: symi,
                            symk: symk,
                            symr: symr,
                            propertyName: GetPropertyName(cType.FileName),
                            capacity: distinctHintCount,
                            recordCountHint: _settings.RecordHint,
                            maxLen: maxLen);
                    }
                    else
                    {
                        column = new SymbolMapColumn(
                            columnID,
                            partitionID,
                            data: colData,
                            symd: symData,
                            symi: symi,
                            symk: symk,
                            symr: symr,
                            propertyName: GetPropertyName(cType.FileName),
                            capacity: distinctHintCount,
                            maxLen: maxLen);
                    }
                }
                else if (cType.ColumnType == EFieldType.Binary)
                {
                    // Byte array.
                    var data  = columnStorage.GetFile(cType, fileID++, EDataType.Data, recordHint);
                    var index = columnStorage.GetFile(cType, fileID++, EDataType.Index, recordHint);
                    column = new BinaryColumn(data, index, cType.MaxSize, GetPropertyName(cType.FileName));
                }
                else
                {
                    // Fixed size.
                    var data = columnStorage.GetFile(cType, fileID++, EDataType.Data, recordHint);
                    column = new FixedColumn(data, cType.ColumnType, GetPropertyName(cType.FileName));
                }

                resultColumns[columnID] = new ColumnSource(cType, column, fileID);
            }
            return(resultColumns);
        }
Ejemplo n.º 3
0
 public static void WritePartitionConfiguration(Stream output, PartitionConfig element)
 {
     PARTITION_SERIALIZER.Serialize(output, element);
 }