зеркало из https://github.com/github/vitess-gh.git
Updates per code review
This commit is contained in:
Родитель
329e730e9d
Коммит
77ce0aae08
|
@ -51,23 +51,12 @@ def exec_query(conn, title, query, response, keyspace=None, kr=None): # pylint:
|
|||
cursor.begin()
|
||||
cursor.execute(query, {})
|
||||
cursor.commit()
|
||||
# sanatize results (index columns are binary blobs)
|
||||
sanatized_results = list(
|
||||
map(
|
||||
lambda row:
|
||||
list(
|
||||
map(
|
||||
lambda column:
|
||||
str(column).decode('unicode_escape').encode('ascii','replace'),
|
||||
row)),
|
||||
cursor.results)
|
||||
)
|
||||
response[title] = {
|
||||
"title": title,
|
||||
"description": cursor.description,
|
||||
"rowcount": cursor.rowcount,
|
||||
"lastrowid": cursor.lastrowid,
|
||||
"results": sanatized_results,
|
||||
"results": cursor.results,
|
||||
}
|
||||
cursor.close()
|
||||
except Exception as e: # pylint: disable=broad-except
|
||||
|
@ -154,13 +143,13 @@ def main():
|
|||
conn, "name_info1",
|
||||
"select * from name_info", response, keyspace="user", kr="80-")
|
||||
|
||||
# music_user_idx table
|
||||
# music_keyspace_idx table
|
||||
exec_query(
|
||||
conn, "music_user_idx0",
|
||||
"select * from music_user_idx", response, keyspace="user", kr="-80")
|
||||
conn, "music_keyspace_idx0",
|
||||
"select music_id, hex(keyspace_id) from music_keyspace_idx", response, keyspace="user", kr="-80")
|
||||
exec_query(
|
||||
conn, "music_user_idx1",
|
||||
"select * from music_user_idx", response, keyspace="user", kr="80-")
|
||||
conn, "music_keyspace_idx1",
|
||||
"select music_id, hex(keyspace_id) from music_keyspace_idx", response, keyspace="user", kr="80-")
|
||||
|
||||
# lookup tables
|
||||
exec_query(
|
||||
|
@ -170,7 +159,7 @@ def main():
|
|||
conn, "music_seq", "select * from music_seq", response,
|
||||
keyspace="lookup", kr="-")
|
||||
exec_query(
|
||||
conn, "name_user_idx", "select * from name_user_idx", response,
|
||||
conn, "name_keyspace_idx", "select name, hex(keyspace_id) from name_keyspace_idx", response,
|
||||
keyspace="lookup", kr="-")
|
||||
|
||||
print json.dumps(response, default=decimal_default)
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
data-ng-include="'result.html'"></div>
|
||||
<div data-ng-repeat="curResult in [result.name_info0]"
|
||||
data-ng-include="'result.html'"></div>
|
||||
<div data-ng-repeat="curResult in [result.music_user_idx0]"
|
||||
<div data-ng-repeat="curResult in [result.music_keyspace_idx0]"
|
||||
data-ng-include="'result.html'"></div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
|
@ -73,7 +73,7 @@
|
|||
data-ng-include="'result.html'"></div>
|
||||
<div data-ng-repeat="curResult in [result.name_info1]"
|
||||
data-ng-include="'result.html'"></div>
|
||||
<div data-ng-repeat="curResult in [result.music_user_idx1]"
|
||||
<div data-ng-repeat="curResult in [result.music_keyspace_idx1]"
|
||||
data-ng-include="'result.html'"></div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
|
@ -81,7 +81,7 @@
|
|||
data-ng-include="'result.html'"></div>
|
||||
<div data-ng-repeat="curResult in [result.music_seq]"
|
||||
data-ng-include="'result.html'"></div>
|
||||
<div data-ng-repeat="curResult in [result.name_user_idx]"
|
||||
<div data-ng-repeat="curResult in [result.name_keyspace_idx]"
|
||||
data-ng-include="'result.html'"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -2,4 +2,4 @@ create table user_seq(id int, next_id bigint, cache bigint, primary key(id)) com
|
|||
insert into user_seq(id, next_id, cache) values(0, 1, 3);
|
||||
create table music_seq(id int, next_id bigint, cache bigint, primary key(id)) comment 'vitess_sequence';
|
||||
insert into music_seq(id, next_id, cache) values(0, 1, 2);
|
||||
create table name_user_idx(name varchar(128), user_id binary(8), primary key(name, user_id));
|
||||
create table name_keyspace_idx(name varchar(128), keyspace_id binary(8), primary key(name, keyspace_id));
|
||||
|
|
|
@ -7,6 +7,6 @@
|
|||
"music_seq": {
|
||||
"type": "sequence"
|
||||
},
|
||||
"name_user_idx": {}
|
||||
"name_keyspace_idx": {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,4 +3,4 @@ create table user_extra(user_id bigint, extra varchar(128), primary key(user_id)
|
|||
create table music(user_id bigint, music_id bigint, primary key(user_id, music_id));
|
||||
create table music_extra(music_id bigint, keyspace_id bigint unsigned, primary key(music_id));
|
||||
create table name_info(name varchar(128), info varchar(128), primary key(name));
|
||||
create table music_user_idx(music_id bigint not null auto_increment, user_id binary(8), primary key(music_id));
|
||||
create table music_keyspace_idx(music_id bigint not null auto_increment, keyspace_id binary(8), primary key(music_id));
|
||||
|
|
|
@ -7,21 +7,21 @@
|
|||
"unicode_loose_md5": {
|
||||
"type": "unicode_loose_md5"
|
||||
},
|
||||
"name_user_idx": {
|
||||
"name_keyspace_idx": {
|
||||
"type": "lookup",
|
||||
"params": {
|
||||
"table": "name_user_idx",
|
||||
"table": "name_keyspace_idx",
|
||||
"from": "name",
|
||||
"to": "user_id"
|
||||
"to": "keyspace_id"
|
||||
},
|
||||
"owner": "user"
|
||||
},
|
||||
"music_user_idx": {
|
||||
"music_keyspace_idx": {
|
||||
"type": "lookup_unique",
|
||||
"params": {
|
||||
"table": "music_user_idx",
|
||||
"table": "music_keyspace_idx",
|
||||
"from": "music_id",
|
||||
"to": "user_id"
|
||||
"to": "keyspace_id"
|
||||
},
|
||||
"owner": "music"
|
||||
},
|
||||
|
@ -38,7 +38,7 @@
|
|||
},
|
||||
{
|
||||
"column": "name",
|
||||
"name": "name_user_idx"
|
||||
"name": "name_keyspace_idx"
|
||||
}
|
||||
],
|
||||
"auto_increment": {
|
||||
|
@ -62,7 +62,7 @@
|
|||
},
|
||||
{
|
||||
"column": "music_id",
|
||||
"name": "music_user_idx"
|
||||
"name": "music_keyspace_idx"
|
||||
}
|
||||
],
|
||||
"auto_increment": {
|
||||
|
@ -74,7 +74,7 @@
|
|||
"column_vindexes": [
|
||||
{
|
||||
"column": "music_id",
|
||||
"name": "music_user_idx"
|
||||
"name": "music_keyspace_idx"
|
||||
},
|
||||
{
|
||||
"column": "keyspace_id",
|
||||
|
@ -90,7 +90,7 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"music_user_idx": {
|
||||
"music_keyspace_idx": {
|
||||
"column_vindexes": [
|
||||
{
|
||||
"column": "music_id",
|
||||
|
|
|
@ -37,10 +37,10 @@ func init() {
|
|||
}
|
||||
|
||||
//====================================================================
|
||||
// Warning: This Vindex is being depcreated in favor of Lookup
|
||||
// LookupHash defines a vindex that uses a lookup table.
|
||||
// The table is expected to define the id column as unique. It's
|
||||
// NonUnique and a Lookup.
|
||||
// Warning: This Vindex is being depcreated in favor of Lookup
|
||||
type LookupHash struct {
|
||||
name string
|
||||
lkp lookupInternal
|
||||
|
@ -134,10 +134,10 @@ func unhashList(ksids [][]byte) ([]sqltypes.Value, error) {
|
|||
|
||||
//====================================================================
|
||||
|
||||
// Warning: This Vindex is being depcreated in favor of LookupUnique
|
||||
// LookupHashUnique defines a vindex that uses a lookup table.
|
||||
// The table is expected to define the id column as unique. It's
|
||||
// Unique and a Lookup.
|
||||
// Warning: This Vindex is being depcreated in favor of LookupUnique
|
||||
type LookupHashUnique struct {
|
||||
name string
|
||||
lkp lookupInternal
|
||||
|
|
Загрузка…
Ссылка в новой задаче