摘要: 修改hive表名:ALTER TABLE old_name RENAME TO new_name;spark:spark.sql("ALTER TABLE old_name RENAME TO new_name") 阅读全文
posted @ 2019-01-03 16:20 xuejianbest 阅读(18115) 评论(0) 推荐(2) 编辑
摘要: spark中Dataset的的saveAsTable方法可以把数据持久化到hive中,其默认是用parquet格式保存数据文件的,若是想让其保存为其他格式,可以用format方法配置。如若想保存的数据文件格式为hive默认的纯文本文件:df.write.mo... 阅读全文
posted @ 2019-01-03 16:19 xuejianbest 阅读(2084) 评论(0) 推荐(0) 编辑
摘要: UNIX时间戳概念从格林尼治时间1970-01-01 00:00:00开始,到现在经过的秒数。时间戳是一个32位的整数(所以UNIX时间戳最多表示到2037年左右)。因为UNIX时间戳只是一个秒数,一个UNIX时间戳在不同时区看来,时间是不同的。如UNIX时... 阅读全文
posted @ 2019-01-03 16:15 xuejianbest 阅读(1521) 评论(0) 推荐(0) 编辑
摘要: 新建hive表:CREATE TABLE `test`( `a` timestamp, `b` struct) --下面可选 [row format delimited fields terminated by '\t'] [STORED AS P... 阅读全文
posted @ 2019-01-03 16:12 xuejianbest 阅读(2121) 评论(0) 推荐(0) 编辑
摘要: 存储表的时候,由以下几点要注意:写入hive表前用coalesce方法对原始数据进行重新分区。因为读取的数据一般是纯文本,写入hive中的默认是用snappy压缩过的parquet(.snappy.parquet),所以分区数如果保持原来的话可能会造成每个.... 阅读全文
posted @ 2019-01-03 16:07 xuejianbest 阅读(1010) 评论(0) 推荐(0) 编辑
摘要: hive本身提供了thrift协议对外提供服务的功能。如果某台机器已经配置好了hive,然后运行以下命令打开thrift,提供对外服务(打开后这台机器就为hive服务器):hive --service metastore & 远程机器想要使用hive,可以... 阅读全文
posted @ 2019-01-03 16:04 xuejianbest 阅读(2322) 评论(0) 推荐(0) 编辑
摘要: 若hive库中有数据存在,直接删除会报错。若想强制删除非空库使用cascade关键字:drop database tmp cascade; 阅读全文
posted @ 2019-01-03 16:03 xuejianbest 阅读(3775) 评论(0) 推荐(0) 编辑
摘要: 安装配置hadoop安装直接执行hadoop任务配置伪分布式模式:修改$HADOOP_HOME/etc/hadoop/core-site.xml修改$HADOOP_HOME/etc/hadoop/hdfs-site.xml格式化namenode启动hdfs检... 阅读全文
posted @ 2019-01-03 15:27 xuejianbest 阅读(204) 评论(0) 推荐(0) 编辑
摘要: setrep指定拷贝份数,如果是目录,要递归修改用-R参数:hadoop fs -setrep 1 \ /data/abc/text1.csv \ /data/abc/text2.csv \ /data/abc/text3.csv ... 阅读全文
posted @ 2019-01-03 15:27 xuejianbest 阅读(271) 评论(0) 推荐(0) 编辑
摘要: hdfs上的文件的最小存储单位是块(block),一个块的大小可以指定,一般默认块的大小为64MB或128MB。文件块的数量影响了spark读取hdfs文件生成的RDD的partition数量。另外hdfs上文件是有多份拷贝的(具体几份可以配置)。若一个Da... 阅读全文
posted @ 2019-01-03 15:27 xuejianbest 阅读(1024) 评论(0) 推荐(0) 编辑
摘要: YARN(Yet Another Resource Negotiator)是hadoop2.0提供的新功能,它是一个集群资源调度管理的软件,其产生是为了更好的管理集群资源,突破hadoop1.0集群管理方式的缺陷。先看原来方式的缺陷hadoop最初采取的集群... 阅读全文
posted @ 2019-01-03 15:27 xuejianbest 阅读(586) 评论(0) 推荐(0) 编辑
摘要: spark读取hdfs上面的文件:var textIn = sc.textFile("hdfs://localhost:9000/user/root/text.in")保存文件到hdsf上:textIn.map((_, 2)).saveAsTextFile(... 阅读全文
posted @ 2019-01-03 15:27 xuejianbest 阅读(1632) 评论(0) 推荐(0) 编辑
摘要: 查看topicbin/kafka-topics.sh \--zookeeper emr-header-1:2181,emr-header-2:2181,emr-header-3:2181/kafka-1.0.1 \--list查看kafka的topic详细信... 阅读全文
posted @ 2019-01-03 14:49 xuejianbest 阅读(9059) 评论(0) 推荐(0) 编辑
摘要: 下载kafka_2.11-1.1.0.tgz,tar -zxf解压并进入解压目录,没有配置环境变量。kafka运行依赖zookeeper,启动zookeeper服务和kafka服务(默认单机模式,由配置文件决定):bin/zookeeper-server-s... 阅读全文
posted @ 2019-01-03 14:44 xuejianbest 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 使用事务可以让一系列操作要不全部成功执行,要么全部不执行:db.beginTransaction(); //开启事务try{ db.execSQL("delete from book where id=?", new String[]{"3"}); ... 阅读全文
posted @ 2019-01-03 14:07 xuejianbest 阅读(363) 评论(0) 推荐(0) 编辑
摘要: 数据库SQLitepublic class MySQLite extends SQLiteOpenHelper { private final String create_book = "create table book " + "(id integ... 阅读全文
posted @ 2019-01-03 14:06 xuejianbest 阅读(1466) 评论(0) 推荐(0) 编辑
摘要: 读写普通文本文件:public class MainActivity extends Activity { EditText edit; @Override protected void onCreate(Bundle savedInsta... 阅读全文
posted @ 2019-01-03 13:59 xuejianbest 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 接收器需要继承BroadcastReseiver类,收到相应广播会执行其onReceive方法:public class MyBroadcastReceiver extends BroadcastReceiver { @Override public voi... 阅读全文
posted @ 2019-01-03 13:55 xuejianbest 阅读(696) 评论(0) 推荐(0) 编辑
摘要: 使用LayoutInflater类的inflate函数,将第一个参数的布局加载到第二个参数的布局上。第一个参数是个int对应一个布局文件,第二个参数是个View对象实例。getMenuInflater().inflate(R.menu.main, layou... 阅读全文
posted @ 2019-01-03 13:50 xuejianbest 阅读(2153) 评论(0) 推荐(0) 编辑
摘要: Activity:一个Activity为一个界面,对应一个继承android.app.Activity的子类。为了显示,可以加载一个layout.xml文件: Activity类:import android.app.Activity;i... 阅读全文
posted @ 2019-01-03 13:46 xuejianbest 阅读(143) 评论(0) 推荐(0) 编辑