Configuring Views in a SOW
This section lists the parameters for defining a View
within the SOW section of an AMPS configuration file. Expand each item for more details.
For backward compatibility, AMPS accepts ViewDefinition
as a synonym for View
.
Below is an example of a SOW
configuration, that shows different approaches to defining a View
.
<SOW>
<!-- Single topic aggregation. -->
<Topic>
<Topic>/ett/order</Topic>
<MessageType>fix</MessageType>
<Key>/orderId</Key>
</Topic>
<View>
<MessageType>nvfix</MessageType>
<Topic>TOTAL_VALUE</Topic>
<UnderlyingTopic>/ett/order</UnderlyingTopic>
<Projection>
<Field>/109</Field>
<Field>SUM(/14 * /6) AS /71406</Field>
</Projection>
<Grouping>
<Field>/109</Field>
</Grouping>
</View>
<!-- Single topic aggregation with filter. -->
<Topic>
<Name>orders</Name>
<MessageType>json</MessageType>
<Key>/orderId</Key>
<FileName>./sow/%n.sow</FileName>
</Topic>
<View>
<Name>CompleteByRegion</Name>
<UnderlyingTopic>orders</UnderlyingTopic>
<MessageType>json</MessageType>
<Projection>
<Field>COUNT(/orderId) AS /completedOrders</Field>
<Field>/region AS /region</Field>
</Projection>
<Grouping>
<Field>/region</Field>
</Grouping>
<Filter>/status = 'complete'</Filter>
</View>
<!-- Single topic aggregation with a hash index
for faster query. -->
<Topic>
<Name>source-for-hash-sample</Name>
<MessageType>json</MessageType>
<Key>/id</Key>
<FileName>./sow/%n.sow</FileName>
</Topic>
<View>
<Name>hash-sample-view</Name>
<MessageType>json</MessageType>
<UnderlyingTopic>source-for-hash-sample</UnderlyingTopic>
<Projection>
<Field>SUM(/qty) as /quantity</Field>
<Field>/customerName</Field>
<Field>/orderType</Field>
</Projection>
<Grouping>
<Field>/customerName</Field>
<Field>/orderType</Field>
</Grouping>
<!-- Provide fast query for exact matches on
*either* name or orderType. -->
<HashIndex>
<Key>/name</Key>
</HashIndex>
<HashIndex>
<Key>/orderType</Key>
</HashIndex>
</View>
<!-- Project from one message type to another. -->
<Topic>
<Name>example</Name>
<MessageType>json</MessageType>
<Key>/id</Key>
<FileName>./sow/%n.sow</FileName>
</Topic>
<View>
<!-- Notice that the nvfix topic named 'example' is not the
same topic as the json topic named 'example'. -->
<Name>example</Name>
<MessageType>nvfix</MessageType>
<UnderlyingTopic>[json].[example]</UnderlyingTopic>
<Projection>
<Field>[json].[example]./id AS /id</Field>
</Projection>
<Grouping>
<Field>[json].[example]./id</Field>
</Grouping>
</View>
<!-- JOIN topics -->
<Topic>
<Name>ORDERS</Name>
<MessageType>nvfix</MessageType>
<Key>/OrderID</Key>
<FileName>./sow/%n.sow</FileName>
</Topic>
<Topic>
<Name>COMPANIES</Name>
<MessageType>nvfix</MessageType>
<Key>/CompanyId</Key>
<FileName>./sow/%n.sow</FileName>
</Topic>
<View>
<Name>TOTAL_COMPANY_VOLUME</Name>
<UnderlyingTopic>
<Join>[ORDERS]./Tick = [COMPANIES]./Tick</Join>
</UnderlyingTopic>
<MessageType>nvfix</MessageType>
<Projection>
<Field>[COMPANIES]./CompanyId</Field>
<Field>[COMPANIES]./Tick</Field>
<Field>[COMPANIES]./Name</Field>
<Field>SUM([ORDERS]./Shares) AS /TotalVolume</Field>
</Projection>
<Grouping>
<Field>[ORDERS]./Tick</Field>
</Grouping>
</View>
</SOW>
Last updated