Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: for the plan.

Jump to: navigation, search

SMILA/Documentation/Data Model and Serialization Formats

< SMILA‎ | Documentation
Revision as of 10:28, 28 July 2011 by (Talk | contribs) (XML format)

SMILA Data Model

  • Implementation bundle: org.eclipse.smila.datamodel
  • Current Version: 0.8.0


The data to be processed in SMILA is represented as records. For example, one record could correspond to one document or to any resource which should be indexed or found in a search. A record consists of metadata and optional attachments.

SMILA data model version 0.8

  • Metadata contains typed values (literals) arranged in maps (key-anything associations) and sequences (lists of anything). Values can be strings, long integers, double precision floating point numbers, booleans, dates (year, month, day) or datetimes (date + time of day, down to seconds). Maps and sequences can be nested arbitrarily, map keys are always strings. All metadata of one record is arranged in a single Map.
  • Attachments can contain any binary content ("byte arrays"), possibly of larger size. During indexing they are not kept in memory all the time, but stored in a "binary storage" service and read only when actually needed.

A single entry in a record's metadata map is called Metadata element. According to the use case, metadata elements can be semantically interpreted as:

Usually, attributes are used when referring to the metadata of an object which is to be processed from a given data source or which is retrieved as the result of a search request. For example, typical attributes characterizing a web page to be indexed are its URL, the size in bytes, the MIME type, the title, and the plain-text content. These attributes are defined by the application domain.
Attributes may not be adequate or sufficient for all record types. For example, in search processing, a record represents not a single object from some data source but rather a search request object. In such a case, the record's metadata does not contain attributes from the application domain on top-level but rather request parameters that configure and influence the request execution. These parameters are defined by the pipelets which are used in the workflow that was triggered by the search request. Also, their names do not start with underscores. However, a request or result record may contain application-specific attributes on deeper nested levels. Find an example, hopefully illustrating the difference between attributes and parameters, in Search API.
An annotation can be used to add a data structure to the record which was generated as the result of some processing step. E.g., a named-entity-recognition pipelet could add an annotation describing at which character position some entity was found, meaning that the record was annotated with this additional information. If annotations appear in the same maps as attributes, their names should be chosen in such a way that they will not conflict with attribute names from the application, e.g. by prefixing them with an underscore "_".
System attributes
These attributes are needed by SMILA in order to coordinate the processing of a record (see below). Their names start with an underscore "_", so that they will not conflict with names from the application domain.

System attributes

Every record must contain a single-valued string attribute named "_recordid" which is required to identify the record. It must be unique for all processed records. This must be ensured by whoever created and submitted the record it to the system (this would be crawlers or agents, usually). There is no predefined format of the record ID, hence it can contain any string. So, creating UUIDs or something similar would be entirely sufficient. Also, the producer must place any information needed to access the original data from which the record was produced into explicitly named attributes.
Every record should also contain a second system attribute named "_source" which contains the ID of the data source (e.g. crawler definition) that produced it. This is used by DeltaIndexing or RecordStorage to perform operations on all records from the same source.

XML format

The XML format of a record is designed to be quite compact:

<Record xmlns="" version="2.0">
  <Val key="_recordid">web:</Val>
  <Val key="_source">web</Val>
  <Val key="url"></Val>
  <Val key="filesize" type="long">1234</Val>
  <Val key="sizeInKb" type="double">1.2</Val>
  <Val key="checked" type="boolean">true</Val>
  <Val key="created" type="date">2010-12-02</Val>
  <Val key="lastModified" type="datetime">2010-12-02T16:20:54+01:00</Val>
  <Seq key="trustee">
  <Seq key="author">
      <Val key="firstname">John</Val>
      <Val key="lastname">Doe</Val>
      <Val key="firstname">Lisa</Val>
      <Val key="lastname">Müller</Val>
  <Map key="contact">
    <Val key="email"></Val>      
    <Map key="address">
      <Val key="street">742 Evergreen Terrace</Val>
      <Val key="city">Springfield</Val>
  <Seq key="emptylist" />
  <Map key="emptymap" />


  • The Any objects are represented by <Val>, <Map>, and <Seq> elements.
  • An object that is part of a map must have an additional key attribute. Elements of sequences must not have the key attribute.
  • The type of a value is defined by an optional type attribute, the default is "string".
  • The format of date values is "yyyy-MM-dd" (see [Javadoc of SimpleDateFormat] for the meaning of the format string)
  • The format of datetime values is "yyyy-MM-dd'T'HH:mm:ssZ", i.e. it must include timezone information.
  • The top-level <Map> element of a record is omitted from the XML.
  • In XML, the record does not contain the attachment values, but only their names so that a reader knows that there are attachments to be processed.

