- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
package com.example.nettytest.nio.day1;
import io.netty.util.internal.StringUtil;
import java.nio.ByteBuffer;
import static io.netty.util.internal.MathUtil.isOutOfBounds;
import static io.netty.util.internal.StringUtil.NEWLINE;
public class ByteBufferUtil {
private static final char[] BYTE2CHAR = new char[256];
private static final char[] HEXDUMP_TABLE = new char[256 * 4];
private static final String[] HEXPADDING = new String[16];
private static final String[] HEXDUMP_ROWPREFIXES = new String[65536 >>> 4];
private static final String[] BYTE2HEX = new String[256];
private static final String[] BYTEPADDING = new String[16];
static {
final char[] DIGITS = "0123456789abcdef".toCharArray();
for (int i = 0; i < 256; i++) {
HEXDUMP_TABLE[i << 1] = DIGITS[i >>> 4 & 0x0F];
HEXDUMP_TABLE[(i << 1) + 1] = DIGITS[i & 0x0F];
}
int i;
// Generate the lookup table for hex dump paddings
for (i = 0; i < HEXPADDING.length; i++) {
int padding = HEXPADDING.length - i;
StringBuilder buf = new StringBuilder(padding * 3);
for (int j = 0; j < padding; j++) {
buf.append(" ");
}
HEXPADDING[i] = buf.toString();
}
// Generate the lookup table for the start-offset header in each row (up to 64KiB).
for (i = 0; i < HEXDUMP_ROWPREFIXES.length; i++) {
StringBuilder buf = new StringBuilder(12);
buf.append(NEWLINE);
buf.append(Long.toHexString(i << 4 & 0xFFFFFFFFL | 0x100000000L));
buf.setCharAt(buf.length() - 9, '|');
buf.append('|');
HEXDUMP_ROWPREFIXES[i] = buf.toString();
}
// Generate the lookup table for byte-to-hex-dump conversion
for (i = 0; i < BYTE2HEX.length; i++) {
BYTE2HEX[i] = ' ' + StringUtil.byteToHexStringPadded(i);
}
// Generate the lookup table for byte dump paddings
for (i = 0; i < BYTEPADDING.length; i++) {
int padding = BYTEPADDING.length - i;
StringBuilder buf = new StringBuilder(padding);
for (int j = 0; j < padding; j++) {
buf.append(' ');
}
BYTEPADDING[i] = buf.toString();
}
// Generate the lookup table for byte-to-char conversion
for (i = 0; i < BYTE2CHAR.length; i++) {
if (i <= 0x1f || i >= 0x7f) {
BYTE2CHAR[i] = '.';
} else {
BYTE2CHAR[i] = (char) i;
}
}
}
/**
* 打印所有内容
* @param buffer
*/
public static void debugAll(ByteBuffer buffer) {
int oldlimit = buffer.limit();
buffer.limit(buffer.capacity());
StringBuilder origin = new StringBuilder(256);
appendPrettyHexDump(origin, buffer, 0, buffer.capacity());
System.out.println("+--------+-------------------- all ------------------------+----------------+");
System.out.printf("position: [%d], limit: [%d]\n", buffer.position(), oldlimit);
System.out.println(origin);
buffer.limit(oldlimit);
}
/**
* 打印可读取内容
* @param buffer
*/
public static void debugRead(ByteBuffer buffer) {
StringBuilder builder = new StringBuilder(256);
appendPrettyHexDump(builder, buffer, buffer.position(), buffer.limit() - buffer.position());
System.out.println("+--------+-------------------- read -----------------------+----------------+");
System.out.printf("position: [%d], limit: [%d]\n", buffer.position(), buffer.limit());
System.out.println(builder);
}
public static void main(String[] args) {
ByteBuffer buffer = ByteBuffer.allocate(10);
buffer.put(new byte[]{97, 98, 99, 100});
debugAll(buffer);
}
private static void appendPrettyHexDump(StringBuilder dump, ByteBuffer buf, int offset, int length) {
if (isOutOfBounds(offset, length, buf.capacity())) {
throw new IndexOutOfBoundsException(
"expected: " + "0 <= offset(" + offset + ") <= offset + length(" + length
+ ") <= " + "buf.capacity(" + buf.capacity() + ')');
}
if (length == 0) {
return;
}
dump.append(
" +-------------------------------------------------+" +
NEWLINE + " | 0 1 2 3 4 5 6 7 8 9 a b c d e f |" +
NEWLINE + "+--------+-------------------------------------------------+----------------+");
final int startIndex = offset;
final int fullRows = length >>> 4;
final int remainder = length & 0xF;
// Dump the rows which have 16 bytes.
for (int row = 0; row < fullRows; row++) {
int rowStartIndex = (row << 4) + startIndex;
// Per-row prefix.
appendHexDumpRowPrefix(dump, row, rowStartIndex);
// Hex dump
int rowEndIndex = rowStartIndex + 16;
for (int j = rowStartIndex; j < rowEndIndex; j++) {
dump.append(BYTE2HEX[getUnsignedByte(buf, j)]);
}
dump.append(" |");
// ASCII dump
for (int j = rowStartIndex; j < rowEndIndex; j++) {
dump.append(BYTE2CHAR[getUnsignedByte(buf, j)]);
}
dump.append('|');
}
// Dump the last row which has less than 16 bytes.
if (remainder != 0) {
int rowStartIndex = (fullRows << 4) + startIndex;
appendHexDumpRowPrefix(dump, fullRows, rowStartIndex);
// Hex dump
int rowEndIndex = rowStartIndex + remainder;
for (int j = rowStartIndex; j < rowEndIndex; j++) {
dump.append(BYTE2HEX[getUnsignedByte(buf, j)]);
}
dump.append(HEXPADDING[remainder]);
dump.append(" |");
// Ascii dump
for (int j = rowStartIndex; j < rowEndIndex; j++) {
dump.append(BYTE2CHAR[getUnsignedByte(buf, j)]);
}
dump.append(BYTEPADDING[remainder]);
dump.append('|');
}
dump.append(NEWLINE +
"+--------+-------------------------------------------------+----------------+");
}
private static void appendHexDumpRowPrefix(StringBuilder dump, int row, int rowStartIndex) {
if (row < HEXDUMP_ROWPREFIXES.length) {
dump.append(HEXDUMP_ROWPREFIXES[row]);
} else {
dump.append(NEWLINE);
dump.append(Long.toHexString(rowStartIndex & 0xFFFFFFFFL | 0x100000000L));
dump.setCharAt(dump.length() - 9, '|');
dump.append('|');
}
}
public static short getUnsignedByte(ByteBuffer buffer, int index) {
return (short) (buffer.get(index) & 0xFF);
}
}
package com.example.nettytest.nio.day1;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import static com.example.nettytest.nio.day1.ByteBufferUtil.debugAll;
/**
* @description: 分散读示例
* @author: xz
* @create: 2022-07-24 20:54
*/
public class TestScatteringReads {
public static void main(String[] args) {
try (FileChannel channel = new RandomAccessFile("readData.txt", "r").getChannel()) {
ByteBuffer b1 = ByteBuffer.allocate(3);
ByteBuffer b2 = ByteBuffer.allocate(3);
ByteBuffer b3 = ByteBuffer.allocate(5);
channel.read(new ByteBuffer[]{b1, b2, b3});
b1.flip();
b2.flip();
b3.flip();
debugAll(b1);
debugAll(b2);
debugAll(b3);
} catch (IOException e) {
}
}
}
package com.example.nettytest.nio.day1;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;
/**
* @description: 集中写示例
* @author: xz
* @create: 2022-07-24 21:07
*/
public class TestGatheringWrites {
public static void main(String[] args) {
ByteBuffer b1 = StandardCharsets.UTF_8.encode("hello");
ByteBuffer b2 = StandardCharsets.UTF_8.encode("world");
ByteBuffer b3 = StandardCharsets.UTF_8.encode("你好");
try (FileChannel channel = new RandomAccessFile("writeData.txt", "rw").getChannel()) {
channel.write(new ByteBuffer[]{b1, b2, b3});
} catch (IOException e) {
}
}
}
我有几个 pandas 数据框。我想在单独的散点图中相互绘制几列,并将它们组合为图中的子图。我想相应地标记每个子图。我在让子图标签正常工作方面遇到了很多麻烦,直到我发现据我所知,有两种直接从数据帧进行
使用 Dask 分布式分散广播列表的合适方法是什么? 案例 1 - 包装列表: [future_list] = client.scatter([my_list], broadcast=True) 情况
使用 Dask 分布式分散广播列表的合适方法是什么? 案例 1 - 包装列表: [future_list] = client.scatter([my_list], broadcast=True) 情况
我有一个包含数组元素的列表: [array([2.40460915, 0.85513601]), array([1.80998096, 0.97406986]), array([2.14505475,
我想显示一些点。这是我的代码: plt.scatter(y[:,0],y[:,1],c=col) plt.show() 并作为 col我有: Col: [1 1 0 1 1 1 1 0 0 0 1
当我在 OSX Yosemite 上运行它时,生成的颜色条有奇怪的白线(见下图)。有什么方法可以生成没有这些难看的线条的颜色条吗? import pylab import numpy x = nump
我已成功绘制了两个图表,但当我绘制第三个图表时,出现无效语法错误。我是否遗漏了一些非常明显的东西? x=df['time'] d=df['dist'] x2=df2['time'] d2=df2['d
我的每个进程都有一个值数组 v 和一个大小相同的进程 ID pid 数组。 pid[i] 指定要将项目 v[i] 发送到哪个进程。 我需要实现一个分散操作(当然还有相应的聚集操作)。 进程 ID 数组
如何使用核心图绘制有间隙的散点图?我正在使用核心绘图库。一切正常,但现在我想在数据线的开头或中间做一个有间隙的散点图?有人帮我吗? 最佳答案 让数据源返回nil 或[NSNull null]。例如,如
我有一些代码可以绘制一些点。我将 ax.scatter 替换为 ax.plot,这样我就可以单独控制每个点的颜色。但是,当我进行此更改时,x 轴和 y 轴的范围似乎会增加。 我无法确定为什么会这样。我
从我复制到自己服务器的已知公共(public)数据集开始。 数据集在这里:https://www.kaggle.com/imdevskp/corona-virus-report/download im
我正在使用 Bokeh 将 ~700 次模拟的结果与使用散点图的另一组结果进行对比。我想使用悬停工具通过分配标识模拟参数的自定义索引来定性地确定数据中的模式。 在下面的代码中,x和 y是来自 Pand
这个问题在这里已经有了答案: matplotlib scatter edge without specifying edgecolor (1 个回答) 3年前关闭。 我想通过使用 2 个索引 [Chi
我希望更好地理解流行的 EIP 分散聚集中的多个分离器、转换器和聚合方法。 用例是我发送一些可以对应于多种不同类型的 XML。我想分割 header 中指定的类型(每种类型不同)并通过与每种类型对应的
考虑以下示例(取自 Stackoverflow 上的另一篇文章): require(ggplot2) d <- data.frame(x = c(102856,17906,89697,74384,91
我有许多带有形状的矩阵 w1、w2、w3...wn (k*n1 、k*n2、k*n3...k*nn) 和 x1、x2、x3...xn 具有形状(n1*m、n2*m、n3*m...nn*m >). 我想
假设我的数据按以下方式组织: x_values = [6.2, 3.6, 7.3, 3.2, 2.7] y_values = [1.5, 3.2, 5.4, 3.1, 2.8] colours = [
我对 Spring Integration 还是很陌生,我尝试使用 IntetrationFlowDefinition.scatterGather() 但无济于事。总体思路是: 将一个String作为
我有一个谷歌分散图,我希望当鼠标悬停在圆圈上时,然后打开一个包含自定义字符串的信息窗口。 例如教程 https://developers.google.com/chart/interactive/do
好吧,我了解 JFreeChart 和其他人,但我正在编写自己的简单散点图。我已经有了一个箱形图(没有 y 轴标签,但当我在报告中解释它时,这不应该是一个大问题)。 我有一个基本的散点图类,但是我尝试
我是一名优秀的程序员,十分优秀!