Stave Repository

Stave is a column based repository. Data is stored in columns. Stave offers better data compression, and extremely fast data retrieval.

Each column in Stave has the following characteristics:

Stave is very good for managing stable data, that maybe changes once a day.

Enabling Symbolic Links

You have to enable symbolic links on your system as the resultant table with the appended records is symlinked to the existing original table.

On Unix and Linux, symbolic links are automatically enabled. Perform the following steps to enable symbolic links on Windows.

  1. Launch secpol.msc using Start or Start → Run
  2. Open Security Settings → Local Policies → User Rights Assignment
  3. In the list, find the Create symbolic links item, which represents SeCreateSymbolicLinkPrivilege.
  4. Double-click on the item and add the user that is running the Ambience service, to the list.
  5. Logout and login to apply the changes.

Ambience will detect if your Operating System supports Symbolic Links. If your Operating System does not support symbolic links, Stave will generate folders for its operation. Be cautioned that this means readers might fail if reading while incremental updates are happening.

Saving Data to a Stave Database

To save data from the Data Designer as a Stave Database:

  1. Right click the DataStore and select Properties.
  2. Select the Type as Stave, as shown in Figure 5.18, “Stave Datastore”.

    Figure 5.18. Stave Datastore

    Stave Datastore
  3. Click Next. Enter a name for the DataStore.
  4. Select the Append to Existing Records option as shown in Figure 5.19, “Append Records Option - Stave Datastore”. This causes new records to be appended to the datastore instead of the datastore being created again.

    Figure 5.19. Append Records Option - Stave Datastore

    Append Records Option - Stave Datastore
  5. Click Finish.
  6. Right click the Datastore and select Generate to write the data to the datastore.

Binning

Binning allows you to create new columns by grouping or deriving data from existing columns.

To use binning, you need to write Scala code.

The following example demonstrates the use of binning to add a column to the Cars database.

  1. Create a composite datasource called Bin-Sample.
  2. Add a Datasource and select cars.ds as the input.

    Figure 5.20. Add a Datasource for Binning

    Add a Datasource for Binning
  3. Add a Datastore and select the type as Stave. Enter the stave folder name as Cars.

    Figure 5.21. Add a Datastore for Binning

    Add a Datastore for Binning
  4. Right click the Datastore and select Generate. This writes the data to the Stave database.
  5. Use your file manager and navigate to the data/stave/eno/Cars folder inside your Ambience installation folder.
  6. Create a new folder called bin and place the following Scala code in a file called GearBoxBin.scala, inside the bin folder.
    import com.elixirtech.stave.ColumnMetadata
    import com.elixirtech.stave.transform.BinLogic
    
    object GearBoxBin extends BinLogic {
      
      val inColumns = 
      List("trade_in_vehicle_drive_train","new_vehicle_drive_train")
      
      def outColumn(in : ColumnMetadata) : ColumnMetadata = {
        in.copy(name=in.name+"_gearbox")
      }
      
      def fn(obj : Object) : Object = {
        try {
          val s = obj.asInstanceOf[String]
          if (s.contains("Auto")) "Automatic"
          else if (s.contains("Manual")) "Manual"
          else "Unknown"
        }
        catch {
          case ex : Exception => "Error"
        }
      }
    }
    
    GearBoxBin
                

    This program creates a new column called trade_in_vehicle_drive_train_gearbox and marks the gear selection as either Auto or Manual, based on the input from the trade_in_vehicle_drive_train column. This shows you whether the traded-in vehicle had automatic or manual gears.

    Similarly, the program creates another new column called new_vehicle_drive_train_gearbox and marks the gear selection as either Auto or Manual, based on the input from the new_vehicle_drive_train column. This shows you whether the newly purchased vehicle has automatic or manual gears.

  7. Right click the Datastore and select Generate. Ambience processes the Scala file and writes the the data to the Stave database.
  8. Right-click the folder tree and select Add - Universe.

    Figure 5.22. Add a Universe

    Add a Universe
  9. Select the Universe type as Stave and enter a name for the Universe.

    Figure 5.23. Select the Universe Type as Stave

    Select the Universe Type as Stave
  10. Choose the Cars table for the Universe.

    Figure 5.24. Select the Cars Table

    Select the Cars Table
  11. Click Finish. The new columns (trade_in_vehicle_drive_train_gearbox and new_vehicle_drive_train) are also displayed in the mapping table.

    Figure 5.25. Binned Column trade_in_vehicle_drive_train_gearbox is Displayed

    Binned Column trade_in_vehicle_drive_train_gearbox is Displayed

    Figure 5.26. Binned Column new_vehicle_drive_train is Displayed

    Binned Column new_vehicle_drive_train is Displayed
  12. Proceed with Universe mapping as documented in the section called “Mapping Stave Columns to Logical Tables”.