See package org.eclipse.smila.datamodel.xml for serialization helper classes.

Due to a bug in the JDK's default implementation of XMLStreamReader you should only use xml in version 1.0. When deserializing you either dont specify the XML declaration at all or you must use
<?xml version="1.0" encoding="utf-8"?>

JSON format

The JSON format of a record looks like this:

  "_recordid" : "web:",
  "_source" : "web",
  "url" : "web:",
  "filesize" : 1234,
  "sizeInKb" : 1.2,
  "checked" : true,
  "created" : "2010-12-02",
  "lastModified" : "2010-12-02T16:20:54+01:00",
  "trustee" : [ "group1", "group2" ],
  "author" : 
  [ {
      "firstname" : "John",
      "lastname" : "Doe"
      "firstname" : "Lisa",
      "lastname" : "Müller"
    } ],
  "contact" : 
    "email" : "",
    "address" : 
      "street" : "742 Evergreen Terrace",
      "city" : "Springfield"
  "_attachments": ["content", "fulltext"]


  • Number value types are determined implicitly when parsing JSON:
    • If a number value can be parsed as a long integer, a long value will be created, else it will become a double value.
  • Date(time) values are not supported by JSON, so they will be parsed to string values
    • So when writing a date(time) value to JSON and read it again, it will be converted to a string value!
    • You can get back the date(time) value, by calling the appropriate conversion methods (AnyMap.getDate(), AnyMap.getDateTime(), Value.asDate(), Value.asDateTime())
  • Map keys are always strings and must be enclosed in quotes.
  • Attachment names can be added as a system attribute "_attachments".

See package org.eclipse.smila.datamodel.ipc for serialization helper classes.

Binary format (BON)

The binary object notation (BON) format is an optimized JSON-like binary representation. SMILA's ipc bundles/classes are designed for easily change between JSON and BON format.

The BON format consists of a sequence of tokens and data with two different types of tokens:

  • Event tokens are single bytes which are describing an event (e.g. OBJECT-START, SEQUENCE-START).
  • Data tokens are the first part of a data entity.

Every data entity consists of up to three parts. The first part is a one byte token which describes the following data type and in case of a string type this token is followed by a data length information (second part). The last part is the information itself (except for the boolean type which is stored within the token).

Integer values are stored in a compressed format. The sign and the integer length (number of bytes) are stored in the token byte. Strings are generally stored in UTF-8 format.

Scalar types

  • Integer (8 bytes, signed)
    • compressed, bytes are stored in network byte order (big endian)
  • Double (8 bytes in network byte order IEEE format (java default))
  • Boolean
  • String: UTF-8 coded Text Strings, max 2^31-1 bytes

List of event tokens

token description byte

List of data tokens

token description byte
SCALAR-INT 1-byte positive integer 0
2-byte positive integer 1
... ...
8-byte positive integer 7
1-byte negative integer 8
2-byte negative integer 9
... ...
8-byte negative integer 15
false 17
SCALAR-FLOAT float (32 bit) 18 (reserved, not implemented)
SCALAR-FLOAT double (64 bit) 19
SCALAR-FLOAT long double (80 bit) 20 (reserved, not implemented)
SCALAR-STRING 1-byte string length 21
2-byte string length 22
3-byte string length 23
4-byte string length 24

See package org.eclipse.smila.datamodel.ipc for serialization helper classes.

Record Filters

Record filters produce reduced copies of a record: A record filter has a name and contains a list of metadata element names. When applied to a record, it produces a copy of the record that contains only the elements of the list.

Record filters are described in a simple XML format:

  <Filter name="filter0" />
  <Filter name="filter1">
    <Element name="attribute" />
  <Filter name="filter3">
    <Element name="attribute1" />
    <Element name="attribute2" />
    <Element name="attribute3" />
  <Filter name="filter-all">
    <Element name="*"  />


  • A filter always copies the system elements "_recordid" and "_source". Therefore, the apparently empty "filter0" in this definition produces records that still contain these system elements.
  • A filter may contain arbitrary numbers of element names. It's fine if an element does not appear in the record to copy, it's just ignored.
  • A filter always removes attachments: The "filter-all" in this definition produces a copy of the record with all metadata elements, but not attachments.

Filters are usually applied by asking the blackboard for a filtered copy of the record's metadata. See Blackboard service API for details. To work with filters directly, see package org.eclipse.smila.datamodel.filter for utility classes.

Back to the top