我正在尝试使用Mathematica来分析一些原始数据.我希望能够动态显示的数据我感兴趣的使用范围Manipulate和ListLinePlot,但情节渲染极为缓慢.我怎样才能加快速度?
以下是一些其他细节.外部文本文件存储原始数据:第一列是时间戳,第二列,第三列和第四列是数据读数,例如:
1309555993069, -2.369941, 6.129157, 6.823794
1309555993122, -2.260978, 6.170018, 7.014479
1309555993183, -2.070293, 6.129157, 6.823794
1309555993242, -1.988571, 6.238119, 7.123442
Run Code Online (Sandbox Code Playgroud)
单个数据文件最多包含2·10 6行.例如,要显示第二列,我使用:
x = Import["path/to/datafile"];
ListLinePlot[x[[All, {1, 2}]]]
Run Code Online (Sandbox Code Playgroud)
该操作的执行时间长得令人难以忍受.要显示我尝试使用的可变数据范围Manipulate:
Manipulate[ListLinePlot[Take[x, numrows][[All, {1, 2}]]], {numrows, 1, Length[x]}]
Run Code Online (Sandbox Code Playgroud)
这条指令有效,但当我尝试显示超过几千行时,它会快速爬行.我怎样才能加快速度?
一些额外的细节:
DataRange避免Take没有帮助.MaxPlotPoints扭曲过多的情节有用.Takein Manipulate没有帮助.Timing[ListLinePlot[Take[x,100000][[All, {1, 2}]]]]返回0.33:这意味着评估Take本身几乎是瞬时的,是绘图减慢一切的速度.任何提示?
我在Play上使用Hibernate 4.1.3(JPA)!框架.数据库是PostgreSQL 8.4.2.模式是使用生成的hibernate.hbm2ddl.auto="update".
简短版本:我有一个有一个@Id字段的类@GeneratedValue.有时,当persist它出现时,我得到一个空列违规,为什么?
更多细节:
我有一个非常简单的类,我想保存到数据库,看起来像这样:
@Entity
class MyObject {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Long id;
@NotNull
public String email;
public Integer total;
}
Run Code Online (Sandbox Code Playgroud)
我通常创建MyObject的实例,我把值赋给email和total领域,同时id为空,我通过保存它EntityManager.persist().Hibernate获取新对象的id并将其保存到DB.
但有时,我得到以下堆栈跟踪:
2012-05-19 00:45:16,335 - [ERROR] - from org.hibernate.engine.jdbc.spi.SqlExceptionHelper [SqlExceptionHelper.java:144] in play-akka.actor.actions-dispatcher-6
ERROR: null value in column "id" violates not-null constraint
2012-05-19 00:45:16,350 - [ERROR] - from application in play-akka.actor.actions-dispatcher-6
! @6ad7j3p8p - Internal server error, for request [POST …Run Code Online (Sandbox Code Playgroud) 我有一个代表产品用法的表,有点像日志.产品使用记录为多个时间戳,我想使用时间范围表示相同的数据.
它看起来像这样(PostgreSQL 9.1):
userid | timestamp | product
-------------------------------------
001 | 2012-04-23 9:12:05 | foo
001 | 2012-04-23 9:12:07 | foo
001 | 2012-04-23 9:12:09 | foo
001 | 2012-04-23 9:12:11 | barbaz
001 | 2012-04-23 9:12:13 | barbaz
001 | 2012-04-23 9:15:00 | barbaz
001 | 2012-04-23 9:15:01 | barbaz
002 | 2012-04-24 3:41:01 | foo
002 | 2012-04-24 3:41:03 | foo
Run Code Online (Sandbox Code Playgroud)
我想要折叠与前一次运行的时间差小于增量(例如:2秒)的行,并获取开始时间和结束时间,如下所示:
userid | begin | end | product
----------------------------------------------------------
001 | 2012-04-23 9:12:05 …Run Code Online (Sandbox Code Playgroud)