Commit 76b66afe authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 8dab9f7f
......@@ -39,8 +39,7 @@
#include "structmember.h"
#include "frameobject.h"
#include <wendelin/bigfile/file.h>
#include <wendelin/bigfile/virtmem.h>
#include "bigfile/_bigfile.h"
#include <wendelin/bigfile/ram.h>
#include <wendelin/bug.h>
#include <wendelin/compat_py2.h>
......@@ -71,89 +70,6 @@ static PyObject *pybuf_str;
#define BIGFILE_USE_PYTS_EXC_INFO (PY_VERSION_HEX >= 0x030700A3)
/*
* python representation of VMA - exposes vma memory as python buffer
*
* also exposes:
*
* .filerange() to know which range in mmaped file this vma covers.
* .pagesize() to know page size of underlying RAM.
*
* and:
*
* .addr_start, .addr_stop to know offset of ndarray in VMA.
* .pyuser generic python-level attribute (see below).
*/
struct PyVMA {
PyObject;
PyObject *in_weakreflist;
VMA;
/* python-level user of this VMA.
*
* for example for ArrayRef to work, BigArray needs to find out VMA ->
* top-level BigArray object for which this VMA was created.
*
* There is vma -> fileh -> file chain, but e.g. for a given ZBigFile there
* can be several ZBigArrays created on top of it to view its data (e.g. via
* BigArray.view()). So even if it can go from vma to -> zfile it does not
* help to find out the top-level ZBigArray object itself.
*
* This way we allow BigArray python code to set vma.pyuser attribute
* pointing to original BigArray object for which this VMA was created. */
PyObject *pyuser;
};
typedef struct PyVMA PyVMA;
/*
* python representation of BigFileH - exposes
*
* .mmap() to create VMAs and
* .dirty_discard() and
* .dirty_writeout() for storing changes back to file.
* .isdirty() for knowing are there any changes at all
*/
struct PyBigFileH {
PyObject;
PyObject *in_weakreflist;
BigFileH;
/* if subclass, in addition to .loadblk/.storeblk, defines .mmapper XXX ... */
PyObject *pymmapper; // python object returned by .mmaper() that is holding virtmem_mapper pycapsule
//virt_mapper *virt_mmap_ops; // XXX ok?
};
typedef struct PyBigFileH PyBigFileH;
/*
* BigFile that can be implemented in python
*
* Allows subclasses to implement .loadblk() (& friends) in python.
* For users .fileh_open() is exposed to get to file handles.
*/
struct PyBigFile {
PyObject;
/* NOTE no explicit weakref support is needed - this is a base class and python
* automatically adds support for weakrefs for in-python defined children */
BigFile;
};
typedef struct PyBigFile PyBigFile;
/* NOTE on refcounting: who holds who
*
*
* vma -> fileh -> file
* ^ |
* +---------+
* fileh->mmaps (kind of weak)
*/
/* like PyObject_New, but fully initializes instance (e.g. calls type ->tp_new) */
#define PyType_New(type, typeobj, args) \
( (type *)PyObject_CallObject((PyObject *)(typeobj), args) )
......
#ifndef _WENDELINCORE_BIGFILE__BIGFILE_H
#define _WENDELINCORE_BIGFILE__BIGFILE_H
/* Wendelin.bigfile | Python interface to memory/files
* Copyright (C) 2014-2019 Nexedi SA and Contributors.
* Kirill Smelkov <kirr@nexedi.com>
*
* This program is free software: you can Use, Study, Modify and Redistribute
* it under the terms of the GNU General Public License version 3, or (at your
* option) any later version, as published by the Free Software Foundation.
*
* You can also Link and Combine this program with other software covered by
* the terms of any of the Free Software licenses or any of the Open Source
* Initiative approved licenses and Convey the resulting work. Corresponding
* source of such a combination shall include the source code for all other
* software used.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See COPYING file for full licensing terms.
* See https://www.nexedi.com/licensing for rationale and options.
*/
// XXX doc
#include <wendelin/bigfile/file.h>
#include <wendelin/bigfile/virtmem.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* python representation of VMA - exposes vma memory as python buffer
*
* also exposes:
*
* .filerange() to know which range in mmaped file this vma covers.
* .pagesize() to know page size of underlying RAM.
*
* and:
*
* .addr_start, .addr_stop to know offset of ndarray in VMA.
* .pyuser generic python-level attribute (see below).
*/
struct PyVMA {
PyObject;
PyObject *in_weakreflist;
VMA;
/* python-level user of this VMA.
*
* for example for ArrayRef to work, BigArray needs to find out VMA ->
* top-level BigArray object for which this VMA was created.
*
* There is vma -> fileh -> file chain, but e.g. for a given ZBigFile there
* can be several ZBigArrays created on top of it to view its data (e.g. via
* BigArray.view()). So even if it can go from vma to -> zfile it does not
* help to find out the top-level ZBigArray object itself.
*
* This way we allow BigArray python code to set vma.pyuser attribute
* pointing to original BigArray object for which this VMA was created. */
PyObject *pyuser;
};
typedef struct PyVMA PyVMA;
/*
* python representation of BigFileH - exposes
*
* .mmap() to create VMAs and
* .dirty_discard() and
* .dirty_writeout() for storing changes back to file.
* .isdirty() for knowing are there any changes at all
*/
struct PyBigFileH {
PyObject;
PyObject *in_weakreflist;
BigFileH;
/* if subclass, in addition to .loadblk/.storeblk, defines .mmapper XXX ... */
PyObject *pymmapper; // python object returned by .mmaper() that is holding virtmem_mapper pycapsule
//virt_mapper *virt_mmap_ops; // XXX ok?
};
typedef struct PyBigFileH PyBigFileH;
/*
* BigFile that can be implemented in python
*
* Allows subclasses to implement .loadblk() (& friends) in python.
* For users .fileh_open() is exposed to get to file handles.
*/
struct PyBigFile {
PyObject;
/* NOTE no explicit weakref support is needed - this is a base class and python
* automatically adds support for weakrefs for in-python defined children */
BigFile;
};
typedef struct PyBigFile PyBigFile;
/* NOTE on refcounting: who holds who
*
*
* vma -> fileh -> file
* ^ |
* +---------+
* fileh->mmaps (kind of weak)
*/
#ifdef __cplusplus
}
#endif
#endif // _WENDELINCORE_BIGFILE__BIGFILE_H
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment