Comments (4)
Hi. Could you try the search again with index.debug = true? Also, could you provide a more complete sample of what you're trying to do, especially e.g. how you initialized "index"? It looks like somewhere it's trying to use page 0 as an index page, which it is not.
from innodb_ruby.
I'm following the examples at http://blog.jcole.us/2013/01/14/efficiently-traversing-innodb-btrees-with-the-page-directory/
Bender:test root# irb -rrubygems -rinnodb
>> space = Innodb::Space.new("mytable.ibd")
=> #<Innodb::Space:0x1024f94c8 @file=#<File:mytable.ibd>, @record_describer=nil, @pages=10752, @size=176160768, @page_size=16384, @fsp={:space_id=>1, :free_inodes=>#<Innodb::List::Inode:0x1024de858 @space=#<Innodb::Space:0x1024f94c8 ...>, @base={:length=>1, :first=>{:offset=>38, :page=>2}, :last=>{:offset=>38, :page=>2}}>, :unused=>0, :free_frag=>#<Innodb::List::Xdes:0x1024e4870 @space=#<Innodb::Space:0x1024f94c8 ...>, @base={:length=>1, :first=>{:offset=>198, :page=>0}, :last=>{:offset=>198, :page=>0}}>, :free_limit=>10304, :full_frag=>#<Innodb::List::Xdes:0x1024e2ef8 @space=#<Innodb::Space:0x1024f94c8 ...>, @base={:length=>1, :first=>{:offset=>158, :page=>0}, :last=>{:offset=>158, :page=>0}}>, :frag_n_used=>40, :size=>10752, :first_unused_seg=>5, :free=>#<Innodb::List::Xdes:0x1024e8308 @space=#<Innodb::Space:0x1024f94c8 ...>, @base={:length=>2, :first=>{:offset=>6518, :page=>0}, :last=>{:offset=>6558, :page=>0}}>, :full_inodes=>#<Innodb::List::Inode:0x1024e1b20 @space=#<Innodb::Space:0x1024f94c8 ...>, @base={:length=>0, :first=>nil, :last=>nil}>, :flags=>{:page_size=>16384, :compressed=>false, :value=>0}}, @compressed=false>
>> index = space.index(3)
=> #<Innodb::Index:0x1024d5a00 @root=#<Innodb::Page::Index: size=16384, space_id=1, offset=3, type=INDEX, prev=nil, next=nil>, @stats={}, @space=#<Innodb::Space:0x1024f94c8 @file=#<File:mytable.ibd>, @record_describer=nil, @pages=10752, @size=176160768, @page_size=16384, @fsp={:space_id=>1, :free_inodes=>#<Innodb::List::Inode:0x1024de858 @space=#<Innodb::Space:0x1024f94c8 ...>, @base={:length=>1, :first=>{:offset=>38, :page=>2}, :last=>{:offset=>38, :page=>2}}>, :unused=>0, :free_frag=>#<Innodb::List::Xdes:0x1024e4870 @space=#<Innodb::Space:0x1024f94c8 ...>, @base={:length=>1, :first=>{:offset=>198, :page=>0}, :last=>{:offset=>198, :page=>0}}>, :free_limit=>10304, :full_frag=>#<Innodb::List::Xdes:0x1024e2ef8 @space=#<Innodb::Space:0x1024f94c8 ...>, @base={:length=>1, :first=>{:offset=>158, :page=>0}, :last=>{:offset=>158, :page=>0}}>, :frag_n_used=>40, :size=>10752, :first_unused_seg=>5, :free=>#<Innodb::List::Xdes:0x1024e8308 @space=#<Innodb::Space:0x1024f94c8 ...>, @base={:length=>2, :first=>{:offset=>6518, :page=>0}, :last=>{:offset=>6558, :page=>0}}>, :full_inodes=>#<Innodb::List::Inode:0x1024e1b20 @space=#<Innodb::Space:0x1024f94c8 ...>, @base={:length=>0, :first=>nil, :last=>nil}>, :flags=>{:page_size=>16384, :compressed=>false, :value=>0}}, @compressed=false>, @debug=false>
>> index.debug = true
=> true
>> index.binary_search([10000])
binary_search: root=3, level=2, key=(10000)
binary_search_by_directory: page=3, level=2, dir.size=1, dir[0]=()
NoMethodError: undefined method `join' for nil:NilClass
from /Library/Ruby/Gems/1.8/gems/innodb_ruby-0.7.11/lib/innodb/index.rb:193:in `linear_search_from_cursor'
from /Library/Ruby/Gems/1.8/gems/innodb_ruby-0.7.11/lib/innodb/index.rb:264:in `binary_search_by_directory'
from /Library/Ruby/Gems/1.8/gems/innodb_ruby-0.7.11/lib/innodb/index.rb:366:in `binary_search'
from (irb):4
>>
And here's the create table
mysql> SHOW CREATE TABLE mytable\G
*************************** 1. row ***************************
Table: mytable
Create Table: CREATE TABLE `mytable` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`words` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `words` (`words`)
) ENGINE=InnoDB AUTO_INCREMENT=721353 DEFAULT CHARSET=utf8
1 row in set (0.00 sec)
from innodb_ruby.
Ah, you are missing a record_describer. You will need to create a Ruby class that describes how to parse records. Unfortunately the binary_search method does not check that a record describer exists, so it aborts in a kind of weird place. I'll fix that up to be more friendly.
This post has an example of a record describer, but unfortunately they are not really documented:
http://blog.jcole.us/2013/01/10/btree-index-structures-in-innodb/
This describer will probably work for the PRIMARY KEY of your table:
class Innodb::RecordDescriber::MyTable < Innodb::RecordDescriber
def self.cursor_sendable_description(page)
{
:type => :clustered,
:key => [
[:INT, :UNSIGNED, :NOT_NULL],
],
:row => [
["CHAR(255)", :NOT_NULL],
],
}
end
end
from innodb_ruby.
That did the trick. Thanks much!
from innodb_ruby.
Related Issues (20)
- undo-history-summary, NoMethodError HOT 1
- Add support for MariaDB 10.5 / 10.6 HOT 1
- Can this tool be used on MacOS?
- Error when invoke secondary index "record-dump"
- Unable to parse data files from MySQL 8.0 HOT 3
- Freed root index page should be skipped
- undefined method `fsp_header' HOT 1
- Errno::ENOENT HOT 1
- Errno::ENOENT
- Add support for Serialized Dictionary Information (SDI) in MySQL 8.0
- Add support for new LOB storage in MySQL 8.0
- Add support for new ZLOB storage in MySQL 8.0
- innodb_space record-dump fails with undefined method error HOT 2
- innodb_space run error: BinData requires ruby >= 1.9.3 HOT 1
- mysql8.0 support HOT 3
- On a clean Ruby 2.7.1p83 install on Windows 10 (64-bit), when I run I get this error: HOT 1
- Any plan to support MySQL8.0? HOT 2
- space-extents-illustrate produce undefined method `ibuf_index?' HOT 1
- Incorrect path for output file in space-index-pages-free-plot mode HOT 3
- Add support for MySQL 8.0 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from innodb_ruby.