Sergey Gladkov > Kafka-0.12 > Kafka::Int64

Download:
Kafka-0.12.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  3
Open  0
View/Report Bugs
Module Version: 0.12   Source   Latest Release: Kafka-0.8008_1

NAME ^

Kafka::Int64 - functions to work with 64 bit elements of the Apache Kafka Wire Format protocol on 32 bit systems

VERSION ^

This documentation refers to Kafka::Int64 version 0.12

SYNOPSIS ^

    use Kafka qw( BITS64 );
    
    # Apache Kafka Wire Format: OFFSET, TIME
    
    $encoded = BITS64 ?
        pack( "q>", $offset + 0 )
        : Kafka::Int64::packq( $offset + 0 );
    
    $offset = BITS64 ?
        unpack( "q>", substr( $response, 0, 8 ) )
        : Kafka::Int64::unpackq( substr( $response, 0, 8 ) );
    
    if ( BITS64 )
    {
        $message->{offset} = $next_offset;
        $next_offset += $message->{length} + 4;
    }
    else
    {
        $message->{offset} = Kafka::Int64::intsum( $next_offset, 0 );
        $next_offset = Kafka::Int64::intsum(
            $next_offset,
            $message->{length} + 4
            );
    }

DESCRIPTION ^

Transparent BigInteger support on 32-bit platforms where native integer type is limited to 32 bits and slow bigint must be used instead. Use functions from this module in such case.

The main features of the Kafka::Int64 module are:

FUNCTIONS

The following functions are available for the Kafka::Int64 module.

intsum( $bint, $int )

Adds two numbers to emulate bigint adding 64-bit integers in 32-bit systems.

The both arguments must be a number. That is, it is defined and Perl thinks it's a number. The first argument may be a Math::BigInt integer.

Returns the value as a Math::BigInt integer, or error will cause the program to halt (confess) if the argument is not a valid number.

packq( $bint )

Emulates pack( "q>", $bint ) to 32-bit systems - assumes decimal string or integer input.

An argument must be a positive number. That is, it is defined and Perl thinks it's a number. The argument may be a Math::BigInt integer.

The special values -1, -2 are allowed.

Returns the value as a packed binary string, or error will cause the program to halt (confess) if the argument is not a valid number.

unpackq( $bstr )

Emulates unpack( "q>", $bstr ) to 32-bit systems - assumes binary input.

The argument must be a binary string of 8 bytes length.

Returns the value as a Math::BigInt integer, or error will cause the program to halt (confess) if the argument is not a valid binary string.

DIAGNOSTICS ^

Kafka::Int64 is not a user module and any functions error is FATAL. FATAL errors will cause the program to halt (confess), since the problem is so severe that it would be dangerous to continue. (This can always be trapped with eval. Under the circumstances, dying is the best thing to do).

Mismatch argument

This means that you didn't give the right argument to some of the functions.

SEE ALSO ^

The basic operation of the Kafka package modules:

Kafka - constants and messages used by the Kafka package modules

Kafka::IO - object interface to socket communications with the Apache Kafka server

Kafka::Producer - object interface to the producer client

Kafka::Consumer - object interface to the consumer client

Kafka::Message - object interface to the Kafka message properties

Kafka::Protocol - functions to process messages in the Apache Kafka's wire format

Kafka::Int64 - functions to work with 64 bit elements of the protocol on 32 bit systems

Kafka::Mock - object interface to the TCP mock server for testing

A wealth of detail about the Apache Kafka and Wire Format:

Main page at http://incubator.apache.org/kafka/

Wire Format at http://cwiki.apache.org/confluence/display/KAFKA/Wire+Format/

Writing a Driver for Kafka at http://cwiki.apache.org/confluence/display/KAFKA/Writing+a+Driver+for+Kafka

AUTHOR ^

Sergey Gladkov, <sgladkov@trackingsoft.com>

CONTRIBUTORS ^

Alexander Solovey

Jeremy Jordan

Vlad Marchenko

COPYRIGHT AND LICENSE ^

Copyright (C) 2012-2013 by TrackingSoft LLC. All rights reserved.

This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic at http://dev.perl.org/licenses/artistic.html.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

syntax highlighting: