scieee AI-readable full text Open interactive document viewer

Efficient query over large datasets of analytical chemistry

Luaces Cachaza, David

Abstract

The efficient management of molecular data is one of the most demanded technologies by the industry. A very important type of search is the substructure searching. The molecular structures may be encoded as graphs where the vertices and bonds represent the atoms and bonds, respectively. In this Thesis, a cutting edge system that enables the storage and querying of molecular data has been designed and implemented, paying attention to the molecular substructure search, where new filter-then-verify(FTV) methods, beyond the state-of-the-art, were designed, implemented, and tested, achieving performance gains over 75% in the filtering stage. A generic framework for the implementation of FTV techniques on a distributed architecture was also developed, enabling the application of the FTV methods on very large graph databases, achieving a great performance gain in both index building and query execution. Finally, the Thesis presents a study for the use of different FTV solutions to obtain approximate results in an interactive searching application.

Full text

INTERNATIONAL DOCTORAL SCHOOL OF THE USC David Luaces Cachaza PhD Thesis EFFICIENT QUERY OVER LARGE DATASETS OF ANALYTICAL CHEMISTRY Santiago de Compostela, 2023 Doctoral Programme in Information Technology Research 7(6('('28725$0(172 '((+%+'0637'4;18'4.#4)' #5'651(#0#.;6+%#. %*'/+564; 'DYLG/XDFHV&DFKD]D '5%1.#&'&17614#/'061+06'40#%+10#.&#70+8'45+&#&'&'5#06+#)1&'%1/2156'.# 241)4#/#&'&17614#/'061'0+08'56+)#%+ĵ0'06'%01.1:ı#5&#+0(14/#%+ĵ0 6$17,$*2'(&203267(/$  DECLARACIÓN DO AUTOR/A DA TESE D./Dna. David Luaces Cachaza Título da tese: EFFICIENT QUERY OVER LARGE DATASETS OF ANALYTICAL CHEMISTRY Presento a miña tese, seguindo o procedemento axeitado ao Regulamento, e declaro que: 1) A tese abarca os resultados da elaboración do meu traballo. 2) De ser o caso, na tese faise referencia ás colaboracións que tivo este traballo. 3) Confirmo que a tese non incorre en ningún tipo de plaxio doutros autores nin de traballos presentados por min para a obtención doutros títulos. 4) A tese é a versión definitiva presentada para a súa defensa e coincide a versión impresa coa presentada en formato electrónico E comprométome a presentar o Compromiso Documental de Supervisión no caso de que o orixinal non estea na Escola. En Santiago de Compostela, 20 de Febreiro de 2023. Sinatura electrónica AUTORIZACIÓN DO DIRECTOR/TITOR DA TESE D./Dna. José Ramón Ríos Viqueira En condición de: Director/a Título da tese: EFFICIENT QUERY OVER LARGE DATASETS OF ANALYTICAL CHEMISTRY INFORMA: Que a presente tese, correspóndese co traballo realizado por D/Dna David Luaces Cachaza, baixo a miña dirección/titorización, e a utorizo a súa presentación , considerando que reúne os r equisitos esixidos no R egulamento de Estudos de Doutoramento da USC, e que como director/titor desta non incorre nas causas de abstención establecidas na Lei 40/2015. En Santiago de Compostela, 20 de Febreiro de 2023 Sinatura electrónica AUTORIZACIÓN DO DIRECTOR/TITOR DA TESE D./Dna. Tomás Fernández Pena En condición de: Director/a Título da tese: EFFICIENT QUERY OVER LARGE DATASETS OF ANALYTICAL CHEMISTRY INFORMA: Que a presente tese, correspóndese co traballo realizado por D/Dna David Luaces Cachaza, baixo a miña dirección/titorización, e a utorizo a súa presentación , considerando que reúne os r equisitos esixidos no R egulamento de Estudos de Doutoramento da USC, e que como director/titor desta non incorre nas causas de abstención establecidas na Lei 40/2015. En Santiago de Compostela, 20 de Febreiro de 2023 Sinatura electrónica Contents Resumo 1 Abstract 11 1 Introduction 15 1.1 Background and motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 1.2 Objectives and contributions of the Thesis . . . . . . . . . . . . . . . . . . . 17 1.3 Projects and publications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 1.4 OutlineoftheThesis .............................. 21 2 Querying Molecular Data: The NEXTCHROM Project 23 2.1 Technologies Available in Cheminformatics . . . . . . . . . . . . . . . . . . 26 2.2 TextSearching ................................. 26 2.3 PeakSearching ................................. 28 2.4 MolformSearching............................... 29 2.5 SubstructureSearching ............................. 31 3 Background and Related Work on Subgraph Searching 33 3.1 ProblemDefinition ............................... 33 3.2 Stateoftheart.................................. 36 4 Subgraph Searching Techniques for Centralised Architectures 47 4.1 BitmapGGSX.................................. 48 4.2 Column-WiseCT-Index............................. 51 4.3 K-MeansCT-Index ............................... 53 Contents 4.4 PerformanceEvaluation............................. 59 5 Generic Framework for Subgraph Searching in Distributed Architectures 79 5.1 IndexBuilding ................................. 80 5.2 QueryProcessing................................ 84 5.3 PerformanceEvaluation............................. 87 6 Approximate Processing for Interactive Searching in Molecular Datasets 101 6.1 Interactive Searching in Molecular Datasets . . . . . . . . . . . . . . . . . . 101 6.2 Approximate Processing Solutions . . . . . . . . . . . . . . . . . . . . . . . 104 6.3 Experimental Evaluation of Efficacy and Efficiency . . . . . . . . . . . . . . 110 7 Conclusions and Future Work 121 Bibliography 125 List of Figures 131 xv Resumo A xesti´ on eficiente de datos anal´ ıticos tales como os xerados pola cromatograf´ ıa l´ ıquida (LC) e gasosa (GC), os espectros de Resonancia Magn´ etica Nuclear (NMR), infravermellos (IR), ultravioleta (UV), espectrometr´ ıa de masas (MS), ou as estruturas moleculares, ´ e unha das aplicaci´ ons m´ ais atractivas e demandadas por sectores como o qu´ ımico, o biotecnol´ oxico ou o farmac´ eutico nos ´ ultimos anos. Un dos principais problemas atopados nas investigaci´ ons sobre o descubrimento de f´ armacos baseados en produtos naturais ´ e a identificaci´ on e eliminaci´ on de r´ eplicas de compostos co˜ necidos. Esta capacidade de identificar compostos co˜ necidos nunha etapa temper´ a da investigaci´ on representa un grande aforro de tempo e esforzo. Para que este proceso de identificaci´ on sexa efectivo, ´ e necesario dispo˜ ner das t´ ecnicas quimioinform´ aticas oportunas capaces de realizar buscas r´ apidas de subestruturas, espectros e cromatogramas en grandes volumes de datos experimentais. Os sistemas de bases de datos especializados en informaci´ on de experimentos anal´ ıticos son claves no traballo rutineiro dun gran n´ umero de empresas do sector qu´ ımico e farmac´ eutico para facilitar procesos como os de separaci´ on, identificaci´ on e cuantificaci´ on dos ingredientes nunha formulaci´ on, entre outros. Por outra banda, o almacenamento e busca de informaci´ on anal´ ıtica debe complementarse mediante a utilizaci´ on de bases de datos de estruturas moleculares, as cales deben posu´ ır as capacidades necesarias para realizar buscas tanto de datos convencionais (alfanum´ ericos), como de estruturas moleculares, espectros ou cromatogramas. Na actualidade existe unha gran variedade de bibliotecas quimioinform´ aticas e de soluci´ ons para incorporar parte da funcionalidade de estas bibliotecas dentro de sistemas xestores de bases de datos. Alg´ uns exemplos son bibliotecas como RDKit, OpenBabel ou CDK. Neste sentido, a tecnolox´ ıa usada, baseada en bases de datos relacionais e arquitecturas centralizadas, non ´ e´ optima en termos de rendemento e escalabilidade e est´ a limitando a posibilidade de cubrir todo o abano de aplicaci´ ons demandadas actualmente polo mercado. DAVID LUACES CACHAZA Por outra banda, na ´ area de xesti´ on de grandes volumes de datos est´ an a aparecer un conxunto de tecnolox´ ıas que te˜ nen como obxectivo facilitar a xesti´ on e o procesamento anal´ ıtico escalable de grandes conxuntos de datos de natureza posiblemente heterox´ enea (Big Data). Estas tecnolox´ ıas resolven problemas relacionados cos par´ ametros de volume, velocidade de actualizaci´ on e variabilidade dos conxuntos de datos. Nas aplicaci´ ons de quimioinform´ atica descritas arriba, o volume de datos ´ e enorme e a variabilidade da estrutura dos mesmos tam´ en, polo que a incorporaci´ on de t´ ecnicas de Big Data no seu desenvolvemento ´ e algo fundamental. As bases de datos moleculares almacenan o que se pode definir como entidades moleculares. Unha entidade molecular cont´ en as propiedades dunha mol´ ecula, e est´ a composta de diferentes tipos de datos. •Propiedades alfanum´ ericas: incl´ uen propiedades como nome molecular, peso molecular ou n´ umero de ´ atomos que cont´ en a mol´ ecula. •F´ ormula molecular: conxunto de pares compostos polo elemento qu´ ımico e o n´ umero de ´ atomos dese elemento presentes na mol´ ecula. •Estrutura molecular: un grafo representativo da estrutura molecular, onde os v´ ertices representan os ´ atomos e os arcos representan a uni´ on entre os ´ atomos. •Espectro: estruturas que almacenan os datos necesarios para representar diferentes tipos de espectros, inclu´ ındo resonancia magn´ etica nuclear (NMR), cromatogramas ou espectros de masas. Tendo en conta os tipos de datos almacenados nas bases de datos moleculares, os tipos de consulta m´ ais demandados son os seguintes. •Consultas de texto: devolve todas as entidades moleculares que conte˜ nan ou te˜ nan exactamente un texto dado nalgunha das s´ uas propiedades. •Consultas num´ ericas: devolve todas as entidades moleculares que te˜ nan algunha propiedade num´ erica con valor entre un rango dado. •Consultas de picos: devolve as entidades moleculares que conte˜ nan alg´ un espectro que cumpra as restrici´ ons dadas na consulta. •Consultas de f´ ormula molecular: devolve todas as entidades moleculares que incl´ uan na s´ ua f´ ormula molecular os elementos e n´ umero de ´ atomos requiridos. 2 Contents •Consultas de subestrutura: devolve todas as entidades moleculares que conte˜ nan dentro da s´ ua estrutura molecular a consulta. Entre todos os tipos de consulta existentes para as bases de datos moleculares, unha das m´ ais demandadas pola industria e m´ ais desafiantes dende o punto de vista investigador son as buscas por subestrutura, ´ e dicir, recuperar todas as entidades moleculares da base de datos que conte˜ nan na s´ ua estrutura molecular a estrutura molecular dada como consulta. As estruturas moleculares poden codificarse como grafos de pequeno tama˜ no onde os v´ ertices representan os ´ atomos e os arcos representan os enlaces moleculares entre os ´ atomos. Obter todas as instancias que existen dentro dun grafo dun subgrafo dado como consulta ´ e un problema ben co˜ necido, chamado subgraph matching na literatura. Tr´ atase dun problema NP completo e res´ olvese habitualmente mediante a aplicaci´ on de algoritmos de isomorfismo de subgrafos. Os algoritmos de isomorfismo de subgrafos tenden a ter bos rendementos en bases de datos compostas por unicamente un grafo de gran tama˜ no, como por exemplo o tipo de base de datos que se pode atopar na web sem´ antica. Pola contra, as bases de datos moleculares est´ an compostas por norma xeral por un gran n´ umero de grafos de pequeno tama˜ no. Recuperar todos os grafos dunha base de datos que conte˜ nan ao subgrafo dado como consulta ´ e tam´ en un problema ben co˜ necido na comunidade, e ´ e chamado subgraph decision na literatura. Este problema pode ser resolto dunha maneira directa mediante a aplicaci´ on de algoritmos de isomorfismo de grafos, como no caso dos anteriores, a´ ında que normalmente estes algoritmos sufrir´ an de severos problemas de rendemento cando a base de datos chega a un tama˜ no cun n´ umero de mol´ eculas significativo. En xeral, unha mellor maneira de resolver o problema de subgraph decision ´ e mediante o uso de t´ ecnicas de filtrado, co˜ necidas como Filter-Then-Verify (FTV) no estado da arte. As t´ ecnicas FTV dividen o proceso de consulta en d´ uas fases. Primeiro, unha fase de filtrado reduce significativamente o n´ umero de grafos aproveitando alg´ un tipo de estrutura de datos usada como ´ ındice e xerada anteriormente. A segunda fase, co˜ necida como fase de verificaci´ on, aplica un algoritmo de isomorfismo de subgrafos ao conxunto de grafos obtido na fase anterior de filtrado. Un gran n´ umero de propostas baseadas na estratexia FTV foron presentadas pola comunidade para resolver o problema de subgraph decision. Entre todas elas, GraphGrepSX (GGSX) e CT-Index son as que mostraron un maior rendemento para bases de datos cun gran n´ umero de grafos, como ´ e o caso das bases de datos moleculares. Tanto GGSX como CT-Index ap´ oian- 3 DAVID LUACES CACHAZA se na creaci´ on de estruturas de datos que act´ uan como ´ ındices, que se xeran con determinadas caracter´ ısticas extra´ ıdas dos grafos do conxunto de datos. No caso do m´ etodo GGSX, x´ erase unha estrutura de tipo trie con todos os cami˜ nos dunha determinada lonxitude m´ axima contidos en cada grafo do conxunto de datos. Cada nodo do ´ ındice trie representa un cami˜ no espec´ ıfico e referencia a todos os grafos da base de datos que o conte˜ nen. ´ A hora de realizar consultas, na fase de filtrado, GGSX comeza xerando un trie para o grafo usado como consulta, para despois realizar un percorrido en amplitude de ´ ambolos dous tries, o correspondente ao ´ ındice e o correspondente ´ a consulta, para atopar os nodos folla dos cami˜ nos da consulta no trie da base de datos. Unha vez se atopan os nodos folla, obt´ e˜ nense os identificadores dos grafos que conte˜ nen eses cami˜ nos, e real´ ızase unha intersecci´ on entre todos eles para obter un conxunto de candidatos. Este conxunto de candidatos ser´ an analizados para comprobar si conte˜ nen o grafo consulta na fase de verificaci´ on. A verificaci´ on de cada grafo candidato faise aplicando o algoritmo de isomorfismo de subgrafos VF2. Por outra banda, o m´ etodo CT-Index extrae as caracter´ ısticas do grafo para xerar fingerprints (bitmaps) que son almacenados nunha lista. Para xerar os fingerprints, primeiro obt´ en todos os sub´ arbores e ciclos cunha lonxitude m´ axima dada que hai dentro de cada grafo. Cada sub´ arbore ou ciclo codificase en texto usando unha representaci´ on can´ onica sobre a que despois se aplica unha funci´ on hash que obt´ en un n´ umero enteiro. Finalmente, eses n´ umeros enteiros ´ usanse para identificar as posici´ on dos bits que se van a activar no fingerprint. ´ A hora de realizar a consulta, na fase de filtrado, primeiro x´ erase un fingerprint para o grafo da consulta, e compr´ obase se est´ a contido en cada un dos fingerprints almacenados no ´ ındice, para constru´ ır as´ ı o conxunto de candidatos. Finalmente, na fase de verificaci´ on os grafos candidatos compr´ obanse usando o algoritmo de isomorfismo de subgrafos VF2, igual que no caso anterior. ´ Ambalas d´ uas t´ ecnicas que acabamos de describir foron aplicadas con ´ exito a conxuntos de datos de decenas de miles de grafos. Sen embargo, o seu rendemento non ´ e axeitado cando as bases de datos utilizadas alcanzan tama˜ nos de varios centos de miles, ou incluso mill´ ons de grafos. En base a todo o exposto anteriormente, o obxectivo desta tese ´ e o dese˜ no e desenvolvemento dun sistema de almacenamento, indexado e busca de datos moleculares, que permita traballar con todos os tipos de datos existentes nunha entidade molecular, inclu´ ındo datos anal´ ıticos e estruturas moleculares. O sistema deber´ a traballar independentemente da tecno- 4 Contents lox´ ıa de bases de datos subxacente, permitindo a s´ ua implementaci´ on tanto nunha arquitectura centralizada como nunha arquitectura distribu´ ıda. De entre todos os tipos de consulta, o traballo enf´ ocase principalmente nas consultas por subestrutura molecular. Para este tipo de consulta, a tese prop´ on novas soluci´ ons que melloran o estado do arte en arquitecturas centralizadas, e tam´ en proporciona unha contorna para a implementaci´ on de m´ etodos FTV en arquitecturas distribu´ ıdas que proporciona a escalabilidade necesaria para conseguir consultar bases de datos de decenas de mill´ ons de grafos con tempos de resposta aceptables. Por ´ ultimo, a tese tam´ en analiza a posibilidade de usar a fase de filtrado das t´ ecnicas FTV, implementada con dous grandes tipos de estruturas de tipo Sketch, como soluci´ on para alcanzar os tempos de resposta precisos en interfaces de busca e exploraci´ on interactiva. En resumo, as caracter´ ısticas do sistema resultante son as seguintes. • O sistema ten a capacidade de realizar os seguintes tipos de busca en conxuntos de datos moleculares: –Consultas de texto realizadas sobre as propiedades textuais das entidades moleculares. Utilizaranse tecnolox´ ıas de indexaci´ on e busca existentes no estado do arte. –Consultas de picos realizadas en espectros almacenados polas entidades moleculares. Utilizaranse t´ ecnicas de indexaci´ on multidimensional para resolvelas. –Consultas de f´ ormulas moleculares, que ser´ an resoltas mediante a aplicaci´ on de estruturas de datos espec´ ıficas. –Consultas de subestrutura sobre as estruturas moleculares. Utilizaranse t´ ecnicas de FTV para a s´ ua resoluci´ on. • O sistema pode ser despregado tanto nunha arquitectura centralizada como nunha arquitectura distribu´ ıda. No caso da arquitectura centralizada, os datos son almacenados nunha base de datos relacional. No caso da arquitectura distribu´ ıda, util´ ızanse cl´ usteres distribu´ ıdos onde os datos moleculares se almacenan en bases de datos NoSQL baseadas en documentos. • A implementaci´ on utiliza t´ ecnicas existentes no estado da arte para resolver as consultas por texto e por picos, as´ ı como unha estrutura de datos con datos en memoria para a resoluci´ on de buscas por f´ ormula molecular. No caso das consultas por subestrutura, tiv´ eronse que dese˜ nar e implementar avanzadas estruturas de indexaci´ on que permiten 5 DAVID LUACES CACHAZA un bo rendemento en bases de datos de gran tama˜ no (centos de miles ou incluso un mill´ on de mol´ eculas). • Incorp´ oranse novas t´ ecnicas avanzadas para realizar buscas por subestrutura en sistemas distribu´ ıdos de maneira eficiente en bases de datos de gran tama˜ no, no rango de decenas de mill´ ons de estruturas moleculares. • Proponse o uso de d´ uas estruturas de datos de tipo Sketch, os Bloom Filters (BF) e o Count-Min Sketch (CMS), para implementar a fase de filtrado das t´ ecnicas FTV, e conseguir as´ ı soluci´ ons que proporcionan resultados aproximados (con falsos positivos), pero con tempos de resposta moi r´ apidos (por debaixo do segundo), de maneira que poidan ser utilizadas para implementar interfaces de busca e exploraci´ on interactiva sobre grandes cantidades de grafos. Para resolver as consultas por subestrutura molecular prop´ o˜ nense tres novas t´ ecnicas FTV baseadas nas co˜ necidas GraphGrepSX (GGSX) e CT-Index. Estas tres t´ ecnicas son as seguintes. • Bitmap GGSX (BM-GGSX): bas´ ease no m´ etodo GGSX xerando unha estrutura trie da mesma maneira, e aproveita o uso de bitmaps comprimidos para modificar o almacenamento dos identificadores das mol´ eculas en cada nodo, obtendo as´ ı moito mellores tempos de resposta que o propio GGSX. • Column-Wise CT-Index (CW-CTI): bas´ ease no CT-Index e adapta o almacenamento dos fingerprints nunha estrutura de almacenamento por columnas, onde a mesma posici´ on dun bit de todos os fingerprints de todos os grafos da base de datos son almacenados nun bitmap comprimido, conseguindo, desta maneira, que na consulta soamente as posici´ ons correspondentes aos bits que est´ an activos no fingerprint da consulta te˜ nan que ser accedidos. Isto permite que se reduzan moito o n´ umero de comparaci´ ons e que obte˜ na un gran rendemento en consultas de pequeno tama˜ no, e dicir, aquelas que te˜ nen poucos bits con valor 1 no seu fingerprint. • K-Means CT-Index (KM-CTI): bas´ ease no CT-Index, e aplica recursivamente o algorimo de clusterizaci´ on K-Means sobre os fingerprints do CT-Index para constru´ ır unha ´ arbore binaria de fingerprints que act´ ue como ´ ındice. Na ´ arbore, os nodos follas almacenan os fingerprints de cada grafo da base de datos, e os nodos pais de cada nodo 6 Contents also evaluated, to show that it achieves very fast response times, but at the cost of having a quite poor efficacy when its results are compared with those of a subgraph isomorphism algorithm. 13 CHAPTER 1 INTRODUCTION 1.1 Background and motivation The efficient management of analytical data such as molecular structures, chromatography or nuclear magnetic resonance spectra is one of the most demanded technologies in recent years by chemical, biotechnological and pharmaceutical sectors, among others. One of the main problems found in drug discovery research based on natural products is the identification and removal of replicas of known compounds. This identification process is solved through the application of appropriate cheminformatic techniques able to perform searches on molecular datasets. Database systems able to perform fast searchers on large datasets of molecular and analytical data are required in the daily work of many companies and researchers in the chemical and pharmaceutical sectors. Molecular and analytical data are widely heterogeneous, including conventional alphanumeric data, molecular structures (graphs) and spectra and chromatograms (multidimensional data). Nowadays there are many cheminformatic libraries that enable the searching of molecular data, whose functionality has been incorporated in relational database management systems (DBMS). Some examples of the above are OpenBabel [37], RDKit [31] and CDK [43, 50]. However, the technology used, based on object-relational databases and centralised architectures, is not optimal in terms of performance and scalability. As a consequence, the available technologies are limiting the possibility of covering the full range of applications nowadays demanded by the market. Among all the demanded types of searches, one of the most challenging is the substructure DAVID LUACES CACHAZA searching [14, 13], i.e., retrieving all the molecules in a dataset that contain in their molecular structure a given query substructure. Molecular structures have the form of small graphs whose vertices are atoms and whose edges are bonds between atoms. Retrieving all the instances of a given subgraph that occurs inside a graph is a well-known problem, named in the literature as subgraph matching. This is an NP-Complete problem that it is solved through the application of subgraph isomorphism algorithms [11, 24, 42, 45, 54]. These algorithms tend to perform well in databases consisting of just one very large graph, i.e., the kind of database available in the semantic web for example. Molecular databases are composed of a very large number of small graphs. Finding all the graphs which contain a query subgraph is also a well-known problem, named subgraph decision in the literature. This problem may be solved in a straightforward manner through the application of subgraph isomorphism algorithms, although it may suffer from severe performance problems when the database size is large enough. In general, a better approach to solve the subgraph decision problem is to use Filter-Then-Verify (FTV) techniques, where the query process is divided into two stages. First, a filtering stage prunes out a large number of graphs through the use of some indexing structure. Next, a verification stage applies a subgraph isomorphism algorithm to the set of candidate graphs obtained in the filtering stage to get the result set of graphs. Many subgraph search solutions based on a FTV strategy have been proposed over the years [6, 9, 19, 29, 51, 53, 55, 57]. Among them, GGSX [6] and CT-Index [29] have demonstrated better performance than the other when applied to large datasets of small graphs [26], as it is the case of the molecular databases. Both methods rely on building indexing structures with features extracted from the graphs of the dataset. Specifically, GraphGrepSX generates a trie [18] structure with all the paths of each graph whose length is shorter than a given threshold. Each node of the trie represents a specific path and references all the graphs of the database that contains such a path. A breadth-first scan of the query and index trie structures are performed during the filtering stage. On the other hand, CT-Index represents the set of features of a maximum length extracted from the graph with a fingerprint (bitmap). Extracted features are subtrees and cycles whose length is shorter than a given threshold. A hash function is applied to a canonical representation of each feature to generate an index that is used to activate the relevant bit of the fingerprint. The filtering stage in CT-Index is performed by testing bitmap subset between query and database fingerprints. 16 Chapter 1. Introduction The above techniques have been successfully applied to datasets in the range of the tens of thousands of graphs, however, their performance is not adequate when very large datasets of various hundreds of thousands or even millions of graphs are considered. 1.2 Objectives and contributions of the Thesis Based on the motivation described in the previous section, the main objective of the present Thesis is the design and implementation of a data storage, indexing and searching technology that supports all the types of data contained in molecular and analytical datasets. The system should work independently of the underlying database technology, and it should enable its deployment on both centralised and distributed architectures. Among all the query types, the main effort will be devoted to the molecular substructure searching, aiming at the proposal of new solutions with efficacy and/or efficiency beyond that of the state of the art. New solutions should be scalable to be able to deal with very large datasets, they should be efficient with queries of different sizes and they should enable the interactive searching and exploration of such very large datasets. The main characteristics of the system developed in this Thesis are summarized below. • The system provides support for the following types of queries over molecular data: –Textual queries performed over text properties of the molecules, such as its name. State of the art text indexing and searching technologies will be applied. –Peak queries performed over the spectra recorded for the molecules. Multidimensional indexing techniques will support this kind of queries. –Queries over the molecular formulas, for which specific data structures have been developed. –Substructure queries performed over the structure of the molecules, supported by advanced indexing structures designed as part of the Thesis. • The system can be deployed in centralised architectures where the molecular data is stored in relational databases, but also on distributed clusters where molecular data is stored in document-oriented NoSQL databases. • The implementation uses state of the art techniques to support textual and peak queries. An in-memory straightforward structure enables the evaluation of molecular formula 17 DAVID LUACES CACHAZA queries with in memory data. However, new advanced indexing structures had to be developed to enable the application of substructure queries in large databases (in the order of hundreds of thousands of molecules), achieving performance gains in the range of 70%. • The system incorporates new advanced indexing techniques for substructure searching in a distributed system implementation which enables the efficient searching over very large molecular databases (in the range of tens of millions of structures). • Sketches have been used as part of the indexing structures which enables the development of solutions that return approximate results with interactive response times (below one second). Such solutions can be used to implement interactive searching and exploration interfaces for very large molecular datasets. Different structures show better results in terms of efficacy and efficiency for different query sizes. Finally, the main contributions of the Thesis may be resumed as follows. 1. A query system for molecular and analytical data that works on top of different underlying database technologies has been designed and implemented. The system can be deployed in both centralised and distributed architectures, using either relational databases or document-oriented NoSQL databases. The use of advanced data structures enables the improvement of the performance over existing solutions for different types of queries over different types of data. 2. Three new FTV approaches has been proposed and extensively evaluated using realworld databases of size much larger than the one used in previous surveys. The evaluation concludes that a combination of two of them gives a good solution for any query size. Additional details of each of the new approaches are given below. a) Bitmap GGSX leverages the use of compressed bitmaps in the GraphGrepSX trie nodes, enabling a drastic reduction of the filtering time (around 90% less than GraphGrepSX), maintaining the index size and building time almost unaltered. Compared with the other two proposals based on CT-Index, it performs much worse in terms of index size and building time. Regarding query response time, it offers good performance for medium and large queries. 18 Chapter 1. Introduction b) Column-Wise CT-Index reorganizes the CT-Index fingerprints to store them columnwise. The bits of the same position of the fingerprints of all the graphs of the database are stored together in a compressed bitmap. Index size and index building time remains almost unaltered. However, given that only the bitmaps corresponding to bits with value 1 in the query have to be accessed, for small queries (with few 1s in the fingerprint), the solution reaches very good performance. c) K-Means CT-Index recursively applies the K-Means clustering algorithm on CT- Index fingerprints to build a binary tree of fingerprints as index. Its index size and index building time are worse than those of the original CT-Index, but they are better than those of Bitmap GGSX. The approach has good performance in terms of query response time when the query is of medium or large size. Notice that small queries are not very selective and do not really take advantage of the fingerprint binary tree. 3. A generic framework for the implementation of FTV methods on top of large scale data processing engines has been designed and developed. Firstly, the database is divided into partitions and each of them is indexed. The resulting indices are encoded into byte arrays and recorded into distributed data structures. The filtering stage performs index searching in parallel in each partition, and the verification stage resdistributes the candidates obtained in the previous stage and parallelizes the subgraph isomorphism tests. The new FTV techniques described above were adapted to the framework and comprehensively evaluated using databases of sizes orders of magnitude larger than the ones used by previous surveys. The evaluation concludes that the distributed architecture obtains better results when either the query is small or the database is large enough. The scalability of the new distributed solutions are specially important for index building, enabling the construction of indexes for database sizes that would be completely impossible using centralised implementations. 4. The problem of the interactive searching of databases of molecular structures has been introduced and illustrated with a user interface example. Two types of data sketches, namely Bloom Filter (BF) and Count-Min Sketch (CMS), were used with different parameters to implement indexes for the filtering stage of FTV solutions. The use of filtering without verification provides approximate results for the queries that are obtained in much shorter response times, enabling this way interactive system responses 19 DAVID LUACES CACHAZA (below one second). The evaluation shows that CMS structures provide advantages when the result precision (system efficacy) is more important than the query response time (efficiency), specially for large queries. On the other hand, better efficiency at the cost of worse efficacy is offered by the use of fingerprints (Bloom Filters with just one hash function) in the K-Means CT-Index approach. The evaluation was used also to show that some of the available subgraph search implementations do not give precise and complete results compared to subgraph isomorphism algorithms. 1.3 Projects and publications The objective of this Thesis arises from the identification of research problems during the execution of the NEXTCHROM project: Virtual advanced chromatography for an integral management of analytical and molecular data 1. The objectives and main results of this project are described in Chapter 2. The author is this Thesis had active participation and is the main responsible of the results related to data management achived in the project. The following publications describe research results of the present Thesis, in particular those described in Chapters 4 and 5. • D. Luaces, J.R. Viqueira, T.F. Pena, J.M. Cotos, Leveraging bitmap indexing for subgraph searching, in: 22nd International Conference on Extending Database Technology (EDBT), OpenProceedings.org, 2019, pp. 49–60. doi:10.5441/002/edbt.2019.06. • David Luaces, Jos´ e R.R. Viqueira, Jos´ e M. Cotos, and Juli´ an C. Flores. Efficient access methods for very large distributed graph databases. Information Sciences, 573:65–81, 2021. In addition to the work done for the NEXTCHROM project, in the scope of the Thesis, the author was also involved as part of the research team of the following projects, whose objectives were not in the scope of the Thesis. • GEOARPAD: Cultural heritage of the Euroregion Galicia-North of Portugal: valorisation and innovation 2. 1https://citius.gal/research/projects/cromatografia-virtual-avanzada-e-xe stion-integral-de-datos-analiticos-e-moleculares 2https://citius.gal/research/projects/patrimonio-cultural-da-eurorrexion- galicia-norte-de-portugal-valorizacion-e-innovacion 20 Chapter 1. Introduction • SenseStore1: Efficient storage and publication of remote sensing data 3. • TRAFAIR: Understanding Traffic Flows to Improve Air quality 4. Also out of the scope of the Thesis is the following publication. • David Luaces, Jos´ e R. R. Viqueira, Pablo Gamallo, David Mera, and Juli´ an Flores. Geohbbtv: A framework for the development and evaluation of geographic interactive TV contents. Multimedia Tools and Applications, 77, 11 2018. 1.4 Outline of the Thesis The structure of this document is organized as follows. Chapter 2 describes the main objectives and results of the NEXTCHROM project. In particular, a description is given of what is considered in this Thesis molecular data and also of what are considered the more relevant types of queries over molecular data. Chapter 3 provides an in depth description of the background and state of the art relevant for the subgraph searching problem. In particular, the subgraph searching problem is formalized and the most important solutions found in the state of the art related to this problem are described. Special attention is paid and more details are given of the two state-of-the-art graph indexing approaches that are the basis for the new solutions developed in the Thesis, i.e., the GraphGrepSX (GGSX) and CT-Index (CTI) structures. Three new Filter-Then-Verify(FTV) approaches, called Bitmap-GGSX (BM-GGSX), Colum- Wise CT-Index (CW-CTI) and K-Mean CT-Index (KM-CTI), are described in detail in Chapter 4. A performance evaluation of the three new methods compared with the original GGSX and CT-Index is also introduced and discussed. Chapter 5 describes a generic framework for subgraph searching in distributed architectures. The framework uses binary encodings of the indexing structures to enable their use in distributed processing engines. An evaluation of the performance of the framework, considering both different cluster sizes (in number of nodes) and different database sizes (reaching tens of millions of graphs), shows its good behaviour in terms of scalability and how it enables dealing with very large datasets. 3https://citius.gal/research/projects/almacenamento-e-publicacion-eficien tes-de-datos-de-sensorizacion-remota 4https://citius.gal/research/projects/understanding-traffic-flows-to-impr ove-air-quality 21 DAVID LUACES CACHAZA Chapter 6 presents approximate solutions for the subgraph searching problem, suitable to be used in interactive user interfaces for search and exploration over very large datasets. Approximate filtering solutions based on two different types of data sketches, namely Bloom Filters and Count-Min Sketch, are described and evaluated. Different alternatives show better behaviour in terms of either efficacy or efficiency for different query sizes. Finally, the findings of the research undertaken in this Thesis and issues of future work are summarized in Chapter 7. 22 Chapter 2. Querying Molecular Data: The NEXTCHROM Project that makes them useless when the database size rises. To be able to query single peaks of each spectrum, their representation must be normalized, representing the peaks as individual rows in a separate structure. Two broad types of index structures may be used for the peak dimensions in such a dedicated structure. A first approach is a multikey index using a one-dimensional structure, generally a B-Tree. Therefore, all the keys of a multidimensional point must be transformed into single key by concatenating their values in some order. Range queries over the first dimension in the order are resolved efficiently. However, range queries over the other dimensions require the traversal of larger parts of the index tree, resulting in lower performance. A second approach is a multidimensional index such as the R-Tree. In this case, all the dimensions are treated uniformly in the generated tree and the efficiency of the data structure does not depend on the dimension chosen to filter. Both multikey indexes and multidimensional indexes were used in the PostgreSQL DBMS. Multikey B-Tree indexes are directly provided by the DBMS whereas multidimensional R- Tree indexes are incorporated with the PostGIS geospatial extension. The spatial distribution of the peak data showed the convenience of using the xdimension (position in the chemical shift frequency) as the first key and leaving the ydimension (intensity of the signal) as the second key. It was noticed that peak data has much more variability in the values of the xdimension than in the values of the ydimension, thus, an index that filters first in the xdimension eliminates more candidates earlier than an index that filters first in the ydimension. Regarding the distributed implementation based on MongoDB, both multikey and multidimensional indexes were also compared. Multidimensional indexes are provided by the geospatial functionality supported by MongoDB. In general, the multidimensional index performs better than the multikey index, although there might be some queries for which the multikey index might give a better response time. In any case, the geospatial extensions supported by the two databases used in the project showed their utility also to evaluate peak queries in molecular databases, which is not an application considered during their design. 2.4 Molform Searching As already mentioned that a molecular formula (molform) represents the elements and the number of atoms of each chemical element that are present in its internal structure. A query 29 DAVID LUACES CACHAZA H C 1 2 3 1 0 1 1 1 0 0 1 0 m1 m2 m3 m4 m5 m6 m7 m8 m9 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 2 340 0 0 0 0 0 0 0 0 0 40 0 0 1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 40 0 0 1 0 1 0 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 1 0 0 1 0 1 0 0 0 0 0 0 0 0 0 N Figure 2.3: Illustration of the molform index developed during the NEXTCHROM project. over the molecular formula (molform query) specifies a set of chemical elements and a range of possible numbers of atoms for each element. The evaluation of the query must retrieve all the molecular entities whose formula matches the query pattern. A straightforward approach would be to parse a textual representation of the molecular formula of each entity to determine if it matches or not the query. A binary encoding of the formula would slightly reduce the amount of storage and the response time. However, the search will not really improve without a specific indexing structure. Various alternatives were tested in the NEXTCHROM project. A first approach consisted in normalizing of the molecular formula on a different structure, i.e., a new table in the centralised relational architecture and an embedded array on the distributed architecture based on MongoDB. Conventional indices could be created now on the new fields, i.e., on the chemical element and on the number of elements of each chemical element. This solution with conventional indices led to a first major increase in the performance of the query evaluations. A second more sophisticated approach involved the development of a specific indexing structure for molform queries. The structure, illustrated in Figure 2.3, has two levels. In the first level, all the chemical elements are represented. The second level contains the different number of atoms that a molecule might have of each chemical element, together with a bitmap that contains a bit for each molecular entity of the database. The bit corresponding to a given molecule in a leaf node of the structure represents that the molecule has exactly the number of elements of the relevant element in its molecular formula. A query must follow the structure 30 Chapter 2. Querying Molecular Data: The NEXTCHROM Project to obtain all the involved bitmaps and combine them with binary AND and OR operations to obtain a result bitmap with ones in the positions corresponding to the result molecules. A compressed bitmap representation was used to encode those large bitmaps, whose characteristics enable the evaluation of logical operators without the need to decompress. The experiments undertaken in the project with databases of a few millions of molecular entities showed that the new structure provides a significant performance improvement with respect to the conventional structures already provided by the two considered database technologies, i.e., PostgreSQL and MongoDB. It should be noted that the compressed representation for the bitmaps enables the loading of the new data structure completely in memory. 2.5 Substructure Searching As it was already shown above, the molecular structure of each entity is represented with a graph of chemical elements (nodes) and bonds (edges). A molecular substructure query retrieves all the molecular entities whose molecular structure graph contains a given query structure. Different approaches were implemented in the NEXTCHROM project to solve the above queries, always using state-of-the-art technologies and techniques. A first straightforward approach consisted in testing the substructure matching between the query and each molecular entity of the database. This approach was implemented on top of both database technologies, respectively for centralised and distributed architectures. The CDK library was used to perform the test, after retrieving the molecular structure in SMILES [49] format from the database. Since the test is not implemented inside the database, the distributed architecture does not bring any advantage to this approach. Response times were high due to the high complexity of the subgraph matching problem. A more advanced solution involved the implementation of the subgraph testing inside the database. In the NEXTCHROM project, this approach was implemented only in the centralised architecture, using the RDKit extension of the PostgreSQL DBMS. The functions implemented by RDKit and the indexing structures were used to obtain response times near one order of magnitude faster than the straightforward approach implemented with CDK. The last solution developed in the project was the implementation of a Filter-Then-Verify (FTV) approach based on a specialized graph indexing structure. In particular, the Graph- GrepSX (GGSX) [6] data structure was used in a first filtering stage to discard most of the molecular entities of the database. Then, the VF2 algorithm [11] was used to verify each of 31 DAVID LUACES CACHAZA the structures retrieved by GGSX to obtain the final result. This approach reaches response times much faster than those based on the use of RDKit. It enables also the implementation of the approach in distributed architectures. It is notice that, in general, the main advantage of a distributed architecture is the support for the parallel verification of many molecules, when the query is not very selective, i.e., when the query consists of a very small graph that is contained in many molecules. The clear room for improvement in the state-of-the-art techniques used for this complex problem was the main motivation for the start of the present Thesis, which proposes new indexing structures and both centralised and distributed implementations that enable the efficient evaluation of substructure queries over very large databases. Thus, further details about the GGSX structure and also about other state-of-the-art structures will be given in Chapter 3. Discussion about the design, implementation and evaluation of more advanced structures is provided in subsequent chapters. 32 CHAPTER 3 BACKGROUND AND RELATED WORK ON SUBGRAPH SEARCHING The molecular substructure queries discussed in the previous chapter, in the context of the NEXTCHROM project, are a particular application of the more general subgraph queries, which may be issued to databases storing graphs in many application domains. This chapter provides the required background and analysis of the state of the art related to the evaluation of subgraph queries. Specifically, the problem of subgraph searching is first described and formalized. Next, state-of-the-art technologies and techniques relevant to this problem are reviewed and discussed. Specific attention will be given to two data structures that can be used in the filtering stage of a Filter-Then-Verify (FTV) approach, namely, the GraphGrepSX (GGSX) [6] and the CT-Index [29] structures. This special attention is due to the fact that those approaches had already been identified in previous surveys as those with better performance in large datasets, and also because the structures proposed in the present Thesis are based on them. 3.1 Problem Definition Graph databases may be categorized into two main types. A database of the first type consist of a single very large graph. An example of this kind is the semantic web. One of the functionalities most demanded by applications is to identify all the instances in the database of a specific query graph. This is an NP-complete problem, known in the literature as subgraph DAVID LUACES CACHAZA matching, and it is solved through the application of subgraph isomorphism algorithms. The second type of databases are those that contain a very large number of small graphs. A typical example of this type of databases is a molecular database, where each record stores a molecular compound. Querying molecular databases was one of the main objectives of the NEXTCHROM project, as already summarized in the previous chapter. One of the properties of a molecular compound is its molecular structure, which is represented as a graph where the nodes represent the atoms in the molecule, and the edges represent the bonds that connect those atoms. This type of database is currently reaching very large sizes. As an illustrative example, the PubChem1database has an approximate size of one hundred million molecules, as of today. Finding all the records whose graph contains a specific query subgraph is an important functionality for applications, as it was already shown with molecular substructure queries. This is a well-known problem in the literature, named as subgraph decision problem. A straightforward solution to this problem is to apply a subgraph isomorphism algorithm to each graph in the database. In general, this approach is not efficient, and even not feasible for very large databases. A better approach to reduce the query times is to use a Filter-Then-Verify (FTV) method. FTV methods are divided into two stages. The first stage, named filtering, uses an index structure, built from features extracted from the graphs, to discard a large amount of candidates without having to apply the expensive subgraph isomorphism algorithm. Such an algorithm is applied in a second verification stage to refine the broad result containing false positives retrieved by the previous stage. The type of undirected graph with labeled vertices and edges considered in the present work is defined as follows. Definition 1 Agraph is a quadruple (V,E,vl,el), where V is a set of vertices, E ⊆[V]2is a set of undirected edges (represented as sets of two vertices) and vl :V→V L, el :E→EL are mappings that associate a label respectively from the set of vertex labels V L and from the set of edge labels EL to each vertex and edge. Figure 3.1 shows a graph that represents a molecular structure. The set of vertex labels VL contains all the symbols of the chemical elements (C, H, N, etc.). Edge labels EL are the types of possible bonds between atoms, i.e., single (s), double (d), etc. Based on the above formalism, the concept of subgraph isomorphism and the problem of subgraph search, also known as subgraph decision problem, are defined below. 1https://pubchem.ncbi.nlm.nih.gov/ 34 Chapter 3. Background and Related Work on Subgraph Searching C C C C C C C C C C C C N C C NN C C C C H H H H H H H H H H HH H H HH H H H s d d d ss s s s s s s s d s s s s s s d d s ss s s s s s s s s s s s ss s s d s s Figure 3.1: Example of an undirected graph representing the structure of a molecule. C C C C C C C C C C C C N C C NN C C C C H H H H H H H H H H HH H H HH H H H s d d d ss s s s s s s s d s s s s s s d d s ss ss s s s s s s s s s ss s s d s s C C C C C C C N H H H d s s s s s s d s ds f Figure 3.2: Illustration of a subgraph isomporphism. Definition 2 If ga= (Va,Ea,vla,ela)and gb= (Vb,Eb,vlb,elb)are two graphs, a subgraph isomorphism from gato gbis an injective function f :Va∪Ea→Vb∪Eb, such that ∀va∈Va, vla(va) = vlb(f(va)), and ∀ea={va1,va2} ∈ Ea, ela(ea) = elb(f(ea)) and {f(va1),f(va2)} ∈ Eb. Graph gais said to be subgraph isomorphic to graph gb. Figure 3.2 illustrates a subgraph isomporphism f, which maps each vertex and edge of the first graph to a vertex and edge of the second one with identical label, keeping the same topological structure in both cases. Definition 3 If D = [gi]is a graph database (a multiset of graphs), and q is a query graph, 35 DAVID LUACES CACHAZA the subgraph searching problem (also known as subgraph decision problem) aims at finding all the graphs gk∈D, such that there exists at least one subgraph isomorphism f from q to gk. Notice that in the case of the subgraph matching problem all the subgraph isomorphisms from the query graph to the database graph must be found. Contrary to the above, in the subgraph decision problem it is enough to check if a subgraph isomorphism exists or not from the query graph and each of the graphs stored in the database. 3.2 State of the art As stated above, the matching problem is solved through the application of subgraph isomorphism algorithms. Many approaches have been proposed through the years. Some of the most relevant are shortly explained below. A first solution to the problem was provided by Ullman’s algorithm [45], which has been heavily adapted in posterior solutions. This is a backtracking-based algorithm, designed to find the subgraph-isomorphism mapping from a graph qto a graph g. It uses two vectors: A vector Fthat records the vertices of gthat have been used in some intermediate state of the computation and a vector Hthat records the mapping from qto g. Another important algorithm is the VF2 subgraph isomorphism algorithm [11]. This algorithm is especially suited for dealing with small graphs. VF2 is also a backtracking algorithm, and optimizes Ullman’s algorithm by choosing the current query vertex uas the one which is connected from the already matched query vertices. VF2 exploits this constraint to prune out candidates from the set of candidate vertices of each query vertex. QuickSI [42] is another subgraph isomorphism algorithm. QuickSI, in a first indexing phase, precomputes the frequencies of labels and edges and uses them to calculate the average inner support of a vertex or an edge. Using this calculation, it gives priority to vertices with infrequent labels and infrequent adjacent edge labels. This is later used in the matching process to assign weights on the edges of the query graph. The GraphQL [24] subgraph isomorphism algorithm is focused on minimizing the size of the set of candidate vertices. The algorithm, first, indexes the vertex labels along with the labels of neighboring nodes. In a second phase, the algorithm starts by retrieving all possible matches for each node in the pattern. Finally, it applies several rules, which include the use of the indexed labels to prune out unfeasible matches and optimize this way the search order. 36 Chapter 3. Background and Related Work on Subgraph Searching Another subgraph isomorphism algorithm is SPath [54]. SPath maintains a neighborhood signature encoding where the shortest paths are organized in a compact indexing structure. Shortest paths are decomposed in a distance-wise structure in order to reduce space. The query is decomposed in shortest paths that are matched into the shortest paths from each graph in the database. The candidates that can cover the query and provide good selectivity are selected from the set of shortest paths. The performance of the previous algorithms was studied in [32] using four real-world datasets of different sizes and characteristics. Two of those datasets had the form of a collection of multiple small graphs. The other two datasets had the form of a single and relatively large graph. The study concluded that QuickSI had the best performance for both small and large data graphs, even though it was designed for working with small graphs, and GraphQL was the only algorithm to complete all the queries. Han et al. [22] propose TurboISO, a new subgraph isomorphism algorithm that uses two data structures as its index, an inverse index of vertex labels, that provides easy access to vertices with the same label, and a list of adjacent vertices for every vertex. In the query processing phase, a starting root vertex is chosen based on label frequencies and high node degrees. From this starting vertex, the algorithm identifies candidate regions by performing a Depth-First search, minimizing the intermediate candidate results with the matching sequence. In [56], SQBC, a subgraph isomorphism algorithm was proposed to work on large graphs. It achieves the reduction of the search space by employing a structure of maximal cliques, where the locality information is taken into account for both clique and vertex code. BoostIso [39, 48] rewrites the query by merging vertices that share the same label and neighborhoods, and extends this rewriting also to the stored graphs, allowing to dynamically reduce the duplicate computations. Another approach to the problem is proposed by CFLMatch [3], which postpones Cartesian Products. The algorithm uses a compact path index (CPI) to store the potential embeddings of a spanning tree of the query graph. A more recent approach [21] combines the use of a Direct Acyclic Graph (DAG) with a novel backtracking framework based on DAG-ordering. Finally, in recent years, new methods that take advantage of distributed architectures with different parallel optimization strategies have been proposed [2, 25, 40]. Regarding the decision problem, a straightforward solution is given by the direct appli- 37 DAVID LUACES CACHAZA cation of a subgraph isomorphism algorithm between the query graph and each graph of the database. As stated above, this solution cannot achieve good results in terms of performance. To improve the efficiency of the above straightforward solution, many Filter-Then-Verify (FTV) solutions were proposed in the literature, which combine some indexing structure for the filtering stage and some subgraph isomorphism algorithm for the verification stage. Some of the most relevant approaches are discussed below. Yan et al. [51] propose gIndex, an FTV method that performs a frequent data mining algorithm to generate a set of frequent features with at most a previously established maximum size. Additionally, it generates a subset of infrequent subgraphs. In the query processing, gIndex enumerates all the subgraphs whose size is at most the maximum one and checks whether they are in the indices. A hierarchical tree based on frequent tree features is built in TreePi [53]. In the querying stage, TreePi performs a subgraph isomorphism test for each node of the tree, traversing from the root node to the leaf node. A frequent data-mining algorithm is performed in FG-Index [9], following an approach similar to that of gIndex, but, in this case, the size of the features extracted from the graph is not important. In particular, all the frequent subgraphs are generated. It also includes all infrequent edges. The Tree+∆[55] method extracts trees from the graphs using mining and generates all frequent trees with at most a maximum size. Additionally, it generates features while processing queries by choosing all simple cycles from a query graph and, for each of them, it extends them with one vertex to check whether it is discriminative. In the querying stage, only the subtrees whose size does not exceed the maximum one are checked for matching with the index. An FTV method that stores a set of graph signatures, each of them containing a hash value, and a list of eigenvalues for all vertices in the index is proposed in gCode [57]. In the filtering stage it performs a two-step strategy, index-level and object-level. In the index-level step, the method finds all the qualified signatures. Next, in the object-level step, for each qualified graph, it uses a list of pairs of the form (ID,f requency)to perform a pruning of the potential candidates. In [19] is proposed GRAPES, an FTV method that uses a trie structure to index every path extracted from each graph whose length does not exceed a specified maximum. The index records the number of repetitions of each path in each graph and a reference to the starting 38 Chapter 3. Background and Related Work on Subgraph Searching of the GGSX index, now the maximum feature length Shas no direct impact either in the index size or in the filtering time. However, large values of Scombined with insufficiently large values of 2fwould lead to in many collisions of the hash evaluations during the fingerprint construction, and also in fingerprints with many bits set to 1. Therefore, the list of false positives in the candidate list proposed by the filtering stage would be increased and thus the effort done by the verification stage will also be increased, resulting in an overall poor performance in terms of response time. So, the increase of Swould result in better filtering only if 2fis increased accordingly, and therefore, the index size is also increased. On the other hand, an increase of 2fhas a direct negative impact on both the index size and the filtering response time. However, such a cost increase in filtering does not have a positive impact on verification if the value of Sis not increased accordingly, to enable the pruning of more candidates during filtering. 45 CHAPTER 4 SUBGRAPH SEARCHING TECHNIQUES FOR CENTRALISED ARCHITECTURES This chapter provides a description of the design of three new data structures for the filtering stage of FTV subgraph searching techniques, based on the GGSX and CT-Index approaches described in the previous chapter. The Bitmap GGSX (BM-GGSX), described in SubSection 4.1, replaces the collections of graph identifiers and path repetitions stored in GGSX nodes with more efficient compressed bitmap structures. The use of binary operations to determine the candidate graphs enables achieving performance gains of orders of magnitude with respect to the one achieved by the intersection of collections of integer graph identifiers. The Column- Wise CT-Index (CW-CTI), described in SubSection 4.2, stores the CT-Index fingerprints of all the graphs in column-wise order, i.e., all the values of the same bit position of all the fingerprints are stored together in a single compressed bitmap. This way, the bitmap subset testing between the query fingerprint and each of the database fingerprints is replaced by binary operations among large compressed bitmaps. This results in important performance gains for small queries, i.e., query fingerprints with few bits set to 1. For large queries however, the large number of 1 bit values in the query fingerprint demands too many bitmap operations. Thus,another strategy, based on the use of a tree of fingerprints, is used by the K-Means CT- Index (KM-CTI), which is described in SubSection 4.3. KM-CTI achieves better performance with large and highly selective queries, due to the reduction of the search space achieved by the use of the index tree of fingerprints. DAVID LUACES CACHAZA C. C. C. C. C.O.N.C. . O O. C. C.C.N. N. C. C.O. . N O.C. C. C. 1211121 1 1 11112121 1 1 1 1 2 3 1011000010100111 1001000010000101 0001000010000100 RIDs 40001000000000000 Figure 4.1: Example of a BM-GGSX trie structure. 4.1 Bitmap GGSX An improved version of the GGSX method, called Bitmap-GGSX (BM-GGSX for short henceforth), is explained in detail in this section. The original GGSX method is modified in two main aspects: i) The edge labels of the paths are now considered and stored in the BM-GGSX trie nodes, giving an additional filtering power to BM-GGSX over GGSX. ii) The list of pairs (gid,r) of graph identifiers gid and repetitions r, are represented in BM-GGSX using a collection of very large compressed bitmaps, achieving this way a more compact and efficient structure. The canonical representation of paths in the original GGSX method considers only the vertex labels. Therefore, if we compare it with the possible additional incorporation of the edge labels, the generated trie structures are smaller. On the one hand, smaller tries derive in shorter index size and faster filtering response times. But, on the other hand, the number of candidates discarded by the filtering stage is also shorter, and as a consequence, the verification effort and time are larger. BM-GGSX incorporates a new field in each trie node to record the edge labels. With this addition, a node in the BM-GGSX trie structure represents a combination of a graph node with the edge that precedes the node in the path. Obviously, given that paths start at nodes and not at edges, the nodes of the first level of the trie have always null values in the edge labels. The resulting trie structure has more nodes than the 48 Chapter 4. Subgraph Searching Techniques for Centralised Architectures 0 2 3 8 10 13 14 2 1 4 3 1 3 1 ID R (a) 1 2 3 1011000010100111 1001000010000101 0001000010000100 (b) RIDs 40001000000000000 15 2 Figure 4.2: Comparison between (a) GGSX and (b) BM-GGSX path repetitions storage. primitive one at each level but it enables identifying paths that, despite being different, the original structure encoded with identical canonical representation. An example of a small BM-GGSX trie structure is depicted in Figure 4.1. Notice that each node below the second level of the trie contains both a node label (C, O, N, etc.) and an edge label (1 for single, 2 for double, etc.). The original GGSX method stores in each node a list of key-value pairs (gid,r), where gid is an integer identifying the graph that contains the relevant path, and ris the number of repetitions of the path in the graph. The size of these key-value lists increases linearly with the size of the database. BM-GGSX replaces these lists with a structure that exploits the use of bitmaps. In particular, each node stores an array of bitmaps. The bitmap recorded at index rof the array has a 1 in its position iif, and only if, the graph with identifier gid =icontains the relevant path at least rtimes. The bitmaps are compressed in using the Enhanced Word- Aligned Hybrid method [33]. The difference between the two representations used by GGSX and BM-GGSX, respectively, to store the number of times that each path of the trie is repeated in each graph is illustrated in Figure 4.2. Notice that, in BM-GGSX, if the bitmap recorded at the index rof the array has a value of 1 at position i, the bitmaps recorded in indices lower than rmust also have that position iset to 1. This inserts redundant information in the index structure, but it also reduces query response time, as will be explained below. The filtering stage in BM-GGSX exploits the bitmap structure presented above to reduce the number of comparisons. Firstly, the query graph is processed to obtain a trie structure, and as in the original GGSX filtering stage, the BM-GGSX algorithm performs a joint breadthfirst traversal of both query and database tries. For each leaf node of the query trie, the bitmap recorded in the position corresponding to the number of repetitions in the query leaf node is retrieved. Finally, the final set of candidates is obtained by performing a binary AND operation 49 DAVID LUACES CACHAZA C. C. C. C. C.O.N.C. . O O. C. C.C.N. N. C. C.O. . N O.C. C. C. 1211121 1 1 11112121 1 1 1 1 2 3 1011000010 1001000010 0001000010 40001000000 C.O. C. C.O. C. 3 4 2 1 2 3 1011000010 1001000010 0001000010 40001000000 1 2 3 1011000010 1001000010 0001000010 40001000000 40001000000 21001000010 30001000010 AND AND 0001000000 G 3 (a) Query Trie (b) Index Trie (c) Final Candidates Figure 4.3: BM-GGSX filtering stage. 50 Chapter 4. Subgraph Searching Techniques for Centralised Architectures between all the retrieved compressed bitmaps. This operation results in a new bitmap where the bits set to 1 identify the result graph identifiers. Figure 4.3 shows an example of the BM-GGSX filtering stage. More precisely, Figure 4.3(a) shows a query trie with 3 leaf nodes. Figure 4.3(b) shows the database trie, where the nodes corresponding to paths of the query trie leaf nodes are highlighted. Thus, for the node representing path “CC”, the bitmap in position number 4 is retrieved, as 4 is the number of repetitions recorded in the corresponding query trie leaf node. Similarly, for path “COC” the algorithm retrieves the bitmap at position 2 of the array, and for path “OC” bitmap number 3 is retrieved. Finally, the binary AND operation is performed, as it is illustrated in Figure 4.3(c), to obtain the final set of identifiers of graph candidates (only graph G3is a candidate for verification in this example). In the verification stage, BM-GGSX performs a parallel execution, in a multi-thread architecture, of the improved version of the VF2 algorithm provided by the CT-Index method. 4.2 Column-Wise CT-Index Column-Wise CT-Index, CW-CTI for short henceforth, is a modification of the CT-Index method described in SubSection 3.2.2. As described above, the CT-Index structure consists of one fingerprint for each graph of the database. The collection of all fingerprints might be seen as a matrix, where each fingerprint is a row of the matrix and each column is a bit position of the fingerprint. It is noticed that this matrix is recorded row-wise in CT-Index. CW-CTI adapts CT-Index by recording and processing the fingerprints column-wise, leveraging the use of compressed bitmaps. Thus, if 2fis the fingerprint’s length, then the CW-CTI index is a sequence of 2fbitmaps of length n(database size), where bitmap number khas a 1 at position iif, and only if, graph Gihas a 1 at the position kof its fingerprint. Algorithm 1 CW-CTI Index Building 1: procedure APPENDGRAPH(g,idx) 2: for all c∈extractCycles(g,S)do 3: idx[identi fier(g)][hashCycle(c,f)] ←1 4: end for 5: for all t∈extractTrees(g,S)do 6: idx[identi fier(g)][hashTree(t,f)] ←1 7: end for 8: end procedure 51 DAVID LUACES CACHAZA 0123... k... 2-1 f 1 1 0 ... 0 1 0 1 ... 1 1 0 1 ... 1 1 1 1 ... 1 . . . 1 0 0 ... 0 . . . 1 0 1 ... 0 0 1 2 ... i 0 0 1 1 1 2 1 3 ... ... 0 k ... ... 0 2-1 f Gi Figure 4.4: Fingerprint insertion in the CW-CTI index. The index building stage generates fingerprints for each graph in the dataset, in the same manner as that of CT-Index. However, in CW-CTI each bit of the obtained fingerprint is appended to the end of each corresponding column bitmap. Algorithm 1 shows the pseudocode of the algorithm that appends a new graph gto an already existing CW-CTI index idx. First, the extracted cycles from gare processed in lines 2−4 and next lines 5 −7 do the same with the extracted trees. For each extracted feature (either cycle or tree of size lower or equal to a given one s), a function (either hashCycle or hashTree) generates first a canonical string representation of the feature using the labels of vertices and edges, and next, applies a hash function to this canonical representation to obtain an integer index k(0 ≤k≤2f−1). The bit of the structure corresponding to the extracted feature is set to 1 using the graph identifier as a row index and kas a column index. Figure 4.4 illustrates an example of the application of this algorithm. Graph Gihas 10sat positions 1, 2, and 3, hence, bit number iof the bitmaps corresponding to those three positions is set to 1. It is noticed that the bitmaps of CW-CTI are much larger than the fingerprints stored in CT- Index, and they are likely to contain larger sequences of bits with identical value, becoming great candidates for the use of bitmap compression. CW-CTI uses Enhanced Word-Align Hybrid compression [33], which enables the reduction of index size compared to CT-Index. The filtering stage in CW-CTI is completely different from that of the original CT-Index. The process is illustrated in Figure 4.5. First, the query fingerprint is obtained in the same way as it is obtained in the CT-Index method (see Figure 4.5(a)). Next, for each bit set to 1 in the query fingerprint, the compressed bitmap of the relevant position is retrieved from the index structure (see Figure 4.5(b)). In the example, the bits set to 1 in the query are in positions 0, 1, kand 2f−1. Therefore, the compressed bitmaps recorded in those positions are obtained from the data structure. Finally, the binary operation AND is applied to all the retrieved compressed bitmaps to obtain a result bitmap whose bits set to 1 refer to candidate graphs for the subsequent verification stage. The verification stage in CW-CTI performs a subgraph isomorphism test to the final set of 52 Chapter 4. Subgraph Searching Techniques for Centralised Architectures 1 0 1 1 0 2 0 3 ... ... 1 k ... ... 1 2-1 f ... ... ... ... 0 AND 1 AND... AND k AND ... AND 2-1 f (c) Filtering Intersection (b) CW-CTI Index (a) Query Fingerprint 0 1 2 3 ... k... 2-1 f 1 1 0 ... 1 1 0 1 ... 0 1 0 1 ... 1 1 1 1 ... 0 . . . 1 0 0 ... 0 . . . 1 0 1 ... 1 0 1 2 ... i ... 0 ... 1 ... 1 ... 0 ... 0 ... 1 ... n 1 1 0 ... 1 ... 0 1 0 1 ... 0 ... 1 1 0 0 ... 0 ... 0 1 0 1 ... 1 ... 1 Figure 4.5: CW filtering stage. candidates with a parallel execution, in a multi-thread architecture, of the improved version of the VF2 algorithm used by the CT-Index method. 4.3 K-Means CT-Index K-Means CT-Index, KM-CTI for shot henceforth, is another proposal based on the CT-Index method described in SubSection 3.2.2. KM-CTI was constructed with the aim of reducing the number of comparisons performed in the original CT-Index method, which test bitmap containment between the query fingerprint and each one of the fingerprints stored in the index structure. Clearly, the filtering time of CT-Index increases linearly with the database size. KM-CTI uses a binary tree of fingerprints whose leaf nodes are the graph fingerprints. The fingerprints stored in internal nodes are obtained with the binary OR of their children fingerprints. Thus, if the bitmap containment test fails for a parent node it would also fail for all its children, and therefore, it is not needed to proceed with further exploration of that branch of the tree. Thus, if the database is large enough and the number of internal nodes has not many 53 DAVID LUACES CACHAZA bits set to 1, performing a search in the KM-CTI binary tree would require a lower number of comparisons than the number of database fingerprints, reducing therefore the processing time in the filtering stage. To minimize the number of bits set to 1 in internal nodes, the fingerprints under the same branch must be as much similar as possible. To achieve this, in the index building stage, the K-Means [17, 34] clustering method is recursively applied to the original set of fingerprints. In general, K-Means is used to distribute a set of elements in Kclusters, in a way that a given distance is minimized between the elements of each cluster. Generally speaking, the algorithm works as follows. First, Kelements of the set are randomly chosen as centroids of the Kclusters. Next, each element is allocated to its nearest centroid, according to a distance function. Once every element is assigned to a cluster, a new centroid is defined for each cluster. This is done by evaluating some kind of “mean” function between the elements of each cluster. These two processes of allocating elements to their nearest neighbor centroid and computing new centroids are iteratively repeated until the elements of each cluster do not change in two consecutive iterations. The two functions, distance and mean, that enable the application of the K-Means algorithm to sets of fingerprints are defined below. Before those definitions, some notation must be introduced. If fis a positive integer, then Fand Fiare used to denote fingerprints, i.e., one dimensional arrays of 2fbits. Symbols ∧,∨,=,¬,⊕denote respectively the bitwise operations and,or,equal,not and exclusive or between a pair of fingerprints. If iis an integer 0≤i<2f, then F[i]denotes the boolean element corresponding to bit number iof F. Finally, int(b)denotes the integer element (either 0 or 1) corresponding to a boolean element b. The definition of distance between two fingerprints is based on the well-known Hamming Distance [20]. Informally, if either of the two fingerprints is contained in the other, then the distance is defined to be zero, otherwise, the distance is the number of bits set to 1 in the result of the exclusive or of both fingerprints. Formally, function distance is defined as follows: Definition 7 If F1and F2are two fingerprints, then distance(F1,F2)is defined as the integer d=   0(F1∧F2=F1)∨(F1∧F2=F2). ∑2f−1 i=0int((F1⊕F2)[i]) otherwise. Function mean enables K-means algorithm to compute a fingerprint that is representative of a cluster of fingerprints as the centroid. Informally, the bit at position iof the mean of a set 54 Chapter 4. Subgraph Searching Techniques for Centralised Architectures a) Query Size 8 b) Query Size 20 c) Query Size 40 0 20 40 60 80 100 120 140 160 180 200 220 240 Time(ms) 4 5 6 7 BM-GGSX GGSX BM-GGSX GGSX BM-GGSX GGSX BM-GGSX GGSX FilteringTime QueryBuildingTime VerificationTime DF 0 10 20 30 40 50 60 70 Time(ms) 4 5 6 7 BM-GGSX GGSX BM-GGSX GGSX BM-GGSX GGSX BM-GGSX GGSX FilteringTime QueryBuildingTime VerificationTime DF 0 10 20 30 40 50 60 Time(ms) 4 5 6 7 BM-GGSX GGSX BM-GGSX GGSX BM-GGSX GGSX BM-GGSX GGSX FilteringTime QueryBuildingTime VerificationTime DF Figure 4.9: Comparison of response times(ms) between GGSX and BM-GGSX on AIDS for different maximum path sizes and query sizes. 61 DAVID LUACES CACHAZA shows how, for small queries (8 edges), BM-GGSX achieves much better filtering time for all values of the maximum path length, but also better verification time especially when the value of the maximum path length is short (4 and 5). The reduction of the filtering time is due to the new bitmap based representation of the data of each node of the trie and to the relevant implementation based on bitmap operations. The reduction in the verification time is due to the incorporation of edge labels in the represented paths. It is noticed how such incorporation of edges is really significant when small values of maximum path length are used. In fact, due to this, the best value of such maximum length for BM-GGSX is 5, whereas the best value for GGSX is 6. For queries of medium (20 edges) and large (40 edges) size, again, the reduction of the filtering time achieved by BM-GGSX with respect to the original GGSX is huge, as it may be observed in Figures 4.9(b-c). Regarding verification time, some reduction may also be observed in the case of medium size queries and short path lengths (4 and 5). Thus, it may be concluded that the incorporation of edge labels is only worthwhile when short paths are used in the structure and also the queries are not too large. Regarding the best value for the maximum path length, there are not really significant differences for BM-GGSX in the response times achieved with maximum path lengths of 4, 5, 6 and 7. A short value of 4 provides slightly better response times for medium and large sizes. Short values of the maximum path length have the additional advantage of providing better performance in both index size and index building time. The comparison of query result times obtained by CT-Index on the AIDS database, using different values of maximum feature size and fingerprint size is shown in Figure 4.10. For small queries (Figure 4.10(a)), increasing the maximum feature size has an important positive impact on the reduction of verification time. This is also true for medium (Figure 4.10(b)) and large (Figure 4.10(c)) queries, however, verification time in those more selective queries is not as important as in small queries with low selectivity. Large fingerprints are only worth with large features sizes, but they incorporate additional overhead on filtering time. Thus, their positive impact on verification time is translated to an overall better performance only for small low selective queries. The above conclusions obtained for the parameter selection of the CT-Index method, may also be applied to the other two methods based on CT-Index, i.e., CW-CTI and KM-CTI. In particular, the result times obtained by CW-CTI on the AIDS database, using different values of maximum features size and fingerprint size are shown in Figure 4.11, whereas Figure 4.12 shows the results obtained by KM-CTI for all the tested parameter combinations. 62 Chapter 4. Subgraph Searching Techniques for Centralised Architectures a) Query Size 8 b) Query Size 20 c) Query Size 40 0 5 10 15 20 25 30 35 40 45 50 55 time(ms) 4 5 6 7 2048 4096 8192 2048 4096 8192 2048 4096 8192 2048 4096 8192 filtering query verification DF 0 1 2 3 4 5 6 7 8 time(ms) 4 5 6 7 2048 4096 8192 2048 4096 8192 2048 4096 8192 2048 4096 8192 filtering query verification DF 0 1 2 3 4 5 6 7 time(ms) 4 5 6 7 2048 4096 8192 2048 4096 8192 2048 4096 8192 2048 4096 8192 filtering query verification DF fpSize fpSize fpSize Figure 4.10: Comparison of response times(ms) of CT-Index on AIDS for different maximum path sizes, fingerprint sizes and query sizes. 63 DAVID LUACES CACHAZA a) Query Size 8 b) Query Size 20 c) Query Size 40 0 2 4 6 8 10 12 14 16 18 20 22 time(ms) 4 5 6 7 2048 4096 8192 2048 4096 8192 2048 4096 8192 2048 4096 8192 filtering query verification DF 0 1 2 3 4 5 6 time(ms) 4 5 6 7 2048 4096 8192 2048 4096 8192 2048 4096 8192 2048 4096 8192 filtering query verification DF fpSize 0 2 4 6 8 10 12 time(ms) 4 5 6 7 2048 4096 8192 2048 4096 8192 2048 4096 8192 2048 4096 8192 filtering query verification DF fpSize fpSize Figure 4.11: Comparison of response times(ms) of CW-CTI on AIDS for different maximum path sizes, fingerprint sizes and query sizes. 64 Chapter 4. Subgraph Searching Techniques for Centralised Architectures a) Query Size 8 b) Query Size 20 c) Query Size 40 0 5 10 15 20 25 time(ms) 4 5 6 7 2048 4096 8192 2048 4096 8192 2048 4096 8192 2048 4096 8192 filtering query verification DF 0 1 2 3 4 5 6 time(ms) 4 5 6 7 2048 4096 8192 2048 4096 8192 2048 4096 8192 2048 4096 8192 filtering query verification DF 0 1 2 3 4 5 6 7 8 9 10 11 time(ms) 4 5 6 7 2048 4096 8192 2048 4096 8192 2048 4096 8192 2048 4096 8192 filtering query verification DF fpSize fpSize fpSize Figure 4.12: Comparison of response times(ms) of KM-CTI on AIDS for different maximum path sizes, fingerprint sizes and query sizes. 65 DAVID LUACES CACHAZA a) Query Size 8 b) Query Size 20 c) Query Size 40 0 20 40 60 80 100 120 140 160 180 200 220 time 4567 2048 2048 2048 2048 filtering query verification DF 0 10 20 30 40 50 60 70 80 90 100 time 4567 2048 2048 2048 2048 filtering query verification DF 0 50 100 150 200 250 300 time 4567 2048 2048 2048 2048 filtering query verification DF time(ms) time(ms) time(ms) Figure 4.13: Comparison of response times(ms) of BM-GGSX on PubChem200k for different maximum path sizes and query sizes. As a general conclusion derived from the experiment undertaken with the small AIDS dataset, small feature sizes of 4 or 5 are slightly better options for BM-GGSX than using larger sizes of 6 or 7. In the case of CT-Index based methods, large features sizes (6 or 7) accompanied by larger fingerprint size are better for small queries with low selectivity, where the verification time is dominant. However, when the queries turn to be larger and more selective, the verification time is not very important and reducing filtering time becomes more important, therefore, small feature sizes, which do not demand large fingerprint sizes, become better options. A similar experiment was performed with the PubChem200k dataset described above. The mean characteristics of the graphs recorded in this new dataset are similar to those of the AIDS dataset, however, the number of graphs recorded is much larger. Therefore, the number of graphs retrieved on average by each query type is also larger, and therefore, the reduction of the verification time becomes more important. As we will see below, this has an impact on the results and thus, the conclusions obtained regarding the best feature and fingerprint size are also different. Figure 4.13 shows the response times obtained by BM-GGSX for different query and feature sizes. The original GGSX method was not evaluated due to its poor performance with 66 Chapter 4. Subgraph Searching Techniques for Centralised Architectures this large dataset. Contrary to the experiment with the AIDS dataset, now the response time of the verification stage is the most important one for all the query sizes. Feature sizes 5 and 6 are now better for small and medium size queries. For large queries, the size of the extracted features does not seem to have a significant impact on the response time. The results of the evaluation of CT-Index using PubChem200k are shown in Figure 4.14. Again, contrary to what was observed with the AIDS dataset, the increase of the feature and fingerprint sizes has an important positive overall impact on the response time for small and medium queries. For large queries, however, the impact is not so important. The conclusions are similar also for CW-CTI (Figure 4.15) and KM-CTI (Figure 4.16), except that now, a larger feature size (7) does not bring the best result in any case. In general, it seems that a feature size of 6 and a fingerprint size of 4096 has a good compromise between either the best or almost the best query response times and reasonable index size and building time. Based on the above experimental results, and also taking into account relevant decisions made in a previous survey [26], in the following experiment all the methods were evaluated using a feature size of 6. In the case of methods based on CT-Index, the chosen fingerprint size was 4096. The objective of this new experiment is the comparison of the performance of all the methods (except the discarded original GGSX), using increasing database and query sizes. The results and relevant discussion are given in the next subsection. 4.4.3 Performance comparison This subsection discusses the results of the performance comparison of all the methods (except GGSX, which was discarded after the previous experiments). As it was stated above, a maximum path length of 6 and a fingerprint size of 4096 were chosen for building the indices and queries. A first comparison was done using the AIDS dataset and queries of sizes 8, 20 and 40 edges. The results are shown in Figure 4.17. For small queries (Figure 4.17(a)), CW-CTI and BM-GGSX offer the smallest filtering time, however, the verification time of BM-GGSX is larger than that of CT-Index based methods. The new CW-CTI and KM-CTI methods improve the verification response time with respect to the original CT-Index, due to the parallel evaluation of the graph isomorphism algorithm. The filtering of candidates achieved by BMGGSX for medium (Figure 4.17(b)) and large (Figure 4.17(c)) queries is very good, reducing verification time and achieving, this way, a very nice total response time. Regarding CW-CTI and KM-CTI, in general, the former yields better filtering time for small queries, as expected, 67 DAVID LUACES CACHAZA a) Query Size 8 b) Query Size 20 c ) Q uer y Size 40 0 50 100 150 200 250 time 4 5 6 7 2048 4096 8192 2048 4096 8192 2048 4096 8192 2048 4096 8192 filtering query verificatio n DF 0 20 40 60 80 100 120 140 160 180 200 220 time 4 5 6 7 2048 4096 8192 2048 4096 8192 2048 4096 8192 2048 4096 8192 filtering query verificatio n DF 0 100 200 300 400 500 600 700 800 time 4 5 6 7 2048 4096 8192 2048 4096 8192 2048 4096 8192 2048 4096 8192 filtering query verificatio n DF time(ms)time(ms) time(ms) Figure 4.14: Comparison of response times(ms) of CT-Index on PubChem200k for different maximum path sizes, fingerprint sizes and query sizes. 68 Chapter 4. Subgraph Searching Techniques for Centralised Architectures a) Query Size 8 b) Query Size 20 c ) Q uer y Size 40 0 10 20 30 40 50 60 70 80 90 100 110 time 4 5 6 7 2048 4096 8192 2048 4096 8192 2048 4096 8192 2048 4096 8192 filtering query verification DF 0 10 20 30 40 50 60 70 80 90 100 time 4 5 6 7 2048 4096 8192 2048 4096 8192 2048 4096 8192 2048 4096 8192 filtering query verification DF 0 50 100 150 200 250 300 350 400 450 time 4 5 6 7 2048 4096 8192 2048 4096 8192 2048 4096 8192 2048 4096 8192 filtering query verificatio n DF time(ms) time(ms) time(ms) Figure 4.15: Comparison of response times(ms) of CW-CTI on PubChem200k for different maximum path sizes, fingerprint sizes and query sizes. 69 DAVID LUACES CACHAZA a) Query Size 8 b) Query Size 20 c ) Q uer y Size 40 0 20 40 60 80 100 120 140 160 time 4 5 6 7 2048 4096 8192 2048 4096 8192 2048 4096 8192 2048 4096 8192 filtering query verificatio n DF 0 10 20 30 40 50 60 70 80 90 100 time 4 5 6 7 2048 4096 8192 2048 4096 8192 2048 4096 8192 2048 4096 8192 filtering query verification DF 0 50 100 150 200 250 300 350 400 450 time 4 5 6 7 2048 4096 8192 2048 4096 8192 2048 4096 8192 2048 4096 8192 filtering query verification DF time(ms) time(ms) time(ms) Figure 4.16: Comparison of response times(ms) of KM-CTI on PubChem200k for different maximum path sizes, fingerprint sizes and query sizes. 70 Chapter 4. Subgraph Searching Techniques for Centralised Architectures BM-GGSX and CT-Index based methods use different types of graph features and relevant representation in their data structures, therefore, different false positive ratios are expected for these two techniques in the results of the filtering stage, which has a big impact on the dominant verification response time. Thus, as it is shown in Figure 4.20, the best performance of BM-GGSX in filtering time is not translated to a better performance in total response time. Besides, the use of a parallel implementation for the verification stage in CW-CTI and KMCTI provides a great advantage over the original CT-Index method. Figure 4.20(a) shows that CW-CTI is the best solution for small queries since it combines a very good solution for the filtering stage with the parallel evaluation of the verification stage. Notice that small queries are not very selective and therefore they retrieve many graphs, therefore, the subgraph isomorphism algorithm has to be applied many times. Doing this application in parallel is a key issue to achieve good total response times. For medium (Figure 4.20(b)) and large (Figure 4.20(c)) queries, BM-GGSX improves the verification stage response times, as its ratio of false positives improves a lot over that of small queries. Besides, KM-CTI improves slightly the performance with respect to CW-CTI, due to the relative reduction of the filtering time. Overall, however, there are small differences between CW-CTI and KM-CTI, since the effectiveness of their filtering stage is identical and they use exactly the same verification stage, whose response time almost determines the total response time. Taking into account all the evaluated characteristics, it may be concluded that a combination of the CW-CTI method for small queries and the KM-CTI method for medium and large ones is a good choice for the implementation of FTV techniques for subgraph searching over very large datasets. Notice that both structures may be perfectly combined just by storing the database fingerprints column-wise, as in CW-CTI, and adding the KM-CTI fingerprint tree. Leaf nodes of the tree must reference appropriate positions in the CW-CTI bitmaps. 77 CHAPTER 5 GENERIC FRAMEWORK FOR SUBGRAPH SEARCHING IN DISTRIBUTED ARCHITECTURES This chapter describes the design of a generic framework for the implementation of FTV subgraph searching algorithms in distributed computing platforms. As noted in Chapter 4, index size and building time increases linearly and exponentially, respectively, with the size of the database. When dealing with very large databases (tens of million), working in a centralised architecture might be unfeasible. The designed generic framework allows to deal with very large databases by implementing both filtering and verification algorithms on top of the open-source cluster computing framework Apache Spark [52]. The key components of the framework are those related to the partitioning of both the database and the indexing structures, to enable the parallel filtering. The re-partitioning of the filtered candidates alleviates data skew during the parallel evaluation of the verification stage. The graphs are recorded in the distributed NoSQL document-based database MongoDB. The methods tested on the previous chapter where adapted to work with this framework. The experiments show a great performance gain in both index building and query response times, especially for small size queries, where the framework leverages the use of powerful clusters to reduce significantly the verification times, and for large databases, which are not approachable by a centralised architecture. DAVID LUACES CACHAZA 5.1 Index Building The procedure that creates distributed indexes in the platform is generic, and therefore independent of the particular indexing technique chosen. Broadly speaking, the database is first partitioned by the range of the graph identifier. It is assumed that graph identifiers are incrementally generated by the system and that the database is not going to be updated after the partitioning. Thus, partitions are perfectly distributed and data skew is not possible in this scenario. An index is generated in parallel for each partition and stored in a separate structure. The pseudocode of such a generic index building procedure that allows every FTV method to work in a distributed architecture is given in Algorithm 4. The input data is composed of three elements: i) an index name iname that enables its identification, ii) an input graph database D, and iii) a number of partitions p. The number of partitions pshould be specified based on the number of data processing nodes available in the cluster. The number of graphs per partition (partition size pSize) is automatically obtained by dividing the database size by the number of partitions. This calculation is done in line 2. In line 3, function createIndex creates the base data structures for the index, and it also stores both the number of partitions and the partition size. An initial data structure is allocated for each partition of the index. Each iteration of the loop of lines 4 −8 is executed in parallel by a different executor of the distributed processing framework. A range query in the graph database Dis performed in line 5 to obtain all the graphs of the current partition i. Graphs should be partitioned and stored in a distributed data management technology, using the same auto-incremental identifier used here to perform the range query, in order to achieve an efficient implementation without data skew. Line 6 creates the index for the current partition iusing the graphs retrieved by the above range query. This function must be defined according to the chosen filtering indexing Algorithm 4 Distributed Index Building 1: procedure BUILDINDEX(iname,D,p) 2: pSize ←ceil(size(D)/p) 3: idx ←createIndex(iname,p,pSize) 4: for i←0,p−1do .Each iteration executed in parallel 5: G←getGraphsByRange(D,pSize ∗i,pSize ∗(i+1)−1) 6: pIdx ←createIndexForPartition(G,pSize,i) 7: storeIndexPartition(idx, pIdx) 8: end for 9: end procedure 80 Chapter 5. Generic Framework for Subgraph Searching in Distributed Architectures structure. Finally, the generated index partition is stored in the index structure in line 7. In the implementation of the framework presented in this work, the graphs are incrementally numbered, partitioned and recorded in the document-based NoSQL database MongoDB. Implementation of both the distributed index building and the query processing is done with Apache Spark. Thus, Spark structures and relevant operations are used as follows to implement Algorithm 4. First, line 3 of the algorithm is implemented by creating a Spark Dataset structure that contains one row for each partition, which records the partition number i. The dataset is partitioned into ppartitions using the partition number, therefore, each partition contains just one row. The loop of lines 4 −8 is implemented by applying Spark Map operation to the above Dataset. The implementation of line 5 is achieved with a range query over the graph number on MongoDB. Line 6 creates an index for each partition pIdx which is initially encoded in memory using the native index technique structure. However, to be able to embed the index in a row of a Spark Dataset, to enable its distributed management, it has to be encoded in a binary format. To achieve this, each underlying indexing technique must be extended with a serialization strategy for its index, that encodes in binary format the whole structure. Line 7 generates a new row in the output Dataset of the Map operation, which contains both the partition number and the binary serialization of the generated index structure. Broadly speaking, the availability of a binary serialization of the underlying indexing structure enables its recording into the distributed Dataset structures of Apache Spark. Thus, both index building, and index querying (as it will be shown below), may be performed in parallel using Dataset level operations of Spark (like the operation Map). The following subsections provided details related to the encoding of each of the used indexing structure in binary format. 5.1.1 Index Building in BM-GGSX To adapt the BM-GGSX method to the generic framework described above, its trie index structure must be encoded and serialized into a byte array. To achieve this, the trie has to be processed in some order and each node of the trie has to be encoded in a byte string. The concatenation of the byte string of each node in the chosen traversal order produces the required trie serialization. The order chosen matches the one used during the query processing, i.e., breath-first order. The serialization of a trie node into a byte array is illustrated in Figure 5.1. The first two 81 DAVID LUACES CACHAZA VEC... C P 11 C P 12 C P 13 C P 14 C P 21 C P 22 C P 23 C P 24 C P c1 C P c2 C P c3 C P c4 R... R P 11 R P 12 R P 13 R P 14 R P 21 R P 22 R P 23 R P 24 R P r+1 1 R P 2 R P 3 R P 4 ... RB 11 RB 12 RB 1 b1 RB 21 RB 22 RB 2 b2 RB r1 RB r2 RB r br ... ... ... r+1 r+1 r+1 Figure 5.1: Serialization into a byte array of a trie node in BM-GGSX. bytes record references to the vertex (V) and edge (E) label fields. The number of children of the present node is recorded in the third byte C. Next, for each child node, four bytes ([CiP1−CiP4]for child i) are used to record a pointer to its location in the trie byte array. These pointers enable the implementation of searching processes directly over the binary encoding of the trie. Leaf nodes have no children, therefore, Cis set to 0 in these nodes and the children pointers are not recorded. Byte Rrecords the number of rows in the bit array of the node, i.e., the maximum number of repetitions. Each row bitmap is compressed using the Enhanced Word-Aligned Hybrid bitmap compression method [33], therefore each row may have a different size in its serialized representation. Thus, for each row of the bit array, a pointer of four bytes ([RiP1−RiP4]for row i) records the location of the serialization of the row in the byte array. Finally, each row bitmap is recorded in (RiB1RiB2...RiBbi for row i). Notice that nodes are recorded following a specific ordering in the binary serial representation of the trie. However, the recording of references from parent to children nodes in the representation enables the implementation of the searching processes directly over the binary representation, improving the performance of the approach with respect to a straightforward approach based on the complete decoding of the whole structure. 5.1.2 Index Building in CW-CTI The column-wise representation of the graph fingerprints used by CW-CTI must be serialized into a byte array. The main problem to take into account to devise such a binary format is derived from the variable size nature of the compressed representations of each fingerprint column. To cope with the variable size of each column, the binary encoding has been divided into two main parts. In the first part of the structure, for each of the fingerprint columns, a pointer to a specific location of the byte array is recorded, where the relevant binary encoding of the 82 Chapter 5. Generic Framework for Subgraph Searching in Distributed Architectures ... C P 11 C P 12 C P 13 C P 14 C P 21 C P 22 C P 23 C P 24 Cf 1 C 2 C 3 C 4 ... C 11 C 12 C 1 b C 21 C 22 C 2 b C 1 C 2 C b ... ... ... f 2f 2f 2 B B B B B B BB B PPPP 2+1 f 2+1 f 2+1 f 2+1 Figure 5.2: Serialization of CW-CTI. column is stored. Those pointers are represented with four bytes and are illustrated in the first row of Figure 5.2. In particular, bytes denoted by CkP1−CkP4represent the four bytes of the pointer to column number k. The byte array of the compressed representation of each column is stored at the byte position referenced by the relevant pointer. In the figure, the second row illustrates the serialization of these compressed bitmaps. In particular, CkB1−CkBbdenotes the bbytes of the compressed representation of column number k. It should be noted that a more simple representation of the compressed bitmaps could have been chosen, for example, one based on the simple recording of the size preceding the representation of each bitmap, which is very common to represent variable size vectors of data elements. However, such a representation would not provide direct access to a specific column and would demand the processing of all the preceding columns to access a specific one. Contrary to the above, the use of pointers in the serialized structure enables the direct access to the compressed bitmap of each column, which in turn enables a more efficient implementation of the filtering algorithm. It is reminded that such an algorithm performs the binary AND operation among the columns that contain a bit 1 in the query fingerprint, thus, only those columns need to be accessed to evaluate a specific query. 5.1.3 Index Building in KM-CTI As in the case of BM-GGSX, the serialization of the KM-CTI structure requires the serialization of a tree. To achieve this, again, a traversal order has to be chosen and a serialization strategy has to be defined for each of the tree node types. In this case, a depth-first order has been chosen to serialize the tree, as the structure is traversed using this order during query processing. The serialization of each of the two node types is described below. Each internal node contains a fingerprint and a couple of pointers, referencing the left and right children. Fingerprints are serialized using a fixed number of bbytes. Pointers to nodes in the structure are represented with four bytes. In addition to the above data, the encoding of each node must include a byte that records the type of node, i.e., either internal or leaf. The 83 DAVID LUACES CACHAZA V12b C P L1 C P L2 C P L3 C P L4 C P R1 C P R2 C P R3 C P R4 ... VVL V12 C I 11 C I 12 C I 13 C I 14 C V 11 C V 12 C V 1b ... VL ... C I 21 C I 22 C I 23 C I 24 C V 21 C V 22 C V 2b ... (a) (b) b V N Figure 5.3: Serialization in KM-CTI: (a) Internal node and (b) Leaf node. byte array used to encode an internal node is illustrated in Figure 5.3 (a). The first bbytes, (V1−Vb), are used to record the node fingerprint (the disjunction of the fingerprints in its subtree). The next byte (L) is used to record the node type, internal node in this case. Finally, the byte array records two sequences of four bytes used as pointers to the left (CLP1−CLP4) and right (CRP1−CRP4) children of the node. Leaf nodes of KM-CTI include the following data: A fingerprint that represents the disjunction of all the fingerprints of all the graphs accessed through the leaf node. One pair (gi,fi), for each graph accessed through the node, where giis the integer graph identifier and fiis the fingerprint that represents the features extracted from the graph. The binary encoding contains the bbytes of the node fingerprint, an extra byte that represents the type of node (leaf node in this case), a byte that records the number of graphs accessed through the node and, for each such graph, 4 bytes to represent its identifier and bbytes to represent its fingerprint. The serialization of leaf nodes is illustrated in Figure 5.3 (b). Bytes (V1−Vb)record the node fingerprint, byte Lrepresents the node type, byte Nrecords the number of graphs accessed through the node, and, for each pair (gi,fi), bytes [CiI1−CiI4]represent the graph identifier giand bytes CiV1−CiVbrepresent the graph fingerprint fi. 5.2 Query Processing Once the indices have been created, partitioned and distributed, they can be used to implement a parallel version of the filtering stage. Broadly speaking, each partition of the index works as a centralised index for the graphs that lie inside that partition, therefore, the searching can be done in parallel in all the partitions. The collection of graph candidates retrieved by each partition must be collected and repartitioned again to enable an efficient parallel implementation of the verification stage, avoiding partition skew. More details of the FTV searching algorithm are given below. Algorithm 5 provides a pseudocode that shows the design of the FTV distributed subgraph searching function of the proposed framework. The input data of this function is given by a 84 Chapter 5. Generic Framework for Subgraph Searching in Distributed Architectures Algorithm 5 Distributed Subgraph Search 1: function DISTRIBUTEDSUBGRAPHSEARCH(q,D,idx) 2: p←getNumPartitions(idx) 3: candidates ←initializeCollection() 4: for i←0,p−1do .Filter: Each iteration executed in parallel 5: pIdx ←getIndexPartition(idx,i) 6: pCandidates ←filter(q,pIdx) 7: append(pCandidates,candidates) 8: end for 9: repartition(candidates,p) 10: result ←initializeCollection() 11: for i←0,p−1do .Verify: Each iteration executed in parallel 12: pCandidates ←getPartition(candiates,i) 13: pCandidateRanges ←f old(pCandidates) 14: for all range ∈pCandidateRanges do 15: G←getGraphsByRange(D,range.start,range.end) 16: for all g∈Gdo 17: if subgraphIsomorphic(q,g)then append(g,result) 18: end if 19: end for 20: end for 21: end for 22: return result 23: end function query graph q, an input graph database D, stored in a distributed data management technology, and a distributed index idx, constructed using the procedure described in the previous section. The algorithm starts by obtaining the number of partitions from the index (line 2) and by initializing a collection of graph candidates for the verification stage (line 3). The filtering stage of the searching process is implemented with the loop of lines 4 −8. Each iteration of this loop performs the searching process in a different partition of the index. The parallel implementation of the filtering stage is achieved by the implementation in parallel of each iteration of this loop. The filtering stage has three steps: i) line 5 obtains the relevant partition from the index. ii) Line 6 performs the searching of the query graph qin the index partition idx obtained in the previous step. iii) Line 7 appends the graph candidates retrieved by the searching process of the previous step to the result collection of candidates initialized earlier. At this moment, for each partition of the index, there is a partition of the graph candidates obtained at that 85 DAVID LUACES CACHAZA partition. Clearly, the distribution of the candidates among the different partitions might not be well balanced, having partitions with many candidates and partitions with few or even without candidates. Applying the verification stage in parallel to these unbalanced partitions would lead to an inefficient implementation, due to partition skew. To avoid this, line 9 repartitions the result collection of candidates, before it is used as input to the verification stage, which is implemented in the loop of lines 11 −21. The iterations of this loop are executed in parallel. Each loop iteration applies the subgraph isomorphism algorithm to the graphs of one of the candidate partitions. First, the candidate graph identifiers of the current partition are obtained from the relevant collection in line 12. Graph identifiers are ordered and folded in line 13 into collections of ranges to improve the efficiency of the graph retrieval from the database. Thus, for example, for the collection of graph identifiers {1,2,3,4,8,9,10,15}, the following ranges are generated {[1−4],[8−10],[15,15]}and, thus, only three range queries have to be submitted to the distributed database to obtain all the required graphs. Notice that the repartitioning performed in line 9 must use a range approach and not a hash approach. Otherwise, line 13 would general large numbers of ranges and the database access would be too inefficient. For each obtained graph identifier range, line 15 submits a range query to the database to obtain a collection of graphs G. Finally, line 17 evaluates the subgraph isomorphism algorithm VF2 for each graph retrieved from the database, and appends the graph to the result in case of a positive result of VF2. The current implementation of the framework stores each graph in a JSON document recorded in a MongoDB collection. Apache Spark is used to execute the searching process in parallel in the cluster. Thus, as already described in the previous section, the distributed index structure is stored in a Spark Dataset, which includes one row for each index partition. It is reminded that the index is actually recorded in a byte array field of this Dataset. The filtering stage (loop of lines 4 −8) is, therefore, implemented with a distributed Map operation over the distributed index Dataset structure. Graph qis used in each Map evaluation to search the serialized encoding of the index stored in the Dataset. The output of the above Map operation is a Dataset of candidate graph identifiers. The Dataset with the result candidate graph identifiers is re-partitioned (see line 9) before it is used as input in the verification stage. The verification stage is also implemented with a Map operation over the Dataset of candidate graph identifiers. The index building and query processing algorithms described above are generic, in the 86 Chapter 5. Generic Framework for Subgraph Searching in Distributed Architectures a) Filtering Time with 64E for small queries b) Filtering Time with 64E for large queries DBSize DBSize Time(ms) Time(ms) Figure 5.7: Average filtering time for distributed implementation (64 executors). 93 DAVID LUACES CACHAZA (Figure 5.7(a)), whereas the best performance for large queries is achieved by KM-CTI (Figure 5.7(b)). It is noticed that the distributed implementation of the system enables the filtering of databases of tens of millions of graphs with response times below one second, both for small and large queries. The best approach would the direct use of the fingerprints (i.e., the use of CT-Index) for small queries and the use of the fingerprint tree (i.e. KM-CTI) for large queries. This reminds also a common optimization decision in conventional databases, which prefer the scan of the whole table for queries of low selectivity and use an index for queries of high selectivity. The above conclusions on the response time of the filtering stage may be in general extrapolated to the response time of the whole query, i.e., including both filtering and verification stages. It is noticed that now, contrary to what happened with the centralised implementations, the implementation of the verification stage is identical for all the indexing methods. Figure 5.8 illustrates the horizontal scalability of the distributed implementation of the whole FTV subgraph search. The experiments were executed on the database of 4 M graphs. In general, CT-Index behaves better for small queries and KM-CTI has better performance for large queries. Given that the verification stage has a great influence on the total response time for small queries, the differences between CT-Index and KM-CTI are not really important when the number of executors is large. For large queries, the filtering time gains importance, due to the high selectivity of the query and the fewer candidates to verify. Therefore, KM-CTI keeps its advantage also for total response time in large queries. The impact of the database size on the total response time of the system is illustrated in Figure 5.9, where all the experiments were executed using the maximum number of executors and partitions (64). Now, it is noticed that for small queries (Figure 5.9(a)), where the verification time is the most important component, both CT-Index and KM-CTI offer similar performance and scalability, being CT-Index slightly better when the database size is very large (16M graphs). On the other hand, it is clear that the use of the fingerprint tree is an advantage for large queries (Figure 5.9(b)), where the filtering time is more important than the verification time. Once the various indexing approaches have been compared, taking into account both index building time and filtering and total query response time, a couple of questions need still to be resolved. It has been shown that the distributed implementation brings a clear advantage over the centralised one in terms of index building time. However, the filtering and total response time of centralised and distributed implementations have not been compared. Additionally, 94 Chapter 5. Generic Framework for Subgraph Searching in Distributed Architectures a) Total Time on 4M DB for small queries b) Total Time on 4M DB for large queries Time(minutes) Time(minutes) Executors Executors Figure 5.8: Average total response time for distributed implementations (4M graph database size). 95 DAVID LUACES CACHAZA a) Total Time with 64E for small queries b) Total Time with 64E for large queries DBSize DBSize Time(ms) Time(ms) Figure 5.9: Average total response time for distributed implementation (64 executors). 96 Chapter 5. Generic Framework for Subgraph Searching in Distributed Architectures it is not clear whether the parallel application of the VF2 subgraph isomorphism algorithm might bring results competitive with those of the implemented distributed FTV approaches. The discussion below will show some light on these two issues. The first question to respond is whether the distributed filtering reaches better performance than the centralised one. Figure 5.10 compares the filtering time obtained by the centralised version of KM-CTI with the filtering time of the relevant distributed implementation, using 4, 16 and 64 executors. For small queries (Figure 5.10(a)), the distributed implementation behaves better when the number of executors is increased. However, the centralised implementation has better performance than the distributed one. It is observed, however, that the difference in performance between the distributed and centralised implementations is reduced when the database size increases. Thus, it is expected that with really large database sizes, the distributed implementation might get better performance than the distributed one. For medium and large query sizes (Figures 5.10(b-c)), the centralised implementation is clearly better than the distributed one. The comparison of centralised and distributed implementations of KM-CTI in terms of total response time is shown in Figure 5.11. Now, the centralised implementation gets better results only when the query is large and the database is small (below 1M graphs). This is due to the great performance gain achieved by the distributed implementation with respect to the centralised one in the verification stage, when the set of candidates to verify is large, i.e., when the query is small or the database is large enough. As a conclusion, the centralised approach gets better performance in the filtering stage, but the distributed implementation of the verification stage is what enables the efficient querying of very large databases. It is also noticed that, although the centralised approach is faster in filtering, very large datasets may be indexed only with a distributed approach. The fact that the index must fit in main memory is also a limitation of the centralised approach for filtering very large datasets. A final experiment tested the performance of the FTV approaches with respect to the distributed evaluation of the VF2 subgraphs isomorphism algorithm over the whole database. The KM-CTI approach was selected to represent the FTV approaches. The results are shown in Figure 5.12. The FTV approach gets performances orders of magnitude better than the direct distributed evaluation of VF2. For this reason the yellow and green lines representing the FTV methods in the Figure seem to be overlapped. The performance improvement of the FTV approach increases linearly with the database size. It is obvious that the direct distributed implementation of VF2 is not an option in practice for very large databases. 97 DAVID LUACES CACHAZA a) Filtering Time for small queries b) Filtering Time for medium queries c) Filtering Time for large queries Time(s) Time(s) Time(s) DBSize DBSize DBSize Figure 5.10: Comparison of query filtering time between centralised and distributed implementations for KM-CTI method. 98 Chapter 5. Generic Framework for Subgraph Searching in Distributed Architectures a) Total Time for small queries b) Total Time for medium queries c) Total Time for large queries DBSize DBSize DBSize Time(s)Time(s) Time(s) Figure 5.11: Comparison of query total response time between centralised and distributed implementations for KM-CTI method. 99 DAVID LUACES CACHAZA Time(s) DBSize Figure 5.12: Illustration of the significance of the use of indexing with respect to the simple parallel evaluation of a subgraph isomorphism algorithm. 100 CHAPTER 6 APPROXIMATE PROCESSING FOR INTERACTIVE SEARCHING IN MOLECULAR DATASETS In previous chapters, it was shown how different indexing techniques used in FTV strategies helped in achieving important performance improvements during the evaluation of subgraph searching queries. However, a very common scenario is the one where the user must perform interactive searching and browsing tasks to get a general overview of the dataset contents. When the size of the dataset is very large, such as the PubChem dataset that contains around 100M graphs, performing searching with interactive response times (subsecond in general) requires the presentation of approximate results. Based on the above, in this chapter, various approximate processing approaches, some of them already used in the filtering stage of FTV techniques, are analyzed and compared to determine if they might be good candidates for the construction of interactive searching solutions. 6.1 Interactive Searching in Molecular Datasets The need for the elimination of replicas from known compounds is one of the problems, which arises in the chemical, biotechnological and pharmaceutical research areas, that motivate the research effort towards the design of better techniques for substructure searching. However, in many cases, the user does not have a clear and precise idea of what is looking for, and what DAVID LUACES CACHAZA B C N O Elements F Ne Al Si P S Cl Ar Sc Ti V Cr H He Li Be Na Mg K Ca Bounds ResultSearch Molecule1 Molecule2 Molecule3 Molecule4 Molecule5 Molecule6 Molecule7 Molecule8 Molecule9 Molecule10 Molecule11 Molecule12 Molecule13 Molecule14 Molecule15 Molecule16 Molecule17 Molecule18 H C C N Verify Molecule Explorer +-+- Figure 6.1: Mockup of an interactive searching application. is really helping is the availability of interactive search interfaces. Such interfaces must have very fast response times [8, 36], but it might be acceptable to get approximate responses, i.e., response sets that might include some molecules whose structure does not really contain the query substructure. One possible such interactive searching interface is described below. Let us consider the mockup of an interactive searching user interface shown in Figure 6.1. At the left part of the interface, the user may drag chemical elements to the search area to define atoms and, next, link them using the different types of available bounds. As the search structure is being modified by the user, the result list is automatically updated to obtain all the molecules from the database whose structure contains the search substructure. One of the molecules of the list (the first one by default) is shown in the result visualization area. The user may choose any of the molecules of the result list to graphically explore its structure. To achieve a usable interface, the list of result molecules must be updated interactively, i.e., with response times below one second, every time the user does some update in the search structure. Therefore, substructure queries should be solved with response times below one second, independently of the size of the structure drawn by the user and independently of the size of the database. It might be acceptable, however, that some of the molecules of the list 102 Chapter 6. Approximate Processing for Interactive Searching in Molecular Datasets Probability 0 0,05 0,1 0,15 0,2 0,25 0,3 0,35 0,4 012345678910 Number of hash functions 0 10 20 30 40 50 60 70 80 90 100 110 0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 Error Number of elements 0 1 2 3 4 5 6 7 8 9 10 0 100 200 300 400 500 600 700 800 900 1000 Error Number of elements 512 4096 1024 2048 256 256 512 1024 2048 4096 (a) Máximum errror for number of elements and number of counters per hash function (b) Probability of having higher error for number of hash functions Figure 6.5: Error guaranteed and relevant probability for increasing number of elements inserted in Count-Min Sketch with different number of counters per hash function. In particular, if f req(si)denotes the real frequency of element siin S, and CMS(si)denotes the approximation of the frequency obtained from the CMS, then the expression CMS(si)≤f req(si)+ε∗n,ε=e/w is guaranteed with a probability of 1 −e−d. Therefore, given an objective error factor ε= error/nand a given probability for the guarantee of the error of 1−δ, the required values for dand wmay be obtained with the following formulas: w=le εmd=ln 1 δ Figure 6.5(a) shows values of the absolute error for different values of the number of elements inserted nand for the number of counters stored for each hash function w. On the other hand, Figure 6.5(b) shows how the probability of having a higher error decreases by increasing the number of hash functions dused. 109 DAVID LUACES CACHAZA 6.2.3 Sachem Sachem [30] is an open-source chemical cartridge for the PostgreSQL database that allows efficient molecular substructure searches in databases of different sizes, including large size databases. Sachem implements two search methods. The first one is a modification of the OrChem[41] cartridge, porting it to PostgreSQL and adding some optimizations, such as replacing the molecule storage format from text to a binary format or optimizing the VF2 algorithm for better performance. The second method is an extension of the previous and employs fixed-size fingerprints, which are adapted to be stored in inverted indices in the Apache Lucy 1database. Apache Lucy is a port of the well-established Apache Lucene [4]. The indexing works as follows. First, the molecule is decomposed into substructural features, which are encoded into fingerprints. Next, the fingerprint bits are converted into keywordlike descriptors compatible with Apache Lucy text documents. The resulting keywords are concatenated to a string and indexed as documents using a whitespace analyzer. It should be noted that Sachem does not take into account the types of bounds (tags of edges in the graph), and therefore, the edges are used neither for indexing nor for searching. This leads to a faster performance, with the cost of not retrieving exact solutions in some scenarios. note that if we consider the results obtained by the VF2 algorithm for each query as the correct ones, then both false positives and false negatives can be found in the results obtained by Sachem. It is also reminded that the filtering stage of all the FTV approaches used in this Thesis may yield false positives, but not false negatives. Based on these observations, Sachem will be considered as another approach with approximate results, and thus, it will be compared with the other approaches in terms of both efficiency and efficacy. 6.3 Experimental Evaluation of Efficacy and Efficiency This section presents and discusses the results of the evaluation performed, in terms of efficacy and efficiency, of subgraph search solutions build with fingerprints (Bloom Filters of just one hash function) and also with Count-Min Sketches. These solutions are also compared with Sachem, to show where they are located with respect to currently available systems. 1https://lucy.apache.org/ 110 Chapter 6. Approximate Processing for Interactive Searching in Molecular Datasets 6.3.1 Evaluation Framework The experiments were performed in a centralised hardware architecture of a single node with the following configuration. Ubuntu Server release 20.04.2, with a KVM processor of 2.20 GHz and 8 cores, 8 GB of RAM and 40 GB of disk. Various different subgraph search approaches constructed with Bloom Filters (actually fingerprints) and Count-Min Sketches were tested. Specifically: •KM-CTI: Various solutions based on the KM-CTI indexing structure proposed in this Thesis were evaluated. As it was remarked, the fingerprints used by this approach are actually Bloom Filters with a single hash function. Six different fingerprint sizes were considered ranging from 256 bits to 8192 bits. These approaches were evaluated with just the filtering stage (approximate solutions) and with both filtering and verification stages. •CMS: Various solutions based on the use of Count-Min Sketches for the filtering stage of FTV approaches were implemented and evaluated. The CMS was used to replace the fingerprint in an approach based on the CT-Index. Recording the number of repetitions (frequency) for each feature extracted from each graph instead of a single Boolean value provides additional information that is used to discard more graphs during the filtering stage. On the other hand, the resulting indexing structure is larger and the filtering response time is increased. CMS structures with 1, 2 and 3 hash functions and with a number of counters per hash function ranging from 256 to 4096 were considered. Again, these approaches were evaluated with just the filtering stage (approximate solutions) and with both filtering and verification stages. •Sachem: The extension was installed in a PostgreSQL database and its performance was compared with the various combinations of the approaches above. One database was constructed for the experiments, composed of 200k molecules, extracted from the PubChem dataset. The queries used in the experiments were also obtained from the PubChem dataset following the approach already described in Section 4.4.1. Three sets of 1000 queries were built, one set for small size queries (8 edges), another set for medium size queries (20 edges), and a last set for large size queries (40 edges). 111 DAVID LUACES CACHAZA 6.3.2 Evaluation of the System Efficacy To be able to give a measure of the system efficacy, a reference approach that provides maximum efficacy (a gold standard) has to be chosen. In this Thesis, the selected gold standard is the VF2 subgraph isomorphism algorithm [11]. The efficacy measures used in this section are those most commonly used in the field of information retrieval [35]. Let Rbe the set of graphs retrieved by the system and Gthe set of graphs contained in the result of the gold standard, i.e., the set of graphs that the system should have retrieved. Then, the following efficacy measures are defined: •Precision: It is defined as the ratio of true positive graphs retrieved by the system with respect to all the graphs retrieved by the system. More formally, precision =R∩G R. The precision gives an inverse measure of the amount of incorrect results retrieved by the system. Thus, a precision of 1 means that all the graphs retrieved by the systems are correct, although perhaps the system may not retrieve all the required graphs. •Recall: It is defined as the ratio of true positive graphs with respect to the result of the gold standard. More formally, recall =R∩G G. The recall gives a measure of how complete the result is with respect to the gold standard. Thus, a recall of 1 means that all the graphs of the gold standard have been retrieved by the system, although there might be some graphs retrieved by the system that should not have been retrieved. •F-Score (F1-Score): It combines the two measures above into a simple measure, enabling this way the comparison of different approaches with a single aggregated measure. This measure assumes the same importance for both recall and precision. The mathematical expression that obtains this measure from the two previous as follos. F-Score =2∗precision ∗recall precision +recall . 112 Chapter 6. Approximate Processing for Interactive Searching in Molecular Datasets It is noticed that all the subgraph search solutions described in previous chapters reach the gold standard, since their verification stage consists in the evaluation of VF2 to discard false positives. It is reminded, however, that the filtering stages of the FTV approaches described in this Thesis might have false positives, therefore the precision of their results is usually lower than 1. Finally, the Sachem implementation yields both false positives and false negatives, therefore, in general, this system does not achieve a perfect precision nor a perfect recall. The precision values achieved by each of the approximate search approaches evaluated for different query sizes are illustrated in Figure 6.6. More precisely, 6.6(a) shows the average precision of the 1000 queries of small size (size 8) for various filtering approaches using CMS and KM-CTI; as well as the precision reached by Sachem. The CMS structures reach a very high precision (around 0.9) when the number of counters per hash function is higher or equal to 1024. The use of more than one hash function does not bring a significant improvement in precision for numbers of counters greater than 1024. A similar precision for these small queries is also achieved by KM-CTI using a bitset of at least 2048 bits. The precision of Sachem is lower, slightly above 0.8. For medium and large queries, see Figures 6.6(b) and 6.6(c), respectively, again a CMS with 1024 counters and just one hash function brings a good precision (above 0.8). However, now the KM-CTI does not reach such high precision, even with the highest number of bits. The precision of Sachem is only slightly higher than 0.6. Both CMS and KM-CTI have recall values of 1, therefore their F-Score is only determined by their precision. This is not the case for Sachem, which has both false positives and false negatives. The values of the F-Score of all the approaches are shown in Figure 6.7. The comparison between CMS and KM-CTI throws the same conclusions as the comparison of their result precision. Again, a CMS of 1024 with just one hash function gives F-Scores that are not significantly improved by higher numbers of counters or hash functions. Again, the KM-CTI has F-Scores similar to those of CMS only for small queries. Now, Sachem is penalised even more, due to the presence of false negatives, and its F-Score is not higher than 0.6 in any case, even for small queries. As a conclusion of the above comparison of the efficacy of the different approaches, a solution based on the CMS provides good results for queries of any size. Using a maximum feature size of 6 does not required more than 1024 counters and more than one hash function to achieve good results. KM-CTI should only be used for small queries and Sachem does not give good enough results in any case. 113 DAVID LUACES CACHAZA a) Query Size 8 b) Query Size 20 c) Query Size 40 Figure 6.6: Response average precision. 114 Chapter 6. Approximate Processing for Interactive Searching in Molecular Datasets a) Query Size 8 b) Query Size 20 c) Query Size 40 Figure 6.7: Response F-Score 115 DAVID LUACES CACHAZA Figure 6.8: Index size (MB). 6.3.3 Evaluation of the System Efficiency Two different measures were considered to evaluate the efficiency of the different approaches, namely the amount of memory required to record the index structure and the query response time. The size of the indexing structure used by each approach is shown in Figure 6.8. The size of the index for the approaches based on the CMS structure is larger and increases significantly with the number of counters and hash functions. KM-CTI performs better than CMS in terms of memory usage and Sachem has the smallest index size. The approaches whose efficacy was compared in the previous section are now evaluated in terms of their query response times. The average response times achieved by each of the approaches with the three query sizes are shown in Figure 6.9. The fastest CMS based 116 Chapter 6. Approximate Processing for Interactive Searching in Molecular Datasets a) Query Size 8 b) Query Size 20 c) Query Size 40 Figure 6.9: Average response time (ms) of the approximate searching approaches. 117 DAVID LUACES CACHAZA approach of those identified in the previous section as having good efficacy is the one with 1024 counters and just one hash function. The response time of this CMS based approach is similar to the one achieved by Sachem, but it is reminded that the efficacy of Sachem is too poor. On the other hand, the response times achieved by KM-CTI based solutions are by far much better. Based on the above, we can conclude that CMS and KM-CTI based approaches are better than Sachem because they have better efficacy and also either better or equal efficiency. Regarding whether to use CMS or KM-CTI based approaches, it is clear that KM-CTI is better for small queries. However, for medium and large queries it depends on the application. If efficacy is more important than efficiency, then it is better to use a CMS structure. On the contrary, if the efficiency is the key factor, it is clear that KM-CTI is going to reach much better performance. As it was shown above, CMS based approaches have better efficacy and KM-CTI has better response time. One possible way to get an idea of whether a better efficacy compensates for a worse response time is to include the verification stage in the comparison. In particular, we will observe whether the better efficacy produces a gain in verification response time that compensates the worse response time of the filtering stage. The total response times of all the approaches for the three different query sizes are shown in Figure 6.10. Sachem has the best figures in terms of response time, but it is reminded that Sachem does not have a good efficacy, whereas the other approaches have perfect recall and precision. For small queries (see Figure 6.10(a)), as it was expected, approaches based on KM-CTI are slightly better than those based on CMS. It is reminded that KM-CTI has better results also in terms of index size. For queries of medium size (see Figure 6.10(b)), the response times of all the approaches are very similar. Finally, CMS based approaches have better response time than those based on KM-CTI for large queries (see Figure 6.10(c)). It is also noticed that, if we discard the CMS with 256 counters and the KM-CTI with 256 bits, which have clearly worse performance, all the other approaches have similar performance. Thus, if the objective is to have perfect efficacy, it is not worth creating large indexes since 512 counters with just one hash function for CMS and 1024 bits for KM-CTI offer a very good query response time. 118 Bibliography [1] Michael A. Bender, Martin Farach-Colton, Rob Johnson, Russell Kraner, Bradley C. Kuszmaul, Dzejla Medjedovic, Pablo Montes, Pradeep Shetty, Richard P. Spillane, and Erez Zadok. Don’t thrash: How to cache your hash on flash. Proc. VLDB Endow., 5(11):1627–1637, jul 2012. [2] B. Bhattarai, H. Liu, and H. Howie Huang. Ceci: Compact embedding cluster index for scalable subgraph matching. In Proceedings of the ACM SIGMOD International Conference on Management of Data, pages 1447–1462, 2019. [3] F. Bi, L. Chang, X. Lin, L. Qin, and W. Zhang. Efficient subgraph matching by postponing cartesian products. In Proceedings of the 2016 ACM SIGMOD International Conference on Management of Data, pages 1199–1214. ACM, 2016. [4] A Białecki and G Ingersoll. Lucid imagination. Apache lucene 4. SIGIR 2012 workshop on open source information retrieval, page 17, 2012. [5] Burton H. Bloom. Space/time trade-offs in hash coding with allowable errors. Commun. ACM, 13(7):422–426, July 1970. [6] V. Bonnici, A. Ferro, R. Giugno, A. Pulvirenti, and D. Shasha. Enhancing graph database indexing by suffix tree structure. In IAPR International Conference on Pattern Recognition in Bioinformatics, pages 195–203. Springer, 2010. [7] Flavio Bonomi, Michael Mitzenmacher, Rina Panigrahy, Sushil Singh, and George Varghese. An improved construction for counting Bloom filters. Lecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics), 4168 LNCS:684 – 695, 2006. DAVID LUACES CACHAZA [8] Stuart K. Card, George G. Robertson, and Jock D. Mackinlay. The information visualizer, an information workspace. In Proceedings of the SIGCHI Conference on Human Factors in Computing Systems, CHI ’91, page 181–186, New York, NY, USA, 1991. Association for Computing Machinery. [9] J. Cheng, Y. Ke, W. Ng, and A. Lu. FG-Index: Towards verification-free query processing on graph databases. In Proceedings of the ACM SIGMOD International Conference on Management of Data, pages 857–872, 2007. [10] Saar Cohen and Yossi Matias. Spectral bloom filters. In Proceedings of the ACM SIGMOD International Conference on Management of Data, page 241–252, New York, NY, USA, 2003. [11] L.P. Cordella, P. Foggia, C. Sansone, and M. Vento. A (sub) graph isomorphism algorithm for matching large graphs. IEEE Transactions on Pattern Analysis and Machine Intelligence, 26(10):1367–1372, 2004. [12] Graham Cormode and S. Muthukrishnan. An improved data stream summary: The count-min sketch and its applications. Journal of Algorithms, 55(1):58 – 75, 2005. [13] H.-C. Ehrlich and M. Rarey. Systematic benchmark of substructure search in molecular graphs - From Ullmann to VF2. Journal of Cheminformatics, 4(1), Jul 2012. [14] H.-C. Ehrlich, A. Volkamer, and M. Rarey. Searching for substructures in fragment spaces. Journal of Chemical Information and Modeling, 52(12):3181–3189, 2012. PMID: 23205736. [15] Bin Fan, David G. Andersen, Michael Kaminsky, and Michael D. Mitzenmacher. Cuckoo filter: Practically better than bloom. In CoNEXT 2014 - Proceedings of the 2014 Conference on Emerging Networking Experiments and Technologies, page 75 – 87, 2014. [16] Li Fan, Pei Cao, Jussara Almeida, and Andrei Z. Broder. Summary cache: A scalable wide-area web cache sharing protocol. IEEE/ACM Transactions on Networking, 8(3):281 – 293, 2000. [17] E. Forgy. Cluster analysis of multivariate data: efficiency versus interpretability of classifications. Biometrics, 21:768–780, 1965. 126 Bibliography [18] Edward Fredkin. Trie memory. Commun. ACM, 3(9):490–499, sep 1960. [19] R. Giugno, V. Bonnici, N. Bombieri, A. Pulvirenti, A. Ferro, and D. Shasha. Grapes: A software for parallel searching on biological graphs targeting multi-core architectures. PLoS ONE, 8(10), 2013. [20] R. W. Hamming. Error detecting and error correcting codes. Bell System Technical Journal, 29(2):147–160, 1950. [21] Myoungji Han, Hyunjoon Kim, Geonmo Gu, Kunsoo Park, and Wook-Shin Han. Efficient subgraph matching: Harmonizing dynamic programming, adaptive matching order, and failing set together. In Proceedings of the 2019 International Conference on Management of Data, SIGMOD ’19, pages 1429–1446, New York, NY, USA, 2019. ACM. [22] W.-S. Han, J. Lee, and J.-H. Lee. Turboiso: Towards ultrafast and robust subgraph isomorphism search in large graph databases. In Proceedings of the 2013 ACM SIGMOD International Conference on Management of Data, pages 337–348. ACM, 2013. [23] W.-S. Han, J. Lee, M.-D. Pham, and J.X. Yu. iGraph: A framework for comparisons of disk based graph indexing techniques. Proceedings of the VLDB Endowment, 3(1):449– 459, 2010. [24] H. He and A. K. Singh. Graphs-at-a-time: Query language and access methods for graph databases. In Proceedings of the ACM SIGMOD International Conference on Management of Data, pages 405–417, 2008. [25] X. Jin and L. Lai. Mpmatch: A multi-core parallel subgraph matching algorithm. In Proceedings - 2019 IEEE 35th International Conference on Data Engineering Workshops, ICDEW 2019, pages 241–248, 2019. [26] F. Katsarou, N. Ntarmos, and P. Triantafillou. Performance and scalability of indexed subgraph query processing methods. Proceedings of the VLDB Endowment, 8(12):1566– 1577, 2015. [27] F. Katsarou, N. Ntarmos, and P. Triantafillou. Subgraph querying with parallel use of query rewritings and alternative algorithms. In Advances in Database Technology - EDBT, volume 2017-March, pages 25–36, 2017. 127 DAVID LUACES CACHAZA [28] Foteini Katsarou, Nikos Ntarmos, and Peter Triantafillou. Hybrid algorithms for subgraph pattern queries in graph databases. In 2017 IEEE International Conference on Big Data (Big Data), pages 656–665, 2017. [29] K. Klein, N. Kriege, and P. Mutzel. Ct-index: Fingerprint-based graph indexing combining cycles and trees. In Data Engineering (ICDE), 2011 IEEE 27th International Conference on, pages 1115–1126. IEEE, 2011. [30] Miroslav Kratochv´ ıl, Jiˇ r´ ı Vondr´ aˇ sek, and Jakub Galgonek. Sachem: A chemical cartridge for high-performance substructure search. Journal of Cheminformatics, 10(1), 2018. [31] G. Landrum. Rdkit: Open-source cheminformatics software. 2017. [32] J. Lee, W.-S. Han, R. Kasperovics, and J.-H. Lee. An in-depth comparison of subgraph isomorphism algorithms in graph databases. In Proceedings of the VLDB Endowment, volume 6, pages 133–144, 2012. [33] D. Lemire, O. Kaser, and K. Aouiche. Sorting improves word-aligned bitmap indexes. Data and Knowledge Engineering, 69(1):3–28, 2010. [34] J. MacQueen. Some methods for classification and analysis of multivariate observations. In Proceedings of the Fifth Berkeley Symposium on Mathematical Statistics and Probability, Volume 1: Statistics, pages 281–297, Berkeley, 1967. University of California Press. [35] Raghavan P. Sch¨ utze H. Manning, C.D. Introduction to Information Retrieval. Cambridge University Press, 2008. [36] Jakob Nielsen. Usability Engineering. Morgan Kaufmann, 1994. [37] Noel M. O’Boyle, Michael Banck, Craig A. James, Chris Morley, Tim Vandermeersch, and Geoffrey R. Hutchison. Open babel: An open chemical toolbox. 3(10), 2011. [38] Prashant Pandey, Michael A. Bender, Rob Johnson, and Rob Patro. A general-purpose counting filter: Making every bit count. In Proceedings of the ACM SIGMOD International Conference on Management of Data, volume Part F127746, page 775 – 787, 2017. 128 Bibliography [39] X. Ren and J. Wang. Exploiting vertex relationships in speeding up subgraph isomorphism over large graphs. Proceedings of the VLDB Endowment, 8(5):617–628, 2015. [40] Xuguang Ren, Junhu Wang, Wook-Shin Han, and Jeffrey Xu Yu. Fast and robust distributed subgraph enumeration. Proc. VLDB Endow., 12(11):1344–1356, July 2019. [41] Mark Rijnbeek and Christoph Steinbeck. Orchem - An open source chemistry search engine for Oracle®. Journal of Cheminformatics, 1(1), 2009. [42] H. Shang, Y. Zhang, X. Lin, and J. X. Yu. Taming verification hardness: An efficient algorithm for testing subgraph isomorphism. Proceedings of the VLDB Endowment, 1(1):364–375, 2008. [43] Christoph Steinbeck, Yongquan Han, Stefan Kuhn, Oliver Horlacher, Edgar Luttmann, and Egon Willighagen. The chemistry development kit (cdk): An open-source java library for chemo- and bioinformatics. 43(2):493 – 500, 2003. [44] S. Sun and Q. Luo. Scaling up subgraph query processing with efficient subgraph matching. In Proceedings - International Conference on Data Engineering, volume 2019- April, pages 220–231, 2019. [45] J. R. Ullmann. An algorithm for subgraph isomorphism. Journal of the ACM, 23(1):31– 42, 1976. [46] J. Wang, N. Ntarmos, and P. Triantafillou. Indexing query graphs to speedup graph query processing. In Advances in Database Technology - EDBT, volume 2016-March, pages 41–52, 2016. [47] J. Wang, N. Ntarmos, and P. Triantafillou. Graphcache: A caching system for graph queries. In Advances in Database Technology - EDBT, volume 2017-March, pages 13– 24, 2017. [48] J. Wang, X. Ren, S. Anirban, and X.-W. Wu. Correct filtering for subgraph isomorphism search in compressed vertex-labeled graphs. Information Sciences, 482:363–373, 2019. [49] David Weininger. Smiles, a chemical language and information system: 1: Introduction to methodology and encoding rules. 28(1):31 – 36, 1988. 129 DAVID LUACES CACHAZA [50] Egon L. Willighagen, John W. Mayfield, Jonathan Alvarsson, Arvid Berg, Lars Carlsson, Nina Jeliazkova, Stefan Kuhn, Tom´ aˇ s Pluskal, Miquel Rojas-Chert´ o, Ola Spjuth, Gilleain Torrance, Chris T. Evelo, Rajarshi Guha, and Christoph Steinbeck. The chemistry development kit (cdk) v2.0: atom typing, depiction, molecular formulas, and substructure searching. 9(1), 2017. [51] X. Yan, P.S. Yu, and J. Han. Graph indexing: A frequent structure-based approach. In Proceedings of the ACM SIGMOD International Conference on Management of Data, pages 335–346, 2004. [52] M. Zaharia, R.S. Xin, P. Wendell, T. Das, M. Armbrust, A. Dave, X. Meng, J. Rosen, S. Venkataraman, M.J. Franklin, A. Ghodsi, J. Gonzalez, S. Shenker, and I. Stoica. Apache spark: A unified engine for big data processing. Communications of the ACM, 59(11):56–65, 2016. [53] S. Zhang, M. Hu, and J. Yang. Treepi: A novel graph indexing method. In Proceedings - International Conference on Data Engineering, pages 966–975, 2007. [54] P. Zhao and J. Han. On graph query optimization in large networks. Proceedings of the VLDB Endowment, 3(1):340–351, 2010. [55] P. Zhao, J. X. Yu, and P. S. Yu. Graph indexing: Tree + Delta >=Graph. In 33rd International Conference on Very Large Data Bases, VLDB 2007 - Conference Proceedings, pages 938–949, 2007. [56] W. Zheng, L. Zou, X. Lian, H. Zhang, W. Wang, and D. Zhao. SQBC: An efficient subgraph matching method over large and dense graphs. Information Sciences, 261:116– 131, 2014. [57] L. Zou, L. Chen, J. X. Yu, and Y. Lu. A novel spectral coding in a large graph database. In Advances in Database Technology - EDBT 2008 - 11th International Conference on Extending Database Technology, Proceedings, pages 181–192, 2008. 130 List of Figures Fig. 2.1 Illustration of a molecular entity. . . . . . . . . . . . . . . . . . . . . . . . 24 Fig. 2.2 Example of an NRM spectrum. . . . . . . . . . . . . . . . . . . . . . . . . 28 Fig. 2.3 Illustration of the molform index developed during the NEXTCHROM project. 30 Fig. 3.1 Example of an undirected graph representing the structure of a molecule. . . 35 Fig. 3.2 Illustration of a subgraph isomporphism. . . . . . . . . . . . . . . . . . . . 35 Fig. 3.3 Representation of a trie structure used as index in GGSX. . . . . . . . . . . 41 Fig. 3.4 Example of the filtering stage in GGSX. . . . . . . . . . . . . . . . . . . . 41 Fig. 3.5 CT-Index fingerprint building example. . . . . . . . . . . . . . . . . . . . . 43 Fig. 3.6 Example of the filtering stage in CT-Index. . . . . . . . . . . . . . . . . . . 44 Fig. 4.1 Example of a BM-GGSX trie structure. . . . . . . . . . . . . . . . . . . . . 48 Fig. 4.2 Comparison between (a) GGSX and (b) BM-GGSX path repetitions storage. 49 Fig. 4.3 BM-GGSX filtering stage. . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Fig. 4.4 Fingerprint insertion in the CW-CTI index. . . . . . . . . . . . . . . . . . . 52 Fig.4.5 CWfilteringstage................................ 53 Fig. 4.6 Example of distance and mean measures between bitmaps used in KM-CTI. 55 Fig. 4.7 Example of the index building stage in KM-CTI. . . . . . . . . . . . . . . . 56 DAVID LUACES CACHAZA Fig. 4.8 Example of the filtering stage in KM-CTI. . . . . . . . . . . . . . . . . . . 58 Fig. 4.9 Comparison of response times(ms) between GGSX and BM-GGSX on AIDS for different maximum path sizes and query sizes. . . . . . . . . . . . . . . 61 Fig. 4.10 Comparison of response times(ms) of CT-Index on AIDS for different maximum path sizes, fingerprint sizes and query sizes. . . . . . . . . . . . . . . 63 Fig. 4.11 Comparison of response times(ms) of CW-CTI on AIDS for different maximum path sizes, fingerprint sizes and query sizes. . . . . . . . . . . . . . . . 64 Fig. 4.12 Comparison of response times(ms) of KM-CTI on AIDS for different maximum path sizes, fingerprint sizes and query sizes. . . . . . . . . . . . . . . . 65 Fig. 4.13 Comparison of response times(ms) of BM-GGSX on PubChem200k for different maximum path sizes and query sizes. . . . . . . . . . . . . . . . . . . 66 Fig. 4.14 Comparison of response times(ms) of CT-Index on PubChem200k for different maximum path sizes, fingerprint sizes and query sizes. . . . . . . . . . . 68 Fig. 4.15 Comparison of response times(ms) of CW-CTI on PubChem200k for different maximum path sizes, fingerprint sizes and query sizes. . . . . . . . . . . 69 Fig. 4.16 Comparison of response times(ms) of KM-CTI on PubChem200k for different maximum path sizes, fingerprint sizes and query sizes. . . . . . . . . . . 70 Fig. 4.17 Performance comparison of the methods on the AIDS database for different querysizes.................................... 71 Fig. 4.18 Index Size and Building Time for increasing database sizes. . . . . . . . . . 73 Fig. 4.19 Filtering time for increasing database and query sizes. . . . . . . . . . . . . 74 Fig. 4.20 Total response time for increasing database and query sizes. . . . . . . . . . 76 Fig. 5.1 Serialization into a byte array of a trie node in BM-GGSX. . . . . . . . . . . 82 Fig. 5.2 Serialization of CW-CTI. . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 Fig. 5.3 Serialization in KM-CTI: (a) Internal node and (b) Leaf node. . . . . . . . . 84 Fig. 5.4 Index Building Time in distributed system varying (a) number of executors and(b)databasesize. ............................. 89 Fig. 5.5 Comparison of index building time between centralised and distributed implementations for (a) BM-GGSX and (b) KM-CTI. . . . . . . . . . . . . . . 90 Fig. 5.6 Average filtering time for distributed implementations (4M graph database size). ...................................... 92 Fig. 5.7 Average filtering time for distributed implementation (64 executors). . . . . 93 132 List of Figures Fig. 5.8 Average total response time for distributed implementations (4M graph database size). ...................................... 95 Fig. 5.9 Average total response time for distributed implementation (64 executors). . 96 Fig. 5.10 Comparison of query filtering time between centralised and distributed implementations for KM-CTI method. . . . . . . . . . . . . . . . . . . . . . . 98 Fig. 5.11 Comparison of query total response time between centralised and distributed implementations for KM-CTI method. . . . . . . . . . . . . . . . . . . . . 99 Fig. 5.12 Illustration of the significance of the use of indexing with respect to the simple parallel evaluation of a subgraph isomorphism algorithm. . . . . . . . . 100 Fig. 6.1 Mockup of an interactive searching application. . . . . . . . . . . . . . . . 102 Fig. 6.2 Illustration of the insertion and querying in a Bloom Filter. . . . . . . . . . . 105 Fig. 6.3 False positive probability achieved for increasing number of elements inserted in Bloom Filters of just one hash function with different sizes (256- 8192). ..................................... 106 Fig. 6.4 Illustration of the insertion and querying in a Count-Min Sketch. . . . . . . 108 Fig. 6.5 Error guaranteed and relevant probability for increasing number of elements inserted in Count-Min Sketch with different number of counters per hash function. .................................... 109 Fig. 6.6 Response average precision. . . . . . . . . . . . . . . . . . . . . . . . . . . 114 Fig.6.7 ResponseF-Score ............................... 115 Fig.6.8 Indexsize(MB)................................. 116 Fig. 6.9 Average response time (ms) of the approximate searching approaches. . . . . 117 Fig. 6.10 Average response times (ms) including also the verification stage. . . . . . . 119 133 The efficient management of molecular data is one of the most demanded technologies by the industry. A very important type of search is the substructure searching. The molecular structures may be encoded as graphs where the vertices and bonds represent the atoms and bonds, respectively. In this Thesis, a cutting edge system that enables the storage and querying of molecular data has been designed and implemented, paying attention to the molecular substructure search, where new filter-then-verify(FTV) methods, beyond the state-of- the-art, were designed, implemented, and tested, achieving performance gains over 75% in the filtering stage. A generic framework for the implementation of FTV techniques on a distributed architecture was also developed, enabling the application of the FTV methods on very large graph databases,