File: README

package info (click to toggle)
zeroc-ice 3.3.1-12
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 40,720 kB
  • ctags: 46,971
  • sloc: cpp: 241,481; java: 104,729; cs: 66,568; python: 18,996; makefile: 5,797; xml: 5,397; ruby: 4,788; php: 3,172; yacc: 3,113; lex: 2,223; ansic: 1,249; perl: 1,200; sh: 182; sql: 73
file content (111 lines) | stat: -rw-r--r-- 3,068 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
This demo shows how to transform a Freeze map when its definition
changes.

In this demo, we start with a simple "contacts" map:

  key = string
  value = struct ContactData
          {
             string phoneNumber;
          };

Later on, we want to add a new data member to ContactData:

//
// New version of ContactData defined in NewContactData.ice
//
struct NewContactData
{
    string phoneNumber;
    string emailAddress;
};

If the contacts map was not sorted on its key, the transformation
would be a straightforward 'FreezeScript' transformation:

$ transformdb --old ContactData.ice --new NewContactData.ice db dbnew

(with -f <xml-file> if you want a customized transformation)

With a sorted map, the situation is more complicated. transformdb
is unaware of the sort order, and as a result transforms the map into
an unsorted map -- or more precisely, a new map sorted using Berkeley 
DB's default sort order (comparison of binary strings that correspond 
to data encoded using the Ice encoding).

The solution, illustrated in this demo, is to recreate the map 
after the successful transformdb transformation.

This demo provides four programs:

 - java Create

   Creates or updates the contacts map in the 'db' directory (uses 
   the old version of ContactData)

 - java Read

   Reads and displays the contents of the contacts map in the 'db' 
   directory (uses the old version of ContactData)

 - java ReadNew

   Reads and displays the contents of the contacts map in the 'dbnew'
   directory (uses the new version of ContactData)
   
 - java Recreate

   Recreate the contacts map in the 'dbnew' directory (uses the new 
   version of ContactData)


Running the demo
----------------

 - first create the original map, by running Create:

   $ java Create

 - display the entries created by create:

   $ java Read

   Please notice the alphabetical sort order.

 - transform the contacts database to the new format:

   $  transformdb --old ContactData.ice --new NewContactData.ice \
       -f transform.xml db dbnew

 - read the transformed contacts map:

   $ java ReadNew

   You'll notice the sort order (looks random), and the corrupt index.
   The index is actually created by ReadNew when it opens contacts;
   the mismatch between the expected sort order (alphabetical) and
   actual sort order leads to this corruption.

   If you prefer, you can update ReadNew with

      boolean createDb = false

   With this update, ReadNew does not create the index and will fail
   to open the contacts map when the associated phoneNumber index does
   not exist.

 - recreate the new contacts map with:

   $ java Recreate

   Recreate reads and rewrites the contacts map with the proper sort
   order; it also removes and recreates the phoneNumber index. You can
   run 'java Recreate --Freeze.Trace.Map=2' to get more information on
   the actions performed by Recreate.

 - read again the new contacts map:

   $ java ReadNew

   This time, the sort order should be alphabetical again, and ReadNew
   is expected to complete successfully.