我有一个相当大的项目(15个以上的子项目),它有很多外部依赖项.当我改变一行build.sbt然后点击刷新时,IntelliJ会在很长一段时间内(30多分钟)继续解决各种依赖关系.
应该这么慢吗?从命令行使用sbt不会超过30秒左右.
我在用 -
Macbook pro mid 2015 with 16 GB ram
IntelliJ IDEA Ultimate 2017.2.5
sbt 0.13.13
scala 2.11.11
Run Code Online (Sandbox Code Playgroud) #include <stdio.h>
#include <time.h>
#define N 32768
char a[N][N];
char b[N][N];
int main() {
int i, j;
printf("address of a[%d][%d] = %p\n", N, N, &a[N][N]);
printf("address of b[%5d][%5d] = %p\n", 0, 0, &b[0][0]);
clock_t start = clock();
for (j = 0; j < N; j++)
for (i = 0; i < N; i++)
a[i][j] = b[i][j];
clock_t end = clock();
float seconds = (float)(end - start) / CLOCKS_PER_SEC;
printf("time taken: %f secs\n", seconds);
start = clock();
for (i = 0; …Run Code Online (Sandbox Code Playgroud) 我有一个数据流流作业,将 Pub/Sub 订阅作为无限源。我想知道数据流在哪个阶段确认传入的发布/订阅消息。在我看来,如果在数据流管道的任何阶段抛出异常,消息就会丢失。
此外,我想知道如何使用发布/订阅无界源编写数据流管道以在失败时进行消息检索的最佳实践。谢谢!
dataflow google-cloud-platform google-cloud-pubsub apache-beam
我有两个我正在尝试的表UNION。列idintable1的类型为STRING。我没有在列table2,所以我写SELECT NULL AS id FROM table2但BigQuery认为,列id在table2类型为INT64。
我收到此错误 -
Column 2 in UNION ALL has incompatible types: STRING, INT64。
如果我改写,SELECT "" AS id FROM table2则查询有效。
我在Django REST框架中具有以下自定义异常处理程序。
class ErrorMessage:
def __init__(self, message):
self.message = message
def insta_exception_handler(exc, context):
response = {}
if isinstance(exc, ValidationError):
response['success'] = False
response['data'] = ErrorMessage("Validation error")
return Response(response)
Run Code Online (Sandbox Code Playgroud)
我想要一个JSON输出,如下所示
"success":false,
"data":{ "message" : "Validation error" }
Run Code Online (Sandbox Code Playgroud)
但是我得到了错误TypeError: Object of type 'ErrorMessage' is not JSON serializable。为什么像ErrorMessage上面这样简单的类不能JSON可序列化?我怎么解决这个问题?
如何使用CircleCI并行运行并行gradle测试?我有一个包含多个模块的项目,我希望CircleCI能够运行一个不同处理器的模块.目前,当我指定并行性时,它会在所有处理器上运行所有测试.
我遵循 Google Pub/Sub 快速入门指南。当我尝试运行时,gcloud components install beta出现以下错误。
ERROR: (gcloud.components.install) Permission denied:
[/usr/local/google-cloud-sdk.staging]
Ensure you have the permissions to access the file and that the file is not in use.
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?
我正在尝试使用 Google 云 Pub/Sub 模拟器来测试我的 scala 应用程序。文件说明如下 -
\n\n\n\n\n运行 env-init 命令确定并设置模拟器使用的环境变量。请注意,按照这些说明操作后,代码中的 Google Cloud Pub/Sub 客户端库将调用在本地实例中运行的 API,而不是生产 API。
\n
但是,当我发布消息或创建主题时,它会在云中执行,而不是在本地模拟器上执行。println(s"ENV: ${sys.env("PUBSUB_EMULATOR_HOST")}")我已确认使用which prints正确设置了环境变量ENV: localhost:8085。
我尝试强制库使用我的本地设置,如下所示
\n\nval settings = TopicAdminSettings.defaultBuilder()\n .setChannelProvider(InstantiatingChannelProvider.newBuilder()\n .setEndpoint("localhost:8085")\n .setCredentialsProvider(TopicAdminSettings.defaultCredentialsProviderBuilder().build())\n .build())\n .build()\n\nval topicAdminClient = TopicAdminClient.create(settings)\ntopicAdminClient.createTopic(topicName)\nRun Code Online (Sandbox Code Playgroud)\n\n这样我成功地将请求发送到我的本地设置,但这会导致以下错误 -
\n\n[pubsub] 6 14, 2017 2:49:11 \xe5\x8d\x88\xe5\xbe\x8c io.gapi.emulators.grpc.GrpcServer$3 operationComplete\n[pubsub] INFO: Adding handler(s) to newly registered Channel.\n[pubsub] 6 14, 2017 2:49:11 \xe5\x8d\x88\xe5\xbe\x8cio.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\n[pubsub] INFO: Detected non-HTTP/2 connection.\n[pubsub] 6 14, 2017 2:49:11 \xe5\x8d\x88\xe5\xbe\x8c …Run Code Online (Sandbox Code Playgroud) 标题几乎概括了一切。无论我将窗口宽度设置得有多短,GroupByKey在 DirectRunner 上运行作业时都不会触发。使用 DataflowRunner 时,一切都按预期工作。
命令式编程中有一个有用的模式,即,将双链表与哈希表结合使用以在链表中进行恒定时间查找。
这种模式的一种应用是在LRU缓存中。双链表的头部将包含高速缓存中最近最少使用的条目,而双链表的最后一个元素将包含最近使用的条目。哈希表中的关键字是条目的关键字,值是指向与关键字/条目相对应的链表中节点的指针。当在缓存中查询条目时,哈希表将用于指向其在链表中的节点,然后将该节点从其在链表中的当前位置删除,并放置在链表的末尾-list使其成为最近使用的条目。为了驱逐,我们仅从链接列表的开头删除条目,因为它们是最近最少使用的条目。查找和逐出操作都将花费固定时间。
我可以考虑使用两个TreeMap在Haskell中实现此目标,并且我知道时间复杂度将为O(log n)。但是我有点不舒服,因为时间复杂度的恒定因素似乎有点高。具体来说,要执行查找,首先需要检查条目是否存在并保存其值,然后首先需要从LRU映射中删除它,然后使用新的密钥重新插入。这意味着每次查找将导致遍历根节点三遍。
在Haskell中有更好的方法吗?
我有以下新类型声明。它包装了Monad堆栈变压器,堆叠了一些标准的mtl monad,例如Reader和Except。
newtype TrxDbFileBased f a = TrxDbFileBased {
unTrxDbFileBased :: ExceptT TrxDbError (ReaderT TrxDbFileBasedEnv f) a
} deriving (
Functor
, Applicative
, Monad
, MonadError TrxDbError
, MonadReader TrxDbFileBasedEnv
, MonadIO
, MonadTrans
)
data TrxDbFileBasedEnv = TrxDbFileBasedEnv {
workingDirectory :: FilePath
} deriving (Show)
data TrxDbError = TrxDbErrorIO TrxDbFileBasedEnv IOException
| TrxDbErrorStr TrxDbFileBasedEnv String
deriving (Show)
Run Code Online (Sandbox Code Playgroud)
我希望此新类型是的实例,MonadTrans但出现以下错误。
• Can't make a derived instance of ‘MonadTrans TrxDbFileBased’
(even with cunning GeneralizedNewtypeDeriving):
cannot eta-reduce the representation type …Run Code Online (Sandbox Code Playgroud)