{"action":"created","issue":{"url":"https://api.github.com/repos/aerospike/aerospike-client-php/issues/40","labels_url":"https://api.github.com/repos/aerospike/aerospike-client-php/issues/40/labels{/name}","comments_url":"https://api.github.com/repos/aerospike/aerospike-client-php/issues/40/comments","events_url":"https://api.github.com/repos/aerospike/aerospike-client-php/issues/40/events","html_url":"https://github.com/aerospike/aerospike-client-php/issues/40","id":68058327,"number":40,"title":"Use BLOB type for serializing params for UDF function","user":{"login":"bpaquet","id":337117,"avatar_url":"https://avatars.githubusercontent.com/u/337117?v=3","gravatar_id":"","url":"https://api.github.com/users/bpaquet","html_url":"https://github.com/bpaquet","followers_url":"https://api.github.com/users/bpaquet/followers","following_url":"https://api.github.com/users/bpaquet/following{/other_user}","gists_url":"https://api.github.com/users/bpaquet/gists{/gist_id}","starred_url":"https://api.github.com/users/bpaquet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bpaquet/subscriptions","organizations_url":"https://api.github.com/users/bpaquet/orgs","repos_url":"https://api.github.com/users/bpaquet/repos","events_url":"https://api.github.com/users/bpaquet/events{/privacy}","received_events_url":"https://api.github.com/users/bpaquet/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/aerospike/aerospike-client-php/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":{"login":"rbotzer","id":133497,"avatar_url":"https://avatars.githubusercontent.com/u/133497?v=3","gravatar_id":"","url":"https://api.github.com/users/rbotzer","html_url":"https://github.com/rbotzer","followers_url":"https://api.github.com/users/rbotzer/followers","following_url":"https://api.github.com/users/rbotzer/following{/other_user}","gists_url":"https://api.github.com/users/rbotzer/gists{/gist_id}","starred_url":"https://api.github.com/users/rbotzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbotzer/subscriptions","organizations_url":"https://api.github.com/users/rbotzer/orgs","repos_url":"https://api.github.com/users/rbotzer/repos","events_url":"https://api.github.com/users/rbotzer/events{/privacy}","received_events_url":"https://api.github.com/users/rbotzer/received_events","type":"User","site_admin":false},"milestone":null,"comments":2,"created_at":"2015-04-13T09:53:08Z","updated_at":"2015-04-14T06:45:42Z","closed_at":null,"body":"Is there a way to always use blob serialization when calling an UDF function ?\r\n"},"comment":{"url":"https://api.github.com/repos/aerospike/aerospike-client-php/issues/comments/92651655","html_url":"https://github.com/aerospike/aerospike-client-php/issues/40#issuecomment-92651655","issue_url":"https://api.github.com/repos/aerospike/aerospike-client-php/issues/40","id":92651655,"user":{"login":"bpaquet","id":337117,"avatar_url":"https://avatars.githubusercontent.com/u/337117?v=3","gravatar_id":"","url":"https://api.github.com/users/bpaquet","html_url":"https://github.com/bpaquet","followers_url":"https://api.github.com/users/bpaquet/followers","following_url":"https://api.github.com/users/bpaquet/following{/other_user}","gists_url":"https://api.github.com/users/bpaquet/gists{/gist_id}","starred_url":"https://api.github.com/users/bpaquet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bpaquet/subscriptions","organizations_url":"https://api.github.com/users/bpaquet/orgs","repos_url":"https://api.github.com/users/bpaquet/repos","events_url":"https://api.github.com/users/bpaquet/events{/privacy}","received_events_url":"https://api.github.com/users/bpaquet/received_events","type":"User","site_admin":false},"created_at":"2015-04-14T06:45:42Z","updated_at":"2015-04-14T06:45:42Z","body":"Mmh, my question were not very good.\n\nSo.\nI'm using aerospike as redis drop in. Goal : no modification in client code.\nFor that, I'have written this small wrapper\nhttps://github.com/bpaquet/aerospike_redis_php\n\nThe only problem I have is for storing gzcompress string into aerospike.\nWith redis, I can do $r->set('toto', gzcompress(big_json));\nWith aerospike too, bit the string is truncated at first NULL.\n\nI have read the 'known problem' of the readme, but custom serializer code\nseems to not be used with UDF.\nI have try to unpack('C*') the string to force the drive to use bytes\narray, but it perform very slowly, and I get  some memory overflow.\n\nThe only workaround I have is to base64 encode the gzcompress string :(\n\nAny better idea ?\n\nOn Tue, Apr 14, 2015 at 3:45 AM, Ronen Botzer <notifications@github.com>\nwrote:\n\n> Yes, you can create pack bytes into a PHP string, pass that as the\n> argument to the record UDF, cast it to bytes(), then inspect bytes as\n> meaningful params. You'll use API methods in Aerospike's bytes Lua module\n> <http://www.aerospike.com/docs/udf/api/bytes.html>.\n>\n> Assume you have registered the following UDF module as example_bytes_udf:\n>\n> function inspect_bytes_input(rec, input)\n>     local bytes_input = bytes(32)\n>     bytes.append_string(bytes_input, input)\n>     local ret = map()\n>     ret['size'] = bytes.size(bytes_input)\n>     ret['type'] = bytes.get_type(bytes_input)\n>     ret['byte1'] = bytes.get_byte(bytes_input, 1)\n>     ret['byte2'] = bytes.get_byte(bytes_input, 2)\n>     ret['byte3'] = bytes.get_byte(bytes_input, 3)\n>     ret['byte4'] = bytes.get_byte(bytes_input, 4)\n>     return retend\n>\n> I can call this from PHP as follows:\n>\n> $db->apply($key, \"example_bytes_udf\", \"inspect_bytes_input\", array(\"moo\\7x\\7\"), $ret_val);var_dump($ret_val);\n>\n> And I get the following:\n>\n> array(6) {\n>   [\"size\"]=>\n>   int(6)\n>   [\"byte1\"]=>\n>   int(109)\n>   [\"byte2\"]=>\n>   int(111)\n>   [\"byte3\"]=>\n>   int(111)\n>   [\"byte4\"]=>\n>   int(7)\n>   [\"type\"]=>\n>   int(4)\n> }\n>\n> Which means it sees 6 chars in the input (two of them are the \\7 bell\n> character), inspecting individual bytes shows the expected values in each\n> position, and the input is an as_bytes of type 'generic'.\n>\n> I hope that helps.\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/aerospike/aerospike-client-php/issues/40#issuecomment-92555868>\n> .\n>\n"}}