小编wur*_*eka的帖子

在PostgreSQL中使用crosstab()时,引号不正确

我有一张桌子t1如下:

create table t1 (
  person_id int,
  item_name varchar(30),
  item_value varchar(100)
);
Run Code Online (Sandbox Code Playgroud)

此表中有五条记录:

person_id | item_name | item_value
   1        'NAME'      'john'
   1        'GENDER'    'M'
   1        'DOB'       '1970/02/01'
   1        'M_PHONE'   '1234567890'
   1        'ADDRESS'   'Some Addresses unknown'
Run Code Online (Sandbox Code Playgroud)

现在我想用交叉功能提取NAME,GENDER数据,所以我写了一个SQL为:

select * from crosstab(
  'select person_id, item_name, item_value from t1 
   where person_id=1 and item_name in ('NAME', 'GENDER') ') 
as virtual_table (person_id int, NAME varchar, GENDER varchar)
Run Code Online (Sandbox Code Playgroud)

我的问题是,正如您所看到的SQL in crosstab()contains condition item_name,这将导致引号不正确.我该如何解决这个问题?

postgresql quotes pivot crosstab

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

Grails 3.0.x 拦截器 matchAll().excludes 用于多个控制器

根据Grails 3.0.11 拦截器文档,我编写自己的拦截器如下:

class AuthInterceptor {
    int order = HIGHEST_PRECEDENCE;
    AuthInterceptor() {
        println("AuthInterceptor.AuthInterceptor(): Enter..............");
        // ApiController.index() and HomeController.index() don't need authentication.
        // Other controllers need to check authentication

        matchAll().excludes {
            match(controller:'api', action:'index);
            match(controller:'home', action:'index');
        }
    }
    boolean before() {
        println "AuthInterceptor.before():Enter----------------->>>>>>";
        log.debug("AuthInterceptor.before(): params:${params}");
        log.debug("AuthInterceptor.before(): session.id:${session.id}");
        log.debug("AuthInterceptor.before(): session.user:${session.user?.englishDisplayName}");
        if (!session.user) {
            log.debug("AuthInterceptor.before(): display warning msg");
            render "Hi, I am gonna check authentication"
            return false;
        } else {
            return true;
        }
    }

    boolean after() {
        log.debug("AuthInterceptor.after(): Enter ...........");
        true
    } …
Run Code Online (Sandbox Code Playgroud)

authentication grails interceptor grails-3.0.10

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

为什么 Google 云上的 vGPU (Tesla K80) 比 T460P 上的 GTX940M 慢

我对 Google 云虚拟机上的 vGPU (Tesla K80) 有疑问。

我的笔记本电脑是 Lenovo T460P,配备以下规格:

  • CPU:英特尔 i7-6700HQ
  • 内存:16GB
  • GPU:nVIDIA GTX 940M(CUDA 核心:348)
  • 操作系统:Windiws 10 Pro 64位
  • OpenCV:ver3.2.0,支持 CUDA 8.0(我从http://jamesbowley.co.uk/downloads/下载)

我在 Google Cloud 中创建的虚拟机包含以下规格:

  • CPU:vCPU x 2
  • 内存:4GB
  • 硬盘:25GB
  • GPU:vGPU (Tesla K80) x 1(CUDA 核心 4992)
  • 操作系统:Ubuntu 16.04 LTS 64位
  • CUDA 驱动程序:我按照以下链接的安装过程进行操作: https: //cloud.google.com/compute/docs/gpus/add-gpus
  • OpenCV:ver 3.2.0(编译参数:
    • cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -DWITH_CUDA=ON -DWITH_CUBLAS=ON -DWITH_TBB=ON -D CUDA_GENERATION=自动 -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -DWITH_NVCUVID=1 - DWITH_CUFFT=ON -DWITH_EIGEN=ON -DWITH_IPP=ON )

我使用 opencv 用 160 张正图像和 800 张负图像来训练 LBP …

google-app-engine gpu google-cloud-platform ubuntu-16.04

5
推荐指数
0
解决办法
651
查看次数

Groovy 动态添加带参数的方法

我想向现有的类 java.util.Date 添加一个方法“toFormatString(fmt)”。我的代码如下:

Date.metaClass.toFormatString(String fmt) = {
  SimpleDateFormat sdf = new SimpleDateFormat(fmt)
  return sdf.format(delegate)
}
Run Code Online (Sandbox Code Playgroud)

但是,Intellij 给了我一个错误:要分配给的值无效。

methods groovy arguments dynamic

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

如何将外部 application.yml 加载到 Micronaut Picocli 开发的应用程序中?

  • Java:11.0.7
  • 微博:2.1.2
  • Micronaut 个人资料:cli-app

我在 cli-app 配置文件中有一个使用 micronaut 框架开发的应用程序。我的应用程序使用Hibernate和GORM包,所以application.yml中有相关配置

在默认配置中,micronaut 从 src/main/resources 加载 application.yml。

如果我希望我的应用程序从如下参数中加载 application.yml:

java -Dmicronaut.config=/etc/fooApp/application.yml -jar fooApp.jar
Run Code Online (Sandbox Code Playgroud)

我应该怎么做 ?谢谢

picocli micronaut

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