GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • V11 Documentation
  • Privacy Statement
  • License Agreement
  • Contact Us

This view

  • Original page
  • New address

GeezerVison is showing docs.voltactivedata.com — Chapter 12. Using Compound Procedures

  • Volt Active Data
  • Developer Hub
  • Books
    • VoltDB Tutorial
    • Using VoltDB
    • VoltDB Guide to Performance and Customization
    • VoltDB Administrator's Guide
    • Volt Kubernetes Administrator's Guide
    • VoltDB Quick Reference
  • Current docs ▶
  • VoltDB V11
    • VoltDB V16
    • VoltDB V15.3 LTS
    • VoltDB V14.3 LTS
    • VoltDB V13.3 LTS
    • VoltDB V12.3 LTS
    • VoltDB V11.4
    • VoltDB V10.2
    • VoltDB V9.3
Chapter 12. Using Compound Procedures

Guide to Performance and Customization

  • Preface▶
    • 1. Organization of this Manual
    • 2. Other Resources
  • 1. Introduction▶
    • 1.1. What Affects Performance?
    • 1.2. How to Use This Book
  • 2. Hello, World! Revisited▶
    • 2.1. Optimizing your Application for VoltDB
    • 2.2. Applying Hello World to a Practical Problem
    • 2.3. Partitioned vs. Replicated Tables
      • 2.3.1. Defining the Partitioning Column
      • 2.3.2. Creating the Stored Procedures
    • 2.4. Using Asynchronous Stored Procedure Calls
      • 2.4.1. Understanding Asynchronous Programming
      • 2.4.2. The Callback Procedure
      • 2.4.3. Making an Asynchronous Procedure Call
    • 2.5. Connecting to all Servers
    • 2.6. Putting it All Together
    • 2.7. Next Steps
  • 3. Understanding VoltDB Execution Plans▶
    • 3.1. How VoltDB Selects Execution Plans for Individual SQL Statements
    • 3.2. Understanding VoltDB Execution Plans
    • 3.3. Reading the Execution Plan and Optimizing Your SQL Statements
      • 3.3.1. Evaluating the Use of Indexes
      • 3.3.2. Evaluating the Table Order for Joins
  • 4. Using Indexes Effectively▶
    • 4.1. Basic Principles for Effective Indexing
    • 4.2. Defining Indexes
    • 4.3. The Goals for Effective Indexing
    • 4.4. How Indexes Work
    • 4.5. Summary
  • 5. Client2, A Modern Java Client Programming Interface (API)▶
    • 5.1. Configuring the Client
    • 5.2. Connecting to the Database
    • 5.3. Calling Procedures
      • 5.3.1. Handling Backpressure
      • 5.3.2. Handling Request Timeouts
      • 5.3.3. Defining Options on a Per-Call Basis
  • 6. Prioritizing Transactions▶
    • 6.1. How Prioritizing Transactions Works
    • 6.2. Enabling Prioritized Transactions
    • 6.3. Prioritizing Transactions at Runtime
    • 6.4. Prioritizing Other Types of Transactions
  • 7. Creating Flexible Schemas With JSON▶
    • 7.1. Using JSON Data Structures as VoltDB Content
    • 7.2. Querying JSON Data
    • 7.3. Updating JSON Data
    • 7.4. Indexing JSON Fields
    • 7.5. Summary: Using JSON in VoltDB
  • 8. Creating Geospatial Applications▶
    • 8.1. The Geospatial Datatypes
      • 8.1.1. The GEOGRAPHY_POINT Datatype
      • 8.1.2. The GEOGRAPHY Datatype
      • 8.1.3. Sizing GEOGRAPHY Columns
      • 8.1.4. How Geospatial Values are Interpreted
    • 8.2. Entering Geospatial Data
    • 8.3. Working With Geospatial Data
      • 8.3.1. Working With Locations
      • 8.3.2. Working With Regions
  • 9. Creating Custom Importers, Exporters, and Formatters▶
    • 9.1. Writing a Custom Exporter
      • 9.1.1. The Structure and Workflow of the Export Client
      • 9.1.2. How to Use Custom Properties to Configure the Client
      • 9.1.3. How to Compile and Install the Client
      • 9.1.4. How to Configure the Export Client
    • 9.2. Writing a Custom Importer
      • 9.2.1. Designing and Coding a Custom Importer
      • 9.2.2. Packaging and Installing a Custom Importer
      • 9.2.3. Configuring and Running a Custom Importer
    • 9.3. Writing a Custom Formatter
      • 9.3.1. The Structure of the Custom Formatter
      • 9.3.2. Compiling and Packaging Custom Formatter Bundles
      • 9.3.3. Installing and Invoking Custom Formatters
      • 9.3.4. Using Custom Formatters With the kafkaloader Utility
  • 10. Creating Custom SQL Functions▶
    • 10.1. Writing a User-Defined Scalar Function
    • 10.2. Writing a User-Defined Aggregate Function
    • 10.3. Loading User-Defined Functions into the Database
    • 10.4. Declaring a User-Defined Function
    • 10.5. Invoking User-Defined Functions in SQL Statements
  • 11. Creating Custom Tasks▶
    • 11.1. Overview of How Custom Tasks Work
    • 11.2. Modifying the Procedure Call and Arguments
      • 11.2.1. Designing a Java Class That Implements ActionGenerator
      • 11.2.2. Compiling and Loading the Class into VoltDB
      • 11.2.3. Declaring the Task
    • 11.3. Modifying the Interval Between Invocations
      • 11.3.1. Designing a Java Class That Implements IntervalGenerator
      • 11.3.2. Compiling and Loading the Class into VoltDB
      • 11.3.3. Declaring the Task
    • 11.4. Modifying Both the Procedure and Interval
      • 11.4.1. Designing a Java Class That Implements ActionScheduler
      • 11.4.2. Compiling and Loading the Class into VoltDB
      • 11.4.3. Declaring the Task
  • 12. Using Compound Procedures▶
    • 12.1. How Compound Procedures Work
    • 12.2. Defining the Compound Procedure
    • 12.3. Compiling and Loading the Compound Procedure
    • 12.4. Declaring the Compound Procedure
    • 12.5. Invoking the Compound Procedure
    • 12.6. Handling Errors
    • 12.7. Managing Compound Procedures and System Resources
  • 13. Understanding VoltDB Memory Usage▶
    • 13.1. How VoltDB Uses Memory
    • 13.2. Actions that Impact Memory Usage
    • 13.3. How VoltDB Manages Memory
    • 13.4. How Memory is Allocated and Deallocated
    • 13.5. Controlling How Memory is Allocated
    • 13.6. Understanding Memory Usage for Specific Applications
  • 14. Managing Time▶
    • 14.1. The Importance of Time
    • 14.2. Using NTP to Manage Time
      • 14.2.1. Basic Configuration
      • 14.2.2. Troubleshooting Issues with Time
      • 14.2.3. Correcting Common Problems with Time
      • 14.2.4. Example NTP Configuration
    • 14.3. Configuring NTP in a Hosted, Virtual, or Cloud Environment
      • 14.3.1. Considerations for Hosted Environments
      • 14.3.2. Considerations for Virtual and Cloud Environments

Chapter 12. Using Compound Procedures

Compound procedures are a special type of procedure that let you extend the capabilities of the database server. Compound procedures are not transactional. However, they do let you chain multiple transactional stored procedures together, define branching and error handling, along with any additional programming logic your application needs. In other words, they let you automate complex business processes into a single callable procedure.

The primary use for compound procedures is processing inbound topics, where the topic invokes a procedure. At times the business logic for adding intelligence to the stream requires more than just a single transaction. (For example, the topic record's contents need to be written to two separately partitioned tables.) Compound procedures provide the ability to add logic similar to that used by a client application, except executed automatically on the cluster.

The following sections explain what compound procedures are, how they work, as well as how to create, declare, and invoke them. A final section covers special considerations around error handling and performance.

12.1. How Compound Procedures Work

Regular VoltDB stored procedures are transactional. That is, the procedure, whether single- or multi-partitioned, succeeds or rolls back as a whole. Combined with single-threaded, non-locking execution engines, partitioned procedures allow VoltDB to provide best-in-class throughput while guaranteeing reliability and consistency.

However, not all business logic fits within a single stored procedure. For example, an application might need to accept messages from IoT devices, look up the device ID to find out which account it is assigned to, associate the message with the account ID, record the usage, and pass the enhanced message along to other applications. In this case, the device records are likely to be partitioned on the device ID while account records are partitioned on the account ID — different partitions. 

Now, it is possible to complete the entire interaction in one multi-partitioned procedure. However, this is not recommended, since it will block all other transactions until it finishes. The alternative is for the application to call two or more partitioned procedures to perform the device and account lookups and then record the final usage. But when automating streams with VoltDB topics, there is no application to link the transactions together. Instead, a single procedure is associated with the inbound topic as part of the topic declaration in the configuration file. With compound procedures, it is now possible to include the necessary business logic in a single compound procedure, which can be invoked by the inbound topic.

The process for creating a compound procedure is:

  1. Define the procedure as a Java class that extends VoltCompoundProcedure.

  2. Compile and Load the procedure by compiling the Java source file, packaging it in a JAR file (just as you would transactional procedures), and loading it into your database using the sqlcmd LOAD CLASSES directive.

  3. Declare the procedure in your schema using the CREATE COMPOUND PROCEDURE FROM CLASS statement.

  4. Invoke the procedure by associating it with an inbound topic in the configuration file, or the procedure can be called from a client application.

The following sections describe each of these step separately.

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.