当前位置: 首页 > news >正文

头歌:共享单车之数据分析

第1关 统计共享单车每天的平均使用时间

package com.educoder.bigData.sharedbicycle;import java.io.IOException;
import java.text.ParseException;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Scanner;
import java.math.RoundingMode;
import java.math.BigDecimal;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.FastDateFormat;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil;
import org.apache.hadoop.hbase.mapreduce.TableMapper;
import org.apache.hadoop.hbase.mapreduce.TableReducer;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.util.Tool;import com.educoder.bigData.util.HBaseUtil;/*** 统计共享单车每天的平均使用时间*/
public class AveragetTimeMapReduce extends Configured implements Tool {public static final byte[] family = "info".getBytes();public static class MyMapper extends TableMapper<Text, BytesWritable> {protected void map(ImmutableBytesWritable rowKey, Result result, Context context)throws IOException, InterruptedException {/********** Begin *********/long beginTime = Long.parseLong(Bytes.toString(result.getValue(family, "beginTime".getBytes())));long endTime = Long.parseLong(Bytes.toString(result.getValue(family, "endTime".getBytes())));String format = DateFormatUtils.format(beginTime, "yyyy-MM-dd", Locale.CHINA);long useTime = endTime - beginTime;BytesWritable bytesWritable = new BytesWritable(Bytes.toBytes(format + "_" + useTime));context.write(new Text("avgTime"), bytesWritable);		 /********** End *********/}}public static class MyTableReducer extends TableReducer<Text, BytesWritable, ImmutableBytesWritable> {@Overridepublic void reduce(Text key, Iterable<BytesWritable> values, Context context)throws IOException, InterruptedException {/********** Begin *********/double sum = 0;int length = 0;Map<String, Long> map = new HashMap<String, Long>();for (BytesWritable price : values) {byte[] copyBytes = price.copyBytes();String string = Bytes.toString(copyBytes);String[] split = string.split("_");if (map.containsKey(split[0])) {Long integer = map.get(split[0]) + Long.parseLong(split[1]);map.put(split[0], integer);} else {map.put(split[0], Long.parseLong(split[1]));}}Collection<Long> values2 = map.values();for (Long i : values2) {length++;sum += i;}BigDecimal decimal = new BigDecimal(sum / length /1000);BigDecimal setScale = decimal.setScale(2, RoundingMode.HALF_DOWN);Put put = new Put(Bytes.toBytes(key.toString()));put.addColumn(family, "avgTime".getBytes(), Bytes.toBytes(setScale.toString()));context.write(null, put);	 /********** End *********/}}public int run(String[] args) throws Exception {// 配置JobConfiguration conf = HBaseUtil.conf;// Scanner sc = new Scanner(System.in);// String arg1 = sc.next();// String arg2 = sc.next();String arg1 = "t_shared_bicycle";String arg2 = "t_bicycle_avgtime";try {HBaseUtil.createTable(arg2, new String[] { "info" });} catch (Exception e) {// 创建表失败e.printStackTrace();}Job job = configureJob(conf, new String[] { arg1, arg2 });return job.waitForCompletion(true) ? 0 : 1;}private Job configureJob(Configuration conf, String[] args) throws IOException {String tablename = args[0];String targetTable = args[1];Job job = new Job(conf, tablename);Scan scan = new Scan();scan.setCaching(300);scan.setCacheBlocks(false);// 在mapreduce程序中千万不要设置允许缓存// 初始化Mapreduce程序TableMapReduceUtil.initTableMapperJob(tablename, scan, MyMapper.class, Text.class, BytesWritable.class, job);// 初始化ReduceTableMapReduceUtil.initTableReducerJob(targetTable, // output tableMyTableReducer.class, // reducer classjob);job.setNumReduceTasks(1);return job;}
}

第2关 统计共享单车在指定地点的每天平均次数 

package com.educoder.bigData.sharedbicycle;import java.io.IOException;import java.math.BigDecimal;import java.math.RoundingMode;import java.util.ArrayList;import java.util.Collection;import java.util.HashMap;import java.util.Locale;import java.util.Map;import java.util.Scanner;import org.apache.commons.lang3.time.DateFormatUtils;import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.conf.Configured;import org.apache.hadoop.hbase.CompareOperator;import org.apache.hadoop.hbase.client.Put;import org.apache.hadoop.hbase.client.Result;import org.apache.hadoop.hbase.client.Scan;import org.apache.hadoop.hbase.filter.BinaryComparator;import org.apache.hadoop.hbase.filter.Filter;import org.apache.hadoop.hbase.filter.FilterList;import org.apache.hadoop.hbase.filter.SingleColumnValueFilter;import org.apache.hadoop.hbase.filter.SubstringComparator;import org.apache.hadoop.hbase.io.ImmutableBytesWritable;import org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil;import org.apache.hadoop.hbase.mapreduce.TableMapper;import org.apache.hadoop.hbase.mapreduce.TableReducer;import org.apache.hadoop.hbase.util.Bytes;import org.apache.hadoop.io.BytesWritable;import org.apache.hadoop.io.DoubleWritable;import org.apache.hadoop.io.Text;import org.apache.hadoop.mapreduce.Job;import org.apache.hadoop.util.Tool;import com.educoder.bigData.util.HBaseUtil;/*** 共享单车每天在韩庄村的平均空闲时间*/public class AverageVehicleMapReduce extends Configured implements Tool {public static final byte[] family = "info".getBytes();public static class MyMapper extends TableMapper<Text, BytesWritable> {protected void map(ImmutableBytesWritable rowKey, Result result, Context context)throws IOException, InterruptedException {/********** Begin *********/String beginTime = Bytes.toString(result.getValue(family, "beginTime".getBytes()));String format = DateFormatUtils.format(Long.parseLong(beginTime), "yyyy-MM-dd", Locale.CHINA);BytesWritable bytesWritable = new BytesWritable(Bytes.toBytes(format));context.write(new Text("河北省保定市雄县-韩庄村"), bytesWritable);/********** End *********/}}public static class MyTableReducer extends TableReducer<Text, BytesWritable, ImmutableBytesWritable> {@Overridepublic void reduce(Text key, Iterable<BytesWritable> values, Context context)throws IOException, InterruptedException {/********** Begin *********/double sum = 0;int length = 0;Map<String, Integer> map = new HashMap<String, Integer>();for (BytesWritable price : values) {byte[] copyBytes = price.copyBytes();String string = Bytes.toString(copyBytes);if (map.containsKey(string)) {Integer integer = map.get(string) + 1;map.put(string, integer);} else {map.put(string, new Integer(1));}}Collection<Integer> values2 = map.values();for (Integer i : values2) {length++;sum += i;}BigDecimal decimal = new BigDecimal(sum / length);BigDecimal setScale = decimal.setScale(2, RoundingMode. HALF_DOWN);Put put = new Put(Bytes.toBytes(key.toString()));put.addColumn(family, "avgNum".getBytes(), Bytes.toBytes(setScale.toString()));context.write(null, put);/********** End *********/}}public int run(String[] args) throws Exception {// 配置JobConfiguration conf = HBaseUtil.conf;//Scanner sc = new Scanner(System.in);//String arg1 = sc.next();//String arg2 = sc.next();String arg1 = "t_shared_bicycle";String arg2 = "t_bicycle_avgnum";try {HBaseUtil.createTable(arg2, new String[] { "info" });} catch (Exception e) {// 创建表失败e.printStackTrace();}Job job = configureJob(conf, new String[] { arg1, arg2 });return job.waitForCompletion(true) ? 0 : 1;}private Job configureJob(Configuration conf, String[] args) throws IOException {String tablename = args[0];String targetTable = args[1];Job job = new Job(conf, tablename);Scan scan = new Scan();scan.setCaching(300);scan.setCacheBlocks(false);// 在mapreduce程序中千万不要设置允许缓存/********** Begin *********///设置过滤ArrayList<Filter> listForFilters = new ArrayList<Filter>();Filter destinationFilter =new SingleColumnValueFilter(Bytes.toBytes("info"), Bytes.toBytes("destination"),CompareOperator.EQUAL, new SubstringComparator("韩庄村"));Filter departure = new SingleColumnValueFilter(Bytes.toBytes("info"), Bytes.toBytes("departure"),CompareOperator.EQUAL, Bytes.toBytes("河北省保定市雄县"));listForFilters.add(departure);listForFilters.add(destinationFilter);scan.setCaching(300);scan.setCacheBlocks(false);Filter filters = new FilterList(listForFilters);scan.setFilter(filters);/********** End *********/// 初始化Mapreduce程序TableMapReduceUtil.initTableMapperJob(tablename, scan, MyMapper.class, Text.class, BytesWritable.class, job);// 初始化ReduceTableMapReduceUtil.initTableReducerJob(targetTable, // output tableMyTableReducer.class, // reducer classjob);job.setNumReduceTasks(1);return job;}}

第3关 统计共享单车指定车辆每次使用的空闲平均时间 

package com.educoder.bigData.sharedbicycle;import java.io.IOException;import java.math.BigDecimal;import java.math.RoundingMode;import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.conf.Configured;import org.apache.hadoop.hbase.CompareOperator;import org.apache.hadoop.hbase.client.Put;import org.apache.hadoop.hbase.client.Result;import org.apache.hadoop.hbase.client.Scan;import org.apache.hadoop.hbase.filter.Filter;import org.apache.hadoop.hbase.filter.SingleColumnValueFilter;import org.apache.hadoop.hbase.io.ImmutableBytesWritable;import org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil;import org.apache.hadoop.hbase.mapreduce.TableMapper;import org.apache.hadoop.hbase.mapreduce.TableReducer;import org.apache.hadoop.hbase.util.Bytes;import org.apache.hadoop.io.BytesWritable;import org.apache.hadoop.io.Text;import org.apache.hadoop.mapreduce.Job;import org.apache.hadoop.util.Tool;import com.educoder.bigData.util.HBaseUtil;/*** * 统计5996共享单车每次使用的空闲平均时间*/public class FreeTimeMapReduce extends Configured implements Tool {public static final byte[] family = "info".getBytes();public static class MyMapper extends TableMapper<Text, BytesWritable> {protected void map(ImmutableBytesWritable rowKey, Result result, Context context)throws IOException, InterruptedException {/********** Begin *********/long beginTime = Long.parseLong(Bytes.toString(result.getValue(family, "beginTime".getBytes())));long endTime = Long.parseLong(Bytes.toString(result.getValue(family, "endTime".getBytes())));BytesWritable bytesWritable = new BytesWritable(Bytes.toBytes(beginTime + "_" + endTime));context.write(new Text("5996"), bytesWritable);      /********** End *********/}}public static class MyTableReducer extends TableReducer<Text, BytesWritable, ImmutableBytesWritable> {@Overridepublic void reduce(Text key, Iterable<BytesWritable> values, Context context)throws IOException, InterruptedException {/********** Begin *********/long freeTime = 0;long beginTime = 0;int length = 0;for (BytesWritable time : values) {byte[] copyBytes = time.copyBytes();String timeLong = Bytes.toString(copyBytes);String[] split = timeLong.split("_");if(beginTime == 0) {beginTime = Long.parseLong(split[0]);continue;}else {freeTime = freeTime + beginTime - Long.parseLong(split[1]);beginTime = Long.parseLong(split[0]);length ++;}}Put put = new Put(Bytes.toBytes(key.toString()));BigDecimal decimal = new BigDecimal(freeTime / length /1000 /60 /60);BigDecimal setScale = decimal.setScale(2, RoundingMode.HALF_DOWN);put.addColumn(family, "freeTime".getBytes(), Bytes.toBytes(setScale.toString()));context.write(null, put);/********** End *********/}}public int run(String[] args) throws Exception {// 配置JobConfiguration conf = HBaseUtil.conf;// Scanner sc = new Scanner(System.in);// String arg1 = sc.next();// String arg2 = sc.next();String arg1 = "t_shared_bicycle";String arg2 = "t_bicycle_freetime";try {HBaseUtil.createTable(arg2, new String[] { "info" });} catch (Exception e) {// 创建表失败e.printStackTrace();}Job job = configureJob(conf, new String[] { arg1, arg2 });return job.waitForCompletion(true) ? 0 : 1;}private Job configureJob(Configuration conf, String[] args) throws IOException {String tablename = args[0];String targetTable = args[1];Job job = new Job(conf, tablename);Scan scan = new Scan();scan.setCaching(300);scan.setCacheBlocks(false);// 在mapreduce程序中千万不要设置允许缓存/********** Begin *********///设置过滤条件Filter filter = new SingleColumnValueFilter(Bytes.toBytes("info"), Bytes.toBytes("bicycleId"), CompareOperator.EQUAL, Bytes.toBytes("5996"));scan.setFilter(filter); /********** End *********/// 初始化Mapreduce程序TableMapReduceUtil.initTableMapperJob(tablename, scan, MyMapper.class, Text.class, BytesWritable.class, job);// 初始化ReduceTableMapReduceUtil.initTableReducerJob(targetTable, // output tableMyTableReducer.class, // reducer classjob);job.setNumReduceTasks(1);return job;}}

第4关 统计指定时间共享单车使用次数

package com.educoder.bigData.sharedbicycle;import java.io.IOException;import java.util.ArrayList;import org.apache.commons.lang3.time.FastDateFormat;import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.conf.Configured;import org.apache.hadoop.hbase.CompareOperator;import org.apache.hadoop.hbase.client.Put;import org.apache.hadoop.hbase.client.Result;import org.apache.hadoop.hbase.client.Scan;import org.apache.hadoop.hbase.filter.Filter;import org.apache.hadoop.hbase.filter.FilterList;import org.apache.hadoop.hbase.filter.SingleColumnValueFilter;import org.apache.hadoop.hbase.io.ImmutableBytesWritable;import org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil;import org.apache.hadoop.hbase.mapreduce.TableMapper;import org.apache.hadoop.hbase.mapreduce.TableReducer;import org.apache.hadoop.hbase.util.Bytes;import org.apache.hadoop.io.IntWritable;import org.apache.hadoop.io.Text;import org.apache.hadoop.mapreduce.Job;import org.apache.hadoop.util.Tool;import com.educoder.bigData.util.HBaseUtil;/*** 共享单车使用次数统计*/public class UsageRateMapReduce extends Configured implements Tool {public static final byte[] family = "info".getBytes();public static class MyMapper extends TableMapper<Text, IntWritable> {protected void map(ImmutableBytesWritable rowKey, Result result, Context context)throws IOException, InterruptedException {/********** Begin *********/IntWritable doubleWritable = new IntWritable(1);context.write(new Text("departure"), doubleWritable);/********** End *********/}}public static class MyTableReducer extends TableReducer<Text, IntWritable, ImmutableBytesWritable> {@Overridepublic void reduce(Text key, Iterable<IntWritable> values, Context context)throws IOException, InterruptedException {/********** Begin *********/        int totalNum = 0;for (IntWritable num : values) {int d = num.get();totalNum += d;}Put put = new Put(Bytes.toBytes(key.toString()));put.addColumn(family, "usageRate".getBytes(), Bytes.toBytes(String.valueOf(totalNum)));context.write(null, put);/********** End *********/}}public int run(String[] args) throws Exception {// 配置JobConfiguration conf = HBaseUtil.conf;// Scanner sc = new Scanner(System.in);// String arg1 = sc.next();// String arg2 = sc.next();String arg1 = "t_shared_bicycle";String arg2 = "t_bicycle_usagerate";try {HBaseUtil.createTable(arg2, new String[] { "info" });} catch (Exception e) {// 创建表失败e.printStackTrace();}Job job = configureJob(conf, new String[] { arg1, arg2 });return job.waitForCompletion(true) ? 0 : 1;}private Job configureJob(Configuration conf, String[] args) throws IOException {String tablename = args[0];String targetTable = args[1];Job job = new Job(conf, tablename);ArrayList<Filter> listForFilters = new ArrayList<Filter>();FastDateFormat instance = FastDateFormat.getInstance("yyyy-MM-dd");Scan scan = new Scan();scan.setCaching(300);scan.setCacheBlocks(false);// 在mapreduce程序中千万不要设置允许缓存/********** Begin *********/try {Filter destinationFilter = new SingleColumnValueFilter(Bytes.toBytes("info"), Bytes.toBytes("beginTime"), CompareOperator.GREATER_OR_EQUAL, Bytes.toBytes(String.valueOf(instance.parse("2017-08-01").getTime())));Filter departure = new SingleColumnValueFilter(Bytes.toBytes("info"), Bytes.toBytes("endTime"), CompareOperator.LESS_OR_EQUAL, Bytes.toBytes(String.valueOf(instance.parse("2017-09-01").getTime())));listForFilters.add(departure);listForFilters.add(destinationFilter);}catch (Exception e) {e.printStackTrace();return null;}Filter filters = new FilterList(listForFilters);scan.setFilter(filters);/********** End *********/// 初始化Mapreduce程序TableMapReduceUtil.initTableMapperJob(tablename, scan, MyMapper.class, Text.class, IntWritable.class, job);// 初始化ReduceTableMapReduceUtil.initTableReducerJob(targetTable, // output tableMyTableReducer.class, // reducer classjob);job.setNumReduceTasks(1);return job;}}

 第5关 统计共享单车线路流量

package com.educoder.bigData.sharedbicycle;import java.io.IOException;import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil;
import org.apache.hadoop.hbase.mapreduce.TableMapper;
import org.apache.hadoop.hbase.mapreduce.TableReducer;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.util.Tool;import com.educoder.bigData.util.HBaseUtil;/*** 共享单车线路流量统计*/
public class LineTotalMapReduce extends Configured implements Tool {public static final byte[] family = "info".getBytes();public static class MyMapper extends TableMapper<Text, IntWritable> {protected void map(ImmutableBytesWritable rowKey, Result result, Context context)throws IOException, InterruptedException {/********** Begin *********/String start_latitude = Bytes.toString(result.getValue(family, "start_latitude".getBytes()));String start_longitude = Bytes.toString(result.getValue(family, "start_longitude".getBytes()));String stop_latitude = Bytes.toString(result.getValue(family, "stop_latitude".getBytes()));String stop_longitude = Bytes.toString(result.getValue(family, "stop_longitude".getBytes()));String departure = Bytes.toString(result.getValue(family, "departure".getBytes()));String destination = Bytes.toString(result.getValue(family, "destination".getBytes()));IntWritable doubleWritable = new IntWritable(1);context.write(new Text(start_latitude + "-" + start_longitude + "_" + stop_latitude + "-" + stop_longitude + "_" + departure + "-" + destination), doubleWritable);/********** End *********/}}public static class MyTableReducer extends TableReducer<Text, IntWritable, ImmutableBytesWritable> {@Overridepublic void reduce(Text key, Iterable<IntWritable> values, Context context)throws IOException, InterruptedException {/********** Begin *********/int totalNum = 0;for (IntWritable num : values) {int d = num.get();totalNum += d;}Put put = new Put(Bytes.toBytes(key.toString() + totalNum ));put.addColumn(family, "lineTotal".getBytes(), Bytes.toBytes(String.valueOf(totalNum)));context.write(null, put);/********** End *********/}}public int run(String[] args) throws Exception {// 配置JobConfiguration conf = HBaseUtil.conf;// Scanner sc = new Scanner(System.in);// String arg1 = sc.next();// String arg2 = sc.next();String arg1 = "t_shared_bicycle";String arg2 = "t_bicycle_linetotal";try {HBaseUtil.createTable(arg2, new String[] { "info" });} catch (Exception e) {// 创建表失败e.printStackTrace();}Job job = configureJob(conf, new String[] { arg1, arg2 });return job.waitForCompletion(true) ? 0 : 1;}private Job configureJob(Configuration conf, String[] args) throws IOException {String tablename = args[0];String targetTable = args[1];Job job = new Job(conf, tablename);Scan scan = new Scan();scan.setCaching(300);scan.setCacheBlocks(false);// 在mapreduce程序中千万不要设置允许缓存// 初始化Mapreduce程序TableMapReduceUtil.initTableMapperJob(tablename, scan, MyMapper.class, Text.class, IntWritable.class, job);// 初始化ReduceTableMapReduceUtil.initTableReducerJob(targetTable, // output tableMyTableReducer.class, // reducer classjob);job.setNumReduceTasks(1);return job;}
}

相关文章:

头歌:共享单车之数据分析

第1关 统计共享单车每天的平均使用时间 package com.educoder.bigData.sharedbicycle;import java.io.IOException; import java.text.ParseException; import java.util.Collection; import java.util.Date; import java.util.HashMap; import java.util.Locale; import java…...

MySQL的数据类型和细节

1.整型 数值类型字节描述TINYINT[UNSIGNED]1很小的整数&#xff0c;默认有符号 [-128,127]/[0,255]SMALLINT[UNSIGNED]2较小的整数&#xff0c;默认有符号 [-32768,32767]/[0,65535]MEDIUMINT[UNSIGNED]3中等的整数&#xff0c;默认有符号 [-8388608,8388607]/[0,16777215]…...

自建AWS S3存储服务

unsetunset前言unsetunset AWS S3&#xff08;Amazon S3&#xff0c;全名为亚马逊简易存储服务&#xff09;&#xff0c;是亚马逊公司利用其亚马逊网络服务系统所提供的网络在线存储服务。我常用的很多SaaS服务中提供的文件存储功能&#xff0c;底层也都是AWS S3&#xff0c;比…...

『论文阅读|研究用于视障人士户外障碍物检测的 YOLO 模型』

研究用于视障人士户外障碍物检测的 YOLO 模型 摘要1 引言2 相关工作2.1 障碍物检测的相关工作2.2 物体检测和其他基于CNN的模型 3 问题的提出4 方法4.1 YOLO4.2 YOLOv54.3 YOLOv64.4 YOLOv74.5 YOLOv84.6 YOLO-NAS 5 实验和结果5.1 数据集和预处理5.2 训练和实现细节5.3 性能指…...

LeetCode--1445. 苹果和桔子

文章目录 1 题目描述2 测试用例3 解题思路 1 题目描述 表: Sales ------------------------ | Column Name | Type | ------------------------ | sale_date | date | | fruit | enum | | sold_num | int | ------------------------(sale…...

Java基础知识

一、标识符规范 标识符必须以字母(汉字)、下划线、美元符号开头&#xff0c;其他部分可以是字母、下划线、美元符号&#xff0c;数字的任意组合。谨记不能以数字开头。java使用unicode字符集&#xff0c;汉字也可以用该字符集表示。因此汉字也可以用作变量名。 关键字不能用作…...

并发编程-Synchronized

什么是Synchronized synchronized是Java提供的一个关键字&#xff0c;Synchronized可以保证并发程序的原子性&#xff0c;可见性&#xff0c;有序性。 我们会把synchronized称为重量级锁。主要原因&#xff0c;是因为JDK1.6之前&#xff0c;synchronized是一个重量级锁相比于J…...

C语言——从头开始——深入理解指针(1)

一.内存和地址 我们知道计算上CPU&#xff08;中央处理器&#xff09;在处理数据的时候&#xff0c;是通过地址总线把需要的数据从内存中读取的&#xff0c;后通过数据总线把处理后的数据放回内存中。如下图所示&#xff1a; 计算机把内存划分为⼀个个的内存单元&#xff0c;每…...

微信小程序-绑定数据并在后台获取它

如图 遍历列表的过程中需要绑定数据&#xff0c;点击时候需要绑定数据 这里是源代码 <block wx:for"{{productList}}" wx:key"productId"><view class"product-item" bindtap"handleProductClick" data-product-id"{{i…...

【删除数组用delete和Vue.delete有什么区别】

删除数组用delete和Vue.delete有什么区别&#xff1f; 在 JavaScript 中&#xff0c;delete 和 Vue.js 中的 Vue.delete 是两个完全不同的概念&#xff0c;它们在删除数组元素时的作用和效果也有所不同。 JavaScript 中的 delete 关键字&#xff1a; 在原生 JavaScript 中&a…...

【QT+QGIS跨平台编译】之四十二:【QWT+Qt跨平台编译】(一套代码、一套框架,跨平台编译)

文章目录 一、QWT介绍二、QWT下载三、文件分析四、pro文件五、编译实践5.1 Windows下编译4.2 Linux下编译5.3 MacOS下编译一、QWT介绍 QWT是一个基于Qt框架的开源C++库,用于创建交互式的图形用户界面。它提供了丰富的绘图和交互功能,可以用于快速开发图形化应用程序。 QWT包…...

yum方式快速安装mysql

问题描述 使用yum的方式简单安装了一下mysql&#xff0c;对过程进行简单记录。 步骤 ①安装wget和vim sudo yum -y install wget vim②下载mysql的rpm包 sudo wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm③升级和更新rpm包 sudo rpm -Uv…...

基于Java的家政预约管理平台

功能介绍 平台采用B/S结构&#xff0c;后端采用主流的Springboot框架进行开发&#xff0c;前端采用主流的Vue.js进行开发。 整个平台包括前台和后台两个部分。 前台功能包括&#xff1a;首页、家政详情、家政入驻、用户中心模块。后台功能包括&#xff1a;家政管理、分类管理…...

C语言前世今生

C语言前世今生 C语言的发展历史 C语言于1972年11月问世&#xff0c;1978年美国电话电报公司&#xff08;AT&T&#xff09;贝尔实验室正式发布C语言&#xff0c;1983年由美国国家标准局&#xff08;American National Standards Institute&#xff0c;简称ANSI&#xff09…...

android aidl进程间通信封装通用实现-用法说明

接上一篇&#xff1a;android aidl进程间通信封装通用实现-CSDN博客 该aar包的使用还是比较方便的 一先看客户端 1 初始化 JsonProtocolManager.getInstance().init(mContext, "com.autoaidl.jsonprotocol"); //客户端监听事件实现 JsonProtocolManager.getInsta…...

【Java中23种设计模式-单例模式2--懒汉式线程不安全】

加油&#xff0c;新时代打工人&#xff01; 今天&#xff0c;重新回顾一下设计模式&#xff0c;我们一起变强&#xff0c;变秃。哈哈。 23种设计模式定义介绍 Java中23种设计模式-单例模式 package mode;/*** author wenhao* date 2024/02/19 09:16* description 单例模式--懒…...

【后端高频面试题--Linux篇】

&#x1f680; 作者 &#xff1a;“码上有前” &#x1f680; 文章简介 &#xff1a;后端高频面试题 &#x1f680; 欢迎小伙伴们 点赞&#x1f44d;、收藏⭐、留言&#x1f4ac; 后端高频面试题--Linux篇 往期精彩内容Windows和Linux的区别&#xff1f;Unix和Linux有什么区别…...

网络原理HTTP/HTTPS(2)

文章目录 HTTP响应状态码200 OK3xx 表示重定向4xx5xx状态码小结 HTTPSHTTPS的加密对称加密非对称加密 HTTP响应状态码 状态码表⽰访问⼀个⻚⾯的结果.(是访问成功,还是失败,还是其他的⼀些情况…).以下为常见的状态码. 200 OK 这是⼀个最常⻅的状态码,表⽰访问成功 2xx都表示…...

【Java中23种设计模式-单例模式2--懒汉式2线程安全】

加油&#xff0c;新时代打工人&#xff01; 简单粗暴&#xff0c;学习Java设计模式。 23种设计模式定义介绍 Java中23种设计模式-单例模式 Java中23种设计模式-单例模式2–懒汉式线程不安全 package mode;/*** author wenhao* date 2024/02/19 09:38* description 单例模式…...

由LeetCode541引发的java数组和字符串的转换问题

起因是今天在刷下面这个力扣题时的一个报错 541. 反转字符串 II - 力扣&#xff08;LeetCode&#xff09; 这个题目本身是比较简单的&#xff0c;所以就不讲具体思路了。问题出在最后方法的返回值处&#xff0c;要将字符数组转化为字符串&#xff0c;第一次写的时候也没思考直…...

React hook之useRef

React useRef 详解 useRef 是 React 提供的一个 Hook&#xff0c;用于在函数组件中创建可变的引用对象。它在 React 开发中有多种重要用途&#xff0c;下面我将全面详细地介绍它的特性和用法。 基本概念 1. 创建 ref const refContainer useRef(initialValue);initialValu…...

基于Uniapp开发HarmonyOS 5.0旅游应用技术实践

一、技术选型背景 1.跨平台优势 Uniapp采用Vue.js框架&#xff0c;支持"一次开发&#xff0c;多端部署"&#xff0c;可同步生成HarmonyOS、iOS、Android等多平台应用。 2.鸿蒙特性融合 HarmonyOS 5.0的分布式能力与原子化服务&#xff0c;为旅游应用带来&#xf…...

DBAPI如何优雅的获取单条数据

API如何优雅的获取单条数据 案例一 对于查询类API&#xff0c;查询的是单条数据&#xff0c;比如根据主键ID查询用户信息&#xff0c;sql如下&#xff1a; select id, name, age from user where id #{id}API默认返回的数据格式是多条的&#xff0c;如下&#xff1a; {&qu…...

IoT/HCIP实验-3/LiteOS操作系统内核实验(任务、内存、信号量、CMSIS..)

文章目录 概述HelloWorld 工程C/C配置编译器主配置Makefile脚本烧录器主配置运行结果程序调用栈 任务管理实验实验结果osal 系统适配层osal_task_create 其他实验实验源码内存管理实验互斥锁实验信号量实验 CMISIS接口实验还是得JlINKCMSIS 简介LiteOS->CMSIS任务间消息交互…...

推荐 github 项目:GeminiImageApp(图片生成方向,可以做一定的素材)

推荐 github 项目:GeminiImageApp(图片生成方向&#xff0c;可以做一定的素材) 这个项目能干嘛? 使用 gemini 2.0 的 api 和 google 其他的 api 来做衍生处理 简化和优化了文生图和图生图的行为(我的最主要) 并且有一些目标检测和切割(我用不到) 视频和 imagefx 因为没 a…...

纯 Java 项目(非 SpringBoot)集成 Mybatis-Plus 和 Mybatis-Plus-Join

纯 Java 项目&#xff08;非 SpringBoot&#xff09;集成 Mybatis-Plus 和 Mybatis-Plus-Join 1、依赖1.1、依赖版本1.2、pom.xml 2、代码2.1、SqlSession 构造器2.2、MybatisPlus代码生成器2.3、获取 config.yml 配置2.3.1、config.yml2.3.2、项目配置类 2.4、ftl 模板2.4.1、…...

CRMEB 中 PHP 短信扩展开发:涵盖一号通、阿里云、腾讯云、创蓝

目前已有一号通短信、阿里云短信、腾讯云短信扩展 扩展入口文件 文件目录 crmeb\services\sms\Sms.php 默认驱动类型为&#xff1a;一号通 namespace crmeb\services\sms;use crmeb\basic\BaseManager; use crmeb\services\AccessTokenServeService; use crmeb\services\sms\…...

AI语音助手的Python实现

引言 语音助手(如小爱同学、Siri)通过语音识别、自然语言处理(NLP)和语音合成技术,为用户提供直观、高效的交互体验。随着人工智能的普及,Python开发者可以利用开源库和AI模型,快速构建自定义语音助手。本文由浅入深,详细介绍如何使用Python开发AI语音助手,涵盖基础功…...

【C++】纯虚函数类外可以写实现吗?

1. 答案 先说答案&#xff0c;可以。 2.代码测试 .h头文件 #include <iostream> #include <string>// 抽象基类 class AbstractBase { public:AbstractBase() default;virtual ~AbstractBase() default; // 默认析构函数public:virtual int PureVirtualFunct…...

API网关Kong的鉴权与限流:高并发场景下的核心实践

&#x1f525;「炎码工坊」技术弹药已装填&#xff01; 点击关注 → 解锁工业级干货【工具实测|项目避坑|源码燃烧指南】 引言 在微服务架构中&#xff0c;API网关承担着流量调度、安全防护和协议转换的核心职责。作为云原生时代的代表性网关&#xff0c;Kong凭借其插件化架构…...