小编use*_*214的帖子

Scala/Slick,"等待连接20000ms后超时"错误

下面的代码块一直在抛出错误.

  Timeout after 20000ms of waiting for a connection.","stackTrace":[{"file":"BaseHikariPool.java","line":228,"className":"com.zaxxer.hikari.pool.BaseHikariPool","method":"getConnection"
Run Code Online (Sandbox Code Playgroud)

此外,我的数据库访问看起来太慢,xs.map()的每个元素大约需要1秒.下面,getFutureItem()调用db.run().

xs.map{ x => 
    val item: Future[List[Sometype], List(Tables.myRow)] = getFutureItem(x)         
    Await.valueAfter(item, 100.seconds) match {
        case Some(i) => i
        case None => println("Timeout getting items after 100 seconds")
    }
}
Run Code Online (Sandbox Code Playgroud)

Slick会在每次迭代"x"值时记录此信息:

[akka.actor.default-dispatcher-3] [akka://user/IO-HTTP/listener-0/24] Connection was PeerClosed, awaiting TcpConnection termination...
[akka.actor.default-dispatcher-3] [akka://user/IO-HTTP/listener-0/24] TcpConnection terminated, stopping
[akka.actor.default-dispatcher-3] [akka://system/IO-TCP/selectors/$a/0] New connection accepted
[akka.actor.default-dispatcher-7] [akka://user/IO-HTTP/listener-0/25] Dispatching POST request to http://localhost:8080/progress to handler Actor[akka://system/IO-TCP/selectors/$a/26#-934408297]
Run Code Online (Sandbox Code Playgroud)

我的配置:

"com.zaxxer" % "HikariCP" % "2.3.2"

default_db {
  url = ...
  user = …
Run Code Online (Sandbox Code Playgroud)

mysql scala sbt slick hikaricp

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

Sbt-assembly未解决的依赖,Scala

我正在安装Sbt-Assembly,但现在卡住了.

Sbt Version (from 'sbt about'): 0.13.8
Current project is built against scala 2.11.6
Sbt, sbt plugins, and build definitions are using Scala 2.10.4
Run Code Online (Sandbox Code Playgroud)

项目/ assembly.sbt

   addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.0")
   resolvers += Resolver.url("bintray-sbt-plugins", url("http://dl.bintray.com/sbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)
Run Code Online (Sandbox Code Playgroud)

build.sbt

   scalaVersion in ThisBuild := "2.11.6"
Run Code Online (Sandbox Code Playgroud)

〜/名.bst/0.13/global.sbt

   scalaVersion := "2.11.6"
Run Code Online (Sandbox Code Playgroud)

我意识到sbt-assembly是针对scala 2.10的.如果我将我的项目更改为scala 2.10,我有2.10的新不可用依赖项,这是不可取的.有没有办法配置我的项目只使用2.10组装插件?

  ==== bintray-sbt-plugins: tried
  http://dl.bintray.com/sbt/sbt-plugin-releases/com.eed3si9n/sbt-assembly/scala_2.11/sbt_0.13/0.14.0/ivys/ivy.xml

  ::::::::::::::::::::::::::::::::::::::::::::::
  ::          UNRESOLVED DEPENDENCIES         ::
  ::::::::::::::::::::::::::::::::::::::::::::::
  :: com.eed3si9n#sbt-assembly;0.14.0: not found
  ::::::::::::::::::::::::::::::::::::::::::::::

  Note: Some unresolved dependencies have extra attributes.  
  Check that these dependencies exist with the requested attributes.

      com.eed3si9n:sbt-assembly:0.14.0 …
Run Code Online (Sandbox Code Playgroud)

plugins scala sbt sbt-assembly

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

这是解决LuaJit与Torch"没有足够的内存"的实用方法吗?

StanfordNLP的TreeLSTM与具有> 30K实例的数据集一起使用时,会导致LuaJit错误地显示"Not Enough Memory".我正在使用LuaJit Data Structures解决这个问题.为了将数据集放在lua堆之外,需要将树放在LDS.Vector中.

由于LDS.Vector包含cdata,第一步是将Tree类型转换为cdata对象:

local ffi = require('ffi')

ffi.cdef([[
typedef struct CTree {
   struct CTree* parent;
   int num_children;
   struct CTree* children [25];
   int idx;
   int gold_label;
   int leaf_idx;
} CTree;
]])
Run Code Online (Sandbox Code Playgroud)

在read_data.lua中还需要进行一些小的更改来处理新的cdata CTree类型.到目前为止,使用LDS似乎是解决内存限制的合理方法; 但是,CTree需要一个名为"composer"的字段.

Composer的类型为nn.gModule.继续使用此解决方案将涉及将nn.gModule的typedef创建为cdata,包括为其成员创建typedef.在继续之前,这似乎是正确的方向吗?有没有人遇到过这个问题?

c lua stanford-nlp torch lstm

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

这个(简单)代码的时间复杂度是多少?

我试图找出下面代码的运行时间,如果列表是一个arraylist,如果它是一个链表.我很感激任何建议!

数组:我认为删除操作是O(n),循环是N/2,所以O(n ^ 2)

LinkedList:只有引用更改,因此删除的循环时间和循环的N/2,所以O(n)

int halfSize = lst.size() / 2;

for (int i = 0; i < halfSize; i++){
    lst.remove(0);
}
Run Code Online (Sandbox Code Playgroud)

java time complexity-theory

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

光滑的准备好的声明

我正在使用 slick 3.0.0-M1 和 "com.zaxxer" % "HikariCP" % "2.4.3"

Slick 正在为每个查询(由日志记录表明)准备一条语句,这是不好的:

"Preparing statement: select * from ..." 
Run Code Online (Sandbox Code Playgroud)

我的配置告诉 Slick / Hikari 缓存准备好的语句:

myDB {
  url = "jdbc:mysql://...
  user = ...
  ...
  connectionPool = HikariCP
  queueSize = 50000
  maxConnections = 50
  properties.cachePrepStmts = true
  properties.prepStmtCacheSize = 20000
  properties.prepStmtCacheSqlLimit = 100000
}
Run Code Online (Sandbox Code Playgroud)

日志似乎表明这些属性已被读取:

configuration:
...
dataSourceName..................
dataSourceClassName.............
dataSourceProperties............
    {password=<masked>, 
     prepStmtCacheSqlLimit=100000, 
     cachePrepStmts=true, 
     prepStmtCacheSize=20000}
maximumPoolSize.................50
poolName..........................
Run Code Online (Sandbox Code Playgroud)

db 对象被实例化并在测试中使用:

val db = Database.forConfig("", config.getConfig("myDB"))
val qTemplate = StaticQuery[(Int), MyRow] + "select * from table_name where …
Run Code Online (Sandbox Code Playgroud)

mysql scala slick hikaricp

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

如何从 Tensorflow 张量中获取第二个最大值?

现在,我的函数使用 argmax:

 p = tf.stop_gradient(tf.argmax(prev, 1))
Run Code Online (Sandbox Code Playgroud)

我曾尝试使用以下方法,但 dimn 不兼容:

 p = tf.stop_gradient(tf.nn.top_k(prev, 2)[1])

 raise ValueError("Linear is expecting 2D arguments: %s" % str(shapes))
 ValueError: Linear is expecting 2D arguments: [[None, 2, 1024], [None, 1024]]
Run Code Online (Sandbox Code Playgroud)

我的 TF 版本可能是 0.5,这就是 top_k 只有 2 个参数的原因。

python tensorflow

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

停止演员里面的Akka演员

我有一个演员,打算做一个长期运行的工作,不再收到任何消息:

    actor {
       def receieve => longRunningJob()
    }
Run Code Online (Sandbox Code Playgroud)

如何调试这个演员的杀戮?

我按照文档说"在一个actor中,你可以通过使用上下文引用来阻止一个子actor:"

    context.stop(childActor)
Run Code Online (Sandbox Code Playgroud)

我还尝试向孩子发送Kill消息,Stop消息和PoisonPill消息,但是在长时间运行的作业中间没有任何阻止它.

java scala actor akka

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

Convert Binary to Decimal in MIPS, Assembly MARS

I am trying to convert binary to decimal in the MIPS language, using the MARS simulator. The program accepts a binary number, and then does the conversion, by multiplying (shift left by the number's place $t9). Another way of saying that is multiplying each 1 digit by 2 raised to the power of the place, and summing that result.

I do not have a very good understanding of how values are stored and communicated between ascii, decimal, and the problem …

assembly base-conversion mips mars-simulator

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

未解决的依赖性SBT,标量

我收到此编译错误:

[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: com.typesafe.sbt#sbt-scalariform;1.3.0: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn] 
[warn]  Note: Some unresolved dependencies have extra attributes.  Check that these dependencies exist with the requested attributes.
[warn]      com.typesafe.sbt:sbt-scalariform:1.3.0 (scalaVersion=2.11, sbtVersion=0.13)
[warn] 
Run Code Online (Sandbox Code Playgroud)

在我的项目的根目录中,我有一个build.sbt文件:

   scalaVersion in ThisBuild := "2.11.6"
Run Code Online (Sandbox Code Playgroud)

我还有一个core/build.sbt文件,其中包含多个解析器,libraryDependencies和排除项.

project/plugins.sbt:

   addSbtPlugin(...)
   resolvers += "Typesafe Public Repo" at "http://repo.typesafe.com/typesafe/releases"
   resolvers += "JBoss Repository" at "http://repository.jboss.org/nexus/content/groups/public//"
Run Code Online (Sandbox Code Playgroud)

〜/名.bst/0.13/global.sbt

   scalaVersion := "2.11.6"
Run Code Online (Sandbox Code Playgroud)

scala ivy sbt typesafe-stack scalariform

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

用于从char类型中减去的简单C语法,小写

我得到一个段.当我尝试从char类型中减去32时(尝试在C中转换为小写而没有tolower())我已经完成了错误.我已经完成了前提条件搜索相关的Q/A线程而没有运气.我也试过'a' - 'A'对于转换值,'32',将其转换为(char*)以及我能想到的任何其他内容.例如:

char* s1 = "Bob";

if (*s1 >= 97 && *s1 <= 122)
     *s1 -= 32;
}
Run Code Online (Sandbox Code Playgroud)

有什么建议?

编辑:

在按照下面的帮助后,我仍然得到错误.(对于此示例,我只是尝试将名称的第一个字母更改为小写.)以下是我正在尝试的内容:

 char* s1 = "Bob";
 printf("\n %s before", s1);

 // below I call my string length function to get actual size instead of 100
 char* temp = malloc(100);   
 temp = s1;

 if (*temp >= 'A' && *temp <= 'Z'){
    *temp -= 32;
 }

 printf("\n%s after", temp);
 free(temp);
Run Code Online (Sandbox Code Playgroud)

另外,为什么我需要为已经在内存中的字符串分配内存?

c syntax lowercase char

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