【Golang】Golang Slice解析
Golang Slice解析
slice实现
Slice是Golang提供的数据结构,slice的底层实现是这样的:
// Definition of slice
type slice struct {
array unsafe.Pointer // Pointer to underlying data array
len int // slice length
cap int // max array size
}
slice更新操作
由于slice传递至函数的是引用,所以作为函数参数传入到函数体内,对slice进行改变是会影响最终结果的。例如下面的例子:
func changeArr(arr []int) {
arr[0] = 1
}
s...
【Big-Data】数据库基础知识
数据库基础
整体架构图
模块详情
Mysql: https://blog.csdn.net/ThinkWon/article/details/104778621
Redis: https://blog.csdn.net/ThinkWon/article/details/103522351
【Golang】Service mesh详解
Definition
Service Mesh是一个可配置的、低时延的架构层应用,主要应用在微服务框架中,用来处理内部微服务的海量数据通信的一种主要基于应用层API编写的框架。整体可以参考下图:
我们从用户发起请求到请求被返回的流程对service mesh负责的各个功能和模块进行拆解。
Container Orchestration Framework
这是一个系统引擎,当外部请求进入到系统内部时,首先访问到整个Framework,这个Framework能够对微服务框架的所有功能模块进行全局和局部的配置以及管理,并在这个基础上提供不同粒度的功能,例如维护服务发现表,进行内部网负载均衡等。
Load Balancing
当有大量流量进入到系统内部时,该功能模块从tr...
【Golang】Goroutine截获输出和错误
Goroutine获取输出
通过chan获取到输出。
参考这个程序代码:
https://github.com/Chengru-Song/algo_practice/blob/master/conc/conc.go
func ConcPattern() {
ch1 := make(chan int)
ch2 := make(chan int)
// var wg sync.WaitGroup
// wg.Add(1)
// wg.Wait()
go func(ch chan int) {
time.Sleep(time.Second * 1)
ch <- 1
}(ch1)
go func(ch chan int) {
// defer wg.D...
【Golang】Golang Map并发编程
Golang Map并发读写
直接并发读写
如果直接对map进行并发读写,那么会造成Panic或者error,如下所示:
package main
func main() {
m := make(map[int]int)
go func() {
for {
read := m[0] // sync read
}
}()
go func() {
for {
m[0] = 1 // sync write
}
}()
}
上面程序有问题
传统加锁读写
package main
func main() {
m := make(map[int]int)
mc := sync.Mutex
...
【AI】Item2Vec详解
item2vec
Usage: item2vec learns item similarity.
Motivation
Item2item relations are important because different than the traditional user2item relations, it shows a more explicit user intent of purchasing. Therefore it has a higher click-through rate.
Solution
Skip Gram
Skip-gram is used to predict context words given a target word.
For...
【AI】WMAPE详解
WMAPE
Advantage: The advantage of this metric over MAPE is that this overcomes the ‘infinite error’ issue.
Key word: Evaluation
Usage: A measure of prediction accuracy of a forecasting method.
WMAPE: weighted mean absolute percentage error’
A measure of prediction accuracy of a forecasting method.
\[\begin{equation}
WMAPE = \frac{\sum^n_{t=1...
共计 136 篇文章,17 页。