scala基本语法-1

时间:2022-05-11 14:55:04
#Hadoop Env
export HADOOP_HOME_WARN_SUPPRESS=1
export JAVA_HOME=/user/local/jdk
export HADOOP_HOME=/user/local/hadoop-2.6.0
export HIVE_HOME=/user/local/hive
export PATH=$JAVA_HOME/bin:$HADOOP_HOME:/bin:$PATH
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
#export TOMCAT_HOME=/root/solr/apache-tomcat-6.0.37
#export JRE_HOME=$JAVA_HOME/jre
#export PATH=$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$HIVE_HOME/bin:$PATH
export PATH=$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$HIVE_HOME/bin:$PATH

#FLUME
#export FLUME_HOME=/usr/local/hadoop/flume/apache-flume-1.5.0-bin
#export FLUME_CONF_DIR=$FLUME_HOME/conf
#export PATH=$PATH:$FLUME_HOME/bin

#mvn
export MAVEN_HOME=/usr/local/apache-maven-3.3.9
export PATH=$PATH:$MAVEN_HOME/bin

#scala
export SCALA_HOME=/user/local/scala-2.9.3
export PATH=$PATH:$SCALA_HOME/bin
#spark
export SPARK_HOME=/user/local/spark-1.4.0-bin-hadoop2.6
export PATH=$PATH:$SPARK_HOME/bin

#hbase
export HBASE_HOME=/user/local/hbase-0.98.20-hadoop2
export PATH=$PATH:$HBASE_HOME/bin

#zk
export ZOOKEEPER_HOME=/user/local/zookeeper-3.4.6
export PATH=$PATH:$ZOOKEEPER_HOME/bin

#storm
export STORM_HOME=/user/local/apache-storm-0.9.2-incubating
export PATH=$PATH:$STORM_HOME/bin

#kafaka
export KAFKA_HOME=/user/local/kafka_2.9.2-0.8.1.1
export PATH=$PATH:$KAFKA_HOME/bin

[root@cdh2 Desktop]# cat /etc/hosts
#127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 name01
#::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 cdh2
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

