luwak_file:create does not truncate file content?

vuleetu vuleetu at
Mon Sep 26 01:04:53 EDT 2011


   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]).

  Size is 0 bytes
  Size is 10 bytes
  Size is 10 bytes
  Size is 107 bytes

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 at').
), it will truncate file contents. Is this the supposed result?

Best regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the riak-users mailing list