小编Jus*_*tFF的帖子

使用Sqoop导入时如何使用指定的Hive数据库

sqoop import --connect jdbc:mysql://remote-ip/db --username xxx --password xxx --table tb --hive-import
Run Code Online (Sandbox Code Playgroud)

上面的命令将表tb导入到' default'Hive数据库中.

我可以使用其他数据库吗?

hadoop hive sqoop

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

发送更改的hashmap,但使用ObjectOutputStream和ObjectInputStream获取相同的hashmap

public static void main(String[] args) throws Exception {
    Socket socket = new Socket("127.0.0.1", 2345);

    ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
    Map<Integer, Integer> testMap = new HashMap<Integer, Integer>();

    testMap.put(1,1);
    oos.writeObject(testMap);
    oos.flush();

    testMap.put(2,2);
    oos.writeObject(testMap);
    oos.flush();

    oos.close();
}


public static void main(String[] args) throws Exception {
    ServerSocket ss = new ServerSocket(2345);
    Socket s = ss.accept();
    ObjectInputStream ois = new ObjectInputStream(s.getInputStream());

    System.out.println((HashMap<Integer, Integer>) ois.readObject());
    System.out.println((HashMap<Integer, Integer>) ois.readObject());

    ois.close;
}
Run Code Online (Sandbox Code Playgroud)

上面的代码来自两个文件.运行它们时,控制台会打印相同的结果:

{1=1}
{1=1}
Run Code Online (Sandbox Code Playgroud)

怎么会发生这种情况?

java hashmap objectoutputstream objectinputstream

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

使用vector初始化链表时c ++分段错误

我打算使用向量初始化链表

这是代码:

#include <vector>
#include <iostream>

using namespace std;

struct ListNode {
    int val;
    ListNode *next;
    ListNode(int x) : val(x), next(NULL) {}
};

int main() {
    int n = 10;
    vector<ListNode> vecListNode;
    for (int i = 0; i != n; ++ i) {
        vecListNode.push_back(ListNode(i));
        if (i) {
            vecListNode[i-1].next = &vecListNode[i];
        }
    }
    ListNode *root = &vecListNode[0];
    while (root) {
        cout << root->val << endl;
        root = root->next;
    }
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

但是,当我运行此代码时,我得到:

0

1

分段错误:11

我正在使用macintosh,默认g ++,非常感谢

c++ segmentation-fault

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