#127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
#::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
#10.99.174.85 hadoop.example.com hadoop
#192.168.0.101 name01
#192.168.0.102 data01
#192.168.0.103 data02
#192.168.0.103 cdh2
#192.168.111.126 cdh1
192.168.3.127 cdh2
#192.168.111.128 cdh3
[root@cdh2 Desktop]# cat /etc/sys
sysconfig/ sysctl.conf system-release system-release-cpe
[root@cdh2 Desktop]# cat /etc/sys
sysconfig/ sysctl.conf system-release system-release-cpe
[root@cdh2 Desktop]# cat /etc/sys
sysconfig/ sysctl.conf system-release system-release-cpe
[root@cdh2 Desktop]# cat /etc/sysconfig/
cat: /etc/sysconfig/: Is a directory
[root@cdh2 Desktop]# cd /etc/sysconfig/
[root@cdh2 sysconfig]# ll
total 216
-rw-r--r--. 1 root root 403 Jan 30 2012 atd
-rw-r-----. 1 root root 647 Jun 22 2012 auditd
-rw-r--r--. 1 root root 395 Sep 9 2013 authconfig
drwxr-xr-x. 2 root root 4096 Sep 9 2013 cbq
-rw-r--r--. 1 root root 27 Sep 9 2013 clock
drwxr-xr-x. 2 root root 4096 Feb 22 2013 console
-rw-r--r--. 1 root root 2651 Feb 21 2013 cpuspeed
-rw-r--r--. 1 root root 110 Jul 18 2011 crond
-rw-r--r--. 1 root root 16 Sep 9 2013 firstboot
-rw-r--r--. 1 root root 25 Sep 9 2013 grub
-rw-r--r--. 1 root root 529 Dec 5 2012 htcacheclean
-rw-r--r--. 1 root root 947 Dec 5 2012 httpd
-rw-r--r--. 1 root root 47 Sep 9 2013 i18n
-rw-r--r--. 1 root root 1154 Feb 22 2013 init
-rw-------. 1 root root 481 Sep 9 2013 ip6tables
-rw-------. 1 root root 1988 Feb 21 2013 ip6tables-config
-rw-------. 1 root root 481 Sep 9 2013 ip6tables.old
-rw-------. 1 root root 476 Sep 9 2013 iptables
-rw-------. 1 root root 1974 Feb 21 2013 iptables-config
-rw-------. 1 root root 476 Sep 9 2013 iptables.old
-rw-r--r--. 1 root root 903 Oct 12 2012 irqbalance
-rw-r--r--. 1 root root 1204 Feb 21 2013 kdump
-rw-r--r--. 1 root root 180 Sep 9 2013 kernel
-rw-r--r--. 1 root root 63 Sep 9 2013 keyboard
drwxr-xr-x. 2 root root 4096 Sep 9 2013 modules
-rw-r--r--. 1 root root 634 Feb 22 2013 netconsole
-rw-r--r-- 1 root root 92 Jun 17 07:24 network
drwxr-xr-x. 4 root root 4096 Nov 11 2010 networking
drwxr-xr-x. 2 root root 4096 Jul 4 03:39 network-scripts
-rw-r--r--. 1 root root 712 Nov 13 2012 nspluginwrapper
-rw-r--r-- 1 root root 85 May 3 08:09 ntpd
-rw-r--r-- 1 root root 167 May 3 08:09 ntpdate
drwxr-xr-x 2 root root 4096 May 10 15:47 pgsql
-rw-r--r--. 1 root root 1459 Nov 23 2004 prelink
-rw-r--r--. 1 root root 178 Oct 2 2012 quota_nld
-rw-r--r--. 1 root root 2440 Dec 6 2012 raid-check
-rw-r--r--. 1 root root 551 Aug 23 2010 readahead
-rw-r--r--. 1 root root 659 Feb 22 2013 readonly-root
-rw-r-----. 1 root root 41 Dec 17 2011 rngd
-rw-r--r--. 1 root root 200 Jan 9 2013 rsyslog
-rw-r--r--. 1 root root 111 Feb 21 2013 samba
-rw-r--r--. 1 root root 136 Feb 21 2013 sandbox
-rw-r--r--. 1 root root 553 Nov 20 2012 saslauthd
lrwxrwxrwx. 1 root root 17 Sep 9 2013 selinux -> ../selinux/config
-rw-r--r--. 1 root root 125 Feb 21 2013 smartmontools
-rw-r-----. 1 root root 438 Feb 21 2013 sshd
-rw-r--r--. 1 root root 428 Jun 22 2012 sysstat
-rw-r--r--. 1 root root 6253 Jun 22 2012 sysstat.ioconf
-rw-------. 1 root root 73 Sep 9 2013 system-config-firewall
-rw-------. 1 root root 71 Sep 9 2013 system-config-firewall.old
-rw-r--r--. 1 root root 304 Oct 18 2012 system-config-users
-rw-r--r--. 1 root root 183 Feb 21 2013 udev
-rw-r--r--. 1 root root 644 Feb 4 2013 wpa_supplicant
-rw------- 1 root root 376 May 10 11:35 xinetd
[root@cdh2 sysconfig]# ls -l
total 216
-rw-r--r--. 1 root root 403 Jan 30 2012 atd
-rw-r-----. 1 root root 647 Jun 22 2012 auditd
-rw-r--r--. 1 root root 395 Sep 9 2013 authconfig
drwxr-xr-x. 2 root root 4096 Sep 9 2013 cbq
-rw-r--r--. 1 root root 27 Sep 9 2013 clock
drwxr-xr-x. 2 root root 4096 Feb 22 2013 console
-rw-r--r--. 1 root root 2651 Feb 21 2013 cpuspeed
-rw-r--r--. 1 root root 110 Jul 18 2011 crond
-rw-r--r--. 1 root root 16 Sep 9 2013 firstboot
-rw-r--r--. 1 root root 25 Sep 9 2013 grub
-rw-r--r--. 1 root root 529 Dec 5 2012 htcacheclean
-rw-r--r--. 1 root root 947 Dec 5 2012 httpd
-rw-r--r--. 1 root root 47 Sep 9 2013 i18n
-rw-r--r--. 1 root root 1154 Feb 22 2013 init
-rw-------. 1 root root 481 Sep 9 2013 ip6tables
-rw-------. 1 root root 1988 Feb 21 2013 ip6tables-config
-rw-------. 1 root root 481 Sep 9 2013 ip6tables.old
-rw-------. 1 root root 476 Sep 9 2013 iptables
-rw-------. 1 root root 1974 Feb 21 2013 iptables-config
-rw-------. 1 root root 476 Sep 9 2013 iptables.old
-rw-r--r--. 1 root root 903 Oct 12 2012 irqbalance
-rw-r--r--. 1 root root 1204 Feb 21 2013 kdump
-rw-r--r--. 1 root root 180 Sep 9 2013 kernel
-rw-r--r--. 1 root root 63 Sep 9 2013 keyboard
drwxr-xr-x. 2 root root 4096 Sep 9 2013 modules
-rw-r--r--. 1 root root 634 Feb 22 2013 netconsole
-rw-r--r-- 1 root root 92 Jun 17 07:24 network
drwxr-xr-x. 4 root root 4096 Nov 11 2010 networking
drwxr-xr-x. 2 root root 4096 Jul 4 03:39 network-scripts
-rw-r--r--. 1 root root 712 Nov 13 2012 nspluginwrapper
-rw-r--r-- 1 root root 85 May 3 08:09 ntpd
-rw-r--r-- 1 root root 167 May 3 08:09 ntpdate
drwxr-xr-x 2 root root 4096 May 10 15:47 pgsql
-rw-r--r--. 1 root root 1459 Nov 23 2004 prelink
-rw-r--r--. 1 root root 178 Oct 2 2012 quota_nld
-rw-r--r--. 1 root root 2440 Dec 6 2012 raid-check
-rw-r--r--. 1 root root 551 Aug 23 2010 readahead
-rw-r--r--. 1 root root 659 Feb 22 2013 readonly-root
-rw-r-----. 1 root root 41 Dec 17 2011 rngd
-rw-r--r--. 1 root root 200 Jan 9 2013 rsyslog
-rw-r--r--. 1 root root 111 Feb 21 2013 samba
-rw-r--r--. 1 root root 136 Feb 21 2013 sandbox
-rw-r--r--. 1 root root 553 Nov 20 2012 saslauthd
lrwxrwxrwx. 1 root root 17 Sep 9 2013 selinux -> ../selinux/config
-rw-r--r--. 1 root root 125 Feb 21 2013 smartmontools
-rw-r-----. 1 root root 438 Feb 21 2013 sshd
-rw-r--r--. 1 root root 428 Jun 22 2012 sysstat
-rw-r--r--. 1 root root 6253 Jun 22 2012 sysstat.ioconf
-rw-------. 1 root root 73 Sep 9 2013 system-config-firewall
-rw-------. 1 root root 71 Sep 9 2013 system-config-firewall.old
-rw-r--r--. 1 root root 304 Oct 18 2012 system-config-users
-rw-r--r--. 1 root root 183 Feb 21 2013 udev
-rw-r--r--. 1 root root 644 Feb 4 2013 wpa_supplicant
-rw------- 1 root root 376 May 10 11:35 xinetd
[root@cdh2 sysconfig]# cd network-scripts/
[root@cdh2 network-scripts]# ls -ltr
total 208
-rw-r--r--. 1 root root 29853 Jan 9 2013 network-functions-ipv6
-rw-r--r--. 1 root root 13079 Jan 9 2013 network-functions
-rwxr-xr-x. 1 root root 1125 Jan 9 2013 net.hotplug
-rwxr-xr-x. 1 root root 4623 Jan 9 2013 init.ipv6-global
-rwxr-xr-x. 1 root root 3770 Jan 9 2013 ifup-wireless
-rwxr-xr-x. 1 root root 2488 Jan 9 2013 ifup-tunnel
-rwxr-xr-x. 1 root root 3499 Jan 9 2013 ifup-sit
-rwxr-xr-x. 1 root root 1925 Jan 9 2013 ifup-routes
-rwxr-xr-x. 1 root root 4154 Jan 9 2013 ifup-ppp
-rwxr-xr-x. 1 root root 2364 Jan 9 2013 ifup-post
-rwxr-xr-x. 1 root root 954 Jan 9 2013 ifup-plusb
-rwxr-xr-x. 1 root root 727 Jan 9 2013 ifup-plip
-rwxr-xr-x. 1 root root 10401 Jan 9 2013 ifup-ipv6
-rwxr-xr-x. 1 root root 11971 Jan 9 2013 ifup-ippp
-rwxr-xr-x. 1 root root 10157 Jan 9 2013 ifup-eth
-rwxr-xr-x. 1 root root 859 Jan 9 2013 ifup-bnep
-rwxr-xr-x. 1 root root 12365 Jan 9 2013 ifup-aliases
-rwxr-xr-x. 1 root root 1434 Jan 9 2013 ifdown-tunnel
-rwxr-xr-x. 1 root root 1370 Jan 9 2013 ifdown-sit
-rwxr-xr-x. 1 root root 835 Jan 9 2013 ifdown-routes
-rwxr-xr-x. 1 root root 1064 Jan 9 2013 ifdown-ppp
-rwxr-xr-x. 1 root root 1481 Jan 9 2013 ifdown-post
-rwxr-xr-x. 1 root root 4168 Jan 9 2013 ifdown-ipv6
-rwxr-xr-x. 1 root root 781 Jan 9 2013 ifdown-ippp
-rwxr-xr-x. 1 root root 5397 Jan 9 2013 ifdown-eth
-rwxr-xr-x. 1 root root 627 Jan 9 2013 ifdown-bnep
-rw-r--r--. 1 root root 254 Jan 9 2013 ifcfg-lo
lrwxrwxrwx. 1 root root 20 Sep 9 2013 ifdown -> ../../../sbin/ifdown
lrwxrwxrwx. 1 root root 11 Sep 9 2013 ifdown-isdn -> ifdown-ippp
lrwxrwxrwx. 1 root root 18 Sep 9 2013 ifup -> ../../../sbin/ifup
lrwxrwxrwx. 1 root root 9 Sep 9 2013 ifup-isdn -> ifup-ippp
-rw-r--r--. 3 root root 260 Jul 4 2015 ifcfg-eth2.bak
-rw-r--r-- 1 root root 305 Jul 4 03:39 ifcfg-eth0
[root@cdh2 network-scripts]# cat ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
IPV6INIT=yes
NM_CONTROLLED=yes
ONBOOT=yes
TYPE=Ethernet
UUID="2d678a8b-6c40-4ebc-8f4e-245ef6b7a969"
HWADDR=00:0C:29:D5:9C:DD
#IPADDR=192.168.0.103
IPADDR=192.168.3.127
NETMASK=255.255.255.0
DNS2=114.114.114.114
GATEWAY=192.168.3.1
#GATEWAY=192.168.111.1
DNS1=8.8.8.8
USERCTL=no
[root@cdh2 network-scripts]# cat /etc/hosts
#127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 name01
#::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 cdh2
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

