Skip to content

Commit c389bd2

Browse files
spetruniaGunnar Kudrjavets
authored andcommitted
Issue #14: post-review fixes: spelling, better comments and variable names
Test Plan: N/A Reviewers: maykov, hermanlee4, yoshinorim, jonahcohen Reviewed By: jonahcohen Differential Revision: https://reviews.facebook.net/D33453
1 parent a024e82 commit c389bd2

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

storage/rocksdb/ha_rocksdb.cc

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,8 +1676,8 @@ void ha_rocksdb::convert_record_to_storage_format(rocksdb::Slice *packed_rec)
16761676

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

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

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

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

18831883
/*
18841884
Setup data needed to convert table->record[] to and from record storage format.
1885+
1886+
@seealso
1887+
ha_rocksdb::convert_record_to_storage_format,
1888+
ha_rocksdb::convert_record_from_storage_format
18851889
*/
18861890

18871891
void ha_rocksdb::setup_field_converters()
@@ -1896,7 +1900,7 @@ void ha_rocksdb::setup_field_converters()
18961900
for (i= 0; i < table->s->fields; i++)
18971901
{
18981902
Field *field= table->field[i];
1899-
field_enc[i].skip= false;
1903+
field_enc[i].dont_store= false;
19001904

19011905
/*
19021906
Check if this field is
@@ -1910,10 +1914,11 @@ void ha_rocksdb::setup_field_converters()
19101914
KEY *pk_info= &table->key_info[table->s->primary_key];
19111915
for (uint kp= 0; kp < pk_info->user_defined_key_parts; kp++)
19121916
{
1917+
/* key_part->fieldnr is counted from 1 */
19131918
if (field->field_index + 1 == pk_info->key_part[kp].fieldnr)
19141919
{
19151920
if (pk_descr->can_unpack(kp))
1916-
field_enc[i].skip= true; /* Don't store */
1921+
field_enc[i].dont_store= true;
19171922
break;
19181923
}
19191924
}

storage/rocksdb/ha_rocksdb.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,13 @@ class ha_rocksdb: public handler
197197
*/
198198
typedef struct st_field_encoder
199199
{
200-
/* skip=true means this is decodeable part of PK and so not stored */
201-
bool skip;
200+
/*
201+
This is set to true for columns of Primary Key that can be decoded from
202+
their mem-comparable form.
203+
Since we can get them from the key part of RocksDB key->value pair, we
204+
don't need to store them in the value part.
205+
*/
206+
bool dont_store;
202207

203208
uint null_offset;
204209
uchar null_mask; // 0 means the field cannot be null

storage/rocksdb/rdb_datadic.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,15 @@ class Stream_reader
5050
if (len)
5151
ptr= &str.at(0);
5252
else
53+
{
54+
/*
55+
One can a create a Stream_reader for reading from an empty string
56+
(although attempts to read anything will fail).
57+
We must not access str.at(0), since len==0, we can set ptr to any
58+
value.
59+
*/
5360
ptr= NULL;
61+
}
5462
}
5563

5664
explicit Stream_reader(const rocksdb::Slice *slice)

0 commit comments

Comments
 (0)