kdb: guid encoding in c results in invalid serialization





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I'm trying to manipulate guid from C++. Whenever I attempt to serialize a guid, I get a null pointer.



U g={0};
auto k = ku(g);
auto p = ::b9(2, k);


First two lines are straight from the manual for creating a null guid. This will result in p == 0.



Really what I was attempting to do was creating a list of guid and then serializing:



k = ktn(UU, 3)
kU(k)[0] = <an instance of U with the g bytes initialized>
kU(k)[1] = <an instance of U with the g bytes initialized>
kU(k)[2] = <an instance of U with the g bytes initialized>


That did not work when attempting to serialize.










share|improve this question





























    0















    I'm trying to manipulate guid from C++. Whenever I attempt to serialize a guid, I get a null pointer.



    U g={0};
    auto k = ku(g);
    auto p = ::b9(2, k);


    First two lines are straight from the manual for creating a null guid. This will result in p == 0.



    Really what I was attempting to do was creating a list of guid and then serializing:



    k = ktn(UU, 3)
    kU(k)[0] = <an instance of U with the g bytes initialized>
    kU(k)[1] = <an instance of U with the g bytes initialized>
    kU(k)[2] = <an instance of U with the g bytes initialized>


    That did not work when attempting to serialize.










    share|improve this question

























      0












      0








      0








      I'm trying to manipulate guid from C++. Whenever I attempt to serialize a guid, I get a null pointer.



      U g={0};
      auto k = ku(g);
      auto p = ::b9(2, k);


      First two lines are straight from the manual for creating a null guid. This will result in p == 0.



      Really what I was attempting to do was creating a list of guid and then serializing:



      k = ktn(UU, 3)
      kU(k)[0] = <an instance of U with the g bytes initialized>
      kU(k)[1] = <an instance of U with the g bytes initialized>
      kU(k)[2] = <an instance of U with the g bytes initialized>


      That did not work when attempting to serialize.










      share|improve this question














      I'm trying to manipulate guid from C++. Whenever I attempt to serialize a guid, I get a null pointer.



      U g={0};
      auto k = ku(g);
      auto p = ::b9(2, k);


      First two lines are straight from the manual for creating a null guid. This will result in p == 0.



      Really what I was attempting to do was creating a list of guid and then serializing:



      k = ktn(UU, 3)
      kU(k)[0] = <an instance of U with the g bytes initialized>
      kU(k)[1] = <an instance of U with the g bytes initialized>
      kU(k)[2] = <an instance of U with the g bytes initialized>


      That did not work when attempting to serialize.







      kdb






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 26 '18 at 22:15









      PBelzilePBelzile

      735




      735
























          1 Answer
          1






          active

          oldest

          votes


















          2














          I believe you should be using 3 as the first argument to b9. For example:



          jmcmurray@homer ~/c $ more test.c
          #include"k.h"
          K f(K x)
          {
          K k = ktn(UU,3);I j=0;
          for(j=0;j<3;j++){
          U g={0};I i=0;
          for(i=j;i<j+16;i++){
          g.g[i] = (unsigned char)i;
          }
          kU(k)[0] = g;
          }
          return b9(3,k);
          }
          jmcmurray@homer ~/c $ gcc -shared -fPIC -DKXVER=3 test.c -o test.so
          jmcmurray@homer ~/c $ q
          KDB+ 3.5 2017.11.30 Copyright (C) 1993-2017 Kx Systems
          l64/ 8()core 16048MB jmcmurray homer.aquaq.co.uk 192.168.1.57 EXPIRE 2019.06.30 AquaQ #52428

          q)f:`:./test 2:(`f;1)
          q)f
          0x010000003e000000020003000000000002030405060708090a0b0c0d0e0f00ae67af727f000..
          q)-9!f
          00000203-0405-0607-0809-0a0b0c0d0e0f 001868af-727f-0000-6062-67af727f0000 a0a..
          q)


          Here I am able to return a serialised list of GUIDs from my shared object & deserialize on the q side. When I tried with 2 as in your example I got a 'type error when running the function in q.



          According to https://code.kx.com/q/interfaces/capiref/#b9-serialize 3 means




          unenumerate, compress, allow serialization of timespan and timestamp




          2 is the same without "compress". So I guess you must compress GUIDs?






          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53489936%2fkdb-guid-encoding-in-c-results-in-invalid-serialization%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            I believe you should be using 3 as the first argument to b9. For example:



            jmcmurray@homer ~/c $ more test.c
            #include"k.h"
            K f(K x)
            {
            K k = ktn(UU,3);I j=0;
            for(j=0;j<3;j++){
            U g={0};I i=0;
            for(i=j;i<j+16;i++){
            g.g[i] = (unsigned char)i;
            }
            kU(k)[0] = g;
            }
            return b9(3,k);
            }
            jmcmurray@homer ~/c $ gcc -shared -fPIC -DKXVER=3 test.c -o test.so
            jmcmurray@homer ~/c $ q
            KDB+ 3.5 2017.11.30 Copyright (C) 1993-2017 Kx Systems
            l64/ 8()core 16048MB jmcmurray homer.aquaq.co.uk 192.168.1.57 EXPIRE 2019.06.30 AquaQ #52428

            q)f:`:./test 2:(`f;1)
            q)f
            0x010000003e000000020003000000000002030405060708090a0b0c0d0e0f00ae67af727f000..
            q)-9!f
            00000203-0405-0607-0809-0a0b0c0d0e0f 001868af-727f-0000-6062-67af727f0000 a0a..
            q)


            Here I am able to return a serialised list of GUIDs from my shared object & deserialize on the q side. When I tried with 2 as in your example I got a 'type error when running the function in q.



            According to https://code.kx.com/q/interfaces/capiref/#b9-serialize 3 means




            unenumerate, compress, allow serialization of timespan and timestamp




            2 is the same without "compress". So I guess you must compress GUIDs?






            share|improve this answer




























              2














              I believe you should be using 3 as the first argument to b9. For example:



              jmcmurray@homer ~/c $ more test.c
              #include"k.h"
              K f(K x)
              {
              K k = ktn(UU,3);I j=0;
              for(j=0;j<3;j++){
              U g={0};I i=0;
              for(i=j;i<j+16;i++){
              g.g[i] = (unsigned char)i;
              }
              kU(k)[0] = g;
              }
              return b9(3,k);
              }
              jmcmurray@homer ~/c $ gcc -shared -fPIC -DKXVER=3 test.c -o test.so
              jmcmurray@homer ~/c $ q
              KDB+ 3.5 2017.11.30 Copyright (C) 1993-2017 Kx Systems
              l64/ 8()core 16048MB jmcmurray homer.aquaq.co.uk 192.168.1.57 EXPIRE 2019.06.30 AquaQ #52428

              q)f:`:./test 2:(`f;1)
              q)f
              0x010000003e000000020003000000000002030405060708090a0b0c0d0e0f00ae67af727f000..
              q)-9!f
              00000203-0405-0607-0809-0a0b0c0d0e0f 001868af-727f-0000-6062-67af727f0000 a0a..
              q)


              Here I am able to return a serialised list of GUIDs from my shared object & deserialize on the q side. When I tried with 2 as in your example I got a 'type error when running the function in q.



              According to https://code.kx.com/q/interfaces/capiref/#b9-serialize 3 means




              unenumerate, compress, allow serialization of timespan and timestamp




              2 is the same without "compress". So I guess you must compress GUIDs?






              share|improve this answer


























                2












                2








                2







                I believe you should be using 3 as the first argument to b9. For example:



                jmcmurray@homer ~/c $ more test.c
                #include"k.h"
                K f(K x)
                {
                K k = ktn(UU,3);I j=0;
                for(j=0;j<3;j++){
                U g={0};I i=0;
                for(i=j;i<j+16;i++){
                g.g[i] = (unsigned char)i;
                }
                kU(k)[0] = g;
                }
                return b9(3,k);
                }
                jmcmurray@homer ~/c $ gcc -shared -fPIC -DKXVER=3 test.c -o test.so
                jmcmurray@homer ~/c $ q
                KDB+ 3.5 2017.11.30 Copyright (C) 1993-2017 Kx Systems
                l64/ 8()core 16048MB jmcmurray homer.aquaq.co.uk 192.168.1.57 EXPIRE 2019.06.30 AquaQ #52428

                q)f:`:./test 2:(`f;1)
                q)f
                0x010000003e000000020003000000000002030405060708090a0b0c0d0e0f00ae67af727f000..
                q)-9!f
                00000203-0405-0607-0809-0a0b0c0d0e0f 001868af-727f-0000-6062-67af727f0000 a0a..
                q)


                Here I am able to return a serialised list of GUIDs from my shared object & deserialize on the q side. When I tried with 2 as in your example I got a 'type error when running the function in q.



                According to https://code.kx.com/q/interfaces/capiref/#b9-serialize 3 means




                unenumerate, compress, allow serialization of timespan and timestamp




                2 is the same without "compress". So I guess you must compress GUIDs?






                share|improve this answer













                I believe you should be using 3 as the first argument to b9. For example:



                jmcmurray@homer ~/c $ more test.c
                #include"k.h"
                K f(K x)
                {
                K k = ktn(UU,3);I j=0;
                for(j=0;j<3;j++){
                U g={0};I i=0;
                for(i=j;i<j+16;i++){
                g.g[i] = (unsigned char)i;
                }
                kU(k)[0] = g;
                }
                return b9(3,k);
                }
                jmcmurray@homer ~/c $ gcc -shared -fPIC -DKXVER=3 test.c -o test.so
                jmcmurray@homer ~/c $ q
                KDB+ 3.5 2017.11.30 Copyright (C) 1993-2017 Kx Systems
                l64/ 8()core 16048MB jmcmurray homer.aquaq.co.uk 192.168.1.57 EXPIRE 2019.06.30 AquaQ #52428

                q)f:`:./test 2:(`f;1)
                q)f
                0x010000003e000000020003000000000002030405060708090a0b0c0d0e0f00ae67af727f000..
                q)-9!f
                00000203-0405-0607-0809-0a0b0c0d0e0f 001868af-727f-0000-6062-67af727f0000 a0a..
                q)


                Here I am able to return a serialised list of GUIDs from my shared object & deserialize on the q side. When I tried with 2 as in your example I got a 'type error when running the function in q.



                According to https://code.kx.com/q/interfaces/capiref/#b9-serialize 3 means




                unenumerate, compress, allow serialization of timespan and timestamp




                2 is the same without "compress". So I guess you must compress GUIDs?







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 27 '18 at 12:55









                Jonathon McMurrayJonathon McMurray

                1,705319




                1,705319
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53489936%2fkdb-guid-encoding-in-c-results-in-invalid-serialization%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    To store a contact into the json file from server.js file using a class in NodeJS

                    Redirect URL with Chrome Remote Debugging Android Devices

                    Dieringhausen