Skip to content

Team API: Design Document

AKAlilonu edited this page Jun 5, 2018 · 20 revisions

Purpose

Team API is building a high-level API to work with the 'trie' data structure implemented. The purpose of our API is to facilitate transfer data between the client and the server.

API Requirements

Functionalities identified

Inserting and removing nodes from a given trie

Finding a target node within a given trie

Supporting get/request calls to the Redis server

Method

Given a shell command, retrieve or store data into the data structure on the Redis server via the Hiredis library.

Data we'll be working with

redisContext and tries

Structure

At the top level of the API, we have

  • an include directory that contains all of the header files,
    • trie.h, for working with tries,
    • zset.h, for working with sorted sets, and
    • common.h, for functions that are used by both tries and sorted sets.
  • a lib directory by which we access the Redis server,
  • a samples directory with example implementations of the code
  • a src directory with implementations of all the header files,
  • a tests directory that contains all the tests,
  • a gitignore that tells Git which files to exclude from commits,
  • a gitmodules file that defines the properties of the API submodule,
  • a YAML file,
  • an AUTHORS file with the names of the members of the API team,
  • a Makefile, and
  • a README that contains instructions for installing and using the API.

Use Cases

Example 1 (checking if a word is valid within a trie):

Spellcheck team calls valid_word(char*, trie*)

API team calls find(redisContext*, "TFIND trie* char*"): bool

Trie team calls TFIND(trie*, char*): bool

Example 2 (finding the next match in a trie):

Fulltext team calls next_match(match* match): match*

API team calls find(redisContext*, "NEXT_ITEM trie* char"): bool

Trie team calls TRIE_SEARCH(char* word, trie_t* t): int

Trie team returns validated match*

Example 3 (defining a new word in a trie):

Autocomplete team calls define_new_word(char* pf, trie_t* dict): trie_t*

API team calls find(redisContext, "INSERT trie* char"): bool

Trie team calls insert_string(char* word, trie_t* t): int

UML Diagram

Find the UML diagram attached.

Hiredis

Task for the week is to write a wrapper for the hiredis client. Hiredis is a client library for redis that uses a high-level API but has minimal explicit bindings for commands in redis. If we wrap hiredis, we essentially use code to turn the hiredis library into a different interface Hiredis had synchronous, asynchronous and reply parsing API

Clone this wiki locally