#127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
#::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
#10.99.174.85 hadoop.example.com hadoop
#192.168.0.101 name01
#192.168.0.102 data01
#192.168.0.103 data02
#192.168.0.103 cdh2
#192.168.111.126 cdh1
192.168.3.127 cdh2
#192.168.111.128 cdh3
[root@cdh2 network-scripts]# ll
total 208
-rw-r--r-- 1 root root 305 Jul 4 03:39 ifcfg-eth0
-rw-r--r--. 3 root root 260 Jul 4 2015 ifcfg-eth2.bak
-rw-r--r--. 1 root root 254 Jan 9 2013 ifcfg-lo
lrwxrwxrwx. 1 root root 20 Sep 9 2013 ifdown -> ../../../sbin/ifdown
-rwxr-xr-x. 1 root root 627 Jan 9 2013 ifdown-bnep
-rwxr-xr-x. 1 root root 5397 Jan 9 2013 ifdown-eth
-rwxr-xr-x. 1 root root 781 Jan 9 2013 ifdown-ippp
-rwxr-xr-x. 1 root root 4168 Jan 9 2013 ifdown-ipv6
lrwxrwxrwx. 1 root root 11 Sep 9 2013 ifdown-isdn -> ifdown-ippp
-rwxr-xr-x. 1 root root 1481 Jan 9 2013 ifdown-post
-rwxr-xr-x. 1 root root 1064 Jan 9 2013 ifdown-ppp
-rwxr-xr-x. 1 root root 835 Jan 9 2013 ifdown-routes
-rwxr-xr-x. 1 root root 1370 Jan 9 2013 ifdown-sit
-rwxr-xr-x. 1 root root 1434 Jan 9 2013 ifdown-tunnel
lrwxrwxrwx. 1 root root 18 Sep 9 2013 ifup -> ../../../sbin/ifup
-rwxr-xr-x. 1 root root 12365 Jan 9 2013 ifup-aliases
-rwxr-xr-x. 1 root root 859 Jan 9 2013 ifup-bnep
-rwxr-xr-x. 1 root root 10157 Jan 9 2013 ifup-eth
-rwxr-xr-x. 1 root root 11971 Jan 9 2013 ifup-ippp
-rwxr-xr-x. 1 root root 10401 Jan 9 2013 ifup-ipv6
lrwxrwxrwx. 1 root root 9 Sep 9 2013 ifup-isdn -> ifup-ippp
-rwxr-xr-x. 1 root root 727 Jan 9 2013 ifup-plip
-rwxr-xr-x. 1 root root 954 Jan 9 2013 ifup-plusb
-rwxr-xr-x. 1 root root 2364 Jan 9 2013 ifup-post
-rwxr-xr-x. 1 root root 4154 Jan 9 2013 ifup-ppp
-rwxr-xr-x. 1 root root 1925 Jan 9 2013 ifup-routes
-rwxr-xr-x. 1 root root 3499 Jan 9 2013 ifup-sit
-rwxr-xr-x. 1 root root 2488 Jan 9 2013 ifup-tunnel
-rwxr-xr-x. 1 root root 3770 Jan 9 2013 ifup-wireless
-rwxr-xr-x. 1 root root 4623 Jan 9 2013 init.ipv6-global
-rwxr-xr-x. 1 root root 1125 Jan 9 2013 net.hotplug
-rw-r--r--. 1 root root 13079 Jan 9 2013 network-functions
-rw-r--r--. 1 root root 29853 Jan 9 2013 network-functions-ipv6
[root@cdh2 network-scripts]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:D5:9C:DD
inet addr:192.168.3.127 Bcast:192.168.3.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:19 Base address:0x2024

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:201 errors:0 dropped:0 overruns:0 frame:0
TX packets:201 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:26314 (25.6 KiB) TX bytes:26314 (25.6 KiB)

