ljson.slapdash package

Submodules

ljson.slapdash.disk module

class ljson.slapdash.disk.Selector(header, dct, table)[source]

Bases: object

getone(column=None)[source]
class ljson.slapdash.disk.Table(header, file_, reread_stats=False)[source]

Bases: ljson.slapdash.generic.SlapdashTable

additem(document)[source]
calculate_stats()[source]
classmethod empty(file_or_filename)[source]

Create a new empty table with the given file or filename.

static from_file(file_)[source]

WARNING: file_ must be opened in r+ mode!

insert_stats()[source]
save(fout)[source]

Save this table to the file fout.

ljson.slapdash.generic module

Some generic functions and classes for ljson.slapdash.

class ljson.slapdash.generic.SlapdashHeader(descriptor)[source]

Bases: object

A Header for ljson slapdash tables. Used to describe the table (as good as possible).

static from_file(fin)[source]

Construct the header from the file.

get_header()[source]

Return a JSON header.

class ljson.slapdash.generic.SlapdashTable[source]

Bases: object

A messy table.

SlapdashTable is used to store inhomogenous data, like in a document-oriented database.

additem(document)[source]

Add a document to the table.

This will update the header according to the inserted document.

calculate_stats()[source]

Calculate statistical information about the data structure. Returns a dict:

{
        "length": int,
        "field_count": dict,
        "total_datatype_count": dict,
        "per_field_datatype_count": dict
}
classmethod empty()[source]

Return a new empty slapdash table.

static from_file(file_)[source]

Read a SlapdashTable from a file

insert_stats()[source]

Calculate statistical information about the data structure and store the gathered information in the Header.

classmethod open(filename)[source]

Equivalent to Table.from_file(open(filename, "r+"))

save(fout)[source]
split(ignore=None)[source]

Split the table into tables containing exactly one document type.

Warning: If the table highly inhomogenous, this will produce a high number of tables.

Attribute names listed in ignore will be ignored by the split process and the data will not appear in the resulting tables.

Warning: Currently not implemented.

ljson.slapdash.generic.document_matches(document, dct)[source]

Return True, if the document matches the given dict. If a value in the dict is not contained in the document, this will return false.

ljson.slapdash.mem module

class ljson.slapdash.mem.Selector(header, dct, table)[source]

Bases: object

getone(column=None)[source]
class ljson.slapdash.mem.Table(header, documents)[source]

Bases: ljson.slapdash.generic.SlapdashTable

additem(document)[source]
calculate_stats()[source]
classmethod empty()[source]
static from_file(file_)[source]
insert_stats()[source]
save(fout)[source]

Module contents

ljson.slapdash is basically the messy little brother of ljson.

slapdash is oriented on document-oriented databases. The main difference to ljson is that slapdash rows do not get typechecked and there is no way to ensure homogenity.

However the header might provide some information about the data, for instance, what fields are most common, most unique.