コード例 #1
0
        private ImpalaClient Connect(string connectString)
        {
            if (!connectString.StartsWith(PREFIX))
            {
                throw new ArgumentException("Invalid connection string!");
            }

            var hostPort = connectString.Substring(PREFIX.Length).Split(":");
            var host     = hostPort[0];
            var port     = Int32.Parse(hostPort[1]);

            return(ImpalaClient.Connect(host, port));
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: timfan3939/ImpalaSharp
        static void Main(string[] args)
        {
            var host = "somehost.example.com";
            var port = 21000;

            var sql = @"select count(*) cc, somekey from sometable group by somekey";

            using (var impala = ImpalaClient.Connect(host, port))
            {
                {
                    var queryResult = impala.Query(sql);
                    queryResult.Result.ForEach(e =>
                    {
                        Console.WriteLine(@"{0}={1}", e["somekey"], e["cc"]);
                    });
                    Console.WriteLine(@"Elapsed: {0}", queryResult.ElapsedTime);
                }

                // Specify configuration each query.
                var conf = new Dictionary <string, string>()
                {
                    // e.g. "2g"
                    { "mem_limit", "-1" },
                };
                {
                    var queryResult = impala.Query(sql, conf);
                    Console.WriteLine(@"Elapsed: {0}", queryResult.ElapsedTime);
                }


                // Specific result handling.
                {
                    var queryResult = impala.Query(sql, conf, new MyHandler());
                    Console.WriteLine(@"Elapsed: {0}", queryResult.ElapsedTime);
                }
            }
        }