diff --git a/doc/Makefile b/doc/Makefile index 7529ebb..59576f7 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -6,6 +6,7 @@ SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = build +DOXYGENDIR = doxygen # User-friendly check for sphinx-build ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) @@ -50,8 +51,12 @@ help: clean: rm -rf $(BUILDDIR)/* + rm -rf $(DOXYGENDIR)/* html: + @echo "Generating Doxygen documentation..." + doxygen Doxyfile + @echo "Doxygen documentation generated. \n" $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." @@ -114,6 +119,9 @@ epub: @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: + @echo "Generating Doxygen documentation..." + doxygen Doxyfile + @echo "Doxygen documentation generated. \n" $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @@ -121,6 +129,9 @@ latex: "(use \`make latexpdf' here to do that automatically)." latexpdf: + @echo "Generating Doxygen documentation..." + doxygen Doxyfile + @echo "Doxygen documentation generated. \n" $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." $(MAKE) -C $(BUILDDIR)/latex all-pdf diff --git a/doc/source/DMS.rst b/doc/source/DMS.rst index 059d450..93e03f1 100644 --- a/doc/source/DMS.rst +++ b/doc/source/DMS.rst @@ -98,7 +98,7 @@ or more (if there are several versions), and that there is one file per version. Versioning ---------- -The first version of a column file is numbered 1, and each new version increments that +The first version of a column file is numbered 0, and each new version increments that number by 1. The number of the latest version of an OBIDMS column is stored in an `OBIDMS release file `_. @@ -133,13 +133,17 @@ OBIDMS history file An OBIDMS history file consists of an ordered list of views and commands, those commands leading from one view to the next one. -This history can be represented in the form of a --- showing all the +This history can be represented in the form of a ?? showing all the operations ever done in the OBIDMS directory and the views in between them : .. image:: ./images/history.png :width: 150 px :align: center +OBIType header file +======================== + +.. doxygenfile:: obitypes.h OBIIntColumn header file diff --git a/doc/source/pistes.rst b/doc/source/pistes.rst index 53ed591..58388d6 100644 --- a/doc/source/pistes.rst +++ b/doc/source/pistes.rst @@ -9,7 +9,8 @@ Ce que l'on veut pouvoir faire * Gerer les valeurs manquantes * Modifier une colonne en cours d'ecriture (mmap) - * Ajouter des valeurs a la fin d'une colonne en cours d'ecriture (mmap) + * Ajouter des valeurs a la fin du fichier d'une colonne en cours d'ecriture (mmap) + * ****** @@ -17,4 +18,4 @@ Divers ****** * Si l'ordre d'une colonne est change, elle est reecrite (pas d'index). -* Truc pour verrouiller l'acces en lecture a un programme a la fois... \ No newline at end of file +* Utilisation de semaphores pour la lecture diff --git a/src/obicolumn.h b/src/obicolumn.h index 7ccccf0..fb63066 100644 --- a/src/obicolumn.h +++ b/src/obicolumn.h @@ -36,7 +36,7 @@ typedef enum OBIDataType { typedef struct OBIColumnHeader { bool little_endian_order; /**< endian byte order : - True : little endian - - False: big endian + - False: big endianx */ int header_size_value; /**< size of the header: a multiple of PAGESIZE */ int line_count; /**< number of lines of data */ diff --git a/src/obicount/Makefile b/src/obicount/Makefile new file mode 100644 index 0000000..6cc4c91 --- /dev/null +++ b/src/obicount/Makefile @@ -0,0 +1,18 @@ +CC = gcc +CFLAGS = -c -Wall +LDFLAGS = +SOURCES = obicount.c ../obidmscolumn.c +OBJECTS = $(SOURCES:.c=.o) +EXECUTABLE = obicount + +all: $(SOURCES) $(EXECUTABLE) + +$(EXECUTABLE): $(OBJECTS) + $(CC) $(LDFLAGS) $(OBJECTS) -o $@ + +.c.o: + $(CC) $(CFLAGS) $< -o $@ + +clean: + rm *o + rm $(EXECUTABLE) \ No newline at end of file diff --git a/src/obicount/obicount.c b/src/obicount/obicount.c new file mode 100644 index 0000000..3e2bc70 --- /dev/null +++ b/src/obicount/obicount.c @@ -0,0 +1,87 @@ + +#include +#include +#include /* mmap() is defined in this header */ +#include +#include +#include + +#include "../obitypes.h" +#include "../obidmscolumn.h" + + +/** + * @brief Computes the size to map. + * + * * @param OBIDMSColumn_file The file to map. + * @return The size to map. + */ +int get_size_to_map(int OBIDMSColumn_file) +// compute size to map : file size minus size of the header +{ + int size; + struct stat s; + + fstat(OBIDMSColumn_file, &s); + size = (s.st_size) - HEADER_SIZE; + return(size); +} + +/** + * @brief Computes and prints the total number of sequences by summing their counts. + * + * * @param The count file. + */ +int main(int argc, char const *argv[]) +{ + char* map; + int size; + int OBIDMSColumn_file; + int count; + char c; + char num_str[10] = ""; + int num_int; + int i,j; + + // initialize variables + OBIDMSColumn_file = open(argv[1], O_RDONLY); //read only + count = 0; + j = 0; + + // compute size to map + size = get_size_to_map(OBIDMSColumn_file); + + // map the data + map = obi_map_read_only(OBIDMSColumn_file, HEADER_SIZE, size); + + // sum the counts + for (i=0; i +#include +#include /* mmap() is defined in this header */ + + +/** + * @brief Reads a memory block from a file. + * + * * @param file The file that should be mapped. + * * @param size The number of bytes that should be mapped. + * * @param start The position at which the mapping should start. + * @return A pointer on the first element of the block. + */ +char* obi_map_read_only(int file, int start, int size) +{ + char* map; + map = (char*) mmap(0, size, PROT_READ, MAP_PRIVATE, file, start); + if (map == MAP_FAILED) + { + fprintf(stderr, "\nmmap read-only error\n"); + exit(1); + } + return(map); +} + +/** + * @brief Unmaps a memory block. + * + * * @param size The size of the block that should be unmapped. + */ +void obi_unmap(int size) +{ + munmap(0, size); +} diff --git a/src/obidmscolumn.h b/src/obidmscolumn.h new file mode 100644 index 0000000..af97765 --- /dev/null +++ b/src/obidmscolumn.h @@ -0,0 +1,63 @@ +/**************************************************************************** + * OBIDMSColumn header file * + ****************************************************************************/ + +/** + * @file obidmscolumn.h + * @author Celine Mercier + * @date 12 May 2015 + * @brief Header file for the shared elements of all the OBIColumn structures. + */ + +#ifndef OBIDMSCOLUMN_H_ +#define OBIDMSCOLUMN_H_ + +#include +#include +#include +#include + +#include "obitypes.h" + +/** + * @brief Value separator in OBIDMSColumn files. + */ +static const char SEPARATOR = '\n'; + + +/** + * @brief Header size in OBIDMSColumn files. + */ +static const int HEADER_SIZE = 4096; + + +/** + * @brief Number of bytes to map + */ +static const int BUFFER_SIZE = 4; + + +/** + * @brief OBIColumnHeader structure. + */ + +typedef struct OBIDMSColumnHeader { + bool endyan_byte_order; /**< endyan byte order */ + int header_size_value; /**< size of the header: a multiple of PAGESIZE */ + bool file_status; /**< file status : 0 is Open and 1 is Closed */ + pid_t PID; /**< PID of the process that created the file and is + the only one allowed to modify it if it is open */ + int line_count; /**< number of lines of data */ + OBIType_t data_type; /**< type of the data */ + char* creation_date; /**< date of creation of the file */ + int version; /**< version of the OBIColumn */ + char* comments; /**< comments */ +} OBIDMSColumnHeader_t, *OBIDMSColumnHeader_p; + + +char* obi_map_read_only(int file, int start, int size); + +void obi_unmap(int size); + + +#endif /* OBIDMSCOLUMN_H_ */ diff --git a/src/obiintcolumn.h b/src/obiintcolumn.h deleted file mode 100644 index 9a380e6..0000000 --- a/src/obiintcolumn.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** - * OBIIntColumn header file * - ****************************************************************************/ - -/** - * @file obiintcolumn.h - * @author Celine Mercier - * @date 11 May 2015 - * @brief Header file for the OBIIntColumn structure. - */ - -#ifndef OBIINTCOLUMN_H_ -#define OBIINTCOLUMN_H_ - -#include -#include - -#include "obicolumn.h" - - -/** - * @brief OBIIntColumn stucture. - */ - -typedef struct OBIIntcolumn { - -} OBIIntColumn_t, *OBIIntColumn_p; - -/** - * @brief Reads a memory block from an OBIIntColumn file. - * - * @param OBIIntColumn The OBIColumn that should be read. - * @return A pointer on the first element of the block. - */ - -int* readMemoryBlock(int* OBIIntcolumn, int startingPosition, int memoryBlockSize); - - -/** - * @brief Writes a memory block line by line at the end of a file. - */ - -void writeMemoryBlock(int* OBIIntcolumn, int memoryBlockSize, char* fileName); - - -/** - * @brief Returns one line of an OBIColumn. - */ - -int readLine(int line); - - -/** - * @brief Creates a new file for a new version of the OBIColumn. - */ - -void newColumn(OBIIntcolumn* column); - - -/** - * @brief malloc for OBIIntColumn. - */ - -int* OBIIntMalloc(); - - -/** - * @brief realloc for OBIIntColumn. - */ - -int* OBIIntRealloc(); - - -/** - * @brief free for OBIIntColumn. - */ - -void OBIIntFree(); - - -#endif /* OBIINTCOLUMN_H_ */ diff --git a/src/obitypes.h b/src/obitypes.h new file mode 100644 index 0000000..96ce6c9 --- /dev/null +++ b/src/obitypes.h @@ -0,0 +1,50 @@ +/**************************************************************************** + * OBITypes header file * + ****************************************************************************/ + +/** + * @file obitypes.h + * @author Celine Mercier + * @date 18 May 2015 + * @brief Header file for the OBITypes. + */ + +#ifndef OBITYPES_H_ +#define OBITYPES_H_ + +#include + +#define OBIInt_NA (INT32_MIN) +#define OBIFloat_NA (NAN) +#define OBIIdx_NA (SIZE_MAX) + +/** + * @brief enum for the boolean OBIType. + */ + +typedef enum { + FALSE = 0, + TRUE = 1, + OBIBool_NA = 2 +} OBIBool_t, *OBIBool_p; /**< a boolean true/false value */ + + +/** + * @brief enum OBITypes for the data type of the OBIColumns. + */ + +typedef enum OBIType { + OBI_VOID = 0, /**< data type not specified */ + OBIInt_t, /**< a signed integer value (C type : int32_t) */ + OBIFloat_t, /**< a floating value (C type : double) */ + OBIChar_t, /**< a character (C type : char) */ + OBIIdx_t /**< an index in a data structure (C type : size_t) */ +} OBIType_t, *OBIType_p; + +typedef int32_t obiint_t; +typedef double obifloat_t; +typedef char obichar_t; +typedef size_t obiidx_t; + + +#endif /* OBITYPES_H_ */ diff --git a/test_data/count@0.odc b/test_data/count@0.odc new file mode 100644 index 0000000..69efd57 --- /dev/null +++ b/test_data/count@0.odc @@ -0,0 +1,8 @@ +............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... +2 +3 +1 +8 +4 +4 +2