WebAssembly (Wasm) is a binary instruction format for a stack-based virtual machine. Wasm enables developers to use existing code from programming languages such as C, C++, and Rust as part of their application development process. However, Wasm is not just for the web, and today it is moving in exciting new directions. For example, one use-case would be to run Wasm code in a database system on the data already stored in the database system: an example of co-locating computation with data. Using Wasm to extend the capabilities of a database system opens up opportunities to develop many new applications. SingleStoreDB supports Wasm through Code Engine and, in this article, we’ll see how to build a Wasm UDF to perform sentiment analysis on data already stored in SingleStoreDB.
We’ll need to perform a few steps to prepare our development environment, and the following sections will show how to do this. We’ll also use Rust to create our Wasm UDF. Our code example will build upon the example described in the SingleStore blog post [r]evolution Summer 2022: Bring Application Logic to Your Data With SingleStoreDB Code Engine for Wasm.