The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

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

VERSION

This documentation refers to Kafka::Int64 version 0.800_3 .

SYNOPSIS

    use 5.010;
    use strict;
    use warnings;

    use Kafka qw(
        $BITS64
    );

    # Apache Kafka Protocol: FetchOffset, Time

    my $offset = 123;

    my $encoded = $BITS64 ?
        pack( 'q>', $offset )
        : Kafka::Int64::packq( $offset );

    my $response = chr( 0 ) x 8;

    $offset = $BITS64 ?
        unpack( 'q>', substr( $response, 0, 8 ) )
        : Kafka::Int64::unpackq( substr( $response, 0, 8 ) );

    my $next_offset;
    if ( $BITS64 ) {
        $next_offset = $offset + 1;
    }
    else {
        $next_offset = Kafka::Int64::intsum( $offset, 1 );
    }

DESCRIPTION

This module is not intended to be used by end user.

In order to achieve better performance, functions of this module do not perform validation of arguments.

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:

  • Support for working with 64 bit elements of the Kafka Wire Format protocol on 32 bit systems.

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{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 ($Kafka::RECEIVE_LATEST_OFFSET, $Kafka::RECEIVE_EARLIEST_OFFSETS).

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

unpackq( $bstr )

Emulates unpack( q{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.

DIAGNOSTICS

Any error functions 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.

Invalid 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::Connection - interface to connect to a Kafka cluster.

Kafka::Producer - interface for producing client.

Kafka::Consumer - interface for consuming client.

Kafka::Message - interface to access Kafka message properties.

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

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

Kafka::IO - low level interface for communication with Kafka server.

Kafka::Internals - Internal constants and functions used by several package modules.

A wealth of detail about the Apache Kafka and the Kafka Protocol:

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

Kafka Protocol at https://cwiki.apache.org/confluence/display/KAFKA/A+Guide+To+The+Kafka+Protocol

AUTHOR

Sergey Gladkov, <sgladkov@trackingsoft.com>

CONTRIBUTORS

Alexander Solovey

Jeremy Jordan

Vlad Marchenko

COPYRIGHT AND LICENSE

Copyright (C) 2012-2013 by TrackingSoft LLC.

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.