[root@cdh2 network-scripts]# pwd
/etc/sysconfig/network-scripts
[root@cdh2 network-scripts]# ls -ltr /etc/sysconfig/network-scripts
total 208
-rw-r--r--. 1 root root 29853 Jan 9 2013 network-functions-ipv6
-rw-r--r--. 1 root root 13079 Jan 9 2013 network-functions
-rwxr-xr-x. 1 root root 1125 Jan 9 2013 net.hotplug
-rwxr-xr-x. 1 root root 4623 Jan 9 2013 init.ipv6-global
-rwxr-xr-x. 1 root root 3770 Jan 9 2013 ifup-wireless
-rwxr-xr-x. 1 root root 2488 Jan 9 2013 ifup-tunnel
-rwxr-xr-x. 1 root root 3499 Jan 9 2013 ifup-sit
-rwxr-xr-x. 1 root root 1925 Jan 9 2013 ifup-routes
-rwxr-xr-x. 1 root root 4154 Jan 9 2013 ifup-ppp
-rwxr-xr-x. 1 root root 2364 Jan 9 2013 ifup-post
-rwxr-xr-x. 1 root root 954 Jan 9 2013 ifup-plusb
-rwxr-xr-x. 1 root root 727 Jan 9 2013 ifup-plip
-rwxr-xr-x. 1 root root 10401 Jan 9 2013 ifup-ipv6
-rwxr-xr-x. 1 root root 11971 Jan 9 2013 ifup-ippp
-rwxr-xr-x. 1 root root 10157 Jan 9 2013 ifup-eth
-rwxr-xr-x. 1 root root 859 Jan 9 2013 ifup-bnep
-rwxr-xr-x. 1 root root 12365 Jan 9 2013 ifup-aliases
-rwxr-xr-x. 1 root root 1434 Jan 9 2013 ifdown-tunnel
-rwxr-xr-x. 1 root root 1370 Jan 9 2013 ifdown-sit
-rwxr-xr-x. 1 root root 835 Jan 9 2013 ifdown-routes
-rwxr-xr-x. 1 root root 1064 Jan 9 2013 ifdown-ppp
-rwxr-xr-x. 1 root root 1481 Jan 9 2013 ifdown-post
-rwxr-xr-x. 1 root root 4168 Jan 9 2013 ifdown-ipv6
-rwxr-xr-x. 1 root root 781 Jan 9 2013 ifdown-ippp
-rwxr-xr-x. 1 root root 5397 Jan 9 2013 ifdown-eth
-rwxr-xr-x. 1 root root 627 Jan 9 2013 ifdown-bnep
-rw-r--r--. 1 root root 254 Jan 9 2013 ifcfg-lo
lrwxrwxrwx. 1 root root 20 Sep 9 2013 ifdown -> ../../../sbin/ifdown
lrwxrwxrwx. 1 root root 11 Sep 9 2013 ifdown-isdn -> ifdown-ippp
lrwxrwxrwx. 1 root root 18 Sep 9 2013 ifup -> ../../../sbin/ifup
lrwxrwxrwx. 1 root root 9 Sep 9 2013 ifup-isdn -> ifup-ippp
-rw-r--r--. 3 root root 260 Jul 4 2015 ifcfg-eth2.bak
-rw-r--r-- 1 root root 305 Jul 4 03:39 ifcfg-eth0
[root@cdh2 network-scripts]# mkdir /dfs/ftp/aipb/gaopf/
mkdir: cannot create directory `/dfs/ftp/aipb/gaopf/': No such file or directory
[root@cdh2 network-scripts]# mkdir -p /dfs/ftp/aipb/gaopf/
[root@cdh2 network-scripts]# cd /dfs/ftp/aipb/gaopf/
[root@cdh2 gaopf]# pwd
/dfs/ftp/aipb/gaopf
[root@cdh2 gaopf]# mkdir -p /dfs/ftp/aipb/gaopf/logs/
[root@cdh2 gaopf]# ll
total 4
drwxr-xr-x 2 root root 4096 Jul 7 02:46 logs
[root@cdh2 gaopf]# pwd
/dfs/ftp/aipb/gaopf
[root@cdh2 gaopf]# ls /mnt/hgfs/
cloudera hive tab-dt tab-dt-2
[root@cdh2 gaopf]# cp /mnt/hgfs/tab-dt-2/* .
cp: omitting directory `/mnt/hgfs/tab-dt-2/database'
cp: omitting directory `/mnt/hgfs/tab-dt-2/PROCE_DDL_HIVE'
cp: omitting directory `/mnt/hgfs/tab-dt-2/后台维表数据'
[root@cdh2 gaopf]# ll
total 4
drwxr-xr-x 2 root root 4096 Jul 7 02:46 logs
[root@cdh2 gaopf]# cp -r /mnt/hgfs/tab-dt-2/* .
[root@cdh2 gaopf]# ll
total 16
drwxr-xr-x 3 root root 4096 Jul 7 02:50 database
drwxr-xr-x 2 root root 4096 Jul 7 02:46 logs
drwxr-xr-x 2 root root 4096 Jul 7 02:50 PROCE_DDL_HIVE
drwxr-xr-x 2 root root 4096 Jul 7 02:50 后台维表数据
[root@cdh2 gaopf]# ls -l database/
total 20
-rwxr-xr-x 1 root root 560 Jul 7 02:50 config.sh
drwxr-xr-x 3 root root 4096 Jul 7 02:50 procedure
-rwxr-xr-x 1 root root 2471 Jul 7 02:50 runHQLDay.sh
-rwxr-xr-x 1 root root 1802 Jul 7 02:50 runHQLMinute.sh
-rwxr-xr-x 1 root root 1606 Jul 7 02:50 runHQLMonth.sh
[root@cdh2 gaopf]# jps
2771 DataNode
3770 Jps
[root@cdh2 gaopf]# jps
4273 Jps
2771 DataNode
[root@cdh2 gaopf]# scala
Welcome to Scala version 2.9.3 (Java HotSpot(TM) Client VM, Java 1.7.0_67).
Type in expressions to have them evaluated.
Type :help for more information.

