# This file was automatically generated by SWIG (http://www.swig.org).
# Version 2.0.9
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.



from sys import version_info
if version_info >= (2,6,0):
    def swig_import_helper():
        from os.path import dirname
        import imp
        fp = None
        try:
            fp, pathname, description = imp.find_module('_madoka', [dirname(__file__)])
        except ImportError:
            import _madoka
            return _madoka
        if fp is not None:
            try:
                _mod = imp.load_module('_madoka', fp, pathname, description)
            finally:
                fp.close()
            return _mod
    _madoka = swig_import_helper()
    del swig_import_helper
else:
    import _madoka
del version_info
try:
    _swig_property = property
except NameError:
    pass # Python < 2.2 doesn't have 'property'.
def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
    if (name == "thisown"): return self.this.own(value)
    if (name == "this"):
        if type(value).__name__ == 'SwigPyObject':
            self.__dict__[name] = value
            return
    method = class_type.__swig_setmethods__.get(name,None)
    if method: return method(self,value)
    if (not static):
        self.__dict__[name] = value
    else:
        raise AttributeError("You cannot add attributes to %s" % self)

def _swig_setattr(self,class_type,name,value):
    return _swig_setattr_nondynamic(self,class_type,name,value,0)

def _swig_getattr(self,class_type,name):
    if (name == "thisown"): return self.this.own()
    method = class_type.__swig_getmethods__.get(name,None)
    if method: return method(self)
    raise AttributeError(name)

def _swig_repr(self):
    try: strthis = "proxy of " + self.this.__repr__()
    except: strthis = ""
    return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)

try:
    _object = object
    _newclass = 1
except AttributeError:
    class _object : pass
    _newclass = 0

class Exception(Exception):
    __swig_setmethods__ = {}
    __setattr__ = lambda self, name, value: _swig_setattr(self, Exception, name, value)
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, Exception, name)
    __repr__ = _swig_repr
    __swig_destroy__ = _madoka.delete_Exception
    __del__ = lambda self : None;
    def __init__(self, *args): 
        this = _madoka.new_Exception(*args)
        try: self.this.append(this)
        except: self.this = this
    def what(self): return _madoka.Exception_what(self)
Exception_swigregister = _madoka.Exception_swigregister
Exception_swigregister(Exception)


MADOKA_LINE_STR = _madoka.MADOKA_LINE_STR
FILE_CREATE = _madoka.FILE_CREATE
FILE_TRUNCATE = _madoka.FILE_TRUNCATE
FILE_READONLY = _madoka.FILE_READONLY
FILE_WRITABLE = _madoka.FILE_WRITABLE
FILE_SHARED = _madoka.FILE_SHARED
FILE_PRIVATE = _madoka.FILE_PRIVATE
FILE_ANONYMOUS = _madoka.FILE_ANONYMOUS
FILE_HUGETLB = _madoka.FILE_HUGETLB
FILE_PRELOAD = _madoka.FILE_PRELOAD

