一.导入依赖

创建模块,导入以下依赖,maven默认编译版本是1.5,用1.8编译。

pom.xml

    <dependencies>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-client</artifactId>
<version>2.0.5</version>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-server</artifactId>
<version>2.0.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>

二.HBase工具类

package com.bigdata.hbasedemo;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.*;
import org.apache.hadoop.hbase.filter.*;
import org.apache.hadoop.hbase.util.Bytes; import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map; /**
* @description: TODO HBase操作工具类
* @author: HaoWu
* @create: 2020/7/15 22:51
*/
public class HBaseUtils {
private static Admin admin = null;
private static Configuration configuration = null;
private static Connection connection = null; /**
* 私有构造方法
*/
private HBaseUtils() {
//创建配置信息并配置
configuration = HBaseConfiguration.create();
configuration.set("hbase.zookeeper.quorum", "hadoop102:2181,hadoop103:2181,hadoop104:2181");
configuration.set("hbase.rootdir", "hdfs:hadoop102:8020/hbase");
try {
//获取HBase连接对象
connection = ConnectionFactory.createConnection(configuration);
//获取Admin对象
admin = connection.getAdmin();
} catch (IOException e) {
e.printStackTrace();
}
} /**
* 私有成员变量,单例模式
*/
private static HBaseUtils instance = null; public static synchronized HBaseUtils getInstance() {
if (null == instance) {
instance = new HBaseUtils();
}
return instance;
} /**
* 关闭连接
*/
public static void close() {
try {
if (admin != null) {
admin.close();
}
if (connection != null) {
connection.close();
}
} catch (IOException e) {
e.printStackTrace();
}
} /**
* 根据表名获取Table实例
*
* @param tableName
* @return
*/
public static Table getTable(String nameSpace, String tableName) {
Table table = null;
try {
table = connection.getTable(TableName.valueOf(nameSpace, tableName));
} catch (IOException e) {
e.printStackTrace();
}
return table;
} /**
* 创建表
*
* @param nameSpace:命名空间
* @param tableName:表名
* @param splitsKey:预分区
* @param columnFamilies:可变列簇,可设置多个
* @return
*/
public static void createTable(String nameSpace, String tableName, byte[][] splitsKey, String... columnFamilies) {
//获取TableName对象
TableName name = TableName.valueOf(nameSpace, tableName);
try {
//判断表是否存在,存在就删除
if (admin.tableExists(name)) {
admin.disableTable(name);
admin.deleteTable(name);
}
//列簇集合描述
ArrayList<ColumnFamilyDescriptor> columnFamilyDescriptors = new ArrayList<>();
for (String columnFamily : columnFamilies) {
ColumnFamilyDescriptor columnFamilyDescriptor = ColumnFamilyDescriptorBuilder.newBuilder(columnFamily.getBytes()).build();
columnFamilyDescriptors.add(columnFamilyDescriptor);
}
//设置列簇,获取表描述器
TableDescriptor build = TableDescriptorBuilder.newBuilder(name).setColumnFamilies(columnFamilyDescriptors).build();
admin.createTable(build, splitsKey);
} catch (IOException e) {
e.printStackTrace();
}
} /**
* 修改表结构:删除列簇1,修改列簇2的VERSION为3,新增一个列簇3
*
* @param nameSpace
* @param tableName
* @param columnFamfily1
* @param columnFamfily2
* @param columnFamfily3 TODO 异常处理没做好,图方便,建议自己每个操作单独写方法进行异常处理
*/
public static void alterTable(String nameSpace, String tableName, String columnFamfily1, String columnFamfily2, String columnFamfily3) {
TableName name = TableName.valueOf(nameSpace, tableName);
try {
if (admin.tableExists(name)) {
//1.删除列簇1
admin.deleteColumnFamily(name, Bytes.toBytes(columnFamfily1));
//2.修改列簇2
ColumnFamilyDescriptor build2 = ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes(columnFamfily2)).setMinVersions(4).setMaxVersions(4).build();
admin.modifyColumnFamily(name, build2);
//3.增加列簇3
ColumnFamilyDescriptor build3 = ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes(columnFamfily3)).build();
admin.addColumnFamily(name, build3);
}
} catch (IOException e) {
e.printStackTrace();
}
} /**
* 删除表
*
* @param nameSpace
* @param tableName
*/
public static void deleteTable(String nameSpace, String tableName) {
TableName name = TableName.valueOf(nameSpace, tableName);
try {
//1.禁用表
admin.disableTable(name);
//2.删除表
admin.deleteTable(name);
} catch (IOException e) {
e.printStackTrace();
} } /**
* 插入一条数据,值为String-单行单列簇单列
*
* @param tableName:表名
* @param timeStamp:时间戳
* @param rowKey:RowKey
* @param columnFamily:列簇名
* @param column:列限定符
* @param value:String类型值
*/
public static void putStringValue(String nameSpace, String tableName, long timeStamp, String rowKey, String columnFamily, String column, String value) {
//1.获取表操作对象
Table table = getTable(nameSpace, tableName);
//2.封装Put对象,包括rowKey,timeStamp,列簇,列,列值
Put put = new Put(Bytes.toBytes(rowKey), timeStamp);
put.addColumn(Bytes.toBytes(columnFamily), Bytes.toBytes(column), Bytes.toBytes(value));
try {
table.put(put);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (table != null) {
try {
table.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
} /**
* 插入一条数据,值为int-单行单列簇单列
*
* @param tableName:表名
* @param timeStamp:时间戳
* @param rowKey:RowKey
* @param columnFamily:列簇名
* @param column:列限定符
* @param value:int类型值
*/
public static void putintValue(String nameSpace, String tableName, long timeStamp, String rowKey, String columnFamily, String column, int value) {
//1.获取表操作对象
Table table = getTable(nameSpace, tableName);
//2.封装Put对象,包括rowKey,timeStamp,列簇,列,列值
Put put = new Put(Bytes.toBytes(rowKey), timeStamp);
put.addColumn(Bytes.toBytes(columnFamily), Bytes.toBytes(column), Bytes.toBytes(value));
try {
table.put(put);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (table != null) {
try {
table.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
} /**
* 插入多行,多列,单列簇
*
* @param nameSpace
* @param tableName
* @param columnFamily
* @param mapList:将一个Cell数据封装成一个map<String,String>,所有的值类型要求为String。 mapList数据格式:{{ column=name, rowkey=1001, value=lisi},{ column=age, rowkey=1001, value=20},{ column=address, rowkey=1001, value="BeiJing"}...}
*/
public static void putMultipleRowMultipleColumnOneFamily(String nameSpace, String tableName, String columnFamily, List<Map<String, String>> mapList) {
//1.获取表操作对象
Table table = getTable(nameSpace, tableName);
//2.创建List<Put>对象
List<Put> puts = new ArrayList<>();
for (Map<String, String> map : mapList) {
//3.将每个map数据封装成一个Put对象
Put put = new Put(Bytes.toBytes(map.get("rowkey")));
put.addColumn(Bytes.toBytes(columnFamily), Bytes.toBytes(map.get("column")), Bytes.toBytes(map.get("value")));
puts.add(put);
}
try {
//4.执行put操作
table.put(puts);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (table != null) {
try {
table.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
} /**
* 插入单行,多列,单列簇
*
* @param nameSpace
* @param tableName
* @param columnFamily
* @param mapList:将一个Cell数据封装成一个map<String,String>,所有的值类型要求为String。 mapList数据格式:{{ column=name, rowkey=1001, value=lisi},{ column=age, rowkey=1001, value=20},{ column=address, rowkey=1001, value="BeiJing"}...}
*/
public static void putOneRowMultipleColumnOneFamily(String nameSpace, String tableName, String rowKey, String columnFamily, List<Map<String, String>> mapList) {
Table table = getTable(nameSpace, tableName);
List<Put> puts = new ArrayList<>();
for (Map<String, String> map : mapList) {
Put put = new Put(Bytes.toBytes(rowKey));
put.addColumn(Bytes.toBytes(columnFamily), Bytes.toBytes(map.get("column")), Bytes.toBytes(map.get("value")));
puts.add(put);
}
try {
table.put(puts);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (table != null) {
try {
table.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
} /**
*修改数据和新增数据一致
*/ /**
* 删除单行单列簇单列数据
*
* @param nameSpace
* @param tableName
* @param family
* @param column
* @param rowkey
*/
public static void deleteOneRowOneCloumn(String nameSpace, String tableName, String family, String column, String rowkey) {
Table table = getTable(nameSpace, tableName);
Delete delete = new Delete(Bytes.toBytes(rowkey));
delete.addColumn(Bytes.toBytes(family), Bytes.toBytes(column));
try {
table.delete(delete);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (table != null)
try {
table.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} /**
* 查询单行单列簇-可变列
* @param nameSpace
* @param tableName
* @param family
* @param columns
* @param rowkey
*/
public static void get(String nameSpace, String tableName, String family, String rowkey,String... columns) {
//1.创建table对象
Table table = getTable(nameSpace, tableName);
//2.创建Get对象
Get get = new Get(Bytes.toBytes(rowkey));
//3.添加列描述
for (String column : columns) {
get.addColumn(Bytes.toBytes(family), Bytes.toBytes(column));
}
try {
//4.执行查询获取结果
Result result = table.get(get);
//5.获取Cell集合,然后遍历打印
List<Cell> cells = result.listCells();
for (Cell cell : cells) {
//列簇
System.out.println(Bytes.toString(cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength()));
//列
System.out.println(Bytes.toString(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()));
//值
if ("age".equals(Bytes.toString(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()))) {
//值为int类型
System.out.println(Bytes.toInt(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()));
}else {
//值为String类型
System.out.println(Bytes.toInt(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()));}
System.out.println("***************************************************************************");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (table != null)
try {
table.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} /**
* Scan 扫描表-单列簇
* @param nameSpace
* @param tableName
* @param family
*/
public static void scanTable(String nameSpace, String tableName,String family){
//1.创建table对象
Table table = getTable(nameSpace, tableName);
//2.创建Scan对象
Scan scan = new Scan();
//3.指定列簇
scan.addFamily(Bytes.toBytes(family));
try {
//是否结果缓存
scan.setCacheBlocks(false);
//4.执行扫描,遍历结果
ResultScanner resultScanners = table.getScanner(scan);
Iterator<Result> iterator = resultScanners.iterator();
while (iterator.hasNext()){
Result result = iterator.next();
List<Cell> cells = result.listCells();
for (Cell cell : cells) {
//RowKey
System.out.print(Bytes.toString(cell.getRowArray(),cell.getRowOffset(),cell.getRowLength())+":");
//列
System.out.print(Bytes.toString(cell.getQualifierArray(),cell.getQualifierOffset(),cell.getQualifierLength())+":");
//值
if("age".equals(Bytes.toString(cell.getQualifierArray(),cell.getQualifierOffset(),cell.getQualifierLength()))){
//值为int类型
System.out.print(Bytes.toInt(cell.getValueArray(),cell.getValueOffset(),cell.getValueLength())+":"); }else {
//值为String类型
System.out.print(Bytes.toString(cell.getValueArray(),cell.getValueOffset(),cell.getValueLength())+":");
}
System.out.println("***************************************************************************");
}
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (table != null)
try {
table.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} /**
* 获取单值比较器:针对单列族单列进行String值过滤{小于|小于等于|等于|不等于|大于等于|大于}
* @param family 列簇
* @param column 列名
* @param op 枚举类{LESS|LESS_OR_EQUAL|EQUAL|NOT_EQUAL|GREATER_OR_EQUAL|GREATER}
* {小于|小于等于|等于|不等于|大于等于|大于}
* @param value 值
* @return
*/
public static SingleColumnValueFilter getStringSingleColumnValueFilter(String family,String column,CompareOperator op,String value){
return new SingleColumnValueFilter(Bytes.toBytes(family), Bytes.toBytes(column), op, Bytes.toBytes(value));
} /**
* 获取单值比较器:针对单列族单列进行int值过滤{小于|小于等于|等于|不等于|大于等于|大于}
* @param family 列簇
* @param column 列名
* @param op 枚举类{LESS|LESS_OR_EQUAL|EQUAL|NOT_EQUAL|GREATER_OR_EQUAL|GREATER}
* {小于|小于等于|等于|不等于|大于等于|大于}
* @param value 值
* @return
*/
public static SingleColumnValueFilter getIntSingleColumnValueFilter(String family,String column,CompareOperator op,int value){
return new SingleColumnValueFilter(Bytes.toBytes(family), Bytes.toBytes(column), op, Bytes.toBytes(value));
} /**
* 列簇过滤器
* @param family
*/
public static FamilyFilter getFamilyFilter(String family){
return new FamilyFilter(CompareOperator.EQUAL, new BinaryComparator(Bytes.toBytes(family)));
} /**
*列过滤器
* @param column
* @return
*/
public static QualifierFilter getQualifierFilter(String column){
return new QualifierFilter(CompareOperator.EQUAL,new BinaryComparator(Bytes.toBytes(column)));
} /**
* 针对全表的值:过滤出包含值包含"value"的行
* 在 where name like %value% 结合列簇->列->值过滤达到效果
* @param value
* @return
*/
public static ValueFilter getValueFilter(String value){
return new ValueFilter(CompareOperator.EQUAL, new SubstringComparator(value));
} /**
* 获取过滤器链:必须全满足 filter1 and filter2 and filter3
* @param filters
* @return
*/
public static FilterList getFilterListALL(Filter... filters){
FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ALL);
for (Filter filter : filters) {
filterList.addFilter(filter);
}
return filterList;
} /**
* 获取过滤器链:最少有一个满足 filter1 or filter2 or filter3
* @param filters
* @return
*/
public static FilterList getFilterListOne(Filter... filters){
FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ONE);
for (Filter filter : filters) {
filterList.addFilter(filter);
}
return filterList;
} }

三.测试类

package com.bigdata.hbasedemo;

import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.filter.FilterList;
import org.apache.hadoop.hbase.filter.SingleColumnValueFilter;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.Test; import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; /**
* @description: HBaseUtils工具测试类
* @author: HaoWu
* @create: 2020/7/16 8:16
*/
public class HBaseUtilsTest {
//获取工具类对象
HBaseUtils hBaseUtils = HBaseUtils.getInstance();
/**
* 测试创建表
*/
@Test
public void createTable() {
String nameSpace = "bigdata";
String tableName = "user6";
byte[][] splitsKey = new byte[][]{
Bytes.toBytes("10"),
Bytes.toBytes("20"),
Bytes.toBytes("30"),
Bytes.toBytes("40")};
String columnFamily1 = "info1";
String columnFamily2 = "info2";
hBaseUtils.createTable(nameSpace, tableName, splitsKey, columnFamily1, columnFamily2);
} /**
* 测试修改表
*/
@Test
public void alterTable() {
hBaseUtils.alterTable("bigdata", "user", "info1", "info2", "info3");
} /**
* 删除表
*/
@Test
public void deleteTable(){
hBaseUtils.deleteTable("bigdata","user5");
}
/**
* 插入一条数据,值为String类型
*/
@Test
public void putStringValue() {
hBaseUtils.putStringValue("bigdata", "user", 1221312312352L, "1004", "info2", "name", "lisi");
} /**
* 插入一条数据,值为int类型
*/
@Test
public void putintValue() {
hBaseUtils.putintValue("bigdata", "user", 1221312312321L, "1004", "info2", "age", 25);
} /**
* 插入多行,多列,多值,单列簇
*/
@Test
public void putMultipleRowMultipleColumnOneFamily() {
//数据格式:{{ "column"="name", "rowkey"="1001", "value"="lisi"},{ "column"="address", "rowkey"="1001", "value"="BeiJing"}}
List<Map<String, String>> mapList = new ArrayList<>();
ConcurrentHashMap<String, String> map1 = new ConcurrentHashMap<>();
map1.put("column","name");
map1.put("rowkey","1003");
map1.put("value","lisi1");
System.out.println(map1);
ConcurrentHashMap<String, String> map2 = new ConcurrentHashMap<>();
map2.put("column","address");
map2.put("rowkey","1003");
map2.put("value","BeiJing");
ConcurrentHashMap<String, String> map3 = new ConcurrentHashMap<>();
map3.put("column","name");
map3.put("rowkey","1004");
map3.put("value","wangwu1");
mapList.add(map1);
mapList.add(map2);
mapList.add(map3);
System.out.println(mapList.toString());
hBaseUtils.putMultipleRowMultipleColumnOneFamily("bigdata", "user", "info2", mapList);
} /**
* 删除单行单列簇单列
*/
@Test
public void deleteOnerowOneColumn(){
hBaseUtils.deleteOneRowOneCloumn("bigdata","user","info2","address","1001");
} /**
* 查询单行单列簇-可变列
*/
@Test
public void get(){
hBaseUtils.get("bigdata","user","info2","1001","age","name");
} /**
* scan 扫描表-单列簇
*/
@Test
public void scanTable(){
hBaseUtils.scanTable("bigdata","user","info2");
} /**
* 根据条件过滤:where name="wangwu" or(name="lisi" and age>30)
*
*/
@Test
public void testFilter1() throws IOException {
Table table = hBaseUtils.getTable("bigdata", "user");
Scan scan = new Scan();
//name="lisi"
SingleColumnValueFilter filter1 = hBaseUtils.getStringSingleColumnValueFilter("info2", "name", CompareOperator.EQUAL, "lisi");
//age>30
SingleColumnValueFilter filter2 = hBaseUtils.getIntSingleColumnValueFilter("info2", "age", CompareOperator.GREATER,30);
//name="lisi" and age>30
FilterList filterList = hBaseUtils.getFilterListALL(filter1, filter2);
//name="wangwu"
SingleColumnValueFilter filter3 = hBaseUtils.getStringSingleColumnValueFilter("info2", "name", CompareOperator.EQUAL, "wangwu");
//name="wangwu" or(name="lisi" and age>30)
FilterList filters = new FilterList(FilterList.Operator.MUST_PASS_ONE);
filters.addFilter(filter3);
filters.addFilter(filterList);
//设置过滤器
scan.setFilter(filters);
ResultScanner scanner = table.getScanner(scan);
Iterator<Result> iterator = scanner.iterator();
while (iterator.hasNext()){
Result result = iterator.next();
List<Cell> cells = result.listCells();
for (Cell cell : cells) {
//RowKey
System.out.print(Bytes.toString(cell.getRowArray(),cell.getRowOffset(),cell.getRowLength())+":");
//列
System.out.print(Bytes.toString(cell.getQualifierArray(),cell.getQualifierOffset(),cell.getQualifierLength())+":");
//值
if("age".equals(Bytes.toString(cell.getQualifierArray(),cell.getQualifierOffset(),cell.getQualifierLength()))){
//值为int类型
System.out.print(Bytes.toInt(cell.getValueArray(),cell.getValueOffset(),cell.getValueLength())+":"); }else {
//值为String类型
System.out.print(Bytes.toString(cell.getValueArray(),cell.getValueOffset(),cell.getValueLength())+":");
}
System.out.println("***************************************************************************");
}
}
} /**
* 关闭admin, connection
*/
@Test
public void close(){
hBaseUtils.close();
} }

HBase【操作Java api】的更多相关文章

  1. Hbase框架原理及相关的知识点理解、Hbase访问MapReduce、Hbase访问Java API、Hbase shell及Hbase性能优化总结

    转自:http://blog.csdn.net/zhongwen7710/article/details/39577431 本blog的内容包含: 第一部分:Hbase框架原理理解 第二部分:Hbas ...

  2. 5 hbase-shell + hbase的java api

    本博文的主要内容有 .HBase的单机模式(1节点)安装 .HBase的单机模式(1节点)的启动 .HBase的伪分布模式(1节点)安装  .HBase的伪分布模式(1节点)的启动    .HBase ...

  3. HBase的Java Api连接失败的问题及解决方法

    分布式方式部署的HBase,启动正常,Shell操作正常,使用HBase的Java Api操作时总是连接失败,信息如下: This server is in the failed servers li ...

  4. hbase-shell + hbase的java api

    本博文的主要内容有 .HBase的单机模式(1节点)安装 .HBase的单机模式(1节点)的启动 .HBase的伪分布模式(1节点)安装   .HBase的伪分布模式(1节点)的启动    .HBas ...

  5. linux 下通过过 hbase 的Java api 操作hbase

    hbase版本:0.98.5 hadoop版本:1.2.1 使用自带的zk 本文的内容是在集群中创建java项目调用api来操作hbase,主要涉及对hbase的创建表格,删除表格,插入数据,删除数据 ...

  6. HBase Client JAVA API

    旧 的 HBase 接口逻辑与传统 JDBC 方式很不相同,新的接口与传统 JDBC 的逻辑更加相像,具有更加清晰的 Connection 管理方式. 同时,在旧的接口中,客户端何时将 Put 写到服 ...

  7. Hbase之Java API远程访问Kerberos认证

    HbaseConnKer.java package BigData.conn; import BigData.utils.resource.ResourcesUtils; import org.apa ...

  8. Hbase/Hadoop Java API编程常用语句

    从scanner获取rowkey: for(Result rr : scanner){ String key =Bytes.toString(rr.getRow())} HBase API - Res ...

  9. Hbase之JAVA API不能远程访问问题解决

    1.配置Linux的hostname2.配置Linux的hosts,映射ip的hostname的关系3.配置访问windows的hosts 参考文档:http://blog.csdn.net/ty49 ...

随机推荐

  1. Linux安装部署Zabbix

    Zabbix 是一个企业级的分布式开源监控方案,能够监控各种网络参数以及服务器健康性和完整性的软件.Zabbix使用灵活的通知机制,允许用户为几乎任何事件配置基于邮件的告警.这样可以快速反馈服务器的问 ...

  2. Flink 的运行架构详细剖析

    1. Flink 程序结构 Flink 程序的基本构建块是流和转换(请注意,Flink 的 DataSet API 中使用的 DataSet 也是内部流 ).从概念上讲,流是(可能永无止境的)数据记录 ...

  3. linux初中级命令语言

    Linux:开源免费.大部分软件都可以自由获取,同样功能的软件选择较少.主要是字符模式,命令行界面且发行版本较多,难以集中攻击. Xshell与xftp是什么? xshell是一个客户端软件,我们本地 ...

  4. Kali-Linux 2020如何设置中文

    话不多说,直接上步骤 首先,想要修改系统默认语言普通用户是办不到的,这个时候就需要切换为root用户在终端输入 sudo su(切换用户指令,后面不加用户名就默认切换为root) 输入管理员密码后就像 ...

  5. 深入理解Spring IOC容器

    本文将从纯xml模式.xml和注解结合.纯注解的方式讲解Spring IOC容器的配置和相关应用. 纯XML模式 实例化Bean的三种方式: 使用无参构造函数 默认情况下,会使用反射调用无参构造函数来 ...

  6. Alpine容器安装运行ssh

    写在前面 本文介绍了在Alpine容器(docker)上安装运行ssh并保证外界(宿主机)能通过ssh登录的方法,给出了相应的命令.在下在探索过程中借鉴了许多前人的经验,在此先行谢过,所有参考内容都会 ...

  7. [hdu5901]Count primes

    最简单的是利用Min25筛求$h(n)$的过程,即 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define N 1000005 ...

  8. docker创建mongodb并且测试代码

    mongodb docker 安装mongodb-创建用户  docker run -itd --name mongo -p 27017:27017 mongo --auth 进入数据库添加密码   ...

  9. pechkin 导出https路径的图片

    使用Pechkin.Synchronized可以方便导出html为pdf,但是对于https路径的图片并不支持,仅支持http路径下的图片 解决方案:图片使用本地绝对路径(相对于服务器) 以下是我获取 ...

  10. CF1601E Phys Ed Online

    考虑一个贪心. 我们一定采取的方案是 \(b_i = \min_{j = i - k}^i a_j\) \(\sum a_l + b_{l + k} + \min_{i = 1}^2{b_{l + i ...