澳门新浦京娱乐游戏PHP 数组current和next用法分享

本文这里通过示例给大家简单对比分析了PHP
数组current和next的用法,虽然示例很简单,但是对于我们理解current和next非常有帮助,这里推荐给大家。

与网上广为流传的特权方法有所不同,这里是使用闭包来实现的。并以一个简单的JS时钟示例作为演示。

目录:

1.current

各位如果觉得有什么不妥的地方欢迎指出。

  • 连接hadoop配置语法
  • 配置hadoop连接
  • Pushdown配置
  • Create external tables for Azure blob
    storage
<?php
 $transport = array('foot', 'bike', 'car', 'plane');
 $mode = current($transport); //$mode = 'foot';
 $mode = next($transport);   // $mode ='bike';
 $mode = current($transport); //$mode = 'bike';
 $mode = prev($transport);   // $mode ='foot';
 $mode = end($transport);    // $mode ='plane';
 $mode = current($transport); //$mode = 'plane';
 ?>

澳门新浦京娱乐游戏 1澳门新浦京娱乐游戏 2代码

连接hadoop配置语法:  

2.next

(function JSClock(){
//partial class JSClock {                  
    var _timeID = null;
    var _timeRunning = false;
    var _info;
    var _this;
    //构造函数
    function JSClock(elementId) {
        _this = this;
       _info =  document.getElementById(elementId);
    }
    JSClock.prototype.getDateTime = function(){};//因为具体显示需求不同所以没实现
    JSClock.prototype.run = function() {
       var now = {};
       var tick = new Date();
       now.hours = tick.getHours();
       now.minutes = tick.getMinutes();
       now.seconds = tick.getSeconds();
       now.day = tick.getDay();
       now.month = tick.getMonth()+1;
       now.date = tick.getDate();
       now.year = tick.getYear();
       if (now.year < 1000) now.year += 1900;
       _timeRunning = true;
       _info.innerHTML = _this.getDateTime(now);
       _timeID = setTimeout(arguments.callee,1000);
    };
    
    JSClock.prototype.stop = function(){
        if(!_timeRunning)return
        clearTimeout(_timeID);
        _timeRunning = false;
    };
//}
    window.JSClock = JSClock;
})();


<?php
 $transport = array('foot', 'bike', 'car', 'plane');
 $mode = current($transport); //$mode = 'foot';
 $mode = next($transport);   // $mode ='bike';
 $mode = next($transport);   // $mode ='car';
 $mode = prev($transport);   // $mode ='bike';
 $mode = end($transport);    // $mode ='plane';
 ?>

//partial class JSClock{
    //virtual
    JSClock.prototype.getDateTime = function(now){
       var current,weekday;
       current = now.year + “年” + now.month + “月” + now.date + “日 ” + ((now.hours >12) ? now.hours -12 :now.hours);
       current += ((now.minutes < 10) ? “:0” : “:”) + now.minutes;
       current += ((now.seconds < 10) ? “:0” : “:”) + now.seconds;
       current += (now.hours >= 12) ? ” (下午)” : ” (上午)”;
       if(now.day==0) weekday = ” 星期日”;
       if(now.day==1) weekday = ” 星期一”;
       if(now.day==2) weekday = ” 星期二”;
       if(now.day==3) weekday = ” 星期三”;
       if(now.day==4) weekday = ” 星期四”;
       if(now.day==5) weekday = ” 星期五”;
       if(now.day==6) weekday = ” 星期六”;
       current += weekday;
       return current;
    };
//}

global configuration settings for
PolyBase Hadoop and Azure blob storage connectivity, Syntax:

示例很简单,但是却很实用,希望小伙伴们能够喜欢。

//测试
var time = new JSClock(“test”);
time.run();

  • sp_configure:  List all of the
    configuration options
  • 配置与hadoop连接语法:
  • sp_configure [ @configname = ] ‘hadoop connectivity’,

                 [ @configvalue = ] { 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 }  
    [;]  
    
    RECONFIGURE  
    [;]
    

     

//运行结果会在ID为test的元素中实时显示当前时间格式如:

  1. Option 0: Disable Hadoop
    connectivity
  2. Option 1: Hortonworks HDP 1.3 on
    Windows Server
  3. Option 1: Azure blob storage
    (WASB[S])
  4. Option 2: Hortonworks HDP 1.3 on
    Linux
  5. Option 3: Cloudera CDH 4.3 on
    Linux
  6. Option 4: Hortonworks HDP 2.0 on
    Windows Server
  7. Option 4: Azure blob storage
    (WASB[S])
  8. Option 5: Hortonworks HDP 2.0 on
    Linux
  9. Option 6: Cloudera 5.1, 5.2, 5.3,
    5.4, and 5.5 on Linux
  10. Option 7: Hortonworks 2.1, 2.2, and
    2.3 on Linux
  11. Option 7: Hortonworks 2.1, 2.2, and
    2.3 on Windows Server
  12. Option 7: Azure blob storage
    (WASB[S])
          

