Skip to content
Merged
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
3 changes: 2 additions & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ jobs:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
JASP_R_VERSION: '4.5.3'

steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v2
with:
r-version: 'release'
r-version: ${{ env.JASP_R_VERSION }}
- name: Get Installed R Version
run: echo "R_VERSION=$(R --version | head -n 1 | awk '{print $3}')" >> $GITHUB_ENV

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ jobs:
runs-on: windows-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
JASP_R_VERSION: '4.5.3'

name: build test on Windows

steps:

- uses: r-lib/actions/setup-r@v2
with:
r-version: 'release'
r-version: ${{ env.JASP_R_VERSION }}
windows-path-include-rtools: false
windows-path-include-mingw: true

Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ else()
USES_TERMINAL
COMMENT "------ Configuring and Building the libR-Interface")

add_dependencies(SyntaxInterface R-Interface)

endif()

if(NOT USE_QT_STATIC_LIBS)
Expand Down
4 changes: 4 additions & 0 deletions CommonData/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ target_link_libraries(

)

if(MSVC)
target_compile_options(CommonData PRIVATE /EHsc)
endif()

target_compile_definitions(
CommonData
PUBLIC $<$<BOOL:${JASP_PRINT_ENGINE_MESSAGES}>:PRINT_ENGINE_MESSAGES>
Expand Down
11 changes: 11 additions & 0 deletions CommonData/archivereader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ void ArchiveReader::writeEntryToTempFiles(std::function<void(float)> progressCal


std::ofstream file(TempFiles::createSpecific("", _entryPath).c_str(), std::ios::out | std::ios::binary);
if (!file.is_open())
throw runtime_error("Could not open temporary archive entry '" + _entryPath + "' for writing.");

static char streamBuff[8192 * 32];
file.rdbuf()->pubsetbuf(streamBuff, sizeof(streamBuff)); //Set the buffer manually to make it much faster our issue https://github.com/jasp-stats/INTERNAL-jasp/issues/436 and solution from: https://stackoverflow.com/a/15177770
Expand All @@ -130,10 +132,19 @@ void ArchiveReader::writeEntryToTempFiles(std::function<void(float)> progressCal

if(bytes > 0 && errorCode == 0) file.write(copyBuff, bytes);
else break;

if (!file.good())
throw runtime_error("Could not write temporary archive entry '" + _entryPath + "'.");
}
while (true);

if (errorCode != 0)
throw runtime_error("Could not read archive entry '" + _entryPath + "'.");

file.flush();
if (!file.good())
throw runtime_error("Could not flush temporary archive entry '" + _entryPath + "'.");

file.close();
}

Expand Down
2 changes: 1 addition & 1 deletion CommonData/databaseinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2479,7 +2479,7 @@ void DatabaseInterface::close()

_dbCheckMutex.unlock();

while(sqlite3_close(_dbCreated) != SQLITE_OK)
while(_dbCreated && sqlite3_close(_dbCreated) != SQLITE_OK)
{
std::this_thread::sleep_for(std::chrono::nanoseconds(10000000));
}
Expand Down
6 changes: 6 additions & 0 deletions CommonData/databridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ DataBridge::DataBridge(unsigned long sessionID, bool useMemory)
}
}

DataBridge::~DataBridge()
{
delete _dataSet;
_dataSet = nullptr;
}

