- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个与elasticsearch和cassandra交互很多的对象。但我不知道在哪里实例化我的 Cassandra 和 elasticsearch session 。我应该把它放在我的“代码”中,并将 session 传递到我的函数的参数中,如下所示:
cassandra_cluster = Cluster()
session = cassandra_cluster.connect()
es = Elasticsearch()
class Article:
document_type = "cnn_article"
def __init__(self):
self.author = ""
self.url = ""
...
@classmethod
def from_crawl(cls, url):
obj = cls()
# Launch a crawler and fill the fields and return the object
@classmethod
def from_elasticseacrh(cls, elastic_search_document):
obj = cls()
# Read the response from elasticsearch and return the object
def save_to_cassandra(self):
# Save an object into cassandra
session.execute(.....)
def save_to_elasticsearch(self, index_name, es):
# Save an object into elasticsearch
es.index(index=index_name, ...)
...
article = Article.from_crawl("http://cnn.com/article/blabla")
article.save_to_cassandra(session)
article.save_to_elasticsearch("cnn", es)
或者我应该将 cassandra 和 elasticsearch session 的实例化作为实例变量,如下所示:
class Article:
cassandra_cluster = Cluster()
session = cassandra_cluster.connect()
es = Elasticsearch()
document_type = "cnn_article"
def __init__(self):
self.author = ""
self.url = ""
...
@classmethod
def from_crawl(cls, url):
obj = cls()
# Launch a crawler and fill the fields and return the object
@classmethod
def from_elasticseacrh(cls, elastic_search_document):
obj = cls()
# Read the response from elasticsearch and return the object
def save_to_cassandra(self):
# Save an object into cassandra
session.execute(.....)
def save_to_elasticsearch(self):
# Save an object into elasticsearch
es.index(....)
...
article = Article.from_crawl("http://cnn.com/article/blabla")
article.save_to_cassandra()
article.save_to_elasticsearch()
最佳答案
基于他们的文档和这里的一些示例:http://www.datastax.com/dev/blog/datastax-python-driver-multiprocessing-example-for-improved-bulk-data-throughput
我会采用你的第二种方法。他们提到 session 只是用于关闭连接的上下文管理器,并且他们的查询管理器将它们显示为类属性。
我认为两者都可以,但如果您想对其进行多处理,则使用后一种方法可能会稍微容易一些。
关于python - 面向对象编程Python : Where to instantiate Cassandra and elasticsearch cluster?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42207677/
从 Wildfly 8.2.1.Final 升级到 Wildfly 9.0.1.Final 后,我们开始收到很多警告,如下所示: WARNING [org.jgroups.protocols.TCP]
如果是,在哪里可以找到?!根据this infoq 条目,他们已经开源了。但是现在,他们的网站上没有这样的产品。 最佳答案 本页,http://terracotta.org/dl/oss-downlo
这个问题已经有答案了: 已关闭12 年前。 Possible Duplicates: Difference between clustered and nonclustered index What
我将 H2 数据库用于包含大量时间序列的环境数据。时间序列只是定期(例如每小时一次)记录在数据库中的传感器的测量值。 表中存储的数据: CREATE TABLE hydr (dt timestamp
Cluster 和 MPP super 计算机架构之间有什么区别? 最佳答案 在集群中,每台机器在内存、磁盘等方面都在很大程度上独立于其他机器。它们使用普通网络上的一些变体相互连接。集群主要存在于程序
我正在尝试为 akka 集群构建一个大脑 split 解析器。但是很难模拟某些节点无法从原始集群的其余部分访问并形成自己的集群的场景。 不能通过停止和重启节点来完成,因为新启动的节点不是同一个节点,因
我正在尝试在我的应用程序中使用集群。但是,在导入语句中,我得到“无法解析导入 com.google.maps (clustering.Cluster)”。 此外,在使用 ClusterManager
我想知道 Hive 中 Cluster By 和 CLUSTERED BY 的主要区别是什么。 Cluster By 用于对表进行分桶。并且会用到Hash函数。 CLUSTERED BY 用于在 re
我有3台机器,为redis集群创建了6个节点,我几个月前创建成功了,但现在它掉线了,我尽力修复它,但它不起作用,所以我清理所有数据并重新创建它从零开始,当我使用以下命令创建集群时,它在这里阻塞,等待节
我尝试使用 swarm 和 consul 设置 docker 集群。我有 manager、host1 和 host2。 我在管理器上运行 consul 和 swarm manager 容器。 $ do
如果我不使用 DTW 作为距离度量,那么 tslearn.clustering.TimeSeriesKMeans 和 sklearn.cluster.KMeans 是否等同? 如果不是,谁能告诉我这两
我正在研究 Flink 1.9.1 的 docker/k8s 部署可能性。 我正在阅读/观看 [1][2][3][4]。 目前我们确实认为我们会尝试采用作业集群方法,尽管我们想知道这方面的社区趋势是什
我可以使用一些关于 R 中方法的建议来确定最佳集群数,然后用不同的统计标准描述集群。我是 R 的新手,对聚类分析的统计基础有基本的了解。 确定簇数的方法:在文献中,一种常用的方法是所谓的“肘部准则”,
我有一个查询无法执行,并显示“由于文件组“DEFAULT”中磁盘空间不足,无法为数据库“TEMPDB”分配新页面”。 在排除故障的过程中,我正在检查执行计划。有两个标记为“聚集索引扫描(聚集)”的昂贵
我刚刚下载了 Elasticsearch 发行版并运行了它。 curl 'localhost:9200' { "status" : 200, "name" : "cbs", "clu
我有一个集群,其“cluster_ Purpose”设置为“dev_test”。我想将其更改为“生产”。在文档中找不到任何内容。 最佳答案 回答我自己的问题。这是不可能的。 关于Azure ML :
如何将主聚集索引更改为非聚集索引。 (作为“辅助”表,我想对“标题”表的外键列使用聚集索引。) 这对我不起作用(错误似乎是合理的:) DROP INDEX ClientUsers.PK_ClientU
我注意到,当使用 sklearn.cluster.KMeans 从方法 .cluster_centers_ 获取集群时,集群中心和每个集群的手动计算均值似乎不会给出完全相同的答案。 对于小样本量,差异
我在集群环境中使用 Quartz Scheduler 作为 Spring bean。 我有一些用@NotConcurrent 注释的作业,它们在每个集群中运行一次(即仅在一个节点中,仅在一个线程中)。
Node.js 本身有一个名为 Cluster 的核心模块(引用:http://nodejs.org/docs/v0.8.3/api/cluster.html),Learnboost 发布了一个名为
我是一名优秀的程序员,十分优秀!