Git Product home page Git Product logo

k-perl's Introduction

NAME

K - Perl bindings for k (aka q, aka kdb, aka kx)

SYNOPSIS

my $k = K->new(
    host     => 'kserver.example.com',
    port     => 5000,
    user     => 'awhitney',
    password => 'kdb4eva',
    timeout  => 1000,
);

$k->cmd( '4 + 4' );                         # 8
$k->cmd( q/"abc"/ );                        # ['a', 'b', 'c']
$k->cmd( q/`foo`bar!(1;2)/ );               # { foo => 1, bar => 2 }
$k->cmd( q/2012.03.24D12:13:14.15161728/ ); # 385906394151617280

# table
$k->cmd( q/([] foo: (`a;`b); bar: (`c;`d))/ );
# {
#   foo => ['a', 'b'],
#   bar => ['c', 'd'],
# }

# table w/ primary key
$k->cmd( q/([p: (`a;`b)] foo: (`b;`c); bar: (`d;`e))/ );
# {
#   p   => ['a', 'b'],
#   foo => ['b', 'c'],
#   bar => ['d', 'e'],
# },

# execute a command asynchronously
$k->async_cmd( q/.u.upd[`t; (`foo; 2012.03.27D13:14:15.161718; 1.23)]/ );

# receive incoming message
my $msg = $k->recv;

DESCRIPTION

Connect to a remote K or Q instance. Execute commands. Read replies.

K wraps the C library defined by k.h and described here http://code.kx.com/wiki/Cookbook/InterfacingWithC .

K's OO interface is a thin layer of sugar on top of K::Raw which mimics the C library as faithfully as possible.

K returns simple Perl representations of k values. For example, inside k timestamps are 64-bit ints where the value is the number of nanoseconds since 2000.01.01D00:00:00.000 . For such values, K returns the int value (ex: 385906394151617280).

METHODS

new

The constructor takes the following optional arguments:

host (default: 'localhost')
port (default: '5000')
user (default: undef)
password (default: undef)
timeout (default: undef)

If a timeout is given then K will throw an exception if it's unable to connect in the provided number of milliseconds.

cmd

Takes a string containing a q command and executes it synchronously on the remote q instance. Returns the perlified result of the command.

async_cmd

Takes a string containing a q command and executes it asynchronously on the remote q instance.

recv

Listens for a message from the remote q instance. When a message arrives it's returned.

32-bit Perl

Several K datatypes are repesented as longs (64-bit ints). These include timestamps, timespans, and actual longs. Such values become native Perl ints if your Perl supports 64-bit ints. If your Perl doesn't support native 64-bit ints then K longs are represented as Math::Int64 objects. This should be transparent but there may be performance or other implications. The author of this module tests almost exclusively with a 64-bit Perl.

SEE ALSO

K::Raw, Kx, http://kx.com

REPOSITORY

http://github.com/wjackson/k-perl

AUTHORS

Whitney Jackson <[email protected]>

COPYRIGHT & LICENSE

Copyright (c) 2011 Whitney Jackson. All rights reserved This program is
free software; you can redistribute it and/or modify it under the same
terms as Perl itself.

k-perl's People

Contributors

wjackson avatar neilb avatar

Stargazers

STYLIANOS IORDANIS avatar Mohammad Noor avatar Jay Fenton avatar Dylan Cali avatar  avatar John Monteiro avatar

Watchers

 avatar James Cloos avatar Mohammad Noor avatar

Forkers

neilb stjordanis

k-perl's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.