Skip to content

user properties: clean up API#90

Merged
BusyJay merged 1 commit intomasterfrom
busyjay/cleanup-properties
Jul 7, 2017
Merged

user properties: clean up API#90
BusyJay merged 1 commit intomasterfrom
busyjay/cleanup-properties

Conversation

@BusyJay
Copy link
Copy Markdown
Member

@BusyJay BusyJay commented Jul 6, 2017

  • reduce allocation
  • collect lazily
  • strict access mode

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use make_unique().

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But make_unique is introduced in c++14?

@BusyJay BusyJay force-pushed the busyjay/cleanup-properties branch from e4dfd82 to 7cb2901 Compare July 6, 2017 08:37
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any style agreement on this?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clang-format with Google style

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. We should use librocksdb_sys/crocksdb/format-diff.sh to format c/c++ codes, which is adapted from rocksdb.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the same style with RocksDB.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but, I guess this may be a bug with the format tool 😓

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤣 I know. We've borrowed the format-diff script, but leaves out .clang-format config.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I myself use clang-format with google style as command line arguments, which is enough for this project.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andelf can you add the RocksDB clang format config?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copying the .clang-format from top dir of rocksdb solves

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need pub anymore :)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we return a TableProperties<'a> and keep the inner pointer here?
It's a bit of magic for me to figure out how this work.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's suitable that TableProperties contains a lifetime. Maybe we can rename it to TablePropertiesRef. But I believe &'a TableProperties is more clear and rusty than TablePropertiesRef. Actually I don't invent the magic by myself, both CStr and str are implemented via similar logic.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems this has already been discussed here, I think I'm OK with that.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better use c++ style cast

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe wrapping UserCollectedProperties struct is better.
Since we need fast index access for propties, not iterating over style access.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get it. UserCollectedProperties is a map, how do you access it via index?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

impl Index<&str> for it, wraps std::map operator[]

Copy link
Copy Markdown
Member Author

@BusyJay BusyJay Jul 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see. I thought you want to get (k, v) pair at specific position.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can iterate the map to avoid constructing the string?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It depends. I prefer using index access here.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it invokes copying the key here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. But it compare less.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems C++ 14 can find without constructing the string, can we use it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure. I prefer stick to C++ 11 for now since rocksdb itself still just require C++ 11. It may be surprising if the wrapper requires a newer version of compiler.

src/rocksdb.rs Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems not formatted here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I'm waiting Travis to tell me the exact code he likes.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should change to UserCollectedProperties?

@huachaohuang
Copy link
Copy Markdown

LGTM

@huachaohuang
Copy link
Copy Markdown

Btw, a len() method can be helpful.

@BusyJay
Copy link
Copy Markdown
Member Author

BusyJay commented Jul 7, 2017

@zhangjinpeng1987 @disksing @andelf PTAL

@huachaohuang
Copy link
Copy Markdown

A len() for TablePropertiesCollection, thanks.

@BusyJay BusyJay force-pushed the busyjay/cleanup-properties branch from b72feff to 7912996 Compare July 7, 2017 06:00
@disksing
Copy link
Copy Markdown

disksing commented Jul 7, 2017

LGTM

@BusyJay
Copy link
Copy Markdown
Member Author

BusyJay commented Jul 7, 2017

@huachaohuang PTAL

huachaohuang
huachaohuang previously approved these changes Jul 7, 2017
Copy link
Copy Markdown

@huachaohuang huachaohuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

- reduce allocation
- collect lazily
- strict access mode
Copy link
Copy Markdown
Member

@zhangjinpeng87 zhangjinpeng87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@BusyJay BusyJay merged commit a50c084 into master Jul 7, 2017
@BusyJay BusyJay deleted the busyjay/cleanup-properties branch July 7, 2017 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants