Using Bulk Transformation

The transformation is easy to use - you specify table name, partition key ranges, and the action which does transformation. The action manipulates the atom xml directly using AtomAccessor class. Below is example from integration tests:
                    var ranges = PartitionKeyRange.FromKeyRange(new[]
                    {
                        "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"
                    });

                    var target = new TableTransformation(Product.TableName, UpdateAction);

                    target.Transform(ranges, 4);

        private static void UpdateAction(BackupEntity entity)
        {
            var accessor = entity.GetAtomAccessor();

            var customerId = accessor.GetValue((Product x) => x.CustomerId);
            var name = accessor.GetValue((Product x) => x.Name);
            var quantity = accessor.GetValue((Product x) => x.Quantity);
            var pricePerUnit = accessor.GetValue((Product x) => x.PricePerUnit);

            accessor.Add((ProductV2 x) => x.NameAndCustomerId, name + " -> " + customerId);
            accessor.Add((ProductV2 x) => x.Sum, quantity * pricePerUnit);

            accessor.Update((Product x) => x.Name, "see in NameAndCustomerId");
        }

Last edited Jun 8, 2011 at 10:02 PM by alexeikadyrov, version 1

Comments

No comments yet.