标签: haskell-criterion

org.hibernate.QueryException - 无法解析属性

我正在尝试使用Hibernate连接到数据库.

此当前表具有以下布局:

  (field1, field2, field3, optional1, optioanl2...)
Run Code Online (Sandbox Code Playgroud)

其中field1,field2,field3都是外键,并且一起构成一个复合键.

我有以下课程:

@Entity
@Table(name = "db_table_mainRecords")
public class MainRecord implements Serializable{
    @EmbeddedId
    private MainRecordKey   lqk;
    @Transient
    private String          field1;
    @Transient
    private int         field2;
    @Transient
    private int         field3;
    @Column(name = "optional_1")
    private double          optional1;
    @Column(name = "optional_2")
    private double          optional2;

....
  // Getters and setters for all fields, including fields within MainClassKey
....
}
Run Code Online (Sandbox Code Playgroud)

随之而来:

@Embeddable
@Table(name = "db_table_mainRecords")
public class MainRecordKey implements Serializable{
    @Column(name = "field1")
    private String field_1; 
    @Column(name = "field_2")
    private …
Run Code Online (Sandbox Code Playgroud)

mapping hibernate haskell-criterion

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

异步代码在haskell中运行速度比同步版本慢

对以下内容进行基准测试:

#!/usr/bin/env stack
-- stack --resolver lts-16.2 script --package async --package criterion

import           Control.Concurrent.Async (async, replicateConcurrently_)
import           Control.Monad            (replicateM_, void)
import           Criterion.Main

main :: IO ()
main = defaultMain [
    bgroup "tests" [ bench "sync" $ nfIO syncTest
                   , bench "async" $ nfIO asyncTest
                   ]
    ]

syncTest :: IO ()
syncTest = replicateM_ 100000 dummy

asyncTest :: IO ()
asyncTest = replicateConcurrently_ 100000 dummy

dummy :: IO Int
dummy = return $ fib 10000000000

fib :: Int -> Int
fib …
Run Code Online (Sandbox Code Playgroud)

concurrency benchmarking haskell haskell-criterion io-monad

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

Haskell标准使用错误

以下代码命名 fib.hs

import Criterion.Main (defaultMain)
fibZ = 1:1:zipWith (+) fibZ (tail fibZ)
main = defaultMain [
         bench "fibZ 10" $ \n -> fibZ (10+n-n)
       ]
Run Code Online (Sandbox Code Playgroud)

错误

fib.hs:45:10: Not in scope: `bench'
Run Code Online (Sandbox Code Playgroud)

怎么了?我从这里借了这个例子.

benchmarking haskell package ghc haskell-criterion

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

标准限制按日期字段

我有2张桌子,PartnerVisit.合作伙伴可以在同一天进行多次访问.我需要创建一个Criteria限制知道有多少Partner有,因为在给定日期的访问.因此,同一日期的2次或多次访问必须只有一次.

这可以只通过CriteriaRestrictions??

我可以通过以下标准获得所有访问:

Criteria criteria = buildCriteria();
criteria.add(Restrictions.eq(DBConstants.VISIT_COL_VISITOR, partnerVisitor));
criteria.add(Restrictions.ge(DBConstants.VISIT_COL_DATE, startDate));
Run Code Online (Sandbox Code Playgroud)

但是现在,为了过滤重复的日子,我需要这样的东西:

criteria.add(Restrictions.unique(DBConstants.VISIT_COL_DATE));
Run Code Online (Sandbox Code Playgroud)

任何的想法?

编辑: @ user23123412 @netik

Visit.java

private Integer id;
private Date date;
private Partner visitor;

// getters + setters
Run Code Online (Sandbox Code Playgroud)

Visit 与伙伴1相关的表行:

ID  VISITOR DATE
1   1       10/10/2014 16:20
20  1       10/10/2014 18:00
45  1       12/10/2014 16:20
71  1       12/10/2014 19:40
89  1       16/10/2014 11:20
Run Code Online (Sandbox Code Playgroud)

查询后我需要的答案是Visit自给定以来不同日期的计数date.

IE:如果我启动一个查询visitor …

java hibernate haskell-criterion

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

将随机生成的列表作为参数传递给Haskell

我是Haskell的新手,并且在整个IO事情上遇到了麻烦.

我试图找出遍历haskell列表所需的时间.我想生成一个随机数列表并将其作为参数传递给函数,以便我可以打印列表的每个元素.我正在使用CRITERION包作为基准.这是代码:

{-# LANGUAGE OverloadedStrings #-}
import System.Random
import Control.Exception
import Criterion.Main

printElements [] = return ()
printElements (x:xs) = do print(x)
                          printElements xs

randomList 0 = return []
randomList n = do
  x  <- randomRIO (1,100)
  xs <- randomList (n-1)
  return (x:xs)


main = defaultMain [
  bgroup "printElements" [ bench "[1,2,3]"  $ whnf printElements (randomList 10)
               , bench "[4,5,6]"  $ whnf printElements [4,5,6,4,2,5]
               , bench "[7,8,9]"  $ whnf printElements [7,8,9,2,3,4]
               , bench "[10,11,12]" $ whnf printElements [10,11, 12,4,5]
               ] …
Run Code Online (Sandbox Code Playgroud)

benchmarking haskell list haskell-criterion io-monad

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