void DataBridge::provideStateFileName(std::string & root, std::string & relativePath)
{
return TempFiles::createSpecific("state", _analysisId, root, relativePath);
Expand Down
5 changes: 5 additions & 0 deletions CommonData/databridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ class DataBridge
{
public:
DataBridge(unsigned long sessionID, bool useMemory = false);
~DataBridge();
DataBridge(const DataBridge &) = delete;
DataBridge & operator=(const DataBridge &) = delete;
DataBridge(DataBridge &&) = delete;
DataBridge & operator=(DataBridge &&) = delete;

std::string createColumn( const std::string & columnName, bool computed=false); ///< Returns encoded columnname on success or "" on failure (cause it already exists)
bool deleteColumn( const std::string & columnName);
Expand Down
12 changes: 11 additions & 1 deletion CommonData/rbridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ size_t _logWriteFunction(const void * buf, size_t len)
void rbridge_setDataBridge(DataBridge * dataBridge)
{
data_bridge = dataBridge;
rbridge_dataSet = nullptr;
}

void rbridge_clearDataBridge()
{
data_bridge = nullptr;
rbridge_dataSet = nullptr;
}

const std::string jaspBaseDistributionSamplersR =
Expand Down Expand Up @@ -149,6 +156,9 @@ void rbridge_init(DataBridge * dataBridge, sendFuncDef sendToDesktopFunction, po
jaspBaseTransformJohnsonR + "\n" +
jaspBaseTransformYeoJohnsonR + "\n" +
jaspBaseTransformPowerR;
// SyntaxInterface uses insideJasp=false for parse/dataset replay and only
// needs the native callbacks; the Engine still receives the full R helpers.
const char * initRCodeForMode = insideJasp ? initRCode.c_str() : "";

Log::log() << "Entering jaspRCPP_init." << std::endl;
jaspRCPP_init( AppInfo::getBuildYear() .c_str(),
Expand All @@ -162,7 +172,7 @@ void rbridge_init(DataBridge * dataBridge, sendFuncDef sendToDesktopFunction, po
rbridge_moduleLibraryFixer,
resultFont,
tempDirStatic.c_str(),
initRCode.c_str(),
initRCodeForMode,
insideJasp
);
JASPTIMER_STOP(jaspRCPP_init);
Expand Down
1 change: 1 addition & 0 deletions CommonData/rbridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ extern "C" {
typedef std::function<std::string (const std::string &, int progress)> RCallback;

void rbridge_setDataBridge(DataBridge * dataBridge);
void rbridge_clearDataBridge();
void rbridge_init(DataBridge * dataBridge, sendFuncDef sendToDesktopFunction, pollMessagesFuncDef pollMessagesFunction, ColumnEncoder * encoder, const char * resultFont, bool insideJasp = true);

void rbridge_memoryCleaning();
Expand Down
2 changes: 1 addition & 1 deletion QMLComponents/components/JASP/Controls/GridLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ QT.GridLayout

function _checkColumns()
{
if (!_initialized || (width === 0)) return;
if (!_initialized || width <= 0 || implicitWidth <= 0 || !isFinite(width) || !isFinite(implicitWidth)) return;

if (width < (implicitWidth - 1) && gridLayout.columns >= 2)
{
Expand Down
41 changes: 34 additions & 7 deletions QMLComponents/datasetprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,19 @@
#include "utilities/qutils.h"
#include "columnencoder.h"

#include <memory>

DataSetProvider * DataSetProvider::_singleton = nullptr;

DataSetProvider* DataSetProvider::getProvider(bool inMemory, bool reset, QObject* parent)
{
if (!_singleton)
_singleton = new DataSetProvider(inMemory, parent);
else if (_singleton->_inMemory != inMemory)
{
delete _singleton;
_singleton = new DataSetProvider(inMemory, parent);
}
else if (reset)
_singleton->resetDataSet();

Expand All @@ -41,7 +48,7 @@ DataSetProvider::~DataSetProvider()
_singleton = nullptr;
}

DataSetProvider::DataSetProvider(bool inMemory, QObject *parent) : QAbstractTableModel(parent)
DataSetProvider::DataSetProvider(bool inMemory, QObject *parent) : QAbstractTableModel(parent), _inMemory(inMemory)
{
_db = new DatabaseInterface(true, inMemory);
_dataSet = new DataSet();
Expand All @@ -52,13 +59,15 @@ DataSetProvider::DataSetProvider(bool inMemory, QObject *parent) : QAbstractTabl

void DataSetProvider::resetDataSet()
{
beginResetModel();
if (_dataSet)
{
_dataSet->dbDelete();
delete _dataSet;
}

_dataSet = new DataSet();
endResetModel();
}

int DataSetProvider::rowCount(const QModelIndex &) const
Expand Down Expand Up @@ -113,18 +122,36 @@ void DataSetProvider::loadDataSet(const std::map<std::string, stringvec > & data

}

void DataSetProvider::closeDatabase()
{
_db->close();
}

void DataSetProvider::loadDatabase(const Version & jaspVersion)
{
beginResetModel();
delete _dataSet;
_dataSet = nullptr;

_db->close();
_db->load();
_db->upgradeDBFromVersion(jaspVersion);
try
{
_db->close();
_db->load();
_db->upgradeDBFromVersion(jaspVersion);

_dataSet = new DataSet(0); // Setting 0 for "do nothing" because otherwise we can't pass on jaspVersion
_dataSet->dbLoad(1, [](float p) {}, jaspVersion);
std::unique_ptr<DataSet> loadedDataSet(new DataSet(0)); // Setting 0 for "do nothing" because otherwise we can't pass on jaspVersion
loadedDataSet->dbLoad(1, [](float p) {}, jaspVersion);

ColumnEncoder::columnEncoder()->setCurrentNames(_dataSet->getColumnTypesMap());
_dataSet = loadedDataSet.release();
ColumnEncoder::columnEncoder()->setCurrentNames(_dataSet->getColumnTypesMap());
endResetModel();
}
catch (...)
{
_dataSet = new DataSet();
endResetModel();
throw;
}
}

QVariantList DataSetProvider::_getDoubleList(Column * column) const
Expand Down
2 changes: 2 additions & 0 deletions QMLComponents/datasetprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class DataSetProvider : public QAbstractTableModel, public VariableInfoProvider
QVariant data( const QModelIndex & index, int role = Qt::DisplayRole) const override;

void loadDataSet(const std::map<std::string, stringvec > & dataSet, int threshold = 10, bool orderLabelsByValue = true);
void closeDatabase();
void loadDatabase(const Version & jaspVersion);

QVariant provideInfo(VariableInfo::InfoType info, const QString& colName = "", int row = 0) const override;
Expand All @@ -59,6 +60,7 @@ class DataSetProvider : public QAbstractTableModel, public VariableInfoProvider

DatabaseInterface * _db = nullptr;
DataSet * _dataSet = nullptr;
bool _inMemory = true;

};

Expand Down
Loading
Loading