bool indri::file::BulkBlock::getIndex( int index, char* key, int& keyActual, int keyLength, char* value, int& valueActual, int valueLength ) { int count = *(UINT16*) _buffer; keyActual = 0; valueActual = 0; if( index < 0 || index >= count ) return false; if( key ) { int keyStart = _keyStart( index ); int keyEnd = _keyEnd( index ); keyActual = lemur_compat::min( keyEnd - keyStart, keyLength ); memcpy( key, _buffer + keyStart, keyActual ); } if( value ) { int valueStart = _valueStart( index ); int valueEnd = _valueEnd( index ); valueActual = lemur_compat::min( valueEnd - valueStart, valueLength ); memcpy( value, _buffer + valueStart, valueActual ); } return true; }
inline int indri::file::BulkBlock::_keyStart( int index ) { return _valueEnd( index-1 ); }
inline int indri::file::BulkBlock::_dataEnd() { return _valueEnd( count()-1 ); }
inline int indri::file::BulkBlock::_keyStart(int index) { return _valueEnd(index - 1); // key start of index equals with value end of index - 1 }