小编use*_*783的帖子

如何使用CriteriaBuilder调用db函数

我有一个最终可能包含空格的字符串。我想用与 \t、\r、\n 匹配的正则表达式替换这些空格。替换后,我想调用 regexp_like (一个 oracle 函数)来匹配该字符串的字段。

我知道可以使用标准生成器调用数据库函数,如本链接中所述

我不太熟悉 java 中的正则表达式与 oracle 中的正则表达式之间的区别,也不熟悉如何将其拼凑在一起(我从未从 criteriabuilder 中调用过函数)。这是我的尝试步骤以及我在评论中陷入困境的地方

// first replace all spaces with regex for \s,\r,\t, value is the original string
value.replaceAll(" +", "[\\t\\n\\r]+")
// build the db function call expression, seems I cant do table.<String>get(field) and cant pass value as a string
Expression<String> regExp = cb.function("regexp_like", String.class, table.<String>get(field), value);
// now create a predicate not sure how
Predicate fieldMatch = cb.equal(...)
Run Code Online (Sandbox Code Playgroud)

这可能吗?

java hibernate hibernate-criteria

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

重塑函数定义的矩阵

我在matlab中有以下代码

deltax=@(t)xt(t).'-xt(t);
deltay=@(t)yt(t).'-yt(t);
deltaz=@(t)zt(t).'-zt(t);

deltar=@(t)reshape([deltax(:) deltay(:) deltaz(:)].',3*(100+1),[]).';
Run Code Online (Sandbox Code Playgroud)

其中xt,yt,zt都明确定义的功能t.如果我做deltax(2),我得到一个包含101个条目的列数组,类似于deltay(2)和deltaz(2).

但是,当我打电话

deltar(2)
Run Code Online (Sandbox Code Playgroud)

我收到这个错误

Input arguments to function include colon operator. To input the colon character, use ':' instead.
Run Code Online (Sandbox Code Playgroud)

我也试过了

deltar=@(t)reshape([deltax(t)(:) deltay(t)(:) deltaz(t)(:)].',3*(100+1),[]).';
Run Code Online (Sandbox Code Playgroud)

但这给了我语法错误.

我必须做一些基本的matlab错误.

matlab reshape

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

在matlab中绘制立方根

我想在matlab中绘制三次方程x ^ {3} + Ax ^ {2} + 1 = 0的根.我知道A <-1.88有3个真正的根,如果A> -1.88则有1个.我想将3个真实的根作为A的函数绘制,当它切换到1个实根和2个复数时,绘制真实的根和复共轭解的所有部分都在同一个图中(可能是2-3个)图表).

我是一名matlab初学者.我试过了

syms x A
r = solve(x^3 + A*x^2+1 == 0, x);
ezplot(vpa(r(1)),[-10,10])
ezplot(vpa(r(2)),[-10,10])
ezplot(vpa(r(3)),[-10,10])
Run Code Online (Sandbox Code Playgroud)

但vpa不知道如何数字评估r.

matlab

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

如何将2个列表合并到一个球拍中

我有2个动态列表,我想合并为一个.

'(1 2 3 4)
Run Code Online (Sandbox Code Playgroud)

'(15 16)
Run Code Online (Sandbox Code Playgroud)

得到

'(1 2 3 4 15 16)
Run Code Online (Sandbox Code Playgroud)

如何才能做到这一点?

scheme racket

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

如何在elasticsearch中的嵌套聚合中存储空和非空字段?

我在elasticsearch中有以下一组嵌套子聚合(field2是field1的子聚合,field3是field2的子聚合)。然而事实证明,field3 的术语聚合不会对没有 field3 的文档进行存储桶。

我的理解是,除了 field3 的术语查询之外,我还必须使用 Missing 子聚合查询来对这些查询进行存储。

但我不确定如何将其添加到下面的查询中以将两者都存储起来。

{
  "size": 0,
  "aggregations": {
    "f1": {
      "terms": {
        "field": "field1",
        "size": 0,
        "order": {
          "_count": "asc"
        },
        "include": [
          "123"
        ]
      },
      "aggregations": {
        "field2": {
          "terms": {
            "field": "f2",
            "size": 0,
            "order": {
              "_count": "asc"
            },
            "include": [
              "tr"
            ]
          },
          "aggregations": {
            "field3": {
              "terms": {
                "field": "f3",
                "order": {
                  "_count": "asc"
                },
                "size": 0
              },
              "aggregations": {
                "aggTopHits": {
                  "top_hits": {
                    "size": 1
                  }
                }
              } …
Run Code Online (Sandbox Code Playgroud)

elasticsearch elasticsearch-aggregation

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

Springboot MetricRepository

我正在尝试使用

org.springframework.boot.actuate.metrics.repository.MetricRepository
Run Code Online (Sandbox Code Playgroud)

吐出指标

private final MetricRepository repository;

@Autowired
public MetricExporterService(MetricRepository repository) {
    this.repository = repository;
}
Run Code Online (Sandbox Code Playgroud)

但由于我使用的是 Java 1.8,我得到了

Parameter 0 of constructor in com.example.actuator.MetricExporterService required a bean of type 'org.springframework.boot.actuate.metrics.repository.MetricRepository' that could not be found.
    - Bean method 'actuatorMetricRepository' not loaded because @ConditionalOnJava (older than 1.8) found 1.8
Run Code Online (Sandbox Code Playgroud)

有没有办法覆盖这种行为?

spring-boot spring-boot-actuator

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

将字段保留在 mongodb 组中

我在 mongo db 的集合中有以下类型的文档

{_id:xx,

iddoc:yy,   

type1:"sometype1", 

type2:"sometype2",

date: 

{ 

  year:2015,

  month:4,

  day:29,

  type:"day"

},

count:23  }
Run Code Online (Sandbox Code Playgroud)

我想对所有文档按 iddoc 分组的字段计数求和,其中:

type1 in ["type1A","type1B",...] where type2 in ["type2A","type2B",...] date.year: 2015, date.month: 4, date.type: "day" date.day 介于 4 和 7 之间

然后我想对这些总和进行排序。

我现在知道怎么做(见这个问题

db.test.aggregate([
  // Filter the docs based on your criteria
  {$match: {
    type1: {$in: ['type1A', 'type1B']},
    type2: {$in: ['type2A', 'type2B']},
    'date.year': 2015,
    'date.month': 4,
    'date.type': 'day',
    'date.day': {$gte: 4, $lte: 7}
  }},

  // Group by iddoc and count …
Run Code Online (Sandbox Code Playgroud)

mongodb aggregation-framework

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

如何将列表转换为其元素

这一定很容易实现,但我是新手,不知道如何:

我有一个列表(1 2 3 4)并想将其转换为(1)(2)(3)(4)

或者有没有办法将其构建为(1)(2)(3)(4).我在用

 cons '(element) call-function
Run Code Online (Sandbox Code Playgroud)

在函数内构建它(递归)

scheme racket

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