luwak_file:create does not truncate file content?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

luwak_file:create does not truncate file content?

vuleetu
Hi,

   When i tried to use
  
   {ok, File} = luwak_file:create(Riak, <<"file1">>, dict:new()),
   Size = luwak_file:length(Riak, File),
   io:format("Size is ~p bytes~n", [Size]),
   {ok, _, File1} = luwak_io:put_range(Riak, File, 0, <<"1234567890">>),
   Size1 = luwak_file:length(Riak, File1),
   io:format("Size is ~p bytes~n", [Size1]),
   %%create this file again
   {ok, File2} = luwak_file:create(Riak, <<"file1">>, dict:new()),
   Size2 = luwak_file:length(Riak, File2),
   io:format("Size is ~p bytes~n", [Size2]),
   %%write data at pos 100 which is invalid offset, but it works, why?
   {ok, _, File3} = luwak_io:put_range(Riak, File2, 100, <<"abcdefg">>),
   Size3 = luwak_file:length(Riak, File3),
   io:format("Size is ~p bytes~n", [Size3]).


result:
  Size is 0 bytes
  Size is 10 bytes
  Size is 10 bytes
  Size is 107 bytes
  ok


I tried many times and found seems like as long as i did these operation using the same Riak connection, it will show results above. but when i used another Riak connection({ok, Riak} = riak:client_connect('[hidden email]').
), it will truncate file contents. Is this the supposed result?

Best regards
Fisher

_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|

Re: luwak_file:create does not truncate file content?

bryan-basho
Administrator
On Mon, Sep 26, 2011 at 1:04 AM, vuleetu <[hidden email]> wrote:
> I tried many times and found seems like as long as i did these operation
> using the same Riak connection, it will show results above. but when i used
> another Riak connection({ok, Riak} = riak:client_connect('riak@127.0.0.1').
> ), it will truncate file contents. Is this the supposed result?

Hi, Fisher.  I believe you have found a bug in the Luwak library
included with pre-1.0 Riak.  I think if you try the same experiment on
our latest 1.0 release candidate, you'll find that luwak_file:create/3
always creates a new zero-length file, as you expected.

-Bryan

_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com