GitHub PullRequestReviewCommentEvent at 2014-03-31 10:17:56
Repository: HPCC-Platform
Actor: richardkchapman
Payload: {"comment":{"url":"https://api.github.com/repos/hpcc-systems/HPCC-Platform/pulls/comments/11109925","id":11109925,"diff_hunk":"@@ -17271,6 +17285,110 @@ class CRoxieServerLookupJoinActivity : public CRoxieServerTwoInputActivity\n         static unsigned const BadIndex;\n     };\n \n+    class ManyLookupTable : public LookupTable\n+    {\n+    public:\n+        ManyLookupTable(ConstPointerArray &rightRows, IHThorHashJoinArg &helper)\n+        : LookupTable(helper)\n+        {\n+            rightRows.swapWith(rowtable);\n+            UInt64Array groups;\n+            unsigned numRows = rowtable.length();\n+            if (rowtable.length())\n+            {\n+                unsigned groupStart = 0;\n+                const void *groupStartRow = rowtable.item(0);\n+                for(unsigned i=1; i < numRows; i++)\n+                {\n+                    const void *thisRow = rowtable.item(i);\n+                    if (rightCompare->docompare(groupStartRow, thisRow))\n+                    {\n+                        groups.append(makeint64(groupStart, i-groupStart));\n+                        groupStart = i;\n+                        groupStartRow = thisRow;\n+                    }\n+                }\n+                groups.append(makeint64(groupStart, numRows-groupStart));\n+            }\n+            unsigned minsize = (4*groups.length())/3;\n+            size = 2;\n+            while((minsize >>= 1) > 0)\n+                size <<= 1;\n+            mask = size - 1;\n+            table = (__uint64 *) calloc(size, sizeof(__uint64)); // This should probably be allocated from roxiemem\n+            ForEachItemIn(idx, groups)\n+            {\n+                unsigned __int64 group = groups.item(idx);\n+                unsigned groupstart = high(group);\n+                unsigned grouplen = low(group);\n+                const void *row = rowtable.item(groupstart);\n+                add(row, group);\n+            }\n+        }\n+\n+        ~ManyLookupTable()\n+        {\n+            ForEachItemIn(idx, rowtable)\n+            {\n+                ReleaseRoxieRow(rowtable.item(idx));\n+            }\n+            free(table);\n+        }\n+\n+        void add(const void *row, unsigned __int64 group)\n+        {\n+            unsigned start = rightHash->hash(row) & mask;\n+            unsigned index = start;\n+            while(table[index])\n+            {\n+                index++;\n+                if(index==size)\n+                    index = 0;\n+                if(index==start)\n+                    throwUnexpected(); //table is full, should never happen\n+            }\n+            table[index] = group;\n+        }\n+\n+        virtual const void *find(const void * left) const\n+        {\n+            unsigned fstart = leftHash->hash(left) & mask;\n+            unsigned findex = fstart;\n+            while(table[findex])\n+            {\n+                __uint64 group = table[findex];\n+                currentMatch = high(group);","path":"roxie/ccd/ccdserver.cpp","position":193,"original_position":193,"commit_id":"4f7803914e97223fa915c93bfb188071d30508a2","original_commit_id":"4f7803914e97223fa915c93bfb188071d30508a2","user":{"login":"richardkchapman","id":900820,"avatar_url":"https://avatars.githubusercontent.com/u/900820?","gravatar_id":"f77b71ad942cb913583ecf4d79e083d0","url":"https://api.github.com/users/richardkchapman","html_url":"https://github.com/richardkchapman","followers_url":"https://api.github.com/users/richardkchapman/followers","following_url":"https://api.github.com/users/richardkchapman/following{/other_user}","gists_url":"https://api.github.com/users/richardkchapman/gists{/gist_id}","starred_url":"https://api.github.com/users/richardkchapman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richardkchapman/subscriptions","organizations_url":"https://api.github.com/users/richardkchapman/orgs","repos_url":"https://api.github.com/users/richardkchapman/repos","events_url":"https://api.github.com/users/richardkchapman/events{/privacy}","received_events_url":"https://api.github.com/users/richardkchapman/received_events","type":"User","site_admin":false},"body":"It might, depending on how smart the compiler is, how many registers are available and how the chip cache works. But the code would be less clear. I think such optimizations are better left to the c++ compiler.","created_at":"2014-03-31T10:17:56Z","updated_at":"2014-03-31T10:17:56Z","html_url":"https://github.com/hpcc-systems/HPCC-Platform/pull/5579#discussion_r11109925","pull_request_url":"https://api.github.com/repos/hpcc-systems/HPCC-Platform/pulls/5579","_links":{"self":{"href":"https://api.github.com/repos/hpcc-systems/HPCC-Platform/pulls/comments/11109925"},"html":{"href":"https://github.com/hpcc-systems/HPCC-Platform/pull/5579#discussion_r11109925"},"pull_request":{"href":"https://api.github.com/repos/hpcc-systems/HPCC-Platform/pulls/5579"}}}}