Seva Software

 

What is Aruna DB?

Last Updated: 9/25/2001

apack()/aunpack() in aruna.c

Purpose

License

Description

Dependencies

Limitations

Performance Considerations

To Do

Usage

Class Methods

Instance Methods

Testing

A_Debug Usage

 

Purpose:

This module provides to methods (apack and aunpack) that are very similar to Array.pack and String.unpack. These work exactly like pack and unpack but are tailored to support standard database objects such as short, integer, byte, char(), varchar, date, time, etc. These methods are used by A_Buffer to pack key/value pairs into the buffer for reading and writing. Since A_Table, A_Index use A_BTree for storing and retrieving data and A_BTree uses A_Buffer to store and retrieve data, each of the classes indirectly use apack and aunpack. A_Table uses the apack string for many standard column constraints.

 

Description:

Pack and unpack data into an A_Buffer object. See A_Buffer documention for details on how this uses apack/aunpack. See A_BTree documentation to see how to apack/aunpack is used indirectly to reduce disk space and increase performance. See A_Table and A_Index documentation to see how apack/aunpack is used indirectly for standard column constraint checking, to reduce disk space, and increase performance.

Valid or supported pack/unpack string elements:

 

-- not yet supported --

 

Dependencies:

 

Limitations:

 

Performance Considerations:

 

To Do:

 

Usage:

N/A

 

Class Methods:

None

 

Instance Methods:

Array.asearch(value)

This performs a modified binary search on Array for value. This is a binary search on the elements in the array where the index of the first element >= value is returned. This is used by A_FileSort to determine which slot to put rows in as they are being sorted. A similar method can be found in A_Buffer.asearch.

value - is the value you are looking for in the array.

Array.apack(pack_string)

Pack the elements in the array according to the pack_string. Valid pack_string elements are described above. You can look at the documention for Array.pack for more details about how this works. Returns a String. There is a lower level C function that will pack the array directly into your buffer called rb_ary_apack_(). This low level C function is called by A_Buffer.c as key/value pairs are packed into the buffer.

String.aunpack(pack_string)

Unpack the elements in the String according to the pack_string. Valid pack_string elements are described above. You can look at the documention for String.unpack for more details about how this works. Returns an Array. There is a lower level C function that will pack the array directly into your buffer called rb_ary_aunpack_(). This low level C function is called by A_Buffer.c as key/value pairs are unpacked out of the buffer.

String.apack_size()

When string is valid pack string as defined above, this returns the size (in bytes) that will be used by this pack string.

 

Testing: 

tst_apack.rb will test the basic functionality of apack() and aunpack(). To run type

Ruby -I.. tst_apack.rb

 

A_Debug Usage:

N/A