Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mmap-able files #79

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
AC_PREREQ(2.61)

m4_define([PKG_VERSION_MAJOR], [0])
m4_define([PKG_VERSION_MINOR], [3])
m4_define([PKG_VERSION_PATCH], [1])
m4_define([PKG_VERSION_MINOR], [4])
m4_define([PKG_VERSION_PATCH], [0])

m4_define([required_libxml_version], [2.6.17])
m4_define([required_lttoolbox_version], [3.6.0])
m4_define([required_lttoolbox_version], [3.6.5])

AC_INIT([apertium-lex-tools], [PKG_VERSION_MAJOR.PKG_VERSION_MINOR.PKG_VERSION_PATCH], [apertium-stuff@lists.sourceforge.net])
AM_INIT_AUTOMAKE
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
h_sources = irstlm_ranker.h lrx_compiler.h lrx_processor.h multi_translator.h \
tagger_output_processor.h weight.h
tagger_output_processor.h binary_header.h
cc_sources = lrx_compiler.cc lrx_processor.cc multi_translator.cc \
tagger_output_processor.cc

Expand Down
54 changes: 54 additions & 0 deletions src/binary_header.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (C) 2021 Apertium
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <https://www.gnu.org/licenses/>.
*/

#ifndef _LRX_BINARY_HEADER_
#define _LRX_BINARY_HEADER_

#include <cstdint>
#include <lttoolbox/endian_util.h>

// Global lttoolbox features
constexpr char HEADER_LRX[4]{'A', 'L', 'R', 'X'};
enum LRX_FEATURES : uint64_t {
LRX_MMAP = (1ull << 0), // using mmap-compatible format rather than compressed format
LRX_UNKNOWN = (1ull << 1), // Features >= this are unknown, so throw an error; Inc this if more features are added
LRX_RESERVED = (1ull << 63), // If we ever reach this many feature flags, we need a flag to know how to extend beyond 64 bits
};

struct weight {
int32_t id;
char _pad[4]{};
double pisu;
};

inline void weight_to_le(weight& w) {
uint32_t id = static_cast<uint32_t>(w.id);
to_le_32(id);

uint64_t pisu = *reinterpret_cast<uint64_t*>(&w.pisu);
to_le_64(pisu);
}

inline void weight_from_le(weight& w) {
uint32_t id = static_cast<uint32_t>(w.id);
from_le_32(id);

uint64_t pisu = *reinterpret_cast<uint64_t*>(&w.pisu);
from_le_64(pisu);
}

#endif
Loading