go-datastore icon indicating copy to clipboard operation
go-datastore copied to clipboard

Add a Rename method?

Open kevina opened this issue 7 years ago • 3 comments

The migration of the blockstore to multihashs only is going to require a massive renaming off a large number of keys. At least for the flatfs datastore, an important optimization is to rename the file rather than remove and insert a new key. The last time we did such a rename (https://github.com/ipfs/fs-repo-migrations/pull/39) we only had a single datastore config using flatfs so we special cased it. Now things are more complicated with badgerds this will be more difficult.

Is it worth it to provide a Rename method?

kevina avatar Oct 04 '18 19:10 kevina

Agreed, and I'd suggest implementing this more like a query as some datastores are likely to support prefix renames.

magik6k avatar Oct 05 '18 10:10 magik6k

Agreed, and I'd suggest implementing this more like a query as some datastores are likely to support prefix renames.

@magik6k can you clarify. I am not sure I am following. I am thinking something very simple and straight forward

  Rename(oldkey, newkey) error

kevina avatar Oct 05 '18 18:10 kevina

I was thinking about something that would work a bit like linux rename command, possibly restricted to prefix only. That would allow for a nice optimizations in some cases, like ipfs-ds-convert with more advanced datastores.

I'm fine with the basic version too, it might be better in that it will be easier to implement an optimized version for more datastores.

Just throwing ideas.

magik6k avatar Oct 06 '18 04:10 magik6k