scala> def g():Unit={" this String gets lost too"}
g: ()Unit

scala> g

scala> println("Hello, Scala!");
Hello, Scala!

scala> g

scala> val s = "hello"
s: java.lang.String = hello

scala> s
res3: java.lang.String = hello

scala> def h()={" this String gets lost too"}
h: ()java.lang.String

scala> h
res4: java.lang.String = " this String gets lost too"

scala> def h()={" this String does not get lost ..."}
h: ()java.lang.String

scala> h
res5: java.lang.String = " this String does not get lost ..."

scala> 22+5
res6: Int = 27

scala> res6+3
res7: Int = 30

scala> "Hello,"+res7
res8: java.lang.String = Hello,30

scala> res8.
+ asInstanceOf charAt codePointAt codePointBefore codePointCount
compareTo compareToIgnoreCase concat contains contentEquals endsWith
equalsIgnoreCase getBytes getChars indexOf intern isEmpty
isInstanceOf lastIndexOf length matches offsetByCodePoints regionMatches
replace replaceAll replaceFirst split startsWith subSequence
substring toCharArray toLowerCase toString toUpperCase trim

scala> res8.c
charAt codePointAt codePointBefore codePointCount compareTo compareToIgnoreCase
concat contains contentEquals

scala> res8.compareTo
compareTo //顺序? compareToIgnoreCase

scala> res8.compareTo("Hello,30")
res9: Int = 0

scala> res8.compareTo("Hello,")
res10: Int = 2

scala> res8.compareTo("Hello,301")
res11: Int = -1

scala> res8.length
res12: Int = 8

scala> res8.is
isEmpty isInstanceOf

scala> res8.isEmpty
res13: Boolean = false

scala> res8.isInstanceOf(String)
<console>:11: error: Boolean does not take parameters
res8.isInstanceOf(String)
^

scala> res8.isInstanceOf(java.lang.String)
<console>:11: error: Boolean does not take parameters
res8.isInstanceOf(java.lang.String)
^

scala> res8.isInstanceOf("String")
<console>:11: error: Boolean does not take parameters
res8.isInstanceOf("String")
^

scala> res8.isInstanceOf("java.lang.String")
<console>:11: error: Boolean does not take parameters
res8.isInstanceOf("java.lang.String")
^

