Skip to content

d/jubilant-dollop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to build and run tests

# generate build system with debug info and ASAN
CXXFLAGS='-fsanitize=address' hack/hack gen Debug build.debug
# build and run tests
hack/hack test build.debug

Design

Query

This is an object that

  1. parses a textual representation of a query;
  2. creates operators (explained below), and wires them up.

For more details, see the test

RecordSet

I really should have called this "Operator", but it's too late when I realized that. This is an interface with two methods:

  1. AttributeNames
  2. Records

Base table (FROM)

Reads file and parses them.

Projection (SELECT)

Calculates a projection (column mapping), then perform that over each input record.

Limit (TAKE)

Passes through the input but truncates at specified limit

Sort (ORDERBY)

This made me feel a bit "yuck" because I chose to represent records as a sequence of strings. Anyway, held my nose and sorted by numeric value on the order key.

Join (JOIN)

The JOIN foo a syntax actually leads to two operators:

  1. a base table scan (FROM) for file foo
  2. a natural join between the "current" relation and the just-created base table scan on join key a

Aggregate (COUNTBY)

Aggregate using a hash table (unordered_map).

OperatorFactory and FsProvider

Almost the first thing written. Having the two interfaces allowed us to:

  1. Defer implementing the actual logic of processing data while designing the parsing (Query) class
  2. Defer implementing the actual file processing logic while designing base table scan (FROM)
  3. Quickly iterate on the main interface. More iterations led to better designs!

OperatorFactor

Well, in the absence of a good dependency injection framework, had to write the boring wiring code here.

FsProvider

This is the minimal interface we use to interact with the file system: given a string, return an std::istream

My compiler / standard library is too old

Welp, contact me to change the code, or try the following neat Docker trick:

unzip assignment-data.zip
# this will build our code in a Docker container image, and run it in a container
# If you see a blinking cursor on a blank line, it is ready for query input
# type in queries, or press Ctrl-D to terminate input
hack/test-in-docker

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published