Information Technology Reference
In-Depth Information
10.1
Transactions with Bulk Actions
We begin by defining a transaction model for
bulk-action transactions
,thatis,
transactions with bulk actions. Such a transaction can contain the following forward-
rolling
bulk actions
:
1.
Bulk-read actions
of the form RŒs
X
;s
XV
. Such an action takes as input a set s
X
of non-overlapping open, closed, or half-open key ranges .
z
1
;
z
2
/, Œ
z
1
;
z
2
, .
z
1
;
z
2
,
or Œ
z
1
;
z
2
/ and produces as output a tuple set s
XV
consisting of all tuples .x;
v
/
2
r
with key x in one of the ranges in s
X
.
2.
Bulk-insert actions
of the form IŒs
XV
that take as input a set s
XV
of tuples with
keys not appearing in r and insert those tuples into r .
3.
Bulk-delete actions
of the form DŒs
X
;s
XV
. Such an action takes as input a set
s
X
of non-overlapping open, closed, or half-open key ranges and deletes from
r all tuples .x;
v
/ with key x in one of the ranges in s
X
. The deleted tuples are
returned in the set s
XV
.
4.
Bulk-update actions
or
bulk-write actions
of the form WŒs
X
;f;s
XV V
0
.Suchan
action takes as input a set s
X
of non-overlapping open, closed, or half-open key
ranges and a function f on tuple values and replaces, for each key x in one of the
ranges, the tuple .x;
v
/ with key x by the tuple .x; f .
v
//.Thesets
XV V
0
returned
consists of the tuples .x;
v
;f.
v
//.
The undo actions for the bulk-insert and bulk-delete actions are defined in the
obvious way:
5. The undo action I
1
Œs
XV
for bulk-insert action IŒs
XV
deletes from r the tuples
in s
XV
.
6. The undo action D
1
Œs
X
;s
XV
for bulk-delete action DŒs
X
;s
XV
inserts into r
the tuples in s
XV
.
7. The undo action W
1
Œs
X
;f;s
XV V
0
for bulk-update action WŒs
X
;f;s
XV V
0
replaces in r each tuple .x;
v
0
/ with .x;
v
;
v
0
/
2
s
XV V
0
by the tuple .x;
v
/.
The bulk-read, bulk-delete, and bulk-update actions model
SQL
statements such
as
select
from
r
where
C.X/,
delete from
r
where
C.X/,
update
r
set
V
D
f.V/
where
C.X/,
where C.X/ is a disjunction of
range predicates
of the form
z
1
1
X
and
X
2
z
2
with
1
;
2
2f
<;
g
on the primary key X of relation r and f is a function on V .
The bulk-read and bulk-insert actions together can be used to model
SQL
statements
such as
insert into
r
select
from
r
0
where
C.X/
order by
X ,
where r
0
is a relation with a schema compatible with that of r .