private void GenerateParentUpdateForSubfolder(InventoryFolderBase child, byte[] parentIdArray,
            Dictionary<byte[], Dictionary<string, List<Mutation>>> muts, long timeStamp)
        {
            //never mutate the zero ID folder
            if (new Guid(parentIdArray) == Guid.Empty) return;

            List<Mutation> folderMutList = new List<Mutation>();

            Mutation propertiesMut = new Mutation();
            propertiesMut.Column_or_supercolumn = new ColumnOrSuperColumn();
            propertiesMut.Column_or_supercolumn.Super_column = new SuperColumn();
            propertiesMut.Column_or_supercolumn.Super_column.Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("sub_folders");

            Column subfolderCol = new Column
            {
                Name = ByteEncoderHelper.GuidEncoder.ToByteArray(child.ID.Guid),
                Value = SubFolderData.Encode(child.Name, child.Type),
                Timestamp = timeStamp
            };

            List<Column> propertiesColumns = new List<Column>();
            propertiesColumns.Add(subfolderCol);

            propertiesMut.Column_or_supercolumn.Super_column.Columns = propertiesColumns;

            folderMutList.Add(propertiesMut);

            muts[parentIdArray].Add(FOLDERS_CF, folderMutList);
        }
        private Mutation VersionIncrement()
        {
            Mutation versionMut = new Mutation();
            versionMut.Column_or_supercolumn = new ColumnOrSuperColumn();
            versionMut.Column_or_supercolumn.Counter_column = new CounterColumn();
            versionMut.Column_or_supercolumn.Counter_column.Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("count");
            versionMut.Column_or_supercolumn.Counter_column.Value = 1;

            return versionMut;
        }
        private void GetFolderStorageMutations(InventoryFolderBase folder, byte[] folderIdBytes, byte[] userIdBytes,
            FolderMutationSelector mutationTypes, Dictionary<byte[], Dictionary<string, List<Mutation>>> outMuts, Guid newParent,
            long timeStamp)
        {
            //Folder CF mutations
            List<Mutation> folderMutList = new List<Mutation>();

            Mutation propertiesMut = new Mutation();
            propertiesMut.Column_or_supercolumn = new ColumnOrSuperColumn();
            propertiesMut.Column_or_supercolumn.Super_column = new SuperColumn();
            propertiesMut.Column_or_supercolumn.Super_column.Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("properties");

            List<Column> propertiesColumns = new List<Column>();

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

                Column typeCol = new Column
                {
                    Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("type"),
                    Value = ByteEncoderHelper.LittleEndianInt32Encoder.ToByteArray(folder.Type),
                    Timestamp = timeStamp,
                };

                Column userIdCol = new Column
                {
                    Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("user_id"),
                    Value = ByteEncoderHelper.GuidEncoder.ToByteArray(folder.Owner.Guid),
                    Timestamp = timeStamp,
                };

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

                propertiesColumns.Add(nameCol);
                propertiesColumns.Add(typeCol);
                propertiesColumns.Add(userIdCol);
                propertiesColumns.Add(levelCol);
            }

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

                propertiesColumns.Add(parentIdCol);
            }


            propertiesMut.Column_or_supercolumn.Super_column.Columns = propertiesColumns;
            folderMutList.Add(propertiesMut);

            Dictionary<string, List<Mutation>> folderKeyMuts = new Dictionary<string, List<Mutation>>();
            folderKeyMuts[FOLDERS_CF] = folderMutList;

            //version increment
            Mutation versionMut = VersionIncrement();
            folderKeyMuts[FOLDERVERSIONS_CF] = new List<Mutation> { versionMut };

            outMuts[folderIdBytes] = folderKeyMuts;


            //UserFolder CF mutations
            if (!outMuts.ContainsKey(userIdBytes))
            {
                outMuts[userIdBytes] = new Dictionary<string, List<Mutation>>();
            }

            if (!outMuts[userIdBytes].ContainsKey(USERFOLDERS_CF))
            {
                outMuts[userIdBytes].Add(USERFOLDERS_CF, new List<Mutation>());
            }

            List<Mutation> userKeyMuts = outMuts[userIdBytes][USERFOLDERS_CF];
            List<Mutation> userFolderMutList = new List<Mutation>();

            //userfolders index, the list of all folders per user
            Mutation userFolderPropertiesMut = new Mutation();
            userFolderPropertiesMut.Column_or_supercolumn = new ColumnOrSuperColumn();
            userFolderPropertiesMut.Column_or_supercolumn.Super_column = this.BuildFolderIndexEntry(folder, folderIdBytes, mutationTypes, newParent, timeStamp);
            userKeyMuts.Add(userFolderPropertiesMut);
        }
        private void GetGestureDeactivationMutations(byte[] userIdBytes, UUID item, long timeStamp, Dictionary<byte[], Dictionary<string, List<Mutation>>> muts)
        {
            Mutation gestureRemMut = new Mutation();
            gestureRemMut.Deletion = new Deletion();
            gestureRemMut.Deletion.Predicate = new SlicePredicate();
            gestureRemMut.Deletion.Predicate.Column_names = new List<byte[]>();
            gestureRemMut.Deletion.Predicate.Column_names.Add(ByteEncoderHelper.GuidEncoder.ToByteArray(item.Guid));
            gestureRemMut.Deletion.Timestamp = timeStamp;

            muts[userIdBytes][USERACTIVEGESTURES_CF].Add(gestureRemMut);
        }
        private void RemoveFromIndex(Guid userId, Guid folderId, long timeStamp)
        {
            byte[] userIdBytes = ByteEncoderHelper.GuidEncoder.ToByteArray(userId);
            byte[] folderIdBytes = ByteEncoderHelper.GuidEncoder.ToByteArray(folderId);

            Dictionary<byte[], Dictionary<string, List<Mutation>>> muts = new Dictionary<byte[], Dictionary<string, List<Mutation>>>();

            muts[userIdBytes] = new Dictionary<string, List<Mutation>>();
            muts[userIdBytes][USERFOLDERS_CF] = new List<Mutation>();

            Mutation userFolderMut = new Mutation();
            userFolderMut.Deletion = new Deletion();
            userFolderMut.Deletion.Super_column = folderIdBytes;
            userFolderMut.Deletion.Timestamp = timeStamp;

            muts[userIdBytes][USERFOLDERS_CF].Add(userFolderMut);

            ICluster cluster = AquilesHelper.RetrieveCluster(_clusterName);
            cluster.Execute(new ExecutionBlock(delegate(Apache.Cassandra.Cassandra.Client client)
            {
                client.batch_mutate(muts, DEFAULT_CONSISTENCY_LEVEL);

                return null;

            }), KEYSPACE);
        }
示例#6
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.Map) {
           {
             Mutation_map = new Dictionary<byte[], Dictionary<string, List<Mutation>>>();
             TMap _map133 = iprot.ReadMapBegin();
             for( int _i134 = 0; _i134 < _map133.Count; ++_i134)
             {
               byte[] _key135;
               Dictionary<string, List<Mutation>> _val136;
               _key135 = iprot.ReadBinary();
               {
                 _val136 = new Dictionary<string, List<Mutation>>();
                 TMap _map137 = iprot.ReadMapBegin();
                 for( int _i138 = 0; _i138 < _map137.Count; ++_i138)
                 {
                   string _key139;
                   List<Mutation> _val140;
                   _key139 = iprot.ReadString();
                   {
                     _val140 = new List<Mutation>();
                     TList _list141 = iprot.ReadListBegin();
                     for( int _i142 = 0; _i142 < _list141.Count; ++_i142)
                     {
                       Mutation _elem143 = new Mutation();
                       _elem143 = new Mutation();
                       _elem143.Read(iprot);
                       _val140.Add(_elem143);
                     }
                     iprot.ReadListEnd();
                   }
                   _val136[_key139] = _val140;
                 }
                 iprot.ReadMapEnd();
               }
               Mutation_map[_key135] = _val136;
             }
             iprot.ReadMapEnd();
           }
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 2:
         if (field.Type == TType.I32) {
           Consistency_level = (ConsistencyLevel)iprot.ReadI32();
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       default: 
         TProtocolUtil.Skip(iprot, field.Type);
         break;
     }
     iprot.ReadFieldEnd();
   }
   iprot.ReadStructEnd();
 }
        private void GetGestureActivationMutations(byte[] userIdBytes, UUID item, long timeStamp, Dictionary<byte[], Dictionary<string, List<Mutation>>> muts)
        {
            Mutation gestureAddMut = new Mutation();
            gestureAddMut.Column_or_supercolumn = new ColumnOrSuperColumn();
            gestureAddMut.Column_or_supercolumn.Column = new Column();
            gestureAddMut.Column_or_supercolumn.Column.Name = ByteEncoderHelper.GuidEncoder.ToByteArray(item.Guid);
            gestureAddMut.Column_or_supercolumn.Column.Timestamp = timeStamp;
            gestureAddMut.Column_or_supercolumn.Column.Value = new byte[0];

            muts[userIdBytes][USERACTIVEGESTURES_CF].Add(gestureAddMut);
        }
        private void GetItemStorageMutations(InventoryItemBase item, byte[] folderIdBytes, byte[] itemIdBytes, 
            Dictionary<byte[], Dictionary<string, List<Mutation>>> outMuts, long timeStamp)
        {
            //Folder CF mutations
            List<Mutation> itemMutList = new List<Mutation>();

            Mutation propertiesMut = new Mutation();
            propertiesMut.Column_or_supercolumn = new ColumnOrSuperColumn();
            propertiesMut.Column_or_supercolumn.Super_column = new SuperColumn();
            propertiesMut.Column_or_supercolumn.Super_column.Name = itemIdBytes;

            List<Column> propertiesColumns = new List<Column>();

            propertiesColumns.Add(
                new Column
                {
                    Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("name"),
                    Value = ByteEncoderHelper.UTF8Encoder.ToByteArray(item.Name),
                    Timestamp = timeStamp,
                }
            );

            propertiesColumns.Add(
                new Column
                {
                    Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("description"),
                    Value = ByteEncoderHelper.UTF8Encoder.ToByteArray(item.Description),

                    Timestamp = timeStamp,
                }
            );

            propertiesColumns.Add(
                new Column
                {
                    Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("creation_date"),
                    Value = ByteEncoderHelper.LittleEndianInt32Encoder.ToByteArray(item.CreationDate),
                    Timestamp = timeStamp,
                }
            );

            propertiesColumns.Add(
                new Column
                {
                    Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("creator_id"),
                    Value = ByteEncoderHelper.GuidEncoder.ToByteArray(item.CreatorIdAsUuid.Guid),
                    Timestamp = timeStamp,
                }
            );

            propertiesColumns.Add(
                new Column
                {
                    Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("owner_id"),
                    Value = ByteEncoderHelper.GuidEncoder.ToByteArray(item.Owner.Guid),
                    Timestamp = timeStamp,
                }
            );

            propertiesColumns.Add(
                new Column
                {
                    Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("asset_id"),
                    Value = ByteEncoderHelper.GuidEncoder.ToByteArray(item.AssetID.Guid),
                    Timestamp = timeStamp,
                }
            );

            propertiesColumns.Add(
                new Column
                {
                    Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("asset_type"),
                    Value = ByteEncoderHelper.LittleEndianInt32Encoder.ToByteArray(item.AssetType),
                    Timestamp = timeStamp,
                }
            );

            propertiesColumns.Add(
                new Column
                {
                    Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("inventory_type"),
                    Value = ByteEncoderHelper.LittleEndianInt32Encoder.ToByteArray(item.InvType),
                    Timestamp = timeStamp,
                }
            );

            propertiesColumns.Add(
                new Column
                {
                    Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("flags"),
                    Value = ByteEncoderHelper.LittleEndianInt32Encoder.ToByteArray(unchecked((int)item.Flags)),
                    Timestamp = timeStamp,
                }
            );

            propertiesColumns.Add(
                new Column
                {
                    Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("group_owned"),
                    Value = new byte[1] { item.GroupOwned == true ? (byte)1 : (byte)0 },
                    Timestamp = timeStamp,
                }
            );

            propertiesColumns.Add(
                new Column
                {
                    Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("group_id"),
                    Value = ByteEncoderHelper.GuidEncoder.ToByteArray(item.GroupID.Guid),
                    Timestamp = timeStamp,
                }
            );

            propertiesColumns.Add(
                new Column
                {
                    Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("group_permissions"),
                    Value = ByteEncoderHelper.LittleEndianInt32Encoder.ToByteArray(unchecked((int)item.GroupPermissions)),
                    Timestamp = timeStamp,
                }
            );

            propertiesColumns.Add(
                new Column
                {
                    Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("current_permissions"),
                    Value = ByteEncoderHelper.LittleEndianInt32Encoder.ToByteArray(unchecked((int)item.CurrentPermissions)),
                    Timestamp = timeStamp,
                }
            );

            propertiesColumns.Add(
                new Column
                {
                    Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("base_permissions"),
                    Value = ByteEncoderHelper.LittleEndianInt32Encoder.ToByteArray(unchecked((int)item.BasePermissions)),
                    Timestamp = timeStamp,
                }
            );

            propertiesColumns.Add(
                new Column
                {
                    Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("next_permissions"),
                    Value = ByteEncoderHelper.LittleEndianInt32Encoder.ToByteArray(unchecked((int)item.NextPermissions)),
                    Timestamp = timeStamp,
                }
            );

            propertiesColumns.Add(
                new Column
                {
                    Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("everyone_permissions"),
                    Value = ByteEncoderHelper.LittleEndianInt32Encoder.ToByteArray(unchecked((int)item.EveryOnePermissions)),
                    Timestamp = timeStamp,
                }
            );

            propertiesColumns.Add(
                new Column
                {
                    Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("sale_price"),
                    Value = ByteEncoderHelper.LittleEndianInt32Encoder.ToByteArray(item.SalePrice),
                    Timestamp = timeStamp,
                }
            );

            propertiesColumns.Add(
                new Column
                {
                    Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("sale_type"),
                    Value = new byte[1] { item.SaleType },
                    Timestamp = timeStamp,
                }
            );

            propertiesMut.Column_or_supercolumn.Super_column.Columns = propertiesColumns;
            itemMutList.Add(propertiesMut);

            Dictionary<string, List<Mutation>> folderKeyMuts = new Dictionary<string, List<Mutation>>();
            folderKeyMuts[FOLDERS_CF] = itemMutList;

            //version increment
            Mutation versionMut = VersionIncrement();
            folderKeyMuts[FOLDERVERSIONS_CF] = new List<Mutation> { versionMut };

            outMuts[folderIdBytes] = folderKeyMuts;
        }
        /// <summary>
        /// Removes the item from its parent folder container
        /// </summary>
        /// <param name="itemIdBytes"></param>
        /// <param name="oldParentFolderBytes"></param>
        /// <param name="timeStamp"></param>
        /// <param name="muts"></param>
        private void GetItemDeletionMutations(byte[] itemIdBytes, byte[] folderIdBytes, long timeStamp, 
            Dictionary<byte[], Dictionary<string, List<Mutation>>> muts, bool includeParentFolderVersionInc)
        {
            Mutation itemParentMut = new Mutation();
            itemParentMut.Deletion = new Deletion();
            itemParentMut.Deletion.Super_column = itemIdBytes;
            itemParentMut.Deletion.Timestamp = timeStamp;

            if (!muts.ContainsKey(folderIdBytes))
            {
                muts[folderIdBytes] = new Dictionary<string, List<Mutation>>();
            }

            if (!muts[folderIdBytes].ContainsKey(FOLDERS_CF))
            {
                muts[folderIdBytes][FOLDERS_CF] = new List<Mutation>();
            }

            muts[folderIdBytes][FOLDERS_CF].Add(itemParentMut);

            if (includeParentFolderVersionInc)
            {
                if (!muts[folderIdBytes].ContainsKey(FOLDERVERSIONS_CF))
                {
                    muts[folderIdBytes][FOLDERVERSIONS_CF] = new List<Mutation>();
                }

                //version increment
                Mutation versionMut = VersionIncrement();
                muts[folderIdBytes][FOLDERVERSIONS_CF].Add(versionMut);
            }
        }
        private void GetSubfolderEntryDeletionMutations(byte[] folderIdBytes, byte[] parentFolderIdBytes, long timeStamp, Dictionary<byte[], Dictionary<string, List<Mutation>>> muts)
        {
            Mutation folderMut = new Mutation();
            folderMut.Deletion = new Deletion();
            folderMut.Deletion.Super_column = ByteEncoderHelper.UTF8Encoder.ToByteArray("sub_folders");
            folderMut.Deletion.Timestamp = timeStamp;
            folderMut.Deletion.Predicate = new SlicePredicate();
            folderMut.Deletion.Predicate.Column_names = new List<byte[]>();
            folderMut.Deletion.Predicate.Column_names.Add(folderIdBytes);

            if (!muts.ContainsKey(parentFolderIdBytes))
            {
                muts[parentFolderIdBytes] = new Dictionary<string, List<Mutation>>();
            }

            if (!muts[parentFolderIdBytes].ContainsKey(FOLDERS_CF))
            {
                muts[parentFolderIdBytes][FOLDERS_CF] = new List<Mutation>();
            }

            muts[parentFolderIdBytes][FOLDERS_CF].Add(folderMut);
        }
        private void GetItemParentStorageMutations(InventoryItemBase item, byte[] itemIdBytes, byte[] folderIdBytes,
            long timeStamp, Dictionary<byte[], Dictionary<string, List<Mutation>>> outMuts)
        {
            Mutation itemParentMut = new Mutation();
            itemParentMut.Column_or_supercolumn = new ColumnOrSuperColumn();
            itemParentMut.Column_or_supercolumn.Column = new Column();
            itemParentMut.Column_or_supercolumn.Column.Name = ByteEncoderHelper.UTF8Encoder.ToByteArray("parent");
            itemParentMut.Column_or_supercolumn.Column.Timestamp = timeStamp;
            itemParentMut.Column_or_supercolumn.Column.Value = folderIdBytes;

            outMuts[itemIdBytes][ITEMPARENTS_CF] = new List<Mutation>();
            outMuts[itemIdBytes][ITEMPARENTS_CF].Add(itemParentMut);
        }
        private void GetSingleFolderDeletionMutations(byte[] userIdBytes, byte[] folderIdBytes, long timeStamp, Dictionary<byte[], Dictionary<string, List<Mutation>>> muts)
        {
            Mutation folderMut = new Mutation();
            folderMut.Deletion = new Deletion();
            folderMut.Deletion.Timestamp = timeStamp;

            if (!muts.ContainsKey(folderIdBytes))
            {
                muts[folderIdBytes] = new Dictionary<string, List<Mutation>>();
            }

            if (!muts[folderIdBytes].ContainsKey(FOLDERS_CF))
            {
                muts[folderIdBytes][FOLDERS_CF] = new List<Mutation>();
            }

            muts[folderIdBytes][FOLDERS_CF].Add(folderMut);
            

            //index removal
            if (!muts.ContainsKey(userIdBytes))
            {
                muts[userIdBytes] = new Dictionary<string, List<Mutation>>();
            }

            if (!muts[userIdBytes].ContainsKey(USERFOLDERS_CF))
            {
                muts[userIdBytes][USERFOLDERS_CF] = new List<Mutation>();
            }

            Mutation userFolderMut = new Mutation();
            userFolderMut.Deletion = new Deletion();
            userFolderMut.Deletion.Super_column = folderIdBytes;
            userFolderMut.Deletion.Timestamp = timeStamp;

            muts[userIdBytes][USERFOLDERS_CF].Add(userFolderMut);


            //version removal
            if (!muts[folderIdBytes].ContainsKey(FOLDERVERSIONS_CF))
            {
                muts[folderIdBytes][FOLDERVERSIONS_CF] = new List<Mutation>();
            }

            Mutation versionMut = new Mutation();
            versionMut.Deletion = new Deletion();
            versionMut.Deletion.Timestamp = timeStamp;
            muts[folderIdBytes][FOLDERVERSIONS_CF].Add(versionMut);
        }
