Skip to content

A simple Python example of a SingleStore collocated process using the binary protocol and ROWDAT format.

License

Notifications You must be signed in to change notification settings

galleymemsql/collocated-service-using-binary-protocol-example

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Example: SingleStore Collocated Service Using Binary Protocol

Summary

Attention: The code in this repository is intended for experimental use only and is not fully tested, documented, or supported by SingleStore. Visit the SingleStore Forums to ask questions about this repository.

This is a simple Python program that illustrates a SingleStore collocated process using the binary protocol (via Unix sockets and shared memory) and the efficient ROWDAT_1 format.

It simply returns each row it receives with the prefix HELLO .

Usage

To run this example, you'll need to do the following:

  1. Copy this program to each node of your database cluster.
  2. Run this program on each node of your database cluster using python3 xfunc.py.

Once the example is running, you can create the external function in SQL like this:

CREATE EXTERNAL FUNCTION xfunc(a text) RETURNS TEXT AS COLLOCATED SERVICE '/tmp/xfunc_pipe' FORMAT ROWDAT_1;

Finally, you can run the following SQL commands to test it:

CREATE DATABASE test;

CREATE TABLE foobar(a TEXT);

INSERT INTO foobar(a) VALUES ('one'), ('two'), ('three'), ('four'), ('five'), ('six'), ('seven'), ('eight'), ('nine'), ('ten');

CREATE EXTERNAL FUNCTION xfunc(a text) RETURNS TEXT AS COLLOCATED SERVICE '/tmp/xfunc_pipe' FORMAT ROWDAT_1;

SELECT xfunc(a) FROM foobar;

Product Documentation:

External Functions Collocated Service ROWDAT_1 Format

About

A simple Python example of a SingleStore collocated process using the binary protocol and ROWDAT format.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%