Pro MySQL experts voice in open source phần 3

Tham khảo tài liệu 'pro mysql experts voice in open source phần 3', công nghệ thông tin, cơ sở dữ liệu phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 122 CHAPTER 4 MYSQL SYSTEM ARCHITECTURE The IO_CACHE structure is essentially a structure containing a built-in buffer which can be filled with record data However this buffer is a fixed size and so it can store only so many records. Functions throughout the MySQL system can use an IO_CACHE object to retrieve the data they need using the my_b_ functions like my_b_read which reads from the IO_CACHE internal buffer of records . But there s a problem. What happens when somebody wants the next record and IO_CACHE s buffer is full Does the calling program or function need to switch from using the IO_CACHE s buffer to something else that can read the needed records from disk No the caller of my_b_read does not. These macros in combination with IO_CACHE are sort of a built-in switching mechanism for other parts of the MySQL server to freely read data from a record cache but not worry about whether or not the data actually exists in memory. Does this sound strange Take a look at the definition for the my_b_read macro shown in Listing 4-2. Listing 4-2. my_b_read Macro define my_b_read info Buffer Count info - read_pos Count info - read_end memcpy Buffer info - read_pos size_t Count info - read_pos Count 0 info - read_function info Buffer Count Let s break it down to help you see the beauty in its simplicity. The info parameter is an IO_CACHE object. The Buffer parameter is a reference to some output storage used by the caller of my_b_read . You can consider the Count parameter to be the number of records that need to be read. The macro is simply a ternary operator that thing . my_b_read simply looks to see whether the request would read a record from before the end of the internal record buffer info - read_pos Count info - read_end . If so the function copies memcpy the needed records from the IO_CACHE record buffer into the Buffer output parameter. If not it calls the IO_CACHE read_function. This read function can be any of the read functions defined in mysys

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.