小编hua*_*gjs的帖子

如何在elasticsearch中配置“search.max_open_scroll_context”?

我使用scroll在 elasticsearch 中获取数据(版本:7.0.0)。但是,当我使用它时,抛出了异常。

  • 要求:
GET /index-name/_search?scroll=1m
{
    "size": 100,
    "query": {
        "match_all" : {}
    }
}
Run Code Online (Sandbox Code Playgroud)
  • 回复
{
  "error": {
    "root_cause": [
      {
        "type": "exception",
        "reason": "Trying to create too many scroll contexts. Must be less than or equal to: [500]. This limit can be set by changing the [search.max_open_scroll_context] setting."
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "nr-v1",
        "node": "jVqXndodRtqsZ4Srh9eHSg",
        "reason": {
          "type": "exception",
          "reason": "Trying …
Run Code Online (Sandbox Code Playgroud)

elasticsearch

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

为什么在使用for-each时循环变量有效地最终化?

  • 情况1:在使用for-each循环时可以工作吗?
    private void m10(String[] arr) {
        for (String s : arr) {
            Supplier<String> supplier = () -> {
                System.out.println(s);
                return null;
            };
            supplier.get();
        }
    }
Run Code Online (Sandbox Code Playgroud)

要么

    private void m10(Object[] arr) {
        for (Object s : arr) {
            Supplier<String> supplier = () -> {
                System.out.println(s);
                return null;
            };
            supplier.get();
        }
    }
Run Code Online (Sandbox Code Playgroud)
  • 情况2:它将捕获编译时错误
    private void m11(String[] arr) {
        for (int i = 0; i < arr.length; i++) {
            Supplier<String> supplier = () -> {
                System.out.println(arr[i]);
                return null;
            };
            supplier.get();
        }
    }
Run Code Online (Sandbox Code Playgroud)

在情况2中,我知道该变量 …

java lambda final

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

如何使用线程池读取多个文件?

我想使用线程池读取多个文件,但失败了。

@Test
public void test2() throws IOException {
    String dir = "/tmp/acc2tid2999928854413665054";
    int[] shardIds = new int[]{1, 2};
    ExecutorService executorService = Executors.newFixedThreadPool(2);
    for (int id : shardIds) {
        executorService.submit(() -> {
            try {
                System.out.println(Files.readAllLines(Paths.get(dir, String.valueOf(id)), Charset.forName("UTF-8")));
            } catch (IOException e) {
                e.printStackTrace();
            }
        });
    }
}
Run Code Online (Sandbox Code Playgroud)

上面是我写的一个简单示例。它达不到我的目的。

System.out.println(Files.readAllLines(
        Paths.get(dir, String.valueOf(id)), Charset.forName("UTF-8")));
Run Code Online (Sandbox Code Playgroud)

该行将不会运行,也没有警告。不知道为什么

java multithreading file java-8

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

如何为 v-treeview 添加右键单击事件以在 vuetify 中打开菜单?

我想right click event 为 v-treeview添加以打开菜单,但我失败了。我创建了一个可以在左键单击时打开菜单的版本,主要代码是

<v-treeview v-model="tree"  :open="open"  :items="items"  activatable item-key="name"  >
      <template v-slot:label="{item, open, selected}">
      <v-menu
        :value="showMenu"
      >
        <template v-slot:activator="{ on }">
          <v-btn
            flat
            :ripple="false"
            class="ma-0 pa-0"
            v-on="on"
          >
            <!--button icon-->
            <v-icon v-if="!item.file">
              {{ open ? 'mdi-folder-open' : 'mdi-folder' }}
            </v-icon>
            <v-icon v-else>
              {{ files[item.file] }}
            </v-icon>
            <!--button text-->
            {{item.name}}
          </v-btn>
        </template>
        <v-list>
          <v-list-tile v-for="menuItem in menuItems" :key="menuItem">
            <v-list-tile-title>{{menuItem}}</v-list-tile-title>
          </v-list-tile>
        </v-list>
      </v-menu>
    </template>
    </v-treeview>
Run Code Online (Sandbox Code Playgroud)

注:源代码可在https://codepen.io/lhuangjs/pen/axMpYJ运行

但我是迷茫v-on="on"activator slot这么多,我得到一些信息https://github.com/vuetifyjs/vuetify/issues/6866。然而我还是无法理解。有没有更清楚的解释?

谢谢!

vuejs2 vuetify.js

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