//2010年2月6日 0:13:53 (上午) 星期六

  • 示例代码:

 

  1. 显示所有可用的配置列表: EXEC sp_configure;
  2. 显示某个配置项的配置信息:  EXEC sp_configure @configname=’hadoop
    connectivity’;
  3. 设置配置项示例语法如下:       
  4. sp_configure @configname = ‘hadoop connectivity’, @configvalue = 7;

    GO  
    
    RECONFIGURE  
    GO   
    

     

 配置hadoop连接


  • 在本节示例中,连接HDInsight3.2集,对应关系如下:
  • 澳门新浦京娱乐游戏 3
  • 配置polybase连接配置项信息信息如下:
  • sp_configure @configname = ‘hadoop connectivity’, @configvalue = 7;

    GO  
    
    RECONFIGURE  
    GO
    

     

  • 命令行:  services.msc,
    重启下面的服务

    1. SQL Server
      PolyBase Data Movement Service
    2. SQL Server
      PolyBase Engine

 Pushdown配置:


  • To improve query performance, enable
    pushdown computation to a Hadoop cluster
  1. Find the file yarn-site.xml in the installation path of SQL Server.
    Typically, the path is: C:Program FilesMicrosoft SQL
    ServerMSSQL13.MSSQLSERVERMSSQLBinnPolybaseHadoopconf

  2. On the Hadoop machine, find the
    analogous(类似) file in the Hadoop configuration directory. In the
    file, find and copy the value of the configuration key yarn.application.classpath

  3. On the SQL Server
    machine, in the yarn-site.xml file, find the yarn.application.classpath property. Paste
    the value from the Hadoop machine into the value
    element.
  4. $HADOOP_CONF_DIR,/usr/hdp/current/hadoop-client/,/usr/hdp/current/hadoop-client/lib/,/usr/hdp/current/hadoop-hdfs-client/,/usr/hdp/current/hadoop-hdfs-client/lib/,/usr/hdp/current/hadoop-yarn-client/,/usr/hdp/current/hadoop-yarn-client/lib/ 

 Create external tables for Azure blob
storage


  • The Elastic(弹性) Database query
    feature relies on(依靠) the these four DDL statements. Typically,
    these DDL statements are used once or rarely when the schema of your
    application changes
    1. [CREATE MASTER KEY]  
       ()
    2. [CREATE CREDENTIAL]   
      ()
    3. [CREATE DATABASE SCOPED
      CREDENTIAL]  
      ()
    4. [CREATE/DROP EXTERNAL DATA
      SOURCE]   
      ()
    5. [CREATE/DROP EXTERNAL
      TABLE]               
      ()
  • You can use the following syntax to
    drop the master key and credentials
    1. DROP CREDENTIAL
      <credential_name> ON DATABASE;
    2. DROP DATABASE SCOPED CREDENTIAL
      <credential_name>;
    3. DROP MASTER KEY; 
  • 模拟简单文本数据,如下:
  •      
    澳门新浦京娱乐游戏 4
  • 将文本文件上传到 Azure blob storage,
    如下图:
  • 澳门新浦京娱乐游戏 5
  • 远程连接ploybase1, 打开ssms(注:此版本需单独安装),执行脚本如下:
  • CREATE MASTER KEY ENCRYPTION BY PASSWORD = ‘Password01!’;

    CREATE DATABASE SCOPED CREDENTIAL JNAzureCredit   
    WITH IDENTITY = 'zhushy', Secret =  XXXX';  /*存储访问Key*/ 
    
    CREATE EXTERNAL DATA SOURCE JNAzureStorage with (  
            TYPE = HADOOP,   
            LOCATION ='wasb://<blob_container_name>@<azure_storage_account_name>.blob.core.chinacloudapi.cn',  
            CREDENTIAL = JNAzureCredit  
    );


    CREATE EXTERNAL FILE FORMAT TextFileFormat WITH (  
            FORMAT_TYPE = DELIMITEDTEXT,   
            FORMAT_OPTIONS (FIELD_TERMINATOR =' ', USE_TYPE_DEFAULT = TRUE))

    CREATE EXTERNAL TABLE [dbo].[hospital] (  
            [ID] varchar(128) NULL,
            [name] varchar(128) null
    )  
    WITH (LOCATION='/zhu/data1.txt',   
            DATA_SOURCE = JNAzureStorage,  
            FILE_FORMAT = TextFileFormat  
    );  

 
  • 验证数据,输入如下SQL: select *
    from [dbo].[hospital] ,如下图,则OK
  • 澳门新浦京娱乐游戏 6

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注