Featured image of post Weekly Report 2023.30

Weekly Report 2023.30

何来的道貌岸然

生活确实是百姿百态 (贬义)。

Entertainment

工作细胞

作为教育番剧,达到起目的了?我看悬,毕竟很多观众开始推 CP 了。这总是会让我思考,人体本身只是一种自然现象,却被作者主观赋予了感情纠葛,观感差了很多。

可能,我还是会推荐去看《战斗细胞》吧,毕竟是 Kurzgesagt 出品。

Learning

Netty Cumulator

解决半包的利器

  • 固定长度 - FixedLengthFrameDecoder
  • 特定分隔符 - DelimieterBasedFrameDecoder
  • 指定长度存储长度,后续填充数据 - LengthFieldBasedFrameDecoder, LengthFieldPrepender
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
 * Cumulate {@link ByteBuf}s by merge them into one {@link ByteBuf}'s, using memory copies.
 */
public static final Cumulator MERGE_CUMULATOR = new Cumulator() {
    // cumulation 已积攒的数据,in 当次数据
    @Override
    public ByteBuf cumulate(ByteBufAllocator alloc, ByteBuf cumulation, ByteBuf in) {
        if (cumulation == in) {
            // when the in buffer is the same as the cumulation it is doubly retained, release it once
            in.release();
            return cumulation;
        }
        if (!cumulation.isReadable() && in.isContiguous()) {
            // If cumulation is empty and input buffer is contiguous, use it directly
            cumulation.release();
            return in;
        }
        try {
            final int required = in.readableBytes();
            if (required > cumulation.maxWritableBytes() ||
                required > cumulation.maxFastWritableBytes() && cumulation.refCnt() > 1 ||
                cumulation.isReadOnly()) {
                // Expand cumulation (by replacing it) under the following conditions:
                // - cumulation cannot be resized to accommodate the additional data
                // - cumulation can be expanded with a reallocation operation to accommodate but the buffer is
                //   assumed to be shared (e.g. refCnt() > 1) and the reallocation may not be safe.
                return expandCumulation(alloc, cumulation, in);
            }
            cumulation.writeBytes(in, in.readerIndex(), required);
            in.readerIndex(in.writerIndex());
            return cumulation;
        } finally {
            // We must release in all cases as otherwise it may produce a leak if writeBytes(...) throw
            // for whatever release (for example because of OutOfMemoryError)
            in.release();
        }
    }
};

Life

  • 断断续续的雨与未至的台风
  • 零散的梦与破碎的心,还有信心与期待

Thought

原来工作和加班才是生活节奏的主宰者。

Quotation

如果我要拥有一种观点,如果我不能够比全世界最聪明、最有能力、最有资格反驳这个观点的人更能够证否自己,我就不配拥有这个观点。 - 查理·芒格

Recommendation

写作

写任何你感兴趣的,记录你的工作、阅读,展示你的工作文档,记录你学习的东西+在社交媒体上活跃,这样你会遇到朋友,接触到业务,最终你会真正成为互联网公民。

References

Licensed under CC BY-NC-SA 4.0
Last updated on Jul 31, 2023 10:06 CST
The older I get, the more I realize that most of life is a matter of what we pay attention to, of what we attend to [with focus].
Built with Hugo
Theme Stack designed by Jimmy