目录
介绍
数据仓库
传统数据仓库
最新数据仓库
对照
HP Vertica
它是什么?
概念
为什么选择Vertica?
谁用它?
Vertica外部表
Microsoft Connectivity
Vertica .NET集成
Infra Architecture
逻辑架构
连接代码
CRUD操作
创建代码
阅读代码
更新代码
一篇关于使用BigData HP Vertica平台进行.NET数据层编程的文章
介绍
继续我在去年写的关于Cassandra / .NET编程的CodeProject文章,今年的文章与使用HP Vertica的.NET编程有关,这是另一个BigData平台。
本文详细介绍了三个方面。首先是惠普大数据平台Vertica及其维度。其次,.NET应用程序层利用HP Vertica数据存储。最后,.NET代码示例用于CRUD(创建读取更新删除)数据操作。
数据仓库
数据仓库是企业各种业务系统收集的数据的所有或重要部分的中央存储库。这个词是由WH Inmon创造的。
数据仓库的应用包括数据挖掘,Web挖掘和决策支持系统(DSS)。
传统数据仓库
传统上,数据仓库位于企业主机服务器上。来自各种在线事务处理(OLTP)应用程序和其他源的数据被选择性地提取和组织在数据仓库数据库上,以供分析应用程序和用户查询使用。数据仓库强调从不同来源捕获数据,以进行有用的分析和访问。
最新数据仓库
在最新的行业趋势中,数据仓库不仅使用内部系统而且还通过相关的外部系统构建,以获得更好的清晰度和粒度。
商业智能(BI)和数据仓库的世界不断发展。分析数据库服务器,大数据,NoSQL,mashup,SaaS BI,数据虚拟化服务器,高级分析和SOA等技术已经变得可获得,并为组织提供了新的可能性。
对照
作为详细分析的结果,传统仓库和最新大数据仓库的比较如下:
HP Vertica
它是什么?
Vertica Systems是一家分析数据库管理软件公司,成立于2005年,于2011年3月被惠普(Hewlett Packard)收购。
基于集群,面向列的Vertica Analytics Platform旨在管理大量快速增长的数据量,并在用于数据仓库和其他查询密集型应用程序时提供非常快速的查询性能。
概念
HP Vertica建立在四个显着特征(四个C)的基础之上:
- 列存储:存储数据以优化访问
- 压缩:在较少的物理存储中存储更多数据
- 群集:无论您需要三个节点还是300个节点,都可以轻松扩展数据库
- 持续性能:自动优化数据库
为什么选择Vertica?
作为传统的数据存储程序员,相当直接的问题。
在现代商业中,可操作的数据变得比以往任何时候都重要。快速有效地管理数据的能力是巨大的竞争优势——使用Vertica分析平台可轻松实现这一优势。Vertica是一个功能强大的分析数据库,允许用户以快速的速度从大量数据中提取价值。使用上述4C概念可以实现大数据需求。
谁用它?
包括Facebook在内的一些数据巨头 。Facebook选择HP Vertica分析平台作为其大数据基础架构的一个组成部分。参考链接。
Vertica外部表
借助最新版本的Vertica,现在可以使用Vertica Analytics Engine及其分析的全部表现力,而无需将数据加载到Vertica中。它如下图所示。
Microsoft Connectivity
HP Vertica允许您将HP Vertica服务器与包含以前安装在系统上的Microsoft组件的环境集成。Connectivity Pack包括ADO.NET客户端驱动程序以及用于与Microsoft Visual Studio和Microsoft SQL Server集成的其他工具。
HP Vertica的Microsoft Connectivity Pack 允许您将HP Vertica服务器与包含以前安装在系统上的Microsoft组件的环境集成。Connectivity Pack包括ADO.NET客户端驱动程序以及用于与Microsoft Visual Studio和Microsoft SQL Server集成的其他工具。
具体来说,Connectivity Pack是增强的.NET数据提供程序包,并提供与以下Microsoft组件的集成:
- 用于SQL Server 2012的Visual Studio 2008商业智能开发工具集(BIDS).BIDS是一个基于客户端的应用程序,用于开发商业智能解决方案并基于Microsoft Visual Studio开发环境; BIDS包括特定于SQL Server Business Intelligence的其他项目类型。开发人员使用BIDS开发业务解决方案。
- SQL Server数据工具——用于SQL Server 2012的Visual Studio 2010/2012的商业智能(SSDT-BI).SSDT-BI替换了Visual Studio 2010和2012的BIDS。它与BIDS具有相同的用途,为开发商业智能解决方案提供了开发环境。
- SQL Server 2008和2012的SQL Server Analysis Services(SSAS)。使用SSAS进行OLAP和数据挖掘,使用HP Vertica作为多维数据集创建的源。
- SQL Server 2008和2012的SQL Server Integration Services(SSIS),它提供SQL Server类型映射以在HP Vertica和SQL Server之间映射数据类型。使用SSIS进行数据迁移,数据集成和工作流以及ETL。
- SQL Server Reporting Services(SSRS)。使用SSRS生成报告。
Vertica .NET集成
Infra Architecture
在Vertica .NET集成工作中,Infra架构的设计如下:
App Server层添加了Vertica ODBC连接组件,以建立.NET App和HP Vertica数据层之间的通信。
数据层包含基于群集的HP Vertica DB。表示层保持原样。
逻辑架构
根据行业标准的n层体系结构,HP Vertica .NET集成的应用程序逻辑体系结构如下所示:
连接代码
程序员应使用连接属性来配置ADO.NET客户端应用程序和HP Vertica数据库之间的连接。
您可以通过两种方式设置连接属性:
- 包含属性名称和值作为传递给VerticaConnection的连接字符串的一部分。
- 在VerticaConnectionStringBuilder对象中设置属性,然后将对象作为string传递给 VerticaConnection。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40using System; using System.Collections.Generic; using System.Linq; using System.Text; using Vertica.Data.VerticaClient; namespace VerticaApp { class Connectivity { static void Main(string[] args) { /* * HP Vertica ADO.NET drivers connection string builder */ VerticaConnectionStringBuilder builder = new VerticaConnectionStringBuilder(); /* * In the connection string, you need to specify the Host, * Database, and User at the minimum */ builder.Host = "192.10.10.10"; builder.Database = "TestDB"; builder.User = "AppUser"; /* * Build an HP Vertica connection object by the connection strings * Then, initiate the connection by Open method */ VerticaConnection conn = new VerticaConnection(builder.ToString()); conn.Open(); /* * Perform some data operations here.. * Finally, connection object is closed */ conn.Close(); } } }
CRUD操作
CRUD操作是解释应用程序和数据存储层之间功能的最佳用例。在给定的示例中,详细附加了工作代码(删除除外)。
创建代码
您可以使用带参数的预准备语句批量加载数据。如果遇到任何错误,您还可以使用事务来回滚批处理加载。
如果要加载大批量数据(超过100MB),请考虑使用直接批量插入。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49using System; using System.Collections.Generic; using System.Linq; using System.Text; using Vertica.Data.VerticaClient; namespace VerticaApp { class Create { static void Main(string[] args) { /* * HP Vertica ADO.NET drivers connection string builder */ VerticaConnectionStringBuilder builder = new VerticaConnectionStringBuilder(); /* * In the connection string, you need to specify the Host, * Database, and User at the minimum */ builder.Host = "192.10.10.10"; builder.Database = "TestDB"; builder.User = "AppUser"; /* * Build an HP Vertica connection object by the connection strings * Then, initiate the connection by Open method */ VerticaConnection conn = new VerticaConnection(builder.ToString()); conn.Open(); /* * Vertica INSERT operation into the existing Employee table with ID, * First, Last, Mail, Department fields */ VerticaCommand command = conn.CreateCommand(); command.CommandText = "INSERT into Employee values(1001, 'FirstName', 'LastName', 'eMail', 'Dept7')"; Int32 rowsAdd = command.ExecuteNonQuery(); Console.WriteLine(rowsAdd + " rows added!"); /* * Finally, connection object is closed */ conn.Close(); } } }
阅读代码
附加的代码snap用于将现有vertica表中的内容检索到.NET应用程序层。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73using System; using System.Collections.Generic; using System.Linq; using System.Text; using Vertica.Data.VerticaClient; namespace VerticaApp { class Read { static void Main(string[] args) { /* * HP Vertica ADO.NET drivers connection string builder */ VerticaConnectionStringBuilder builder = new VerticaConnectionStringBuilder(); /* * In the connection string, you need to specify the Host, * Database, and User at the minimum */ builder.Host = "192.10.10.10"; builder.Database = "TestDB"; builder.User = "AppUser"; /* * Build an HP Vertica connection object by the connection strings * Then, initiate the connection by Open method */ VerticaConnection conn = new VerticaConnection(builder.ToString()); conn.Open(); /* * Vertica SELECT operation from the existing 2 relational tables * Employee and Department with DeptID field as reference */ VerticaCommand command = conn.CreateCommand(); command.CommandText = "SELECT Mast.EmpID, Mast.FirstName, Mast.LastName, Mast.Mail, Ref.DeptName " + " FROM Employee Mast, Department Ref " + " WHERE Mast.DeptID == Ref.DeptID " + " ORDER BY Mast.EmpID " + " LIMIT 100 "; /* * To read data from the database use VerticaDataReader, * an implementation of DbDataReader */ VerticaDataReader reader = command.ExecuteReader(); Console.WriteLine(" EmployeeNamet Department"); Console.WriteLine("------------t -------------------"); /* * Data Read query is parsed to navigate the final result */ int rows = 0; if (VerticaDataReader.HasRows()) { while (reader.Read()) { Console.WriteLine(" " + reader[1] + reader[2] + " t " + reader[4]); ++rows; } } Console.WriteLine("Total Read Rows: (" + rows + ")"); reader.Close(); /* * Finally, connection object is closed */ conn.Close(); } } }
更新代码
更新方案是更改给定条件的现有Vertica表元素的内容。它由Vertica客户端库派生。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58using System; using System.Collections.Generic; using System.Linq; using System.Text; using Vertica.Data.VerticaClient; namespace VerticaApp { class Update { static void Main(string[] args) { /* * HP Vertica ADO.NET drivers connection string builder */ VerticaConnectionStringBuilder builder = new VerticaConnectionStringBuilder(); /* * In the connection string, you need to specify the Host, * Database, and User at the minimum */ builder.Host = "192.10.10.10"; builder.Database = "TestDB"; builder.User = "AppUser"; /* * Build an HP Vertica connection object by the connection strings * Then, initiate the connection by Open method */ VerticaConnection conn = new VerticaConnection(builder.ToString()); conn.Open(); /* * Vertica UPDATE operation in the existing table Employee * Mail info is updated for the given FirstName and LastName * Updation driving fields are parameterized */ VerticaCommand command = new VerticaCommand(); command.Text = "UPDATE Employee " + " SET Mail = " + "test@test.com" + " WHERE FirstName = @First AND " + " LastName = @Last "; command.Parameters.Add(new VerticaParameter( "First", VerticaType.VarChar)); command.Parameters.Add(new VerticaParameter( "Last", VerticaType.VarChar)); command.Parameters["First"] = 'Ganesan'; command.Parameters["Last"] = 'Senthilvel'; Int32 rowsUpdate = command.ExecuteNonQuery(); /* * Finally, connection object is closed */ conn.Close(); } } }
原文地址:https://www.codeproject.com/Articles/864654/NET-Programming-using-HP-Vertica
最后
以上就是清新紫菜最近收集整理的关于使用HP Vertica进行.NET编程介绍数据仓库HP VerticaVertica .NET集成CRUD操作的全部内容,更多相关使用HP内容请搜索靠谱客的其他文章。
发表评论 取消回复