Skip to content

Commit

Permalink
Issue #14: post-review fixes: spelling, better comments and variable …
Browse files Browse the repository at this point in the history
…names

Test Plan: N/A

Reviewers: maykov, hermanlee4, yoshinorim, jonahcohen

Reviewed By: jonahcohen

Differential Revision: https://reviews.facebook.net/D33453
  • Loading branch information
spetrunia authored and jtolmer committed Jan 5, 2016
1 parent bcfbb3a commit 456ed5a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
15 changes: 10 additions & 5 deletions storage/rocksdb/ha_rocksdb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1676,8 +1676,8 @@ void ha_rocksdb::convert_record_to_storage_format(rocksdb::Slice *packed_rec)

for (uint i=0; i < table->s->fields; i++)
{
/* Don't pack decode-able PK key parts */
if (field_enc[i].skip)
/* Don't pack decodable PK key parts */
if (field_enc[i].dont_store)
continue;

Field *field= table->field[i];
Expand Down Expand Up @@ -1782,7 +1782,7 @@ int ha_rocksdb::convert_record_from_storage_format(uchar * buf)

for (uint i=0; i < table->s->fields; i++)
{
if (field_enc[i].skip)
if (field_enc[i].dont_store)
continue;

Field *field= table->field[i];
Expand Down Expand Up @@ -1882,6 +1882,10 @@ int ha_rocksdb::convert_record_from_storage_format(uchar * buf)

/*
Setup data needed to convert table->record[] to and from record storage format.
@seealso
ha_rocksdb::convert_record_to_storage_format,
ha_rocksdb::convert_record_from_storage_format
*/

void ha_rocksdb::setup_field_converters()
Expand All @@ -1896,7 +1900,7 @@ void ha_rocksdb::setup_field_converters()
for (i= 0; i < table->s->fields; i++)
{
Field *field= table->field[i];
field_enc[i].skip= false;
field_enc[i].dont_store= false;

/*
Check if this field is
Expand All @@ -1910,10 +1914,11 @@ void ha_rocksdb::setup_field_converters()
KEY *pk_info= &table->key_info[table->s->primary_key];
for (uint kp= 0; kp < pk_info->user_defined_key_parts; kp++)
{
/* key_part->fieldnr is counted from 1 */
if (field->field_index + 1 == pk_info->key_part[kp].fieldnr)
{
if (pk_descr->can_unpack(kp))
field_enc[i].skip= true; /* Don't store */
field_enc[i].dont_store= true;
break;
}
}
Expand Down
9 changes: 7 additions & 2 deletions storage/rocksdb/ha_rocksdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,13 @@ class ha_rocksdb: public handler
*/
typedef struct st_field_encoder
{
/* skip=true means this is decodeable part of PK and so not stored */
bool skip;
/*
This is set to true for columns of Primary Key that can be decoded from
their mem-comparable form.
Since we can get them from the key part of RocksDB key->value pair, we
don't need to store them in the value part.
*/
bool dont_store;

uint null_offset;
uchar null_mask; // 0 means the field cannot be null
Expand Down
8 changes: 8 additions & 0 deletions storage/rocksdb/rdb_datadic.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,15 @@ class Stream_reader
if (len)
ptr= &str.at(0);
else
{
/*
One can a create a Stream_reader for reading from an empty string
(although attempts to read anything will fail).
We must not access str.at(0), since len==0, we can set ptr to any
value.
*/
ptr= NULL;
}
}

explicit Stream_reader(const rocksdb::Slice *slice)
Expand Down

0 comments on commit 456ed5a

Please sign in to comment.