小编Adr*_*ian的帖子

Gradle - 如何仅针对特定类型的文件在 fileTree 中迭代

在我的 gradle 任务中,我遍历 fileTree 并且一切正常:

myTask {
  fileTree("${project.projectDir}/dir").visit { FileVisitDetails details ->
    exec {
      //do some operations
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

但现在我的目录中有不同类型的文件:

dir
??? sub1
?   ??? file1.json
?   ??? file2.js
??? sub2
?   ??? file1.json
?   ??? file2.js
??? sub3
    ??? file1.js
    ??? file2.json
Run Code Online (Sandbox Code Playgroud)

如何仅迭代某些类型的文件?因为

"${project.projectDir}/folder/dir/**/*.json"
Run Code Online (Sandbox Code Playgroud)

不起作用。

感谢您的任何建议

gradle filetree

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

如何在 MongoDB 中的长时间戳上创建 TTL 索引

在我的 mongo 数据库中,我有字段时间戳,它在时间戳中保存创建时间,即:"timestamp": 1544029233021 我想在这个字段上创建 TTL 索引,但在文档示例中完成的"createdAt": new Date(),ISODate("2018-12-13T17:00:10.433Z")

是否有可能以任何方式使 TTL 索引在时间戳字段上工作?

因为这不起作用:

db.coll.createIndex( { "timestamp": 1 }, { expireAfterSeconds: 3600 } )
Run Code Online (Sandbox Code Playgroud)

javascript mongodb nosql

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

如何在大型文本文件中对数字进行排序

我的任务是对一个大文本文件(> 1GB)进行排序,其中每行排列一个数字,如下例所示:

1906885614
1069046615
1576929003
1690826360
1540261768
786870227
1737467783
295136587
685162468
Run Code Online (Sandbox Code Playgroud)

这就是我到目前为止所做的.

#include <iostream>
#include <map>
#include <string>
#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    ofstream filtered;
    ofstream filtered1;
    ifstream textfile ("sort_1.txt");
    string text_input;
    map<string, long int> map_data;
    vector<string> sort_vec;
    long int i;

    if (textfile.is_open())
    {
        filtered.open("filtered_list.txt");
        while( ! textfile.eof() )
        {
            getline (textfile, text_input);
            map_data[text_input]++;

            if (map_data[text_input] == 1)
            {
                filtered << text_input << '\n';
            }
        }
        filtered.close();
        textfile.close();
        cout << "Filter Process …
Run Code Online (Sandbox Code Playgroud)

c++ sorting

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

在二维数组中找到最长的路径(如多米诺骨牌)

我需要从某个点找到最长的路径(就像多米诺骨牌一样),它可以在文件中显示:

骨牌

因此,我可以从单元格(0,0)创建的最长的多米诺骨牌是(1,4)点,而不是(3,0)点。

我已经尝试使用dfs解决此问题,并成功找到了整个区域的大小-我不知道如何更改此代码来计算多米诺骨牌的最长路径。

public class Main {

    static int totalRows = 4;
    static int totalCols = 6;
    static int[] rowNbr = {1, -1, 0, 0};
    static int[] colNbr = {0, 0, 1, -1};
    static int count = 0;
    static boolean[][] visited = new boolean[4][6];

    public static void main(String[] args) {
        int mat[][] = {
                {1, 0, 0, 0, 0, 0},
                {1, 1, 1, 1, 1, 0},
                {1, 0, 0, 0, 0, 0},
                {1, 0, 0, 0, 0, 0}};

        dfs(mat, 0, …
Run Code Online (Sandbox Code Playgroud)

java algorithm graph-algorithm

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

POP [BP-SI-80]正在做什么?16位组装

我试图理解这个命令,我有两个不同的意见.

POP [BP-SI-80]节省从堆栈中的一些字DS:[BP-SI-80]SS:[BP-SI-80]

assembly

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

重新安装后,MongoDB 4.2 无法在 ubuntu 18.04 上启动 - 进程立即停止

我对 mongoDB 有问题 - 我会按照官方教程一步一步来:https ://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

我也通过这个答案安装(当然我改变了一些命令来下载 4.2 而不是 4.0 就像在这个答案中一样):https : //askubuntu.com/questions/842592/apt-get-fails-on-16-04-或-18-04-installing-mongodb/842599#842599

但毕竟它仍然不起作用:

adrian@ubuntu:~$ sudo service mongod start
adrian@ubuntu:~$ sudo service mongod status
? mongod.service - MongoDB Database Server
   Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2019-09-26 09:37:53 CEST; 2s ago
     Docs: https://docs.mongodb.org/manual
  Process: 5220 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=62)
 Main PID: 5220 (code=exited, status=62)

Sep 26 09:37:51 ubuntu systemd[1]: Started MongoDB Database Server.
Sep 26 09:37:53 ubuntu systemd[1]: mongod.service: Main …
Run Code Online (Sandbox Code Playgroud)

ubuntu mongodb ubuntu-18.04

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