Skip to content

Adding getDbSize functionality#135

Open
manishankarbalu wants to merge 2 commits into
flipkart-incubator:masterfrom
manishankarbalu:db-size-functionality
Open

Adding getDbSize functionality#135
manishankarbalu wants to merge 2 commits into
flipkart-incubator:masterfrom
manishankarbalu:db-size-functionality

Conversation

@manishankarbalu

Copy link
Copy Markdown

No description provided.

}

func (bdb *badgerDB) GetKeySpaceSize() (int64, error) {
return 0, nil

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Comment thread pkg/serverpb/api.proto
rpc CompareAndSet (CompareAndSetRequest) returns (CompareAndSetResponse);

//GetKeySpaceSize returns the estimated number of keys the db
rpc GetKeySpaceSize (google.protobuf.Empty) returns (KeySpaceSizeResponse);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Can be renamed to GetKeySpaceCount to avoid ambiguity between size and count, as most lsm based stores uses term size to denote mem/disk used in bytes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IMO we should have consistency in name of the exposed command and the rpc method name.

* This methods returns the approximate count of keys in the DKV database
* @return retunrn the count of keys
*/
long getDbSize();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We don't need to add get as a prefix as its implicit that dBSize is a read-only operation

Comment thread cmd/dkvctl/main.go
{"removeNode", "<nexusUrl>", "Remove a master node from DKV cluster", (*cmd).removeNode, "", false},
{"listNodes", "", "Lists the various DKV nodes that are part of the Nexus cluster", (*cmd).listNodes, "", true},
{"getClusterInfo", "<dcId> <database> <vBucket>", "Gets the latest cluster info", (*cmd).getStatus, "", true},
{"getDbSize", "", "Fetches the approximate count of keys in the db", (*cmd).getDbSize, "", true},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same here, let's name this as dbsize to simplify.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also why is it approximate?

Comment thread internal/storage/store.go
// If the expected value is `nil`, then the key is created and
// initialized with the given value, atomically.
CompareAndSet(key, expect, update []byte) (bool, error)
//GetKeySpaceSize returns the estimated number of keys the db

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this estimated?

}

func (ms *memStore) GetKeySpaceSize() (int64, error) {
return 0, nil

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This could be the count of keys in the db.

Comment thread pkg/serverpb/api.proto
// Status indicates the result of the Get operation
Status status = 1;
//Estimated number of keys in the db
int64 dbSize = 2;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

could be simply size or count

}

func (rdb *rocksDB) GetKeySpaceSize() (int64, error) {
defer rdb.opts.statsCli.Timing("rocksdb.property.latency.dbSize", time.Now())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The metric name doesn't match function name. Let's be consistent.

Comment thread pkg/serverpb/api.proto
Status status = 1;
//Estimated number of keys in the db
int64 dbSize = 2;
} No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Empty line at end of file missing.

Comment thread pkg/ctl/client.go
}

// GetDbSize returns the approximate count of the number of the keys in the db
func (dkvClnt *DKVClient) GetDbSize() (*serverpb.KeySpaceSizeResponse, error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could be better named as DBSize


@Override
public long getDbSize() {
//TODO: implement this behaviour

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Probably this shouldn't even be exposed to java client unless its an exact value.

Comment thread pkg/serverpb/api.proto
rpc CompareAndSet (CompareAndSetRequest) returns (CompareAndSetResponse);

//GetKeySpaceSize returns the estimated number of keys the db
rpc GetKeySpaceSize (google.protobuf.Empty) returns (KeySpaceSizeResponse);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IMO we should have consistency in name of the exposed command and the rpc method name.

@kingster kingster linked an issue Mar 23, 2022 that may be closed by this pull request
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.

Implement dbsize as a command

3 participants