示例#13
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.Map) {
     {
       Mutation_map = new Dictionary<byte[], Dictionary<string, List<Mutation>>>();
       TMap _map72 = iprot.ReadMapBegin();
       for( int _i73 = 0; _i73 < _map72.Count; ++_i73)
       {
         byte[] _key74;
         Dictionary<string, List<Mutation>> _val75;
         _key74 = iprot.ReadBinary();
         {
           _val75 = new Dictionary<string, List<Mutation>>();
           TMap _map76 = iprot.ReadMapBegin();
           for( int _i77 = 0; _i77 < _map76.Count; ++_i77)
           {
             string _key78;
             List<Mutation> _val79;
             _key78 = iprot.ReadString();
             {
               _val79 = new List<Mutation>();
               TList _list80 = iprot.ReadListBegin();
               for( int _i81 = 0; _i81 < _list80.Count; ++_i81)
               {
                 Mutation _elem82 = new Mutation();
                 _elem82 = new Mutation();
                 _elem82.Read(iprot);
                 _val79.Add(_elem82);
               }
               iprot.ReadListEnd();
             }
             _val75[_key78] = _val79;
           }
           iprot.ReadMapEnd();
         }
         Mutation_map[_key74] = _val75;
       }
       iprot.ReadMapEnd();
     }
       } else {
     TProtocolUtil.Skip(iprot, field.Type);
       }
       break;
     case 2:
       if (field.Type == TType.I32) {
     Consistency_level = (ConsistencyLevel)iprot.ReadI32();
       } else {
     TProtocolUtil.Skip(iprot, field.Type);
       }
       break;
     default:
       TProtocolUtil.Skip(iprot, field.Type);
       break;
       }
       iprot.ReadFieldEnd();
     }
     iprot.ReadStructEnd();
 }
 protected void CreateMutation(List<Mutation> mutList, String column, Byte[] value, Int64 timestamp)
 {
     Mutation mutation = new Mutation();
     Column col = new Column();
     col.Name = column.ToCassandraByte();
     col.Value = value;
     col.Timestamp = timestamp;
     Int32 ttl = LevelMapping.GetTtl();
     if (ttl > 0)
         col.Ttl = 0;
     ColumnOrSuperColumn cosc = new ColumnOrSuperColumn();
     cosc.Column = col;
     mutation.Column_or_supercolumn = cosc;
     mutList.Add(mutation);
 }
        private void GenerateSubfolderIndexDeletion(Guid oldParentId, long timeStamp, byte[] childIdBytes, Dictionary<byte[], Dictionary<string, List<Mutation>>> muts)
        {
            //we have a new parent, we have to tell the old one we're not its child anymore
            Mutation propertiesRem = new Mutation();
            propertiesRem.Deletion = new Deletion();
            propertiesRem.Deletion.Super_column = ByteEncoderHelper.UTF8Encoder.ToByteArray("sub_folders");
            propertiesRem.Deletion.Predicate = new SlicePredicate();
            propertiesRem.Deletion.Predicate.Column_names = new List<byte[]> { childIdBytes };
            propertiesRem.Deletion.Timestamp = timeStamp;

            Dictionary<string, List<Mutation>> oldParentMutations = new Dictionary<string, List<Mutation>> { { FOLDERS_CF, new List<Mutation> { propertiesRem } } };
            oldParentMutations[FOLDERVERSIONS_CF] = new List<Mutation> { VersionIncrement() };

            muts[ByteEncoderHelper.GuidEncoder.ToByteArray(oldParentId)] = oldParentMutations;
        }
        private void GetItemParentDeletionMutations(byte[] itemIdBytes, long timeStamp, Dictionary<byte[], Dictionary<string, List<Mutation>>> outMuts)
        {
            Mutation itemParentMut = new Mutation();
            itemParentMut.Deletion = new Deletion();
            itemParentMut.Deletion.Timestamp = timeStamp;

            if (! outMuts.ContainsKey(itemIdBytes))
            {
                outMuts[itemIdBytes] = new Dictionary<string, List<Mutation>>();
            }

            if (!outMuts[itemIdBytes].ContainsKey(ITEMPARENTS_CF))
            {
                outMuts[itemIdBytes][ITEMPARENTS_CF] = new List<Mutation>();
            }
            
            outMuts[itemIdBytes][ITEMPARENTS_CF].Add(itemParentMut);
        }
 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.Map) {
     {
       Mutation_map = new Dictionary<byte[], Dictionary<string, List<Mutation>>>();
       TMap _map117 = iprot.ReadMapBegin();
       for( int _i118 = 0; _i118 < _map117.Count; ++_i118)
       {
         byte[] _key119;
         Dictionary<string, List<Mutation>> _val120;
         _key119 = iprot.ReadBinary();
         {
           _val120 = new Dictionary<string, List<Mutation>>();
           TMap _map121 = iprot.ReadMapBegin();
           for( int _i122 = 0; _i122 < _map121.Count; ++_i122)
           {
             string _key123;
             List<Mutation> _val124;
             _key123 = iprot.ReadString();
             {
               _val124 = new List<Mutation>();
               TList _list125 = iprot.ReadListBegin();
               for( int _i126 = 0; _i126 < _list125.Count; ++_i126)
               {
                 Mutation _elem127 = new Mutation();
                 _elem127 = new Mutation();
                 _elem127.Read(iprot);
                 _val124.Add(_elem127);
               }
               iprot.ReadListEnd();
             }
             _val120[_key123] = _val124;
           }
           iprot.ReadMapEnd();
         }
         Mutation_map[_key119] = _val120;
       }
       iprot.ReadMapEnd();
     }
       } else {
     TProtocolUtil.Skip(iprot, field.Type);
       }
       break;
     case 2:
       if (field.Type == TType.I32) {
     Consistency_level = (ConsistencyLevel)iprot.ReadI32();
       } else {
     TProtocolUtil.Skip(iprot, field.Type);
       }
       break;
     default:
       TProtocolUtil.Skip(iprot, field.Type);
       break;
       }
       iprot.ReadFieldEnd();
     }
     iprot.ReadStructEnd();
 }