SKETCH_EXACT_MODE = _madoka.SKETCH_EXACT_MODE
SKETCH_APPROX_MODE = _madoka.SKETCH_APPROX_MODE
class Sketch(_object):
    __swig_setmethods__ = {}
    __setattr__ = lambda self, name, value: _swig_setattr(self, Sketch, name, value)
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, Sketch, name)
    __repr__ = _swig_repr
    def __init__(self, width=0, max_value=0, path=None, flags=0, seed=0): 
        this = _madoka.new_Sketch()
        try: self.this.append(this)
        except: self.this = this
        return _madoka.Sketch_create(self, width, max_value, path, flags, seed)
    __swig_destroy__ = _madoka.delete_Sketch
    __del__ = lambda self : None;

    def __len__(self):
        return self.file_size()

    def create(self, width=0, max_value=0, path=None, flags=0, seed=0):
        """Create new sketch
        Params:
            <int> width
            <int> max_value
            <str> path            
            <int> flags
            <int> seed
        """
        return _madoka.Sketch_create(self, width, max_value, path, flags, seed)

    def open(self, *args):
        """Load sketch from file

        open() uses memory mapped I/O instead of reading the whole sketch into memory

        file_flag as following:
            FILE_CREATE    = 0,
            FILE_TRUNCATE  = 1,
            FILE_READONLY  = 2,
            FILE_WRITABLE  = 3,
            FILE_SHARED    = 4,
            FILE_PRIVATE   = 5,
            FILE_ANONYMOUS = 6,
            FILE_HUGETLB   = 7,
            FILE_PRELOAD   = 8

        Params:
            <str> filepath
            <int> file_flag
        """
        _madoka.Sketch_open(self, *args)

    def close(self):
        return _madoka.Sketch_close(self)

    def load(self, *args):
        """Load sketch from file

        file_flag as following:
            FILE_CREATE    = 0,
            FILE_TRUNCATE  = 1,
            FILE_READONLY  = 2,
            FILE_WRITABLE  = 3,
            FILE_SHARED    = 4,
            FILE_PRIVATE   = 5,
            FILE_ANONYMOUS = 6,
            FILE_HUGETLB   = 7,
            FILE_PRELOAD   = 8

        Params:
            <str> filepath
            <int> file_flag
        """
        return _madoka.Sketch_load(self, *args)

    def save(self, *args):
        """Save sketch to file

        file_flag as following:
            FILE_CREATE    = 0,
            FILE_TRUNCATE  = 1,
            FILE_READONLY  = 2,
            FILE_WRITABLE  = 3,
            FILE_SHARED    = 4,
            FILE_PRIVATE   = 5,
            FILE_ANONYMOUS = 6,
            FILE_HUGETLB   = 7,
            FILE_PRELOAD   = 8

        Params:
            <str> filepath
            <int> file_flag
        """
        return _madoka.Sketch_save(self, *args)

    def get(self, key, key_length=0):
        """Add key-value
        Params:
            <str> key
            <int> key_length
        Return:
            <int> key_value
        """        
        if key_length < 1:
            key_length = len(key)
        return _madoka.Sketch_get(self, key, key_length)

    def set(self, key, value, key_length=0):
        """Set value to key-value
        Params:
            <str> key
            <int> value
            <int> key_length
        Return:
            <int> key_value
        """        
        if key_length < 1:
            key_length = len(key)
        return _madoka.Sketch_set(self, key, key_length, value)

    def inc(self, key, key_length=0):
        """Increment key-value
        Params:
            <str> key
            <int> key_length
        Return:
            <int> key_value
        """
        if key_length < 1:
            key_length = len(key)
        return _madoka.Sketch_inc(self, key, key_length)

    def add(self, key, value, key_length=0):
        """Add value to key-value
        Params:
            <str> key
            <int> value
            <int> key_length
        Return:
            <int> key_value
        """
        if key_length < 1:
            key_length = len(key)
        return _madoka.Sketch_add(self, key, key_length, value)

    def clear(self):
        """Clear sketch"""
        return _madoka.Sketch_clear(self)

    def copy(self, *args):
        """Copy this sketch
        Return:
            <Sketch> sketch
        """
        return _madoka.Sketch_copy(self, *args)

    def shrink(self, *args):
        """Shrink sketche
        Params:
            <Sketch> src_sketch
            <int> width
            <int> max_value
        """
        return _madoka.Sketch_shrink(self, *args)

    def merge(self, *args):
        """Merge two sketches
        Params:
            <Sketch> sketch
        """
        return _madoka.Sketch_merge(self, *args)

    def swap(self, *args):
        """Swap sketches
        Params:
            <Sketch> sketch
        """
        return _madoka.Sketch_swap(self, *args)

    def inner_product(self, *args):
        """Inner product of two sketches
        Params:
            <Sketch> sketch1
            <Sketch> sketch2
        Return:
            <int> inner_product
        """
        return _madoka.Sketch_inner_product(self, *args)

    def width(self): return _madoka.Sketch_width(self)
    def width_mask(self): return _madoka.Sketch_width_mask(self)
    def depth(self): return _madoka.Sketch_depth(self)
    def max_value(self): return _madoka.Sketch_max_value(self)
    def value_mask(self): return _madoka.Sketch_value_mask(self)
    def value_size(self): return _madoka.Sketch_value_size(self)
    def seed(self): return _madoka.Sketch_seed(self)
    def table_size(self): return _madoka.Sketch_table_size(self)
    def file_size(self): return _madoka.Sketch_file_size(self)
    def flags(self): return _madoka.Sketch_flags(self)
    def mode(self): return _madoka.Sketch_mode(self)

Sketch_swigregister = _madoka.Sketch_swigregister
Sketch_swigregister(Sketch)
cvar = _madoka.cvar
SKETCH_ID_SIZE = cvar.SKETCH_ID_SIZE
SKETCH_MAX_ID = cvar.SKETCH_MAX_ID
SKETCH_ID_MASK = cvar.SKETCH_ID_MASK
SKETCH_MIN_WIDTH = cvar.SKETCH_MIN_WIDTH
SKETCH_MAX_WIDTH = cvar.SKETCH_MAX_WIDTH
SKETCH_DEFAULT_WIDTH = cvar.SKETCH_DEFAULT_WIDTH
SKETCH_MAX_MAX_VALUE = cvar.SKETCH_MAX_MAX_VALUE
SKETCH_DEFAULT_MAX_VALUE = cvar.SKETCH_DEFAULT_MAX_VALUE
SKETCH_DEPTH = cvar.SKETCH_DEPTH
SKETCH_APPROX_VALUE_SIZE = cvar.SKETCH_APPROX_VALUE_SIZE
SKETCH_OWNER_OFFSET = cvar.SKETCH_OWNER_OFFSET
SKETCH_OWNER_MASK = cvar.SKETCH_OWNER_MASK

# This file is compatible with both classic and new-style classes.


