Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
lektor
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Kubat
lektor
Validations
daa46f15
Vérifiée
Valider
daa46f15
rédigé
5 years ago
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Use the init function for search add and search insert commands
parent
0fc43780
Aucune branche associée trouvée
Branches contenant la validation
Aucune étiquette associée trouvée
Étiquettes contenant la validation
1 requête de fusion
!71
Resolve "Performance of search commands"
Modifications
3
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
3 fichiers modifiés
inc/lektor/database.h
+11
-8
11 ajouts, 8 suppressions
inc/lektor/database.h
src/commands.c
+7
-2
7 ajouts, 2 suppressions
src/commands.c
src/database/find.c
+8
-4
8 ajouts, 4 suppressions
src/database/find.c
avec
26 ajouts
et
14 suppressions
inc/lektor/database.h
+
11
−
8
Voir le fichier @
daa46f15
...
@@ -88,23 +88,26 @@ struct lkt_search {
...
@@ -88,23 +88,26 @@ struct lkt_search {
lkt_add_queue
,
lkt_add_queue
,
}
type
;
}
type
;
bool
(
*
init
)(
vo
latile
sqlite3
*
);
/* Called at the end of the init phase */
void
(
*
init
)(
vo
id
);
/* Called at the end of the init phase */
void
(
*
call
)(
void
);
/* Called during the iter phase, casted */
void
(
*
call
)(
void
);
/* Called during the iter phase, casted */
struct
lkt_state
*
srv
;
struct
lkt_state
*
srv
;
size_t
c
;
size_t
c
;
long
continuation
;
/* The continuation state of the client */
long
continuation
;
/* The continuation state of the client */
int
msg_count
;
/* How much messages we can send */
int
msg_count
;
/* How much messages we can send */
const
char
*
name
;
/* Stickers and playlists */
const
char
*
name
;
/* Stickers and playlists */
union
{
union
{
int
qu_priority
;
/* Can be used... where the priority is needed! */
int
qu_priority
;
/* Can be used... where the priority is needed! */
int
st_value
;
/* The value of a sticker */
int
st_value
;
/* The value of a sticker */
};
};
int
st_uri
;
/* URI of a sticker */
int
st_uri
;
/* URI of a sticker */
struct
lkt_uri
*
qu_uri
;
/* Kara uri for a queue init function */
};
};
typedef
bool
(
*
lkt_search_init_add_func
)(
volatile
sqlite3
*
,
struct
lkt_uri
*
,
int
);
typedef
bool
(
*
lkt_search_database_func
)(
struct
lkt_state
*
srv
,
size_t
c
,
int
id
,
int
id_len
,
const
char
*
row
);
typedef
bool
(
*
lkt_search_database_func
)(
struct
lkt_state
*
srv
,
size_t
c
,
int
id
,
int
id_len
,
const
char
*
row
);
typedef
bool
(
*
lkt_search_queue_func
)
(
struct
lkt_state
*
srv
,
size_t
c
,
int
id
,
int
id_len
,
const
char
*
row
);
typedef
bool
(
*
lkt_search_sticker_func
)
(
struct
lkt_state
*
srv
,
size_t
c
,
const
char
*
sticker
,
const
char
*
type
,
int
uri
,
int
value
);
typedef
bool
(
*
lkt_search_sticker_func
)
(
struct
lkt_state
*
srv
,
size_t
c
,
const
char
*
sticker
,
const
char
*
type
,
int
uri
,
int
value
);
bool
database_search_database_init
(
volatile
sqlite3
*
db
,
char
*
col_name
,
char
*
rgx
,
struct
lkt_search
*
ret
);
bool
database_search_database_init
(
volatile
sqlite3
*
db
,
char
*
col_name
,
char
*
rgx
,
struct
lkt_search
*
ret
);
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
src/commands.c
+
7
−
2
Voir le fichier @
daa46f15
...
@@ -420,10 +420,16 @@ __find(struct lkt_state *srv, size_t c, char *cmd_args[LKT_MESSAGE_ARGS_MAX], lo
...
@@ -420,10 +420,16 @@ __find(struct lkt_state *srv, size_t c, char *cmd_args[LKT_MESSAGE_ARGS_MAX], lo
break
;
break
;
case
LKT_FND_ACT_ENQUEUE
:
case
LKT_FND_ACT_ENQUEUE
:
search
.
call
=
(
void
(
*
)(
void
))
lkt_callback_send_row_v2
;
search
.
call
=
(
void
(
*
)(
void
))
lkt_callback_send_row_v2
;
search
.
init
=
(
void
(
*
)(
void
))
database_queue_add_uri
;
search
.
type
=
lkt_add_queue
;
search
.
qu_priority
=
5
;
srv
->
mpd_idle_events
|=
MPD_IDLE_PLAYLIST
;
srv
->
mpd_idle_events
|=
MPD_IDLE_PLAYLIST
;
break
;
break
;
case
LKT_FND_ACT_ADD
:
case
LKT_FND_ACT_ADD
:
search
.
call
=
(
void
(
*
)(
void
))
lkt_callback_send_row_v2
;
search
.
call
=
(
void
(
*
)(
void
))
lkt_callback_send_row_v2
;
search
.
init
=
(
void
(
*
)(
void
))
database_queue_add_uri
;
search
.
qu_priority
=
1
;
search
.
type
=
lkt_add_queue
;
srv
->
mpd_idle_events
|=
MPD_IDLE_PLAYLIST
;
srv
->
mpd_idle_events
|=
MPD_IDLE_PLAYLIST
;
break
;
break
;
default:
default:
...
@@ -433,8 +439,7 @@ __find(struct lkt_state *srv, size_t c, char *cmd_args[LKT_MESSAGE_ARGS_MAX], lo
...
@@ -433,8 +439,7 @@ __find(struct lkt_state *srv, size_t c, char *cmd_args[LKT_MESSAGE_ARGS_MAX], lo
/* Select the right column */
/* Select the right column */
mpd_tag
=
cmd_args
[
0
];
mpd_tag
=
cmd_args
[
0
];
if
(
!
strcasecmp
(
"any"
,
mpd_tag
)
||
!
strcasecmp
(
"all"
,
mpd_tag
)
||
!
strcasecmp
(
"query"
,
mpd_tag
))
if
(
!
strcasecmp
(
"any"
,
mpd_tag
)
||
!
strcasecmp
(
"all"
,
mpd_tag
)
||
!
strcasecmp
(
"a"
,
mpd_tag
))
col_name
=
LKT_DATABASE_KARA_COLUMNT_ANY
;
col_name
=
LKT_DATABASE_KARA_COLUMNT_ANY
;
else
if
(
!
strcasecmp
(
"author"
,
mpd_tag
))
else
if
(
!
strcasecmp
(
"author"
,
mpd_tag
))
col_name
=
LKT_DATABASE_NAME_KAUTHOR
;
col_name
=
LKT_DATABASE_NAME_KAUTHOR
;
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
src/database/find.c
+
8
−
4
Voir le fichier @
daa46f15
...
@@ -11,16 +11,16 @@
...
@@ -11,16 +11,16 @@
static
inline
bool
static
inline
bool
__init_search
(
volatile
sqlite3
*
db
,
struct
lkt_search
*
ret
)
__init_search
(
volatile
sqlite3
*
db
,
struct
lkt_search
*
ret
)
{
{
UNUSED
(
db
)
;
bool
sta
=
false
;
switch
(
ret
->
type
)
{
switch
(
ret
->
type
)
{
case
lkt_add_queue
:
case
lkt_add_queue
:
/* Use the add uri */
sta
=
((
lkt_search_init_add_func
)
ret
->
init
)(
db
,
ret
->
qu_uri
,
ret
->
qu_priority
);
ret
urn
fals
e
;
ret
->
type
=
lkt_search_queu
e
;
default:
default:
LOG_WARN_SCT
(
"DB"
,
"Init for type %d is not implemented"
,
ret
->
type
);
LOG_WARN_SCT
(
"DB"
,
"Init for type %d is not implemented"
,
ret
->
type
);
return
false
;
return
false
;
}
}
return
false
;
return
sta
;
}
}
bool
bool
...
@@ -145,6 +145,10 @@ database_search_iter(struct lkt_search *item)
...
@@ -145,6 +145,10 @@ database_search_iter(struct lkt_search *item)
id_len
=
sqlite3_column_int
(
item
->
stmt
,
2
);
id_len
=
sqlite3_column_int
(
item
->
stmt
,
2
);
return
((
lkt_search_database_func
)
item
->
call
)(
item
->
srv
,
item
->
c
,
id
,
id_len
,
sql_row
);
return
((
lkt_search_database_func
)
item
->
call
)(
item
->
srv
,
item
->
c
,
id
,
id_len
,
sql_row
);
case
lkt_search_queue
:
case
lkt_search_queue
:
id
=
sqlite3_column_int
(
item
->
stmt
,
0
);
sql_row
=
(
const
char
*
)
sqlite3_column_text
(
item
->
stmt
,
1
);
id_len
=
sqlite3_column_int
(
item
->
stmt
,
2
);
return
((
lkt_search_queue_func
)
item
->
call
)(
item
->
srv
,
item
->
c
,
id
,
id_len
,
sql_row
);
case
lkt_search_playlist
:
case
lkt_search_playlist
:
default:
default:
LOG_WARN_SCT
(
"DB"
,
"Search operation %d is not implemented"
,
item
->
type
);
LOG_WARN_SCT
(
"DB"
,
"Search operation %d is not implemented"
,
item
->
type
);
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter