Changeset: ff2da9ba47e2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ff2da9ba47e2
Modified Files:
        gdk/gdk.h
        gdk/gdk_atoms.h
Branch: linear-hashing
Log Message:

Move atom declarations and definitions to gdk_atoms.h.


diffs (280 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -985,203 +985,6 @@ typedef var_t stridx_t;
 
 #define BATcount(b)    ((b)->batCount)
 
-/*
- * @+ GDK Extensibility
- * GDK can be extended with new atoms, search accelerators and storage
- * modes.
- *
- * @- Atomic Type Descriptors
- * The atomic types over which the binary associations are maintained
- * are described by an atom descriptor.
- *  @multitable @columnfractions 0.08 0.7
- * @item void
- * @tab ATOMallocate    (str   nme);
- * @item int
- * @tab ATOMindex       (char *nme);
- * @item int
- * @tab ATOMdump        ();
- * @item void
- * @tab ATOMdelete      (int id);
- * @item str
- * @tab ATOMname        (int id);
- * @item unsigned int
- * @tab ATOMsize        (int id);
- * @item int
- * @tab ATOMvarsized    (int id);
- * @item ptr
- * @tab ATOMnilptr      (int id);
- * @item ssize_t
- * @tab ATOMfromstr     (int id, str s, size_t* len, ptr* v_dst);
- * @item ssize_t
- * @tab ATOMtostr       (int id, str s, size_t* len, ptr* v_dst);
- * @item hash_t
- * @tab ATOMhash        (int id, ptr val, in mask);
- * @item int
- * @tab ATOMcmp         (int id, ptr val_1, ptr val_2);
- * @item int
- * @tab ATOMfix         (int id, ptr v);
- * @item int
- * @tab ATOMunfix       (int id, ptr v);
- * @item int
- * @tab ATOMheap        (int id, Heap *hp, size_t cap);
- * @item int
- * @tab ATOMput         (int id, Heap *hp, BUN pos_dst, ptr val_src);
- * @item int
- * @tab ATOMdel         (int id, Heap *hp, BUN v_src);
- * @item size_t
- * @tab ATOMlen         (int id, ptr val);
- * @item ptr
- * @tab ATOMnil         (int id);
- * @item ssize_t
- * @tab ATOMformat      (int id, ptr val, char** buf);
- * @item int
- * @tab ATOMprint       (int id, ptr val, stream *fd);
- * @item ptr
- * @tab ATOMdup         (int id, ptr val );
- * @end multitable
- *
- * @- Atom Definition
- * User defined atomic types can be added to a running system with the
- * following interface:.
- *
- * @itemize
- * @item @emph{ATOMallocate()} registers a new atom definition if
- * there is no atom registered yet under that name.
- *
- * @item @emph{ATOMdelete()} unregisters an atom definition.
- *
- * @item @emph{ATOMindex()} looks up the atom descriptor with a certain name.
- * @end itemize
- *
- * @- Atom Manipulation
- *
- * @itemize
- * @item The @emph{ATOMname()} operation retrieves the name of an atom
- * using its id.
- *
- * @item The @emph{ATOMsize()} operation returns the atoms fixed size.
- *
- * @item The @emph{ATOMnilptr()} operation returns a pointer to the
- * nil-value of an atom. We usually take one dedicated value halfway
- * down the negative extreme of the atom range (if such a concept
- * fits), as the nil value.
- *
- * @item The @emph{ATOMnil()} operation returns a copy of the nil
- * value, allocated with GDKmalloc().
- *
- * @item The @emph{ATOMheap()} operation creates a new var-sized atom
- * heap in 'hp' with capacity 'cap'.
- *
- * @item The @emph{ATOMhash()} computes a hash index for a
- * value. `val' is a direct pointer to the atom value. Its return
- * value should be an hash_t between 0 and 'mask'.
- *
- * @item The @emph{ATOMcmp()} operation compares two atomic
- * values. Its parameters are pointers to atomic values.
- *
- * @item The @emph{ATOMlen()} operation computes the byte length for a
- * value.  `val' is a direct pointer to the atom value. Its return
- * value should be an integer between 0 and 'mask'.
- *
- * @item The @emph{ATOMdel()} operation deletes a var-sized atom from
- * its heap `hp'.  The integer byte-index of this value in the heap is
- * pointed to by `val_src'.
- *
- * @item The @emph{ATOMput()} operation inserts an atom `src_val' in a
- * BUN at `dst_pos'. This involves copying the fixed sized part in the
- * BUN. In case of a var-sized atom, this fixed sized part is an
- * integer byte-index into a heap of var-sized atoms. The atom is then
- * also copied into that heap `hp'.
- *
- * @item The @emph{ATOMfix()} and @emph{ATOMunfix()} operations do
- * bookkeeping on the number of references that a GDK application
- * maintains to the atom.  In MonetDB, we use this to count the number
- * of references directly, or through BATs that have columns of these
- * atoms. The only operator for which this is currently relevant is
- * BAT. The operators return the POST reference count to the
- * atom. BATs with fixable atoms may not be stored persistently.
- *
- * @item The @emph{ATOMfromstr()} parses an atom value from string
- * `s'. The memory allocation policy is the same as in
- * @emph{ATOMget()}. The return value is the number of parsed
- * characters or -1 on failure.  Also in case of failure, the output
- * parameter buf is a valid pointer or NULL.
- *
- * @item The @emph{ATOMprint()} prints an ASCII description of the
- * atom value pointed to by `val' on file descriptor `fd'. The return
- * value is the number of parsed characters.
- *
- * @item The @emph{ATOMformat()} is similar to @emph{ATOMprint()}. It
- * prints an atom on a newly allocated string. It must later be freed
- * with @strong{GDKfree}.  The number of characters written is
- * returned. This is minimally the size of the allocated buffer.
- *
- * @item The @emph{ATOMdup()} makes a copy of the given atom. The
- * storage needed for this is allocated and should be removed by the
- * user.
- * @end itemize
- *
- * These wrapper functions correspond closely to the interface
- * functions one has to provide for a user-defined atom. They
- * basically (with exception of @emph{ATOMput()}, @emph{ATOMprint()}
- * and @emph{ATOMformat()}) just have the atom id parameter prepended
- * to them.
- */
-
-/* atomFromStr returns the number of bytes of the input string that
- * were processed.  atomToStr returns the length of the string
- * produced.  Both functions return -1 on (any kind of) failure.  If
- * *dst is not NULL, *len specifies the available space.  If there is
- * not enough space, or if *dst is NULL, *dst will be freed (if not
- * NULL) and a new buffer will be allocated and returned in *dst.
- * *len will be set to reflect the actual size allocated.  If
- * allocation fails, *dst will be NULL on return and *len is
- * undefined.  In any case, if the function returns, *buf is either
- * NULL or a valid pointer and then *len is the size of the area *buf
- * points to. */
-
-typedef struct {
-       /* simple attributes */
-       char name[IDLENGTH];
-       uint8_t storage;        /* stored as another type? */
-       bool linear;            /* atom can be ordered linearly */
-       uint16_t size;          /* fixed size of atom */
-
-       /* automatically generated fields */
-       const void *atomNull;   /* global nil value */
-
-       /* generic (fixed + varsized atom) ADT functions */
-       ssize_t (*atomFromStr) (const char *src, size_t *len, void **dst, bool 
external);
-       ssize_t (*atomToStr) (char **dst, size_t *len, const void *src, bool 
external);
-       void *(*atomRead) (void *dst, stream *s, size_t cnt);
-       gdk_return (*atomWrite) (const void *src, stream *s, size_t cnt);
-       int (*atomCmp) (const void *v1, const void *v2);
-       BUN (*atomHash) (const void *v);
-       /* optional functions */
-       int (*atomFix) (const void *atom);
-       int (*atomUnfix) (const void *atom);
-
-       /* varsized atom-only ADT functions */
-       var_t (*atomPut) (Heap *, var_t *off, const void *src);
-       void (*atomDel) (Heap *, var_t *atom);
-       size_t (*atomLen) (const void *atom);
-       void (*atomHeap) (Heap *, size_t);
-} atomDesc;
-
-gdk_export atomDesc BATatoms[];
-gdk_export int GDKatomcnt;
-
-gdk_export int ATOMallocate(const char *nme);
-gdk_export int ATOMindex(const char *nme);
-
-gdk_export str ATOMname(int id);
-gdk_export size_t ATOMlen(int id, const void *v);
-gdk_export void *ATOMnil(int id);
-gdk_export int ATOMprint(int id, const void *val, stream *fd);
-gdk_export char *ATOMformat(int id, const void *val);
-
-gdk_export void *ATOMdup(int id, const void *val);
-
 #include "gdk_atoms.h"
 
 /* return the oid value at BUN position p from the (v)oid bat b
diff --git a/gdk/gdk_atoms.h b/gdk/gdk_atoms.h
--- a/gdk/gdk_atoms.h
+++ b/gdk/gdk_atoms.h
@@ -9,6 +9,69 @@
 #ifndef _GDK_ATOMS_H_
 #define _GDK_ATOMS_H_
 
+/* atomFromStr returns the number of bytes of the input string that
+ * were processed.  atomToStr returns the length of the string
+ * produced.  Both functions return -1 on (any kind of) failure.  If
+ * *dst is not NULL, *len specifies the available space.  If there is
+ * not enough space, or if *dst is NULL, *dst will be freed (if not
+ * NULL) and a new buffer will be allocated and returned in *dst.
+ * *len will be set to reflect the actual size allocated.  If
+ * allocation fails, *dst will be NULL on return and *len is
+ * undefined.  In any case, if the function returns, *buf is either
+ * NULL or a valid pointer and then *len is the size of the area *buf
+ * points to.
+ *
+ * atomCmp returns a value less than zero/equal to zero/greater than
+ * zer if the first argument points to a values which is deemed
+ * smaller/equal to/larger than the value pointed to by the second
+ * argument.
+ *
+ * atomHash calculates a hash function for the value pointed to by the
+ * argument.
+ */
+
+typedef struct {
+       /* simple attributes */
+       char name[IDLENGTH];
+       uint8_t storage;        /* stored as another type? */
+       bool linear;            /* atom can be ordered linearly */
+       uint16_t size;          /* fixed size of atom */
+
+       /* automatically generated fields */
+       const void *atomNull;   /* global nil value */
+
+       /* generic (fixed + varsized atom) ADT functions */
+       ssize_t (*atomFromStr) (const char *src, size_t *len, void **dst, bool 
external);
+       ssize_t (*atomToStr) (char **dst, size_t *len, const void *src, bool 
external);
+       void *(*atomRead) (void *dst, stream *s, size_t cnt);
+       gdk_return (*atomWrite) (const void *src, stream *s, size_t cnt);
+       int (*atomCmp) (const void *v1, const void *v2);
+       BUN (*atomHash) (const void *v);
+       /* optional functions */
+       int (*atomFix) (const void *atom);
+       int (*atomUnfix) (const void *atom);
+
+       /* varsized atom-only ADT functions */
+       var_t (*atomPut) (Heap *, var_t *off, const void *src);
+       void (*atomDel) (Heap *, var_t *atom);
+       size_t (*atomLen) (const void *atom);
+       void (*atomHeap) (Heap *, size_t);
+} atomDesc;
+
+gdk_export atomDesc BATatoms[];
+gdk_export int GDKatomcnt;
+
+gdk_export int ATOMallocate(const char *nme);
+gdk_export int ATOMindex(const char *nme);
+
+gdk_export str ATOMname(int id);
+gdk_export size_t ATOMlen(int id, const void *v);
+gdk_export void *ATOMnil(int id);
+gdk_export int ATOMprint(int id, const void *val, stream *fd);
+gdk_export char *ATOMformat(int id, const void *val);
+
+gdk_export void *ATOMdup(int id, const void *val);
+
 #define MAXATOMS       128
 
 /*
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to