I want to build a shared table based on TableLink, any ideas ?

33 views
Skip to first unread message

wener

unread,
Mar 8, 2015, 2:19:05 PM3/8/15
to h2-da...@googlegroups.com
I want to use the h2 server to serve other database and shared them.

This what I think how to do this:

Create a subtype of LinkedIndex
Override the find,add,remove
Based on the pk column and chose a correct connect for the Row.

Any suggestions ?

What about the transactions, only use the in auto commit mode ?
What if there is no pk in Row, need a secondary index ?
What should I be careful ?

Thomas Mueller

unread,
Mar 9, 2015, 1:14:58 PM3/9/15
to h2-da...@googlegroups.com
Hi,

I'm not sure what features you want to add so I can't be certain, but I think it is possible.

I suggest to read all the documentation about linked tables. Then, you may want to read (part of) the implementation of that feature. It is probably more complex for what you need.

Regards,
Thomas

--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

wener

unread,
Mar 11, 2015, 9:39:54 PM3/11/15
to h2-da...@googlegroups.com
A shared table is only route the query to correct table,do not store any data.Shared by primary key, or use some secondary index.

But I got some problem here.
Select will not pass the limit and offset to TableLink, The result set will iterate to apply the limit and offset.when use TableLink,this is very expensive.Is this consider good ?

在 2015年3月10日星期二 UTC+8上午1:14:58,Thomas Mueller写道:
Hi,

I'm not sure what features you want to add so I can't be certain, but I think it is possible.

I suggest to read all the documentation about linked tables. Then, you may want to read (part of) the implementation of that feature. It is probably more complex for what you need.

Regards,
Thomas



On Sunday, March 8, 2015, wener <wene...@gmail.com> wrote:
I want to use the h2 server to serve other database and shared them.

This what I think how to do this:

Create a subtype of LinkedIndex
Override the find,add,remove
Based on the pk column and chose a correct connect for the Row.

Any suggestions ?

What about the transactions, only use the in auto commit mode ?
What if there is no pk in Row, need a secondary index ?
What should I be careful ?

--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database+unsubscribe@googlegroups.com.

Thomas Mueller

unread,
Mar 12, 2015, 2:44:21 AM3/12/15
to h2-da...@googlegroups.com
Hi,

Sorry I don't understand the use case.

A shared table is only route the query to correct table

What is a "shared table"? You want to "correct the table", or query "the correct table"? When do you know the table, and when don't you know it and why don't you know it?
 
,do not store any data.

You are trying to solve access right problems? That doesn't sound right.
 
Shared by primary key, or use some secondary index.

 Sorry I don't understand.

Maybe the problem is that English is not my first language. Maybe you write your query in your original language, and then we use Google translate (to translate it to my first language)?

Regards,
Thomas

wener

unread,
Mar 12, 2015, 3:23:47 AM3/12/15
to h2-da...@googlegroups.com
English is not my first language either. 😂



A table like this
user(id, name, phone, email)

I got three MySQL host a,b,c.
Shared by id, choose mysql[id%3] to save a row.

Use H2 as a middleware

Query -> H2 -> Choose One MySQL

e.g.

select * from user where id=1
This query will route to mysql[1%3 = 1] = b mysql host

select * from user where id=9
This will route to id mysql[9 % 3] = a mysql host




在 2015年3月12日星期四 UTC+8下午2:44:21,Thomas Mueller写道:

wener

unread,
Mar 12, 2015, 3:27:35 AM3/12/15
to h2-da...@googlegroups.com

select * from user where name = 'wener'

For this query, I can not direct choose MySQL host, I have to use my secondary index.
The secondary index is build by fetching the mysql binlog.
The index is used like a Map

id = index[name]

then, use this id to choose which mysql host I should route to.

Thomas Mueller

unread,
Apr 10, 2015, 12:03:04 PM4/10/15
to h2-da...@googlegroups.com
Hi,

I think you would need to implement your own TableEngine (see org.h2.api).

Regards,
Thomas
--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.

Wen er

unread,
Apr 15, 2015, 3:28:47 AM4/15/15
to h2-da...@googlegroups.com
Tanks, I do it in this way, but table engine only take charge of table and index, there is no engines for sequence or other schema object.

--
You received this message because you are subscribed to a topic in the Google Groups "H2 Database" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/h2-database/peIjL4WWrk0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to h2-database...@googlegroups.com.

To post to this group, send email to h2-da...@googlegroups.com.
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.



--
Wener~~~~~~~~
Reply all
Reply to author
Forward
0 new messages