Пример #1
0
        private void PurgeItemsInternal(IEnumerable<InventoryItemBase> items, long timeStamp)
        {
            C5.HashSet<byte[]> allParentFolderBytes = new C5.HashSet<byte[]>(new ByteArrayValueComparer());
            Dictionary<byte[], Dictionary<string, List<Mutation>>> muts = new Dictionary<byte[], Dictionary<string, List<Mutation>>>();

            foreach (InventoryItemBase item in items)
            {
                byte[] oldParentFolderBytes = ByteEncoderHelper.GuidEncoder.ToByteArray(item.Folder.Guid);
                allParentFolderBytes.FindOrAdd(ref oldParentFolderBytes);

                byte[] itemIdBytes = ByteEncoderHelper.GuidEncoder.ToByteArray(item.ID.Guid);

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

                //remove the item from the index
                this.GetItemParentDeletionMutations(itemIdBytes, timeStamp, muts);

                //remove the item from the old folder
                this.GetItemDeletionMutations(itemIdBytes, oldParentFolderBytes, timeStamp, muts, true);
            }

            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);
        }