AHG_Microsoft_StreamInsight_Queries.pdf
(
2838 KB
)
Pobierz
A Hitchhiker’s Guide to Microsoft
StreamInsight Queries
Ramkumar (Ram) Krishnan, Jonathan Goldstein, Alex Raizman
Summary:
This paper is a developer’s introduction to the Microsoft StreamInsight Queries. The paper
has two goals: (1) To help you think through stream processing in simple, layered levels of
understanding, complementing the product documentation. (2) To reinforce this learning through
examples of various use cases, so that you can design the query plan for a particular problem and
compose the LINQ query. This ability for top-down composition of a LINQ query, combined with
bottom-up understanding of the query model, will help you build rich and powerful streaming
applications. The more advanced sections of this paper provide an overview of a query plan, the
operators that constitute the query, and, where appropriate, the foundational query algebra itself. The
paper is not a feature reference or a substitute for MSDN documentation.
Category:
Step-by-Step
Applies to:
StreamInsight
Source:
MSDN Library
(
link to source content
,
linkto code
)
E-book publication date:
November 2012 (Document Version: Jun 12 2012)
Copyright © 2012 by Microsoft Corporation
All rights reserved. No part of the contents of this book may be reproduced or transmitted in any form or by any means without the written
permission of the publisher.
Microsoft and the trademarks listed at
http://www.microsoft.com/about/legal/en/us/IntellectualProperty/Trademarks/EN-US.aspx
are
trademarks of the Microsoft group of companies. All other marks are property of their respective owners.
The example companies, organizations, products, domain names, email addresses, logos, people, places, and events depicted herein are
fictitious. No association with any real company, organization, product, domain name, email address, logo, person, place, or event is
intended or should be inferred.
This book expresses the author’s views and opinions. The information contained in this book is provided without any express, statutory,
or implied warranties. Neither the authors, Microsoft Corporation, nor its resellers, or distributors will be held liable for any damages
caused or alleged to be caused either directly or indirectly by this book.
Contents
1.Introduction........................................................................................................................................................................................................................................................... 4
2.Tutorial..................................................................................................................................................................................................................................................................... 5
2.1 “Hello, Toll!” – Programming a StreamInsight application........................................................................................................................................................ 5
2.2Query Development Process................................................................................................................................................................................................................... 7
2.3Understanding the Query Output.......................................................................................................................................................................................................12
3.More Windows – Hop, Skip and Jump.....................................................................................................................................................................................................14
4.Partitioning Event Streams for Scale out computations ...................................................................................................................................................................17
4.1Snapshot Window and AlterEventDuration to form Sliding Windows................................................................................................................................20
5.Multicast................................................................................................................................................................................................................................................................24
6.Join ..........................................................................................................................................................................................................................................................................24
6.1Alerting and Anomalies – Left Anti Join (LAJ) ................................................................................................................................................................................27
7.Let’s Play Ball – Heavy Hitters ......................................................................................................................................................................................................................30
8. Filter and Project ..............................................................................................................................................................................................................................................31
9.Operators as Legos – building up Outer Join........................................................................................................................................................................................33
10.Union....................................................................................................................................................................................................................................................................38
11.Extending the Query with Smarts ............................................................................................................................................................................................................38
11.1User Defined Function...........................................................................................................................................................................................................................38
11.2User Defined Aggregates.....................................................................................................................................................................................................................39
11.3User Defined Operator ..........................................................................................................................................................................................................................41
12.Notes on Events and Event Modeling....................................................................................................................................................................................................44
12.1Event Shapes..............................................................................................................................................................................................................................................44
12.2
Event Kinds .......................................................................................................................................................................................................................................46
12.3Event “CRUD”.............................................................................................................................................................................................................................................47
13.Step 5 – Time and Commitment ..............................................................................................................................................................................................................48
13.1Why does order matter?.......................................................................................................................................................................................................................48
13.2
Current Time Increment (CTI) Events.....................................................................................................................................................................................51
13.3AdvanceTime Settings ...........................................................................................................................................................................................................................52
14.Conclusion and Future Work .....................................................................................................................................................................................................................52
15.About the Sample Code...............................................................................................................................................................................................................................52
Feedback and Further Information................................................................................................................................................................................................................53
1.Introduction
Enterprises have always been under pressure to reduce the lag between data acquisition and
acting
on the acquired data. Over the past
decade, the expansion of free markets has created a massive user base for consumer and business technology –everyone from a
billionaire in Seattle to a street hawker in Bangalore has a mobile phone. The Web owns our eyeballs – in six short years, online
advertising and its adjoining business models have overtaken traditional media spend. The next generation of productivity and media
products will be a seamless mash-up between a user’s office and personal life with ubiquitous access to any content from any device.
Competitive mandates in manufacturing and worldwide initiatives like Green IT have led to massive volumes of sensor-driven,
machine-
born
data. Utility computing from platforms like Windows Azure aim to eliminate technology barriers of scale and economics. These
irreversible trends portend a scenario where the success of an enterprise depends on its capability to efficiently respond to every
stimulus from its customers and partners. Such a competitive enterprise that seeks a 24x7, 360
o
view of its
opportunities
will face a
torrent of high volume, high velocity business and consumer data.
The singular impact that these trends will have on traditional IT applications is to elevate
the awareness of time
. In this attention-deficit
world described above, every arriving data point is
fungible
–
i.e.
, it represents a customer touch-point, an abnormal sensor reading, or a
trend point
whose business value rapidly diminishes with time
. For a growing number of applications, this necessitates a shift in mindset
where we want to
respond to an opportunity as soon as it presents itself
, based on insight built in an
incremental
manner over time, with
the response having an
optimal
, if not always the best, fidelity or returns.In other words, it necessitates a shift towards
event-driven
processing, where you deal with each arriving data point as an event – as something that happened at a point, or over a period, in time –
and apply your business logic on this event to respond in a time-sensitive manner to the opportunity that this event represents.
This model suits a growing number of applications with demands of low latency (sub-second response time) and high throughput
(handling 100x K events/sec). This includes financial services (risk analytics, algorithmic trading), industrial automation (process control
and monitoring, historian based process analysis), security (anomaly/fraud detection), web analytics (behavioral targeting, clickstream
analytics, customer relationship management), and business intelligence (reporting, predictive analytics, data cleansing) and more.
StreamInsight is a .NET-based platform for the continuous and incremental processing of unending sequences of such events from
multiple sources with near-zero latency. It is a temporal query processing engine that enables an application paradigm where a
standing
(
i.e.
, potentially infinitely running) query processes these
moving
events over windows of time. Processing can range from simple
aggregations, to correlation of events across multiple streams, to detection of event patterns, to building complex time series and
analytical models over streaming data. The StreamInsight programming model enables you to define these queries in declarative LINQ,
along with the ability to seamlessly integrate the results into your procedural logic written in C#. The goal of this paper is to help you
learn, hands-on, how to write declarative queries in LINQ with a clear understanding of reasoning with windows of time.
In this paper, we provide a hands-on, developer’s introduction to the Microsoft StreamInsight Queries. The paper has two goals:
(1) To help you think through stream processing in simple, layered levels of understanding, complementing product documentation. (2)
To reinforce this learning through examples of various use cases – so that you can design the query plan for a particular problem, and
compose the LINQ query. This ability for top-down composition of a LINQ query, combined with a bottom-up understanding of the
query model, will help you build rich and powerful streaming applications. As you read this paper, please study the actual code examples
provided to you in the form of a Visual Studio 2010 solution (HitchHiker.sln).
StreamInsight is an in-memory event processing engine that ships as part SQL Server 2012 and is available separately in the Microsoft
Download Center.It requires .NET 4.0 Full Edition, a C# 3.0 compiler, and Windows7. The engine leverages CLR for its type system and
.NET for runtime, application packaging, and deployment. The choice of Visual Studio gives you the benefit of productivity features like
IntelliSense. An event flow debugger provides a complete developer experience. You are assumed to have a working knowledge of C#
and LINQ.
Plik z chomika:
wiklef8
Inne pliki z tego folderu:
5TSSSISU_SQL_Server_2012.pdf
(659 KB)
802.11_wireless_networks_the_definitive_guide_second_edition.pdf
(9934 KB)
AGM_Application_Virtualization_(App-V)_5.0.pdf
(1605 KB)
AGM_BitLocker_Administration_and_Monitoring_1.0.pdf
(1593 KB)
AGM_Diagnostics_and_Recovery_Toolset_(DaRT)_7.pdf
(1083 KB)
Inne foldery tego chomika:
C#
HTML5
NET
Office 365
PowerShell
Zgłoś jeśli
naruszono regulamin