 |
File Migration
Applications of any model can exchange files, sharing them sequentially but not simultaneously. Ensure the applications involved do not have the files open when they are copied or moved. If the application in question is the c-tree Server, this is especially important. See “Copying Server Controlled Files” for additional information.
Issues that affect file exchanging include byte ordering of numeric values and alignment of data structures. c-tree Plus uses the same default for byte order as the hardware CPU and the default structure alignment dictated by the compiler.
- Byte Ordering is a processor-related issue. Intel-based processors store numeric values least-significant byte first (LOW_HIGH), while other processors store numeric values most-significant byte first (HIGH_LOW). So a four-byte integer containing the value “16” stored on an LOW_HIGH system as the hexadecimal value 10 00 00 00 would be stored on a HIGH_LOW system as the hexadecimal value 00 00 00 10. The order of the bits is consistent within the bytes, but the order of the bytes in the numeric value is reversed. By default, c-tree Plus files are stored in the native format to the operating system, so files created on a HIGH_LOW machine cannot be exchanged directly with applications on a LOW_HIGH machine. See “Portable Data Through UNIFRMAT Support”, which allows HIGH_LOW systems to work with LOW_HIGH files.
- Different compilers align data structures in different ways, but most have compile-time options allowing the alignment to be adjusted. Some compilers default to 1-byte alignment, which means structures are not adjusted in any way. With 2-byte or higher alignment, variables are aligned to the boundary matching the alignment or the variable’s size, whichever is smaller. There is a potential for the compiler to add dead space within a data structure. See “Buffer Regions” for more information on alignment.
Some of the common problems caused by alignment differences are:
- Record lengths when different applications use different amounts of padding;
- Indexing when padding shifts key segments to different locations than specified in the ISEG structure;
- Data corruption when applications align the record buffer differently.
Use the c-tree Plus ctunf1 reformat utility to adjust the alignment and byte ordering for a given file before exchanging it with another platform. See “CTUNF1 - File Reformatting Utility” for more information on this utility.
|