scala> res8.isInstanceOf(java.lang.String)
<console>:11: error: Boolean does not take parameters
res8.isInstanceOf(java.lang.String)
^

scala> res8.toUpperCase
res19: java.lang.String = HELLO,30

scala> var num=0
num: Int = 0

scala> num=2
num: Int = 2

scala> val num=0
num: Int = 0

scala> num=2
<console>:8: error: reassignment to val
num=2
^

scala> 常量不可以改变值.

scala> val num;
<console>:1: error: '=' expected but ';' found.
val num;
^

scala>声明必须初始化.



scala> val num;
<console>:1: error: '=' expected but ';' found.
val num;
^

scala> val num=null;
num: Null = null

scala> val a,b=10
a: Int = 10
b: Int = 10
scala>初始化为相同的值。
scala> val a=2,b=10
<console>:1: error: ';' expected but ',' found.
val a=2,b=10
^

scala> val a=2;b=10
<console>:8: error: reassignment to val
val a=2;b=10
^
scala>给不同的值 就得单独声明并且初始化。
scala> val a=2;val b=10
a: Int = 2
b: Int = 10

scala> 1.toS
toShort toString

scala> 1.toString
res20: java.lang.String = 1

scala> 1.to
toByte toChar toDouble toFloat toInt toLong toShort toString

