小编Fre*_*Box的帖子

mongodb 将 $lte 与 $indexOfArray 一起使用

与模型的集合

{
    stack: [{mean: 3.5}]
}
Run Code Online (Sandbox Code Playgroud)

如何查询平均值小于 4.38 的堆栈数组索引?

db.stacks.aggregate([
    {
        $project: {
            index: { $indexOfArray: ['$stack', {mean: { $lte: 4.38 }}] },
        },
    },
]);
Run Code Online (Sandbox Code Playgroud)

我收到此错误:{

    "ok" : 0,
    "errmsg" : "Expression $lte takes exactly 2 arguments. 1 were passed in.",
    "code" : 16020,
    "codeName" : "Location16020"
}
Run Code Online (Sandbox Code Playgroud)

编辑:

这不会给我错误,但也不匹配任何内容

db.mean.aggregate([
    {
        $project: {
            size: { $size: '$stack' },
            index: { $indexOfArray: ['$stack', {$lte: ['$mean', 4.38] } ] },
        },
    },
])
Run Code Online (Sandbox Code Playgroud)

mongoose mongodb aggregation-framework

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

如何在c#中创建多维对象数组

我正在尝试制作一个脚本,通过制作高度贴图然后从那里填充地形块来动态生成世界块.我的问题是创建一个二维对象数组.

public class Chunk
{
    public Block[,] blocks;

    Generate(){
        //code that makes a height map as a 2 dimensional array as hightmap[x,y]=z
        //convert heightmap to blocks
        for (int hmX = 0; hmX < size; hmX++)
        {
            for (int hmY = 0; hmY < size; hmY++)
            {
                blocks[hmX, hmY] = new Block(hmX, hmY, heightmap.Heights[hmX, hmY], 1);
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这给了我错误:

NullReferenceException未处理,Object引用未设置为对象的实例.

object multidimensional-array xna-4.0 c#-4.0

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

为 kiali、tracing、grafana 创建 VirtualService

我正在尝试在我的默认网关上公开 kiali。我有其他服务适用于默认命名空间中的应用程序,但无法将流量路由到 istio 命名空间中的任何内容

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: gateway
spec:
  selector:
    istio: ingressgateway
  servers:
    - port:
        number: 80
        name: http
        protocol: HTTP
      hosts:
        - '*'
      tls:
        httpsRedirect: true
    - port:
        number: 443
        name: https
        protocol: HTTPS
      hosts:
        - '*'
      tls:
        mode: SIMPLE
        privateKey: /etc/istio/ingressgateway-certs/tls.key
        serverCertificate: /etc/istio/ingressgateway-certs/tls.crt
Run Code Online (Sandbox Code Playgroud)
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: kiali
  namespace: default
spec:
  hosts:
    - kiali.dev.example.com
  gateways:
    - gateway
  http:
    - route:
        - destination:
            host: kiali.istio-system.svc.cluster.local
            port:
              number: 20001

Run Code Online (Sandbox Code Playgroud)

istio

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