Skip to main content

Posts

Showing posts from September, 2016

Toolkit - Writing My Own Database Engine

This post if part of a series about the  File System Toolkit  - a custom content delivery API for SDL Tridion. In the previous post  Criteria for Dynamic Queries , I presented index classes that allow us to execute performant lookups for keys in indexes on the file system. This post presents the logic behind these indexes. The requirement for the Toolkit API was not to use a database or a third party product such as search engines or indexers. In order to do searches for content on a file system where we had JSON files filled with properties we want to search on, we need to have indexes of those properties. It would be impossible to do performant searches without such indexes. This meant creating my own indexes and indexing logic (put, get) backed by a fast searching algorithm. In other words, it meant writing my own simple database engine. The rationale looks like this: Each query must be as fast as possible. The fastest way to query would be to lookup a key in a...

Toolkit - Criteria for Dynamic Queries

This post if part of a series about the  File System Toolkit  - a custom content delivery API for SDL Tridion. In the previous post  Dynamic Content Queries , I presented a Query class that performs CustomMeta queries on JSON models published to the file system. This post presents the logic that actually queries for results and applies different boolean operators for different Criteria. The base class for each criteria is Criterion, which defines the base methods each criteria must implement: public abstract class Criterion { public Set < String > executeQuery () { return executeQuery ( FilterImpl . EMPTY_FILTER ); } public abstract Set < String > executeQuery ( Filter filter ); } The Filter class contains a set of allowed Publication ids, the item type and whether to include the range boundaries or not. The Filter is used in modifying the results retrieved for each criteria from the indexes. Each criteria uses...

Toolkit - Dynamic Query Sorting and Pagination

This post if part of a series about the  File System Toolkit  - a custom content delivery API for SDL Tridion. In the previous post Dynamic Content Queries , I presented a Query class that performs CustomMeta queries on JSON models published to the file system. This post presents the logic that sorts and paginates the result set. The Query class defines four members that help the pagination and sorting logic: Sorter -- the Comparator that perform the actual sorting of two ItemMeta objects (it returns an order between two ItemMeta instances); page -- the page index to return out of all pages; pageSize -- the number of items on a page; totalItemCount -- the total number of items before pagination was applied; Sorting Sorting can be specified on different columns and can use different directions for each column (ascending, descending). A sort column is a predefined metadata of a model (title, last publish date) or a CustomMeta. An association between a sort column an...

Toolkit - Dynamic Content Queries

This post if part of a series about the  File System Toolkit  - a custom content delivery API for SDL Tridion. This post presents the Dynamic Content Query capability. The requirements for the Toolkit API are that it should be able to provide CustomMeta queries, pagination, and sorting -- all on the file system, without the use third party tools (database, search engines, indexers, etc). Therefore I had to implement a simple database engine and indexer -- which is described in more detail in post Writing My Own Database Engine . The querying logic does not make use of cache. This means the query logic is executed every time. When models are requested, the models are however retrieved using the ModelFactory and those are cached. Query Class This is the main class for dynamic content queries. It is the entry point into the execution logic of a query. The class takes as parameter a Criterion (presented below) which triggers the execution of query in all sub-criteria of a...