示例#18
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.String) {
     this.keyspace = iprot.ReadString();
     this.__isset.keyspace = true;
       } else {
     TProtocolUtil.Skip(iprot, field.Type);
       }
       break;
     case 2:
       if (field.Type == TType.Map) {
     {
       this.mutation_map = new Dictionary<string, Dictionary<string, List<Mutation>>>();
       TMap _map64 = iprot.ReadMapBegin();
       for( int _i65 = 0; _i65 < _map64.Count; ++_i65)
       {
         string _key66;
         Dictionary<string, List<Mutation>> _val67;
         _key66 = iprot.ReadString();
         {
           _val67 = new Dictionary<string, List<Mutation>>();
           TMap _map68 = iprot.ReadMapBegin();
           for( int _i69 = 0; _i69 < _map68.Count; ++_i69)
           {
             string _key70;
             List<Mutation> _val71;
             _key70 = iprot.ReadString();
             {
               _val71 = new List<Mutation>();
               TList _list72 = iprot.ReadListBegin();
               for( int _i73 = 0; _i73 < _list72.Count; ++_i73)
               {
                 Mutation _elem74 = new Mutation();
                 _elem74 = new Mutation();
                 _elem74.Read(iprot);
                 _val71.Add(_elem74);
               }
               iprot.ReadListEnd();
             }
             _val67[_key70] = _val71;
           }
           iprot.ReadMapEnd();
         }
         this.mutation_map[_key66] = _val67;
       }
       iprot.ReadMapEnd();
     }
     this.__isset.mutation_map = true;
       } else {
     TProtocolUtil.Skip(iprot, field.Type);
       }
       break;
     case 3:
       if (field.Type == TType.I32) {
     this.consistency_level = (ConsistencyLevel)iprot.ReadI32();
     this.__isset.consistency_level = true;
       } else {
     TProtocolUtil.Skip(iprot, field.Type);
       }
       break;
     default:
       TProtocolUtil.Skip(iprot, field.Type);
       break;
       }
       iprot.ReadFieldEnd();
     }
     iprot.ReadStructEnd();
 }