Mobi_Mtld_DA_Carrier_BucketHandler
extends Mobi_Mtld_DA_DataType
in package
A bucket is a section of the data file. It has an ID, length and a byte array of data. Each bucket type has a specific format. This class handles the conversion of bucket data(binary bytes) to actual values.
The following buckets are handled:
- Property Names - a unique list of property names. The order is the index.
- Property Values - a unique list of property values. The order is the index.
- Properties - collections of property name IDs to property value IDs
- IPv4 Radix Tree - contains the data for the left/right branches of a tree
and property collection IDs
The bucket handler expects the buckets to be in the above order.
Tags
Table of Contents
- BOOLEAN = 0
- Type boolean
- BYTE = 1
- Type byte
- DOUBLE = 6
- Type double
- FLOAT = 5
- Type float
- INTEGER = 3
- Type int
- LONG = 4
- Type long int
- NO_CONTAINER = 0
- for internal api use
- NO_VALUE = -1
- for internal api use
- ORDER_SET_CONTAINER = 1
- for internal api use
- SHORT = 2
- Type short int
- STRING = 7
- Type string
- UNKNOWN = 8
- Unknown type
- $CRC32_DOES_NOT_MATCH : mixed
- CRC Error message
- $names : mixed
- Maps data types to data type names array {byte: string}
- $properties : mixed
- [Properties]
- $propertyNames : mixed
- [PropertyName]
- $propertyStringNames : mixed
- [string]
- $propertyValues : mixed
- [Property]
- $treeLefts : mixed
- [int]
- $treeProperties : mixed
- [Properties]
- $treeRights : mixed
- [int]
- getName() : string
- Get the name of a given data type.
- getPropertyNames() : mixed
- Returns the property names array
- getPropertyNamesAsStrings() : Property
- Returns the property names array
- getTreeLefts() : array<string|int, mixed>
- Returns the Radix Trie "left" pointers
- getTreeProperties() : array<string|int, mixed>
- Returns the properties used in the Radix Trie nodes
- getTreeRights() : array<string|int, mixed>
- Returns the Radix Trie "right" pointers
- needsBuckets() : bool
- Checks if all the necessary buckets have been supplied and processed.
- processBucket() : mixed
- Process a bucket identified by "bucketId". The bucket CRC-32 hash is verified before parsing the bucket data.
- getPropertyValue() : mixed
- Read the appropriate property from the ByteReader depending on the data type. All of the primitive types are fixed length. In addition there are five fixed length UTF8 string values and other special types for strings that are less than certain lengths.
- processIpv4TreeBucket() : mixed
- Load the data for the IPv4 Tree bucket. This bucket has the following structure: <pre> These 3 ints repeat for the entire bucket: <repeating> 4B properties ID value 4B Left value 4B Right value </repeating> </pre>
- processPropertiesBucket() : mixed
- The following is the structure of this bucket: <pre> 2B Num of indexed items <repeating> 2B num items in collection <repeating> 4B property name ID 4B property value ID </repeating> </repeating> </pre> The order of the properties is taken as the index for each item. As each item of the collection is loaded it is looked up in the previously loaded property names and property values IDs.
- processPropertyNamesBucket() : mixed
- The following is the structure of this bucket: <pre> 2B Num of indexed items <repeating> 1B data type of property value 1B length of name ?B property name - ascii string </repeating> </pre> The order of the properties is taken as the index for each item.
- processPropertyValuesBucket() : mixed
- The following is the structure of this bucket: <pre> 2B Number of indexed items <repeating>
Constants
BOOLEAN
Type boolean
public
mixed
BOOLEAN
= 0
BYTE
Type byte
public
mixed
BYTE
= 1
DOUBLE
Type double
public
mixed
DOUBLE
= 6
FLOAT
Type float
public
mixed
FLOAT
= 5
INTEGER
Type int
public
mixed
INTEGER
= 3
LONG
Type long int
public
mixed
LONG
= 4
NO_CONTAINER
for internal api use
public
mixed
NO_CONTAINER
= 0
NO_VALUE
for internal api use
public
mixed
NO_VALUE
= -1
ORDER_SET_CONTAINER
for internal api use
public
mixed
ORDER_SET_CONTAINER
= 1
SHORT
Type short int
public
mixed
SHORT
= 2
STRING
Type string
public
mixed
STRING
= 7
UNKNOWN
Unknown type
public
mixed
UNKNOWN
= 8
Properties
$CRC32_DOES_NOT_MATCH
CRC Error message
private
static mixed
$CRC32_DOES_NOT_MATCH
= 'CRC-32 does not match for bucket "%s".'
$names
Maps data types to data type names array {byte: string}
private
static mixed
$names
= array(self::BOOLEAN => 'Boolean', self::BYTE => 'Byte', self::SHORT => 'Short', self::INTEGER => 'Integer', self::LONG => 'Long', self::FLOAT => 'Float', self::DOUBLE => 'Double', self::STRING => 'String', self::UNKNOWN => 'Unknown')
$properties
[Properties]
private
mixed
$properties
= \null
$propertyNames
[PropertyName]
private
mixed
$propertyNames
= \null
$propertyStringNames
[string]
private
mixed
$propertyStringNames
= \null
$propertyValues
[Property]
private
mixed
$propertyValues
= \null
$treeLefts
[int]
private
mixed
$treeLefts
= \null
$treeProperties
[Properties]
private
mixed
$treeProperties
= \null
$treeRights
[int]
private
mixed
$treeRights
= \null
Methods
getName()
Get the name of a given data type.
public
static getName(mixed $dataTypeID) : string
Parameters
- $dataTypeID : mixed
Return values
string —The name of the data type.
getPropertyNames()
Returns the property names array
public
getPropertyNames() : mixed
Return values
mixed —getPropertyNamesAsStrings()
Returns the property names array
public
getPropertyNamesAsStrings() : Property
Return values
Property —names as string
getTreeLefts()
Returns the Radix Trie "left" pointers
public
getTreeLefts() : array<string|int, mixed>
Return values
array<string|int, mixed> —Radix Trie "left" pointers
getTreeProperties()
Returns the properties used in the Radix Trie nodes
public
getTreeProperties() : array<string|int, mixed>
Return values
array<string|int, mixed> —Radix Trie nodes
getTreeRights()
Returns the Radix Trie "right" pointers
public
getTreeRights() : array<string|int, mixed>
Return values
array<string|int, mixed> —Radix Trie "right" pointers
needsBuckets()
Checks if all the necessary buckets have been supplied and processed.
public
needsBuckets() : bool
Return values
bool —true if all buckets complete, FALSE otherwise
processBucket()
Process a bucket identified by "bucketId". The bucket CRC-32 hash is verified before parsing the bucket data.
public
processBucket(mixed $bucketId, mixed $fileCrc32, mixed $bucketData) : mixed
Parameters
- $bucketId : mixed
- $fileCrc32 : mixed
- $bucketData : mixed
Tags
Return values
mixed —getPropertyValue()
Read the appropriate property from the ByteReader depending on the data type. All of the primitive types are fixed length. In addition there are five fixed length UTF8 string values and other special types for strings that are less than certain lengths.
private
getPropertyValue(mixed $dataType, mixed $reader) : mixed
Parameters
- $dataType : mixed
- $reader : mixed
Return values
mixed —Property value
processIpv4TreeBucket()
Load the data for the IPv4 Tree bucket. This bucket has the following structure: <pre> These 3 ints repeat for the entire bucket: <repeating> 4B properties ID value 4B Left value 4B Right value </repeating> </pre>
private
processIpv4TreeBucket(mixed $data) : mixed
Parameters
- $data : mixed
Return values
mixed —processPropertiesBucket()
The following is the structure of this bucket: <pre> 2B Num of indexed items <repeating> 2B num items in collection <repeating> 4B property name ID 4B property value ID </repeating> </repeating> </pre> The order of the properties is taken as the index for each item. As each item of the collection is loaded it is looked up in the previously loaded property names and property values IDs.
private
processPropertiesBucket(mixed $data) : mixed
Parameters
- $data : mixed
Tags
Return values
mixed —processPropertyNamesBucket()
The following is the structure of this bucket: <pre> 2B Num of indexed items <repeating> 1B data type of property value 1B length of name ?B property name - ascii string </repeating> </pre> The order of the properties is taken as the index for each item.
private
processPropertyNamesBucket(mixed $data) : mixed
Parameters
- $data : mixed
Return values
mixed —processPropertyValuesBucket()
The following is the structure of this bucket: <pre> 2B Number of indexed items <repeating>
private
processPropertyValuesBucket(mixed $data) : mixed
1B container type ID: "no container", "ordered set" etc
<elseif container="ordered set">
1B property type - int, boolean, string etc
2B number of items in the set
<repeat>
<if type=string>
1B property type - the type of string -
1B/2B/4B length of value bytes --OPTIONAL-- (only applies to some string types)
</if>
?B the converted value, some data types have a fixed length such as (boolean len=1, byte len=1, short len=2, int len=4, float len=4)
</repeat>
</if>
2B Num of indexed items
Parameters
- $data : mixed