@ -2605,14 +2605,25 @@ void DBImpl::MultiGet(const ReadOptions& read_options, const size_t num_keys,
ColumnFamilyHandle * * column_families , const Slice * keys ,
ColumnFamilyHandle * * column_families , const Slice * keys ,
PinnableSlice * values , Status * statuses ,
PinnableSlice * values , Status * statuses ,
const bool sorted_input ) {
const bool sorted_input ) {
return MultiGet ( read_options , num_keys , column_families , keys , values ,
MultiGet ( read_options , num_keys , column_families , keys , values ,
/*timestamps=*/ nullptr , statuses , sorted_input ) ;
/* timestamps */ nullptr , statuses , sorted_input ) ;
}
}
void DBImpl : : MultiGet ( const ReadOptions & read_options , const size_t num_keys ,
void DBImpl : : MultiGet ( const ReadOptions & read_options , const size_t num_keys ,
ColumnFamilyHandle * * column_families , const Slice * keys ,
ColumnFamilyHandle * * column_families , const Slice * keys ,
PinnableSlice * values , std : : string * timestamps ,
PinnableSlice * values , std : : string * timestamps ,
Status * statuses , const bool sorted_input ) {
Status * statuses , const bool sorted_input ) {
MultiGetCommon ( read_options , num_keys , column_families , keys , values ,
/* columns */ nullptr , timestamps , statuses , sorted_input ) ;
}
void DBImpl : : MultiGetCommon ( const ReadOptions & read_options ,
const size_t num_keys ,
ColumnFamilyHandle * * column_families ,
const Slice * keys , PinnableSlice * values ,
PinnableWideColumns * columns ,
std : : string * timestamps , Status * statuses ,
const bool sorted_input ) {
if ( num_keys = = 0 ) {
if ( num_keys = = 0 ) {
return ;
return ;
}
}
@ -2658,8 +2669,20 @@ void DBImpl::MultiGet(const ReadOptions& read_options, const size_t num_keys,
autovector < KeyContext * , MultiGetContext : : MAX_BATCH_SIZE > sorted_keys ;
autovector < KeyContext * , MultiGetContext : : MAX_BATCH_SIZE > sorted_keys ;
sorted_keys . resize ( num_keys ) ;
sorted_keys . resize ( num_keys ) ;
for ( size_t i = 0 ; i < num_keys ; + + i ) {
for ( size_t i = 0 ; i < num_keys ; + + i ) {
values [ i ] . Reset ( ) ;
PinnableSlice * val = nullptr ;
key_context . emplace_back ( column_families [ i ] , keys [ i ] , & values [ i ] ,
PinnableWideColumns * col = nullptr ;
if ( values ) {
val = & values [ i ] ;
val - > Reset ( ) ;
} else {
assert ( columns ) ;
col = & columns [ i ] ;
col - > Reset ( ) ;
}
key_context . emplace_back ( column_families [ i ] , keys [ i ] , val , col ,
timestamps ? & timestamps [ i ] : nullptr ,
timestamps ? & timestamps [ i ] : nullptr ,
& statuses [ i ] ) ;
& statuses [ i ] ) ;
}
}
@ -2783,8 +2806,8 @@ void DBImpl::MultiGet(const ReadOptions& read_options,
ColumnFamilyHandle * column_family , const size_t num_keys ,
ColumnFamilyHandle * column_family , const size_t num_keys ,
const Slice * keys , PinnableSlice * values ,
const Slice * keys , PinnableSlice * values ,
Status * statuses , const bool sorted_input ) {
Status * statuses , const bool sorted_input ) {
return MultiGet ( read_options , column_family , num_keys , keys , values ,
MultiGet ( read_options , column_family , num_keys , keys , values ,
/*timestamp=*/ nullptr , statuses , sorted_input ) ;
/* timestamps */ nullptr , statuses , sorted_input ) ;
}
}
void DBImpl : : MultiGet ( const ReadOptions & read_options ,
void DBImpl : : MultiGet ( const ReadOptions & read_options ,
@ -2792,6 +2815,16 @@ void DBImpl::MultiGet(const ReadOptions& read_options,
const Slice * keys , PinnableSlice * values ,
const Slice * keys , PinnableSlice * values ,
std : : string * timestamps , Status * statuses ,
std : : string * timestamps , Status * statuses ,
const bool sorted_input ) {
const bool sorted_input ) {
MultiGetCommon ( read_options , column_family , num_keys , keys , values ,
/* columns */ nullptr , timestamps , statuses , sorted_input ) ;
}
void DBImpl : : MultiGetCommon ( const ReadOptions & read_options ,
ColumnFamilyHandle * column_family ,
const size_t num_keys , const Slice * keys ,
PinnableSlice * values , PinnableWideColumns * columns ,
std : : string * timestamps , Status * statuses ,
bool sorted_input ) {
if ( tracer_ ) {
if ( tracer_ ) {
// TODO: This mutex should be removed later, to improve performance when
// TODO: This mutex should be removed later, to improve performance when
// tracing is enabled.
// tracing is enabled.
@ -2805,8 +2838,20 @@ void DBImpl::MultiGet(const ReadOptions& read_options,
autovector < KeyContext * , MultiGetContext : : MAX_BATCH_SIZE > sorted_keys ;
autovector < KeyContext * , MultiGetContext : : MAX_BATCH_SIZE > sorted_keys ;
sorted_keys . resize ( num_keys ) ;
sorted_keys . resize ( num_keys ) ;
for ( size_t i = 0 ; i < num_keys ; + + i ) {
for ( size_t i = 0 ; i < num_keys ; + + i ) {
values [ i ] . Reset ( ) ;
PinnableSlice * val = nullptr ;
key_context . emplace_back ( column_family , keys [ i ] , & values [ i ] ,
PinnableWideColumns * col = nullptr ;
if ( values ) {
val = & values [ i ] ;
val - > Reset ( ) ;
} else {
assert ( columns ) ;
col = & columns [ i ] ;
col - > Reset ( ) ;
}
key_context . emplace_back ( column_family , keys [ i ] , val , col ,
timestamps ? & timestamps [ i ] : nullptr ,
timestamps ? & timestamps [ i ] : nullptr ,
& statuses [ i ] ) ;
& statuses [ i ] ) ;
}
}
@ -2968,8 +3013,17 @@ Status DBImpl::MultiGetImpl(
uint64_t bytes_read = 0 ;
uint64_t bytes_read = 0 ;
for ( size_t i = start_key ; i < start_key + num_keys - keys_left ; + + i ) {
for ( size_t i = start_key ; i < start_key + num_keys - keys_left ; + + i ) {
KeyContext * key = ( * sorted_keys ) [ i ] ;
KeyContext * key = ( * sorted_keys ) [ i ] ;
assert ( key ) ;
assert ( key - > s ) ;
if ( key - > s - > ok ( ) ) {
if ( key - > s - > ok ( ) ) {
bytes_read + = key - > value - > size ( ) ;
if ( key - > value ) {
bytes_read + = key - > value - > size ( ) ;
} else {
assert ( key - > columns ) ;
bytes_read + = key - > columns - > serialized_size ( ) ;
}
num_found + + ;
num_found + + ;
}
}
}
}
@ -2993,6 +3047,22 @@ Status DBImpl::MultiGetImpl(
return s ;
return s ;
}
}
void DBImpl : : MultiGetEntity ( const ReadOptions & options , size_t num_keys ,
ColumnFamilyHandle * * column_families ,
const Slice * keys , PinnableWideColumns * results ,
Status * statuses , bool sorted_input ) {
MultiGetCommon ( options , num_keys , column_families , keys , /* values */ nullptr ,
results , /* timestamps */ nullptr , statuses , sorted_input ) ;
}
void DBImpl : : MultiGetEntity ( const ReadOptions & options ,
ColumnFamilyHandle * column_family , size_t num_keys ,
const Slice * keys , PinnableWideColumns * results ,
Status * statuses , bool sorted_input ) {
MultiGetCommon ( options , column_family , num_keys , keys , /* values */ nullptr ,
results , /* timestamps */ nullptr , statuses , sorted_input ) ;
}
Status DBImpl : : CreateColumnFamily ( const ColumnFamilyOptions & cf_options ,
Status DBImpl : : CreateColumnFamily ( const ColumnFamilyOptions & cf_options ,
const std : : string & column_family ,
const std : : string & column_family ,
ColumnFamilyHandle * * handle ) {
ColumnFamilyHandle * * handle ) {