小编Har*_*rma的帖子

我怎样才能预先拆分hbase

我将数据存储在具有5个区域服务器的hbase中.我使用url的md5哈希作为我的行键.目前,所有数据仅存储在一个区域服务器中.所以我想预先拆分区域,以便数据在所有区域服务器上统一分布,这样数据将统一到达每个区域服务器.我想将数据拆分为行键的第一个字符.第一个字符是从0到f(16个字符).就像rowkey从0到3开始的数据将在第一个区域服务器中,3-6在第二个,6-9在第3个,ad在第4个,df在第5个.我该怎么做 ?

hadoop hbase

9
推荐指数
2
解决办法
1万
查看次数

为什么"哪个cp | ls -l"不是"ls -l $(哪个cp)"?

根据Linux中的管道方法,第一个命令的输出应该被视为第二个命令的输入.因此,当我这样做时which cp | ls -l,应将其视为ls -l $(which cp)

但输出显示其他东西.

为什么这样 ?

linux bash command-line ls pipe

4
推荐指数
1
解决办法
208
查看次数

awk、pipe 和 tail -f 给出意外行为

这是我的示例日志文件。http://pastebin.com/DwWeFhJk

当我在做

tail -f log | awk '{if (NF>3) {print $1}; }'
Run Code Online (Sandbox Code Playgroud)

我得到的结果是正确的

64.242.88.10
64.242.88.10
64.242.88.10
64.242.88.10
64.242.88.10
64.242.88.10
64.242.88.10
64.242.88.10
64.242.88.10
64.242.88.10
Run Code Online (Sandbox Code Playgroud)

但是当我这样做时:

tail -f log |
awk '{if (NF>3) {print $1}; }' |
awk '{print $1}'
Run Code Online (Sandbox Code Playgroud)

我没有得到任何输出。甚至没有输出的情况下

tail -f log | awk '{if (NF>3) {print $1}; }' | grep "64"
Run Code Online (Sandbox Code Playgroud)

我不明白为什么第一个的输出awk没有作为第二个awk/grep管道之后的输入传递。

linux bash awk pipe tail

4
推荐指数
2
解决办法
1147
查看次数

使用 BufferedImage 和 ImageIO 将图像转换为 byte[] 后图像大小减小

我正在使用以下代码将图像转换为 byte[]。

public static byte[] extractBytes (String ImageName) throws IOException {

   ByteArrayOutputStream baos=new ByteArrayOutputStream();
        BufferedImage img=ImageIO.read(new File(ImageName));
        ImageIO.write(img, "jpg", baos);
        return baos.toByteArray();
    }
Run Code Online (Sandbox Code Playgroud)

现在当我测试我的代码时:

public static void main(String[] args) throws IOException {
    String filepath = "image_old.jpg";
    File outp=new File(filepath);
    System.out.println("Size of original image="+outp.length());
    byte[] data = extractBytes(filepath);
    System.out.println("size of byte[] data="+data.length);
    BufferedImage img = ImageIO.read(new ByteArrayInputStream(data));
    //converting the byte[] array into image again
    File outputfile = new File("image_new.jpg");
    ImageIO.write(img, "jpeg", outputfile);
    System.out.println("size of converted image="+outputfile.length());
}
Run Code Online (Sandbox Code Playgroud)

我得到了非常奇怪的结果:

Size of original …
Run Code Online (Sandbox Code Playgroud)

java bufferedimage image javax.imageio

3
推荐指数
1
解决办法
4391
查看次数

python 中 dict.clear() 的时间复杂度是 O(1) 吗?

根据https://www.ics.uci.edu/~pattis/ICS-33/lectures/complexitypython.txt,dict.clear ()的时间复杂度为O(1)。

据我所知, dict.clear() 与分配 dict = {} 不同,因为 dict.clear() 对同一个字典进行更改,而 dict = {} 创建一个新的字典。

现在,如果 dict.clear() 正在清除同一个 dict 对象,那么它如何在 O(1) 内完成它。

python dictionary time-complexity python-internals

3
推荐指数
1
解决办法
2976
查看次数

读/写阻塞的系统调用是否会将进程置于 TASK_UNINTERRUPTIBLE 或 TASK_INTERRUPTIBLE 状态?

正如 signal(7) 的手册页中提到的,

   Interruption of system calls and library functions by signal handlers
       If a signal handler is invoked while a system call or library function call is blocked, then either:

       * the call is automatically restarted after the signal handler returns; or

       * the call fails with the error EINTR.

       Which  of  these  two behaviors occurs depends on the interface and whether or not the signal handler was established using the SA_RESTART flag (see sigaction(2)).  The details vary across …
Run Code Online (Sandbox Code Playgroud)

linux kernel signals system-calls linux-kernel

2
推荐指数
1
解决办法
2071
查看次数

如果是进程上下文切换,新进程的虚拟地址空间(VAS)是否已加载到CPU上下文(CPU的寄存器)中?

我读过了:

进程切换是从一个进程到另一个进程的上下文切换。它涉及切换所有流程抽象和资源,以支持属于新流程的抽象和资源。最值得注意和最昂贵的是,这意味着切换存储器地址空间。这包括内存地址,映射,页表和内核资源,这是一个相对昂贵的操作。

也:

上下文是任何时间点的CPU寄存器和程序计数器的内容。

当内核(即操作系统的核心)针对CPU上的进程(包括线程)执行以下活动时,可以更详细地描述上下文切换:(1)暂停一个进程的进程并存储进程该进程在内存中某个位置的CPU状态(即上下文),(2)从内存中检索下一个进程的上下文,并将其恢复到CPU的寄存器中,(3)返回到程序计数器指示的位置(即,返回到中断该过程的代码行)以恢复该过程。

由于每个进程的VAS都是独立的,并且最大容量为4GB,如果进程进行上下文切换,进程的整个VAS是否会加载到CPU上下文中?

另外,由于每个进程都有单独的页表,因此如果进行上下文切换,该页表是否也被带入CPU上下文中?

如果否,那么为什么进程上下文切换比线程上下文切换慢(线程共享相同的VAS)?

linux multithreading context-switch linux-kernel multitasking

1
推荐指数
1
解决办法
840
查看次数

带子查询的SQL查询

我的数据是这样的:

data1_qqq_no_abc_ccc
data1_qqq_abc_ccc
data2_qqq_no_abc_ccc
data2_qqq_abc_ccc
data3_qqq_no_abc_ccc
data4_qqq_no_abc_ccc
data4_qqq_abc_ccc
Run Code Online (Sandbox Code Playgroud)

...

现在我想获取数据具有子串_no_abc_ccc的字段,但没有_abc_ccc.在上面的例子中,它的数据3

我正在尝试为它创建一个查询.粗糙的是

select SUBSTRING_INDEX(name, 'abc', 1)  
from table1 
where SUBSTRING_INDEX(name, 'abc', 1) not LIKE "%no" 
  and NOT IN (select SUBSTRING_INDEX(name, '_no_abc', 1) 
              from table 
              where name LIKE "%no_abc");
Run Code Online (Sandbox Code Playgroud)

mysql sql subquery mysql-dependent-subquery

1
推荐指数
1
解决办法
76
查看次数