public ColumnOrSuperColumn(Column column, SuperColumn superColumn)
 {
     if(column != null)
         Column = column;
     if(superColumn != null)
         Super_column = superColumn;
 }
Exemplo n.º 2
0
 public ColumnOrSuperColumn(Column column, SuperColumn superColumn)
 {
     if (column != null)
     {
         Column = column;
     }
     if (superColumn != null)
     {
         Super_column = superColumn;
     }
 }
Exemplo n.º 3
0
        public void Read(TProtocol iprot)
        {
            TField field;

            iprot.ReadStructBegin();
            while (true)
            {
                field = iprot.ReadFieldBegin();
                if (field.Type == TType.Stop)
                {
                    break;
                }
                switch (field.ID)
                {
                case 1:
                    if (field.Type == TType.Struct)
                    {
                        Column = new Column();
                        Column.Read(iprot);
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 2:
                    if (field.Type == TType.Struct)
                    {
                        Super_column = new SuperColumn();
                        Super_column.Read(iprot);
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                default:
                    TProtocolUtil.Skip(iprot, field.Type);
                    break;
                }
                iprot.ReadFieldEnd();
            }
            iprot.ReadStructEnd();
        }
Exemplo n.º 4
0
        private SuperColumn BuildFolderIndexEntry(InventoryFolderBase folder, byte[] folderIdBytes, FolderMutationSelector mutationTypes, 
            Guid newParent, long timeStamp)
        {
            SuperColumn indexColumn = new SuperColumn();
            indexColumn.Name = folderIdBytes;
            List<Column> columns = new List<Column>();

            if (mutationTypes == FolderMutationSelector.All || mutationTypes == FolderMutationSelector.AllButParent)
            {
                columns.Add(new Column
                {
                    Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("name"),
                    Value = ByteEncoderHelper.UTF8Encoder.ToByteArray(folder.Name),
                    Timestamp = timeStamp
                });

                columns.Add(new Column
                {
                    Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("type"),
                    Value = ByteEncoderHelper.Int32Encoder.ToByteArray((int)folder.Type),
                    Timestamp = timeStamp
                });

                columns.Add(new Column
                {
                    Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("level"),
                    Value = new byte[] { (byte)folder.Level },
                    Timestamp = timeStamp
                });
            }

            if (mutationTypes == FolderMutationSelector.All || mutationTypes == FolderMutationSelector.ParentOnly)
            {
                columns.Add(new Column
                {
                    Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("parent_folder"),
                    Value = ByteEncoderHelper.GuidEncoder.ToByteArray(newParent),
                    Timestamp = timeStamp
                });
            }

            indexColumn.Columns = columns;

            return indexColumn;
        }
Exemplo n.º 5
0
        public static SuperColumn ToModel(this Apache.Cassandra.SuperColumn sc)
        {
            var columns = new List <Column>(sc.Columns.Transform(item => item.ToModel()));

            return(new HectorSharp.SuperColumn(sc.Name.UTFDecode(), columns));
        }
Exemplo n.º 6
0
        public static Mutation CreateInsertedOrChangedMutation(FluentMutation mutation)
        {
            switch (mutation.Type)
            {
                case MutationType.Added:
                case MutationType.Changed:
                    var column = mutation.Column;

                    if (column is FluentColumn)
                    {
                        return new Mutation {
                            Column_or_supercolumn = new ColumnOrSuperColumn {
                                Column = CreateColumn((FluentColumn)column)
                            }
                        };
                    }
                    else if (column is FluentSuperColumn)
                    {
                        var colY = (FluentSuperColumn)column;
                        var superColumn = new SuperColumn {
                            Name = colY.ColumnName.TryToBigEndian(),
                            Columns = new List<Column>()
                        };

                        foreach (var col in colY.MutationTracker.GetMutations().Select(x => x.Column).OfType<FluentColumn>())
                            superColumn.Columns.Add(CreateColumn(col));

                        return new Mutation {
                            Column_or_supercolumn = new ColumnOrSuperColumn {
                                Super_column = superColumn
                            }
                        };
                    }
                    break;
            }

            return null;
        }
Exemplo n.º 7
0
        public static ColumnOrSuperColumn CreateColumnOrSuperColumn(IFluentBaseColumn column)
        {
            if (column is FluentColumn)
            {
                return new ColumnOrSuperColumn {
                    Column = CreateColumn((FluentColumn)column)
                };
            }
            else if (column is FluentSuperColumn)
            {
                var colY = (FluentSuperColumn)column;
                var superColumn = new SuperColumn {
                    Name = colY.ColumnName.TryToBigEndian(),
                    Columns = new List<Column>()
                };

                foreach (var col in colY.Columns.OfType<FluentColumn>())
                    superColumn.Columns.Add(CreateColumn(col));

                return new ColumnOrSuperColumn {
                    Super_column = superColumn
                };
            }
            else
            {
                return null;
            }
        }
Exemplo n.º 8
0
        public static FluentSuperColumn ConvertSuperColumnToFluentSuperColumn(SuperColumn col, CassandraColumnFamilySchema schema)
        {
            var superColSchema = new CassandraColumnSchema {
                Name = col.Name
            };

            if (schema != null)
                superColSchema = new CassandraColumnSchema {
                    NameType = schema.SuperColumnNameType,
                    Name = CassandraObject.GetCassandraObjectFromDatabaseByteArray(col.Name, schema.SuperColumnNameType),
                    ValueType = schema.ColumnNameType
                };

            var superCol = new FluentSuperColumn(superColSchema) {
                ColumnName = CassandraObject.GetCassandraObjectFromDatabaseByteArray(col.Name, superColSchema.NameType)
            };

            ((ILoadable)superCol).BeginLoad();
            foreach (var xcol in col.Columns)
                superCol.Columns.Add(ConvertColumnToFluentColumn(xcol, schema));
            ((ILoadable)superCol).EndLoad();

            return superCol;
        }
 public void Read(TProtocol iprot)
 {
     TField field;
       iprot.ReadStructBegin();
       while (true)
       {
     field = iprot.ReadFieldBegin();
     if (field.Type == TType.Stop) {
       break;
     }
     switch (field.ID)
     {
       case 1:
     if (field.Type == TType.Struct) {
       this.column = new Column();
       this.column.Read(iprot);
       this.__isset.column = true;
     } else {
       TProtocolUtil.Skip(iprot, field.Type);
     }
     break;
       case 2:
     if (field.Type == TType.Struct) {
       this.super_column = new SuperColumn();
       this.super_column.Read(iprot);
       this.__isset.super_column = true;
     } else {
       TProtocolUtil.Skip(iprot, field.Type);
     }
     break;
       default:
     TProtocolUtil.Skip(iprot, field.Type);
     break;
     }
     iprot.ReadFieldEnd();
       }
       iprot.ReadStructEnd();
 }
Exemplo n.º 10
0
        private AquilesSuperColumn buildSuperColumn(SuperColumn superColumn)
        {
            if (superColumn == null)
            {
                return null;
            }
            else
            {
                AquilesSuperColumn aquilesSuperColumn = new AquilesSuperColumn();
                aquilesSuperColumn.Name = ByteEncoderHelper.FromByteArray(superColumn.Name);
                aquilesSuperColumn.Columns = new List<AquilesColumn>(superColumn.Columns.Count);
                foreach (Column column in superColumn.Columns)
                {
                    aquilesSuperColumn.Columns.Add(this.BuildColumn(column));
                }

                return aquilesSuperColumn;
            }
        }
Exemplo n.º 11
0
        public static FluentSuperColumn ConvertSuperColumnToFluentSuperColumn(SuperColumn col, CassandraColumnFamilySchema schema = null)
        {
            var superColSchema = new CassandraColumnSchema {
                Name = col.Name
            };

            if (schema != null)
                superColSchema = new CassandraColumnSchema {
                    NameType = schema.SuperColumnNameType,
                    Name = CassandraObject.GetTypeFromDatabaseValue(col.Name, schema.SuperColumnNameType),
                    ValueType = schema.ColumnNameType
                };

            var superCol = new FluentSuperColumn(superColSchema) {
                ColumnName = CassandraObject.GetTypeFromDatabaseValue(col.Name, superColSchema.NameType)
            };

            foreach (var xcol in col.Columns)
                superCol.Columns.Add(ConvertColumnToFluentColumn(xcol, schema));

            return superCol;
        }
Exemplo n.º 12
0
 public ColumnOrSuperColumn(SuperColumn superColumn)
     : this(null, superColumn)
 {
 }
Exemplo n.º 13
0
 private AquilesSuperColumn buildAquilesSuperColumn(SuperColumn superColumn)
 {
     AquilesSuperColumn aquilesSuperColumn = new AquilesSuperColumn();
     aquilesSuperColumn.Name = ByteEncoderHelper.FromByteArray(superColumn.Name);
     if (superColumn.Columns != null)
     {
         foreach (Column column in superColumn.Columns)
         {
             aquilesSuperColumn.Columns.Add(this.buildAquilesColumn(column));
         }
     }
     return aquilesSuperColumn;
 }
Exemplo n.º 14
0
 public ColumnOrSuperColumn(SuperColumn superColumn)
     : this(null, superColumn)
 {
 }
        public void Read(TProtocol iprot)
        {
            iprot.IncrementRecursionDepth();
            try
            {
                TField field;
                iprot.ReadStructBegin();
                while (true)
                {
                    field = iprot.ReadFieldBegin();
                    if (field.Type == TType.Stop)
                    {
                        break;
                    }
                    switch (field.ID)
                    {
                    case 1:
                        if (field.Type == TType.Struct)
                        {
                            Column = new Column();
                            Column.Read(iprot);
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 2:
                        if (field.Type == TType.Struct)
                        {
                            Super_column = new SuperColumn();
                            Super_column.Read(iprot);
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 3:
                        if (field.Type == TType.Struct)
                        {
                            Counter_column = new CounterColumn();
                            Counter_column.Read(iprot);
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 4:
                        if (field.Type == TType.Struct)
                        {
                            Counter_super_column = new CounterSuperColumn();
                            Counter_super_column.Read(iprot);
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    default:
                        TProtocolUtil.Skip(iprot, field.Type);
                        break;
                    }
                    iprot.ReadFieldEnd();
                }
                iprot.ReadStructEnd();
            }
            finally
            {
                iprot.DecrementRecursionDepth();
            }
        }