Hello,
I'd like to create a ruby script that parses emails(that will grow with
volume) and I need to find a way to distinct which emails the script
touches. I can either rename the email after the script is done with it
or move it to another directory. Which would be a least costly operation
or are they both equal expensive?
Would you have any other suggestions for this problem?
The way I understand it is that when you rename or change directory you
are just changing the path. I will be using a linux box(ubuntu) and I
think the directories are stored in a tree structure in which rename
would be less expensive.
Thank you
···
--
Posted via http://www.ruby-forum.com/.
Assuming it's on the same filesystem, and you're using a real
filesystem format (ext2/3, xfs, jfs, etc), they should be almost
identical....
According to the docs on the File class though, it uses syscopy for
move, which seems odd to me, but the performance should be almost
identical.
--Kyle
Kyle Schmitt wrote:
Assuming it's on the same filesystem, and you're using a real
filesystem format (ext2/3, xfs, jfs, etc), they should be almost
identical....
According to the docs on the File class though, it uses syscopy for
move, which seems odd to me, but the performance should be almost
identical.
--Kyle
Hi Kyle,
I'm using ext filesystem. Why would they operations be identical? I
thought the directories are stored in a tree structure so wouldn't it
require another n(logn) operation to find a new directory during a move?
···
--
Posted via http://www.ruby-forum.com/.
Because moving and renaming files consist of the same operations.
To really really overly simplify it, moving a directory primarily
involves updating the directory, not every node under it.
I'm a bit busy to lookup papers on how it works, but do some googling
for how filesystems work.
Kyle Schmitt wrote:
Because moving and renaming files consist of the same operations.
To really really overly simplify it, moving a directory primarily
involves updating the directory, not every node under it.
I'm a bit busy to lookup papers on how it works, but do some googling
for how filesystems work.
Thanks, I'll do the research. I just neded to know of the costs 
···
--
Posted via http://www.ruby-forum.com/.
Just to add a bit more to this conversation, the only time an mv
operation would be more expensive is in the case of actually mv'ing
across filesystems. You could have mv'd a file from say your
/home/username directory on sda1 to /newhome/username on sda2 (two
physically different partitions). Strange that this would come up. I
think rename is mv with a cross filesystem limitation. I don't use
rename for anything in *nix, always has been mv.
···
On Tue, Jun 16, 2009 at 11:45 AM, Mrmaster Mrmaster<mrsolarlife@gmail.com> wrote:
Kyle Schmitt wrote:
Because moving and renaming files consist of the same operations.
To really really overly simplify it, moving a directory primarily
involves updating the directory, not every node under it.
I'm a bit busy to lookup papers on how it works, but do some googling
for how filesystems work.
Thanks, I'll do the research. I just neded to know of the costs 
--
Posted via http://www.ruby-forum.com/.
Historically (~15-20 years ago and prior) you couldn't do a mv across filesystems; at that time mv only changed the inode tables, it didn't do any copying of data. I think the first I ran into a mv which would work across filesystems was in the mid to late 90's.
Matt
···
On Wed, 17 Jun 2009, Phil Romero wrote:
Just to add a bit more to this conversation, the only time an mv
operation would be more expensive is in the case of actually mv'ing
across filesystems. You could have mv'd a file from say your
/home/username directory on sda1 to /newhome/username on sda2 (two
physically different partitions). Strange that this would come up. I
think rename is mv with a cross filesystem limitation. I don't use
rename for anything in *nix, always has been mv.
There is rename functionality in Ruby's standard library. Why bother to call some external command for this?
Kind regards
robert
···
On 17.06.2009 02:56, Mrmaster Mrmaster wrote:
Phil Romero wrote:
On Tue, Jun 16, 2009 at 11:45 AM, Mrmaster >> Mrmaster<mrsolarlife@gmail.com> wrote:
I think the rename command in the linux box calls a perl script too which will add to the cost.
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/