nosql

Query MongoDB for ordered distinct values

折月煮酒 提交于 2019-12-07 01:06:03
问题 I am using Morphia Java driver for querying a MongoDB that contains a collection of the following form: MyCollection { TypeA TypeB } I want to retrieve all distinct values of TypeB which I do using the following code: DBCollection myCol = getDatastore().getCollection(MyCollection.class); List typeBs = myCol.distinct("TypeB"); Above code works as expected, but list of distinct values is of course not sorted. I have experimented with the following code: DBCollection myCol = getDatastore()

Nosql many-to-many

蹲街弑〆低调 提交于 2019-12-07 01:00:51
问题 What is the accepted pattern for handling many-to-many relationships in a document database design? 回答1: How you want to model the many-to-many will depend on what kind of queries you want to ask, how you want to update the data, etc... Say we have foos related to bars in a many to many fashion. You could model a foo as { 'bars': ['bar1', 'bar2', 'bar3'] } and model a bar as { 'foos': ['foo_x', 'foo_y', 'foo_z'] } Or you could model the graph or relations between foo and bar as individual

Best way to store huge log data

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-07 00:16:44
I need an advice on optimal approach to store statistical data. There is a project on Django, which has a database (mysql) of 30 000 online games. Each game has three statistical parameters: number of views, number of plays, number of likes Now I need to store historical data for these three parameters on a daily basis, so I was thinking on creating a single database which will has five columns: gameid, number of views, plays, likes, date (day-month-year data). So in the end, every day for every game will be logged in one row, so in one day this table will have 30000 rows, in 10 days it will

How to query Cassandra by date range

主宰稳场 提交于 2019-12-06 23:32:00
问题 I have a Cassandra ColumnFamily (0.6.4) that will have new entries from users. I'd like to query Cassandra for those new entries so that I can process that data in another system. My sense was that I could use a TimeUUIDType as the key for my entry, and then query on a KeyRange that starts either with "" as the startKey, or whatever the lastStartKey was. Is this the correct method? How does get_range_slice actually create a range? Doesn't it have to know the data type of the key? There's no

How does Apache Cassandra do aggregate operations?

﹥>﹥吖頭↗ 提交于 2019-12-06 22:09:50
问题 I'm fairly new to Apache Cassandra and nosql in general. In SQL I can do aggregate operations like: SELECT country, sum(age) / count(*) AS averageAge FROM people GROUP BY country; This is nice because it is calculated within the DB, rather than having to move every row in the 'people' table into the client layer to do the calculation. Is this possible in Apache Cassandra? How? 回答1: Cassandra is primarily a mechanism that supports fast writes and look-ups. There is no support for calculations

大数据处理思路

假如想象 提交于 2019-12-06 22:02:34
1.处理优化:优化sql、考虑使用临时表或中间表 2.数据库优化:合理构建索引、合理设计表结构、数据库集群 3.分流:用和不用分开、常用和不常用分开;对数据库存放的数据分库分表分区;对文件存放的数据拆文件、考虑分批处理;原则就是尽量减少每次操作的数据的技术; 4.缓存技术:读多写少用缓存 5.合理使用nosql:mongodb、redis、memched、hbase等 6.分布式大数据方案:hadoop、spark、storm等 nosql数据库的种类:临时性键值存储(Memcached Redis)、永久性键值存储(ROMA Redis)、面向文档存储(mongoDB couchDB)、面向列存储(Casssandra HBase) 来源: https://www.cnblogs.com/hzq3554055/p/11999765.html

NoSql的学习

风流意气都作罢 提交于 2019-12-06 20:28:30
1,Node.js的概述: - Node是对ES标准一个实现,Node也是一个JS引擎 ES是国际标准化组织发布的浏览器脚本语言的标准,全名:ECMAScript。 ES6是一个历史名词,泛指ES5.1以后的JavaScript的下一代标准。 - 通过Node可以使js代码在服务器端执行 - Node仅仅对ES标准进行了实现,所以在Node中不包含DOM 和 BOM - Node中可以使用所有的内建对象 String Number Boolean Math Date RegExp Function Object Array 而BOM和DOM都不能使用 但是可以使用 console 也可以使用定时器(setTimeout() setInterval()) - Node可以在后台来编写服务器 Node编写服务器都是单线程的服务器 - 进程 - 进程就是一个一个的工作计划(工厂中的车间) - 线程 - 线程是计算机最小的运算单位(工厂中的工人) 线程是干活的 - 传统的服务器都是多线程的 - 每进来一个请求,就创建一个线程去处理请求 - Node的服务器单线程的 - Node处理请求时是单线程,但是在后台拥有一个I/O线程池 - node是一款对ES标准实现的JS引擎 - 通过node可以使js在服务器中运行 - node就是一款使用js编写的web服务器 - node底层是使用c+

Bulk update/upsert in MongoDB?

三世轮回 提交于 2019-12-06 20:12:30
问题 Is it possible to do bulk update/upsert (not insert) in MongoDB? If yes, please point me to any docs related to this? Thanks 回答1: You can use the command line program mongoimport it should be in your MongoDB bin dir ... There are two options you'll want to look into to use upsert ... --upsert insert or update objects that already exist --upsertFields arg comma-separated fields for the query part of the upsert. You should make sure this is indexed More info here: http://www.mongodb.org/display

When I remove rows in Cassandra I delete only columns not row keys

只谈情不闲聊 提交于 2019-12-06 20:06:08
问题 If I delete every keys in a ColumnFamily in a Cassandra db using remove(key) , then if I use get_range_slices , rows are still there but without columns. How could I remove entire rows? 回答1: Just been having the same issue and I found that: This has been fixed in 0.7 (https://issues.apache.org/jira/browse/CASSANDRA-1027). And backported to 0.6.3 This is also relevant: https://issues.apache.org/jira/browse/CASSANDRA-494 回答2: Why do deleted keys show up during range scans? Because get_range

NoSQL Injection? (PHP->phpcassa->Cassandra)

那年仲夏 提交于 2019-12-06 19:50:01
问题 Anyone familiar enough with the Cassandra engine (via PHP using phpcassa lib) to know offhand whether there's a corollary to the sql-injection attack vector? If so, has anyone taken a stab at establishing best practices to thwart them? If not, would anyone like to ; ) 回答1: No. The Thrift layer used by phpcassa is an rpc framework, not based on string parsing. 回答2: An update - Cassandra v0.8 introduced CQL, which might have brought with it the possibility of injection attacks. However: