BAM Hive script considers the entire data in a column family during the summarization process, and it summarizes repeatedly already summarized data. But most of the use cases we don't need the entire data to be analyzed again in order to produce the final result. Therefore from BAM 2.4.0 we have implemented Incrementally analyzing the data received into the BAM, which will use your resource more efficiently.
In this section we'll discuss about possible use cases and how you can this feature more efficiently.
How to enable incremental analysis for a stream
To enable incremental analysis for your stream,
- Install a toolbox
- Set the
enableIncrementalIndexproperty in the
streams.propertiesfile that is bundled in the .tbox file of your toolbox
It populates the incremental index for that particular stream definition.
The following sample shows how to enable the property. After enabling, all events received for this stream definition will be indexed for incremental processing.
Where to use incremental analysis in a Hive script
In this section we'll discuss about the possible use cases of incremental feature.You can add the @incremental annotation before your hive script and make your hive script to be processed incrementally. Also you need to add a name for the incremental annotation which will make your following query to be processed from the unique pointer; basically this will avoid clashing with other Hive queries. We'll see below in detail about possible syntax and each attributes.
Usecase 1 - incremental processing for the stream that has it enabled from the beginning
@Incremental is the annotation used for incremental processing. The query followed by this annotation will be processed incremental manner.
'name' attribute in the incremental annotation is unique per hive script. Ie, you can have the same name in different hive scripts and those will be processed independently.
'tables' attribute indicates what tables needed to be processed incrementally. You can use more that one tables within the hive query with multiple JOIN, etc, but the table name which is indicated in the tables attribute only will be considered to process incrementally. And also only you can process cassandra hive tables incrementally.
'bufferTime' involves is the time of rows that should be avoided to consideration of current hive processing cycle. This is due to the fact, there might be some partially arrived data and you need to have some buffer time for those data to be fully arrived. This is in millisecond time.
Usecase 2 - enable incremental processing for the Cassandra column family that you insert to from the Hive script
- You need set "cassandra.enable.incremental.process"="true" property if you want to enable the incremental processing via hive query.
- After this you can continue to use the cassandra column family created by the hive query also can be processed incrementally as same as mentioned in the usecase -1.
Usecase 3 - enabling incremental processing with wide row Hive/Cassandra table
- The above example is basically copying the data from one column family to another column family.
:key,:column, :value are basically transpose of the actual row, which basically make row key + colum+key as a row in the hive table, and make the casandra table flat.
Usecase 4 - incremental processing with already existing data
This is similar use case as usecase -1 but here the incremental processing enabled for the stream not from the origin of the event stream and some where in the middle of the event stream.
This feature was added since there are users who already have some data being published, and they may want to switch for incremental processing in the middle. Therefore for the first iteration of incremental processing if the property hasNonIndexedData set, it will consider the non-indexed data also. And then from the second iteration it’ll only consider the indexed data.