scala> 1.to(10)
res21: scala.collection.immutable.Range.Inclusive = Range(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

scala> 1.unary_(10)
unary_+ unary_- unary_~

scala> 1.until(10)
res22: scala.collection.immutable.Range = Range(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> 99.44.toInt
res23: Int = 99

scala> 99.toChar
res24: Char = c

scala> "99.44".toD<console>:1: error: unclosed string literal
"99
^

<console>:8: error: value toD is not a member of java.lang.String
"99.44".toD
^

scala> "99.44".toDou<console>:1: error: unclosed string literal
"99
^

<console>:8: error: value toDou is not a member of java.lang.String
"99.44".toDou
^

scala> "99.44".toDouble
res27: Double = 99.44

scala> "Hello".intersect("World")
res28: String = lo
scala>intersect 找交集.
scala> var ans-8*5+2
| ;
<console>:2: error: '=' expected but ';' found.
;
^

scala> var ans=8*5+2
ans: Int = 42

scala> a+b
res29: Int = 12

scala> a
res30: Int = 2

scala> b
res31: Int = 10

scala> a.+(b)
res32: Int = 12
scala>a.+(b) 这是 加法调用的方法。
scala> a+=1
<console>:9: error: reassignment to val
a+=1
^

scala> var a=2
a: Int = 2

scala> a+=1

scala> a
res35: Int = 3

scala> a++
<console>:9: error: value ++ is not a member of Int
a++
^
scala>没有++
scala> a
res37: Int = 3

scala>




scala> sqrt(2)
<console>:8: error: not found: value sqrt
sqrt(2)
^

scala> sqrt(2)
<console>:8: error: not found: value sqrt
sqrt(2)
^

scala> pow(2,4)
<console>:8: error: not found: value pow
pow(2,4)
^

scala> import java.math.*
<console>:7: error: * is not a member of java.math
import java.math.*
^

scala> import scala.math._
import scala.math._

scala> pow(2,4)
res41: Double = 16.0

scala> sqrt(2)
res42: Double = 1.4142135623730951

scala> min(3.pi)
<console>:11: error: value pi is not a member of Int
min(3.pi)
^

scala> min(3,pi)
<console>:11: error: not found: value pi
min(3,pi)
^

scala> min(3,Pi)
res45: Double = 3.0

scala> min(4,Pi)
res46: Double = 3.141592653589793

scala> "Hello"(4)
res47: Char = o

scala> "Hello"(1)
res48: Char = e

scala> "Hello"(0)
res49: Char = H

scala> "Hello"(4)
res50: Char = o

scala> "Hello".apply(4)
res51: Char = o

scala> "Hello".apply(1)
res52: Char = e

scala> "Hello".apply(0)
res53: Char = H

scala> BigInt.apply(1234567890)
res54: scala.math.BigInt = 1234567890

scala> 3
res55: Int = 3

scala> 10 max 4
res56: Int = 10

scala> 10 max 14
res57: Int = 14

scala> Array(2)
res58: Array[Int] = Array(2)

scala> new Array(2)
res59: Array[Nothing] = Array(null, null)

scala> res58.length
res60: Int = 1

scala> res59.length
res61: Int = 2

scala> Array(4)
res62: Array[Int] = Array(4)

scala> new Array(4)
res63: Array[Nothing] = Array(null, null, null, null)

scala> res62.length
res64: Int = 1

scala> res63.length
res65: Int = 4

scala> Array(Array(1,7),Array(2,9))
res66: Array[Array[Int]] = Array(Array(1, 7), Array(2, 9))

scala> res66(1)
res67: Array[Int] = Array(2, 9)

scala> res66(2)
java.lang.ArrayIndexOutOfBoundsException: 2
at .<init>(<console>:12)
at .<clinit>(<console>)
at .<init>(<console>:11)
at .<clinit>(<console>)
at $print(<console>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:704)
at scala.tools.nsc.interpreter.IMain$Request$$anonfun$14.apply(IMain.scala:920)
at scala.tools.nsc.interpreter.Line$$anonfun$1.apply$mcV$sp(Line.scala:43)
at scala.tools.nsc.io.package$$anon$2.run(package.scala:25)
at java.lang.Thread.run(Thread.java:745)


scala> res66(0)
res69: Array[Int] = Array(1, 7)

scala> res66(1)
res70: Array[Int] = Array(2, 9)

scala> res66.length
res71: Int = 2

scala> res66(1).(0)
<console>:1: error: identifier expected but '(' found.
res66(1).(0)
^

scala> res66(1)(0)
res72: Int = 2

scala> res66(1)(1)
res73: Int = 9

scala> res66(0)(1)
res74: Int = 7

scala> res66(0)(0)
res75: Int = 1

scala>

scala> object AppTest extends App {
| if(args.length>1){
| args.foreach { x => println(x)}
| // println("length>1 "+args(0))
| }else{
|
BigDecimal BigInt E Equiv Fractional
IEEEremainder Integral LowPriorityEquiv LowPriorityOrderingImplicits Numeric
Ordered Ordering PartialOrdering PartiallyOrdered Pi
ScalaNumber ScalaNumericConversions a abs acos
ans asin atan atan2 b
cbrt ceil classOf cos cosh
exp expm1 floor g h
hypot lastException log log10 log1p
max min num package pow
random res0 res1 res10 res11
res12 res13 res19 res2 res20
res21 res22 res23 res24 res27
res28 res29 res3 res30 res31
res32 res34 res35 res37 res4
res41 res42 res45 res46 res47
res48 res49 res5 res50 res51
res52 res53 res54 res55 res56
res57 res58 res59 res6 res60
res61 res62 res63 res64 res65
res66 res67 res69 res7 res70
res71 res72 res73 res74 res75
res8 res9 rint round s
signum sin sinh sqrt tan
tanh toDegrees toRadians ulp
| println("length=0")
| }
| }
defined module AppTest

scala> object AppTest extends App {
| if(args.length>1){
| args.foreach { x => println(x)}
| }else{
|
AppTest BigDecimal BigInt E Equiv
Fractional IEEEremainder Integral LowPriorityEquiv LowPriorityOrderingImplicits
Numeric Ordered Ordering PartialOrdering PartiallyOrdered
Pi ScalaNumber ScalaNumericConversions a abs
acos ans asin atan atan2
b cbrt ceil classOf cos
cosh exp expm1 floor g
h hypot lastException log log10
log1p max min num package
pow random res0 res1 res10
res11 res12 res13 res19 res2
res20 res21 res22 res23 res24
res27 res28 res29 res3 res30
res31 res32 res34 res35 res37
res4 res41 res42 res45 res46
res47 res48 res49 res5 res50
res51 res52 res53 res54 res55
res56 res57 res58 res59 res6
res60 res61 res62 res63 res64
res65 res66 res67 res69 res7
res70 res71 res72 res73 res74
res75 res8 res9 rint round
s signum sin sinh sqrt
tan tanh toDegrees toRadians ulp
| println("length=0")
| }
| }
defined module AppTest

scala> [root@cdh2 gaopf]#
[root@cdh2 gaopf]# pwd
/dfs/ftp/aipb/gaopf
[root@cdh2 gaopf]# cd /user/local/test/
[root@cdh2 test]# ll
total 220
-rw-r--r-- 1 root root 632 Jul 5 02:15 ArrayTest.scala
drwxr-xr-x 2 root root 4096 Jul 5 00:58 bak
-rw-r--r-- 1 root root 650 Jul 5 04:58 BreakTest1.scala
-rw-r--r-- 1 root root 401 Jul 5 04:56 BreakTest.scala
-rw-r--r-- 1 root root 330 Jul 4 19:45 CaseTest2.scala
-rw-r--r-- 1 root root 354 Jul 4 20:07 CaseTest3.scala
-rw-r--r-- 1 root root 263 Jul 4 19:38 CaseTest.scala
drwxr-xr-x 5 root root 4096 Jul 5 05:29 classes
-rw-r--r-- 1 root root 351 Jul 5 02:27 ConcatArray.scala
-rw-r--r-- 1 root root 239 Jul 5 02:03 ConsoleTes.scala
-rw-r--r-- 1 root root 197 Jul 5 01:51 ConsoleTest.scala
-rw-r--r-- 1 root root 239 Jul 5 05:02 DoWhileTest.scala
-rw-r--r-- 1 root root 238 Jul 5 03:42 Factor.scala
-rw-r--r-- 1 root root 238 Jul 5 03:42 FactorTest.scala
-rw-r--r-- 1 root root 475 Jul 4 23:37 File1.scala
-rw-r--r-- 1 root root 529 Jul 4 23:40 File2.scala
-rw-r--r-- 1 root root 411 Jul 4 23:32 File.scala
-rw-r--r-- 1 root root 189 Jul 5 01:26 FileWR.scala
-rw-r--r-- 1 root root 403 Jul 5 03:37 FormatTest.scala
-rw-r--r-- 1 root root 585 Jul 4 20:15 ForTest.scala
-rw-r--r-- 1 root root 414 Jul 5 03:59 Fun2.scala
-rw-r--r-- 1 root root 388 Jul 5 03:49 Fun.scala
-rw-r--r-- 1 root root 325 Jul 5 05:29 HelloWorld23.scala
-rw-r--r-- 1 root root 104 Jul 4 18:44 HelloWorld2.scala
-rw-r--r-- 1 root root 88 Jul 4 04:18 HelloWorld.scala
-rw-r--r-- 1 root root 86 Jul 5 05:24 Hl.scala
-rw-r--r-- 1 root root 204 Jul 5 05:04 IfTest.scala
-rw-r--r-- 1 root root 438 Jul 5 02:21 MatrixTest.scala
-rw-r--r-- 1 root root 183 Jul 5 04:35 Other.scala
-rw-r--r-- 1 root root 223 Jul 5 04:21 Outer1.scala
-rw-r--r-- 1 root root 169 Jul 5 04:14 Outer.scala
-rwxr-xr-x 1 root root 193 Jul 4 04:06 person.sh
-rw-r--r-- 1 root root 365 Jul 5 04:38 ProtectPub.scala
-rw-r--r-- 1 root root 424 Jul 5 03:25 RangeArray.scala
-rw-r--r-- 1 root root 234 Jul 4 22:12 RegexD1.scala
-rw-r--r-- 1 root root 250 Jul 4 22:18 RegexD2.scala
-rw-r--r-- 1 root root 349 Jul 4 22:07 RegexD.scala
-rw-r--r-- 1 root root 231 Jul 4 21:54 RegexReplace.scala
-rw-r--r-- 1 root root 270 Jul 4 21:48 RegexTest1.scala
-rw-r--r-- 1 root root 243 Jul 4 20:49 RegexTest2.scala
-rwxr-xr-x 1 root root 166 Jul 4 04:13 script.sh
-rw-r--r-- 1 root root 602 Jul 5 00:00 Some1.scala
-rw-r--r-- 1 root root 633 Jul 5 00:01 Some.scala
-rw-r--r-- 1 root root 205 Jul 5 01:55 SourceTest.scala
-rw-r--r-- 1 root root 435 Jul 5 03:35 Str.scala
-rw-r--r-- 1 root root 111 Jul 5 05:21 Symb.scala
-rw-r--r-- 1 root root 769 Jul 4 19:07 Test2.scala
-rw-r--r-- 1 root root 426 Jul 4 19:13 Test3.scala
-rw-r--r-- 1 root root 408 Jul 5 00:08 TestExtractor.scala
-rw-r--r-- 1 root root 493 Jul 4 19:00 Test.scala
-rw-r--r-- 1 root root 27 Jul 5 01:57 test.txt
-rw-r--r-- 1 root root 815 Jul 4 19:31 TraitTest.scala
-rw-r--r-- 1 root root 238 Jul 5 04:42 While.scala
-rw-r--r-- 1 root root 176 Jul 5 04:46 WhileTest1.scala
-rw-r--r-- 1 root root 238 Jul 5 04:44 WhileTest.scala
[root@cdh2 test]# vim AppTest.scala
[root@cdh2 test]# scalac AppTest.scala
[root@cdh2 test]# scala AppTest
length=0
[root@cdh2 test]# scala AppTest Hahah hhh jjj nihao
Hahah
hhh
jjj
nihao
[root@cdh2 test]# cat AppTest.scala
object AppTest extends App {
if(args.length>1){
args.foreach { x => println(x)}
// println("length>1 "+args(0))
}else{
println("length=0")
}
}
[root@cdh2 test]#

[root@cdh2 test]# scala AppTest Hahah hhh jjj nihao
Hahah
hhh
jjj
nihao
[root@cdh2 test]# scala -Dscala time AppTest Hahah hhh jjj nihao
Exception in thread "main" java.lang.RuntimeException: Cannot figure out how to run target: time
at scala.sys.package$.error(package.scala:27)
at scala.tools.nsc.GenericRunnerCommand.scala$tools$nsc$GenericRunnerCommand$$guessHowToRun(GenericRunnerCommand.scala:38)
at scala.tools.nsc.GenericRunnerCommand$$anonfun$2.apply(GenericRunnerCommand.scala:48)
at scala.tools.nsc.GenericRunnerCommand$$anonfun$2.apply(GenericRunnerCommand.scala:48)
at scala.Option.getOrElse(Option.scala:108)
at scala.tools.nsc.GenericRunnerCommand.<init>(GenericRunnerCommand.scala:48)
at scala.tools.nsc.GenericRunnerCommand.<init>(GenericRunnerCommand.scala:17)
at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:33)
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:89)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
[root@cdh2 test]# scala -Dscala.time AppTest Hahah hhh jjj nihao
Hahah
hhh
jjj
nihao
[total 2ms]

