Skip to content

FeatureBaseDB/lua-pilosa

Repository files navigation

Lua Client for Pilosa

Coverage Status

Lua client for Pilosa high performance distributed bitmap index. See this article for more information: https://www.pilosa.com/blog/writing-a-client-library/

What's New?

See: CHANGELOG

Requirements

  • Lua 5.1

Install

Pilosa client is on LuaRocks:

luarocks install pilosa

Usage

Quick overview

Assuming Pilosa server is running at localhost:10101 (the default):

local PilosaClient = require "pilosa.client".PilosaClient

-- Create the default client
local client = PilosaClient()

-- Retrieve the schema
local schema = client:schema()

-- Create an Index object
local myindex = schema:index("myindex")

-- Create a Frame object
local myframe = myindex:frame("myframe")

-- make sure the index and frame exists on the server
client:syncSchema(schema)

-- Send a SetBit query. An error is thrown if execution of the query fails.
client:query(myframe:setbit(5, 42))

-- Send a Bitmap query. An error is thrown if execution of the query fails.
local response = client:query(myframe:bitmap(5))

-- Get the result
local result = response.result

-- Act on the result
if result ~= nil then
    bits = result.bitmap.bits
    print("Got bits: ", bits)
end

-- You can batch queries to improve throughput
response = client:query(
    myindex:batchQuery(
        myframe:bitmap(5),
        myframe:bitmap(10)
    )    
)
for i, result in ipairs(response.results) do
    -- Act on the result
    print(result)
end

Documentation

Data Model and Queries

See: Data Model and Queries

Executing Queries

See: Server Interaction

Contributing

See: CONTRIBUTING

License

See: LICENSE