Using the Multi-Stave Feature

Ambience version 4.2 onward supports the Multi-Stave feature.

Stave stores each data set in a separate folder. With the Stave Universe, you can map one set of columns into multiple logical tables. For example, Courses might contain the courses for which a student is registered while Persona might contain all other details of the student.

Therefore, from Ad-Hoc Report and Dashboard, the one large Stave table looks like multiple Universe tables.

To add additional information, you need to add it as other columns to the table using Binning and Derivatives based on existing columns.

What if you have data in another Stave folder that you want to display on your Report or Dashboard? Ambience 4.2 onward allows you to add multiple Stave folders in a single Universe.

Just select the folders you want to add when creating the Stave Universe.

Figure 5.27. Selecting Multiple Stave Folders

Selecting Multiple Stave Folders

After you create the Universe, do the mapping as documented in the section called “Mapping Stave Columns to Logical Tables”.

You cannot create a logical table that spans across two Stave folders. Each logical table must get all columns from a single Stave folder.

Joining Across Multiple-Stave Folders

Ambience version 4.2 onward allows you to join across Stave folders.

For example, suppose you have a State table with two columns: State Name and State Region.

You also have a Weather table with three columns: State Name, Min Temp and Max Temp.

Since there is a common field in these tables, you can join them together.

Select the joinable column from each table - in our example, it is State Name in each table. Then add a new column attribute of type JoinableId from the Column Attributes drop down. Enter any meaningful name as the ID.

Figure 5.28. Joining Two Columns

Joining Two Columns

When creating an Ad-Hoc Report or Dashboard, choose fields from both folders - State and Weather, in our example. The Universe will scan all used tables for join-able attributes and when it finds a match, will allow them to join.

Opening a Stave Universe in the Universe Designer

Double click a Stave Universe from the folder tree to open it in the Universe Designer.

The Universe Designer displays as shown in Figure 5.29, “Universe Designer for a Stave Universe”:

Figure 5.29. Universe Designer for a Stave Universe

Universe Designer for a Stave Universe

Mapping Stave Columns to Logical Tables

Before the Stave columns can be used, you need to map them to a logical table.

Click the Mapping tab. For each row, enter a name for the Universe table and a name for the column as shown in Figure 5.30, “Table Mapping for a Stave Universe”.

Figure 5.30. Table Mapping for a Stave Universe

Table Mapping for a Stave Universe

Observe how Stave automatically names the Date columns once you enter a name for the Universe table for the column marked Date. This occurs since Date in Stave is internally represented as multiple rows, one each for Day, Day of Week, Month, Quarter and Year.

Similarly, Stave automatically names the Time columns once you enter a name for the Universe table for the column marked Time. This occurs since Time in Stave is internally represented as multiple rows, one each for Hour and Minute.

Using Stave

Once you finish Mapping, click the Tables tab.You will see the mapped Universe table as shown in Figure 5.31, “Mapped Table for a Stave Universe”.

Figure 5.31. Mapped Table for a Stave Universe

Mapped Table for a Stave Universe

Click the table and proceed with the operations as specified in the section called “Repository Universe”.