[root@cdh2 test]# scala -Dscala time AppTest Hahah hhh jjj nihao
Exception in thread "main" java.lang.RuntimeException: Cannot figure out how to run target: time
at scala.sys.package$.error(package.scala:27)
at scala.tools.nsc.GenericRunnerCommand.scala$tools$nsc$GenericRunnerCommand$$guessHowToRun(GenericRunnerCommand.scala:38)
at scala.tools.nsc.GenericRunnerCommand$$anonfun$2.apply(GenericRunnerCommand.scala:48)
at scala.tools.nsc.GenericRunnerCommand$$anonfun$2.apply(GenericRunnerCommand.scala:48)
at scala.Option.getOrElse(Option.scala:108)
at scala.tools.nsc.GenericRunnerCommand.<init>(GenericRunnerCommand.scala:48)
at scala.tools.nsc.GenericRunnerCommand.<init>(GenericRunnerCommand.scala:17)
at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:33)
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:89)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
[root@cdh2 test]# scala -Dscala.time AppTest Hahah hhh jjj nihao
Hahah
hhh
jjj
nihao
[total 2ms]
[root@cdh2 test]# cat AppTest.scala
object AppTest extends App {
if(args.length>1){
args.foreach { x => println(x)}
// println("length>1 "+args(0))
}else{
println("length=0")
}
}
[root@cdh2 test]#