{"action":"created","comment":{"url":"https://api.github.com/repos/bendalab/NixView/pulls/comments/174118882","pull_request_review_id":103415208,"id":174118882,"diff_hunk":"@@ -0,0 +1,132 @@\n+#include \"loadthread.h\"\n+#include <QVector>\n+\n+\n+LoadThread::LoadThread(QObject *parent, unsigned int chunksize):\n+    QThread(parent) {\n+    abort = false;\n+    this->chunksize = chunksize;\n+}\n+\n+LoadThread::~LoadThread() {\n+    mutex.lock();\n+    abort = true;\n+    condition.wakeOne();\n+    mutex.unlock();\n+\n+    wait();\n+}\n+\n+\n+void LoadThread::run() {\n+    QVector<double> loadedData;\n+\n+    while(true) {\n+        mutex.lock();\n+        nix::DataArray array = this->array;\n+        nix::NDSize start = this->start;\n+        nix::NDSize extend = this->extend;\n+        unsigned int chunksize = this->chunksize;\n+        mutex.unlock();\n+\n+\n+        unsigned int dataLength = 1;\n+        int readDim =0;\n+        unsigned int offset = start[0];\n+        for (unsigned int i=0; i<extend.size(); i++) {\n+            if(extend[i] > 1) // extend has to define 1d data (all entries 1 exept for one)\n+                dataLength = extend[i];\n+                readDim = static_cast<int>(i);\n+                offset = start[i];\n+        }\n+\n+        int totalChunks;\n+        if( dataLength / chunksize == static_cast<double>(dataLength) / chunksize) {\n+            totalChunks = dataLength / chunksize;\n+        } else {\n+            totalChunks = dataLength / chunksize + 1;\n+        }\n+\n+        extend[readDim] = chunksize;\n+        QVector<double> chunkdata(chunksize);\n+        for (int i=0; i<totalChunks; i++) {\n+\n+            if(i == totalChunks-1) {\n+                extend[readDim] = (dataLength - (totalChunks-1) * chunksize);\n+                chunkdata.resize((dataLength - (totalChunks-1) * chunksize));\n+            }\n+            start[readDim] = offset + i * chunksize;\n+            array.getData(array.dataType(),chunkdata.data(),extend, start);\n+\n+            loadedData.append(chunkdata);\n+\n+            emit(progress(static_cast<double>(i)/totalChunks)); //starts with 0 ends with one step below 1\n+        }\n+\n+        emit dataReady(loadedData);\n+\n+        mutex.lock();\n+        condition.wait(&mutex);\n+        mutex.unlock();\n+        if(abort) {\n+            return;\n+        }\n+    }","path":"utils/loadthread.cpp","position":74,"original_position":74,"commit_id":"45eca05b0306201dbb022e41aa711bde71946440","original_commit_id":"45eca05b0306201dbb022e41aa711bde71946440","user":{"login":"jgrewe","id":772522,"avatar_url":"https://avatars2.githubusercontent.com/u/772522?v=4","gravatar_id":"","url":"https://api.github.com/users/jgrewe","html_url":"https://github.com/jgrewe","followers_url":"https://api.github.com/users/jgrewe/followers","following_url":"https://api.github.com/users/jgrewe/following{/other_user}","gists_url":"https://api.github.com/users/jgrewe/gists{/gist_id}","starred_url":"https://api.github.com/users/jgrewe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jgrewe/subscriptions","organizations_url":"https://api.github.com/users/jgrewe/orgs","repos_url":"https://api.github.com/users/jgrewe/repos","events_url":"https://api.github.com/users/jgrewe/events{/privacy}","received_events_url":"https://api.github.com/users/jgrewe/received_events","type":"User","site_admin":false},"body":"one could remove the if statement, if abort would be checked in the while loop","created_at":"2018-03-13T12:59:13Z","updated_at":"2018-03-13T12:59:24Z","html_url":"https://github.com/bendalab/NixView/pull/100#discussion_r174118882","pull_request_url":"https://api.github.com/repos/bendalab/NixView/pulls/100","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/bendalab/NixView/pulls/comments/174118882"},"html":{"href":"https://github.com/bendalab/NixView/pull/100#discussion_r174118882"},"pull_request":{"href":"https://api.github.com/repos/bendalab/NixView/pulls/100"}}},"pull_request":{"url":"https://api.github.com/repos/bendalab/NixView/pulls/100","id":173762490,"html_url":"https://github.com/bendalab/NixView/pull/100","diff_url":"https://github.com/bendalab/NixView/pull/100.diff","patch_url":"https://github.com/bendalab/NixView/pull/100.patch","issue_url":"https://api.github.com/repos/bendalab/NixView/issues/100","number":100,"state":"open","locked":false,"title":"new thread object that can load data from an Dataarray in the background","user":{"login":"Nyxas","id":30521779,"avatar_url":"https://avatars3.githubusercontent.com/u/30521779?v=4","gravatar_id":"","url":"https://api.github.com/users/Nyxas","html_url":"https://github.com/Nyxas","followers_url":"https://api.github.com/users/Nyxas/followers","following_url":"https://api.github.com/users/Nyxas/following{/other_user}","gists_url":"https://api.github.com/users/Nyxas/gists{/gist_id}","starred_url":"https://api.github.com/users/Nyxas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nyxas/subscriptions","organizations_url":"https://api.github.com/users/Nyxas/orgs","repos_url":"https://api.github.com/users/Nyxas/repos","events_url":"https://api.github.com/users/Nyxas/events{/privacy}","received_events_url":"https://api.github.com/users/Nyxas/received_events","type":"User","site_admin":false},"body":"now with feedback and loading in chunks of given size. ","created_at":"2018-03-08T15:14:12Z","updated_at":"2018-03-13T12:59:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"98600fc162335fd57a833f7702d0747464c4c227","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/bendalab/NixView/pulls/100/commits","review_comments_url":"https://api.github.com/repos/bendalab/NixView/pulls/100/comments","review_comment_url":"https://api.github.com/repos/bendalab/NixView/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bendalab/NixView/issues/100/comments","statuses_url":"https://api.github.com/repos/bendalab/NixView/statuses/45eca05b0306201dbb022e41aa711bde71946440","head":{"label":"Nyxas:lazy_lineplotter","ref":"lazy_lineplotter","sha":"45eca05b0306201dbb022e41aa711bde71946440","user":{"login":"Nyxas","id":30521779,"avatar_url":"https://avatars3.githubusercontent.com/u/30521779?v=4","gravatar_id":"","url":"https://api.github.com/users/Nyxas","html_url":"https://github.com/Nyxas","followers_url":"https://api.github.com/users/Nyxas/followers","following_url":"https://api.github.com/users/Nyxas/following{/other_user}","gists_url":"https://api.github.com/users/Nyxas/gists{/gist_id}","starred_url":"https://api.github.com/users/Nyxas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nyxas/subscriptions","organizations_url":"https://api.github.com/users/Nyxas/orgs","repos_url":"https://api.github.com/users/Nyxas/repos","events_url":"https://api.github.com/users/Nyxas/events{/privacy}","received_events_url":"https://api.github.com/users/Nyxas/received_events","type":"User","site_admin":false},"repo":{"id":98636828,"name":"NixView","full_name":"Nyxas/NixView","owner":{"login":"Nyxas","id":30521779,"avatar_url":"https://avatars3.githubusercontent.com/u/30521779?v=4","gravatar_id":"","url":"https://api.github.com/users/Nyxas","html_url":"https://github.com/Nyxas","followers_url":"https://api.github.com/users/Nyxas/followers","following_url":"https://api.github.com/users/Nyxas/following{/other_user}","gists_url":"https://api.github.com/users/Nyxas/gists{/gist_id}","starred_url":"https://api.github.com/users/Nyxas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nyxas/subscriptions","organizations_url":"https://api.github.com/users/Nyxas/orgs","repos_url":"https://api.github.com/users/Nyxas/repos","events_url":"https://api.github.com/users/Nyxas/events{/privacy}","received_events_url":"https://api.github.com/users/Nyxas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Nyxas/NixView","description":"Viewer for nix datafiles","fork":true,"url":"https://api.github.com/repos/Nyxas/NixView","forks_url":"https://api.github.com/repos/Nyxas/NixView/forks","keys_url":"https://api.github.com/repos/Nyxas/NixView/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Nyxas/NixView/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Nyxas/NixView/teams","hooks_url":"https://api.github.com/repos/Nyxas/NixView/hooks","issue_events_url":"https://api.github.com/repos/Nyxas/NixView/issues/events{/number}","events_url":"https://api.github.com/repos/Nyxas/NixView/events","assignees_url":"https://api.github.com/repos/Nyxas/NixView/assignees{/user}","branches_url":"https://api.github.com/repos/Nyxas/NixView/branches{/branch}","tags_url":"https://api.github.com/repos/Nyxas/NixView/tags","blobs_url":"https://api.github.com/repos/Nyxas/NixView/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Nyxas/NixView/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Nyxas/NixView/git/refs{/sha}","trees_url":"https://api.github.com/repos/Nyxas/NixView/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Nyxas/NixView/statuses/{sha}","languages_url":"https://api.github.com/repos/Nyxas/NixView/languages","stargazers_url":"https://api.github.com/repos/Nyxas/NixView/stargazers","contributors_url":"https://api.github.com/repos/Nyxas/NixView/contributors","subscribers_url":"https://api.github.com/repos/Nyxas/NixView/subscribers","subscription_url":"https://api.github.com/repos/Nyxas/NixView/subscription","commits_url":"https://api.github.com/repos/Nyxas/NixView/commits{/sha}","git_commits_url":"https://api.github.com/repos/Nyxas/NixView/git/commits{/sha}","comments_url":"https://api.github.com/repos/Nyxas/NixView/comments{/number}","issue_comment_url":"https://api.github.com/repos/Nyxas/NixView/issues/comments{/number}","contents_url":"https://api.github.com/repos/Nyxas/NixView/contents/{+path}","compare_url":"https://api.github.com/repos/Nyxas/NixView/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Nyxas/NixView/merges","archive_url":"https://api.github.com/repos/Nyxas/NixView/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Nyxas/NixView/downloads","issues_url":"https://api.github.com/repos/Nyxas/NixView/issues{/number}","pulls_url":"https://api.github.com/repos/Nyxas/NixView/pulls{/number}","milestones_url":"https://api.github.com/repos/Nyxas/NixView/milestones{/number}","notifications_url":"https://api.github.com/repos/Nyxas/NixView/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Nyxas/NixView/labels{/name}","releases_url":"https://api.github.com/repos/Nyxas/NixView/releases{/id}","deployments_url":"https://api.github.com/repos/Nyxas/NixView/deployments","created_at":"2017-07-28T10:03:05Z","updated_at":"2017-07-28T10:03:07Z","pushed_at":"2018-03-13T10:30:15Z","git_url":"git://github.com/Nyxas/NixView.git","ssh_url":"git@github.com:Nyxas/NixView.git","clone_url":"https://github.com/Nyxas/NixView.git","svn_url":"https://github.com/Nyxas/NixView","homepage":"http://bendalab.github.io/NixView","size":11024,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"bendalab:master","ref":"master","sha":"e272a705fa47fb86bca2534404445b10d25478f5","user":{"login":"bendalab","id":10567758,"avatar_url":"https://avatars0.githubusercontent.com/u/10567758?v=4","gravatar_id":"","url":"https://api.github.com/users/bendalab","html_url":"https://github.com/bendalab","followers_url":"https://api.github.com/users/bendalab/followers","following_url":"https://api.github.com/users/bendalab/following{/other_user}","gists_url":"https://api.github.com/users/bendalab/gists{/gist_id}","starred_url":"https://api.github.com/users/bendalab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bendalab/subscriptions","organizations_url":"https://api.github.com/users/bendalab/orgs","repos_url":"https://api.github.com/users/bendalab/repos","events_url":"https://api.github.com/users/bendalab/events{/privacy}","received_events_url":"https://api.github.com/users/bendalab/received_events","type":"Organization","site_admin":false},"repo":{"id":41813337,"name":"NixView","full_name":"bendalab/NixView","owner":{"login":"bendalab","id":10567758,"avatar_url":"https://avatars0.githubusercontent.com/u/10567758?v=4","gravatar_id":"","url":"https://api.github.com/users/bendalab","html_url":"https://github.com/bendalab","followers_url":"https://api.github.com/users/bendalab/followers","following_url":"https://api.github.com/users/bendalab/following{/other_user}","gists_url":"https://api.github.com/users/bendalab/gists{/gist_id}","starred_url":"https://api.github.com/users/bendalab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bendalab/subscriptions","organizations_url":"https://api.github.com/users/bendalab/orgs","repos_url":"https://api.github.com/users/bendalab/repos","events_url":"https://api.github.com/users/bendalab/events{/privacy}","received_events_url":"https://api.github.com/users/bendalab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bendalab/NixView","description":"Viewer for nix datafiles","fork":false,"url":"https://api.github.com/repos/bendalab/NixView","forks_url":"https://api.github.com/repos/bendalab/NixView/forks","keys_url":"https://api.github.com/repos/bendalab/NixView/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bendalab/NixView/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bendalab/NixView/teams","hooks_url":"https://api.github.com/repos/bendalab/NixView/hooks","issue_events_url":"https://api.github.com/repos/bendalab/NixView/issues/events{/number}","events_url":"https://api.github.com/repos/bendalab/NixView/events","assignees_url":"https://api.github.com/repos/bendalab/NixView/assignees{/user}","branches_url":"https://api.github.com/repos/bendalab/NixView/branches{/branch}","tags_url":"https://api.github.com/repos/bendalab/NixView/tags","blobs_url":"https://api.github.com/repos/bendalab/NixView/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bendalab/NixView/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bendalab/NixView/git/refs{/sha}","trees_url":"https://api.github.com/repos/bendalab/NixView/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bendalab/NixView/statuses/{sha}","languages_url":"https://api.github.com/repos/bendalab/NixView/languages","stargazers_url":"https://api.github.com/repos/bendalab/NixView/stargazers","contributors_url":"https://api.github.com/repos/bendalab/NixView/contributors","subscribers_url":"https://api.github.com/repos/bendalab/NixView/subscribers","subscription_url":"https://api.github.com/repos/bendalab/NixView/subscription","commits_url":"https://api.github.com/repos/bendalab/NixView/commits{/sha}","git_commits_url":"https://api.github.com/repos/bendalab/NixView/git/commits{/sha}","comments_url":"https://api.github.com/repos/bendalab/NixView/comments{/number}","issue_comment_url":"https://api.github.com/repos/bendalab/NixView/issues/comments{/number}","contents_url":"https://api.github.com/repos/bendalab/NixView/contents/{+path}","compare_url":"https://api.github.com/repos/bendalab/NixView/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bendalab/NixView/merges","archive_url":"https://api.github.com/repos/bendalab/NixView/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bendalab/NixView/downloads","issues_url":"https://api.github.com/repos/bendalab/NixView/issues{/number}","pulls_url":"https://api.github.com/repos/bendalab/NixView/pulls{/number}","milestones_url":"https://api.github.com/repos/bendalab/NixView/milestones{/number}","notifications_url":"https://api.github.com/repos/bendalab/NixView/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bendalab/NixView/labels{/name}","releases_url":"https://api.github.com/repos/bendalab/NixView/releases{/id}","deployments_url":"https://api.github.com/repos/bendalab/NixView/deployments","created_at":"2015-09-02T16:39:48Z","updated_at":"2017-09-25T08:25:16Z","pushed_at":"2018-03-13T10:30:17Z","git_url":"git://github.com/bendalab/NixView.git","ssh_url":"git@github.com:bendalab/NixView.git","clone_url":"https://github.com/bendalab/NixView.git","svn_url":"https://github.com/bendalab/NixView","homepage":"http://bendalab.github.io/NixView","size":11001,"stargazers_count":6,"watchers_count":6,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":6,"mirror_url":null,"archived":false,"open_issues_count":11,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":6,"open_issues":11,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bendalab/NixView/pulls/100"},"html":{"href":"https://github.com/bendalab/NixView/pull/100"},"issue":{"href":"https://api.github.com/repos/bendalab/NixView/issues/100"},"comments":{"href":"https://api.github.com/repos/bendalab/NixView/issues/100/comments"},"review_comments":{"href":"https://api.github.com/repos/bendalab/NixView/pulls/100/comments"},"review_comment":{"href":"https://api.github.com/repos/bendalab/NixView/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bendalab/NixView/pulls/100/commits"},"statuses":{"href":"https://api.github.com/repos/bendalab/NixView/statuses/45eca05b0306201dbb022e41aa711bde71946440"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"jgrewe"}}