예제 #1
0
        public ObjectSerializer(IEnumerable <ColumnSource> columns,
                                Func <ByteArray, IFixedWidthColumn[], long, IRefTypeColumn[], ReadContext, object> readMethod,
                                Action <object, ByteArray, IFixedWidthColumn[], long, IRefTypeColumn[], PartitionTxData> writeMethod)
        {
            var allColumns = columns.ToArray();

            _fixedColumns = allColumns
                            .Where(c => !((IClassColumnSerializerMetadata)c.Metadata.SerializerMetadata).IsRefType() && c.Metadata.SerializerMetadata.ColumnType != EFieldType.BitSet)
                            .Select(c => c.Column)
                            .Cast <IFixedWidthColumn>().ToArray();

            _refTypeColumns = allColumns
                              .Where(c => ((IClassColumnSerializerMetadata)c.Metadata.SerializerMetadata).IsRefType())
                              .Select(c => c.Column)
                              .Cast <IRefTypeColumn>().ToArray();

            _issetColumn = (IBitsetColumn)allColumns
                           .Select(c => c.Column)
                           .FirstOrDefault(c => c.FieldType == EFieldType.BitSet);

            if (_issetColumn == null)
            {
                throw new NFSdbInitializationException("Type {0} does not have thrift __isset field defined");
            }
            _fillItemMethod = readMethod;
            _writeMethod    = writeMethod;

            _bitsetColSize = _issetColumn.GetByteSize();
        }
예제 #2
0
        public PocoObjectSerializer(IEnumerable <ColumnSource> columns,
                                    Func <ByteArray, IFixedWidthColumn[], long, IRefTypeColumn[], ReadContext, object> readMethod,
                                    Action <object, ByteArray, IFixedWidthColumn[], long, IRefTypeColumn[], PartitionTxData> writeMethod)
        {
            var allColumns = columns.ToArray();

            _fixedColumns = allColumns
                            .Where(c => !((IClassColumnSerializerMetadata)c.Metadata.SerializerMetadata).IsRefType() && c.Metadata.SerializerMetadata.ColumnType != EFieldType.BitSet)
                            .Select(c => c.Column)
                            .Cast <IFixedWidthColumn>().ToArray();

            _stringColumns = allColumns
                             .Where(c => ((IClassColumnSerializerMetadata)c.Metadata.SerializerMetadata).IsRefType())
                             .Select(c => c.Column)
                             .Cast <IRefTypeColumn>().ToArray();

            // IBitsetColumn.
            _issetColumn = (IBitsetColumn)allColumns
                           .Select(c => c.Column)
                           .FirstOrDefault(c => c.FieldType == EFieldType.BitSet);

            if (_issetColumn != null)
            {
                _bitsetColSize = _issetColumn.GetByteSize();
            }

            // Read - write generated methods.
            _readMethod  = readMethod;
            _writeMethod = writeMethod;
        }