When working with enterprise applications, you want to have the same user experience that you know from for instance office applications and browsers. People know how to use the features that can be found in browsers such as bookmarking, favorites, and working with tabs. The search mechanism provided by Google, that uses suggestions based on the text typed by the user, is so common that people expect this in every application. And there are more of these UI patterns. In this session, you will learn how to implement some of the common UI patterns in your ADF application.
Aggregation pipeline has been able to power your analysis of data since version 2.2. In 4.2 we added more power and now you can use it for more powerful queries, updates, and outputting your data to existing collections. Come hear how you can do everything with the pipeline, including single-view, ETL, data roll-ups and materialized views.
Rapid and Scalable Development with MongoDB, PyMongo, and MingRick Copeland
This intermediate-level talk will teach you techniques using the popular NoSQL database MongoDB and the Python library Ming to write maintainable, high-performance, and scalable applications. We will cover everything you need to become an effective Ming/MongoDB developer from basic PyMongo queries to high-level object-document mapping setups in Ming.
When working with enterprise applications, you want to have the same user experience that you know from for instance office applications and browsers. People know how to use the features that can be found in browsers such as bookmarking, favorites, and working with tabs. The search mechanism provided by Google, that uses suggestions based on the text typed by the user, is so common that people expect this in every application. And there are more of these UI patterns. In this session, you will learn how to implement some of the common UI patterns in your ADF application.
Aggregation pipeline has been able to power your analysis of data since version 2.2. In 4.2 we added more power and now you can use it for more powerful queries, updates, and outputting your data to existing collections. Come hear how you can do everything with the pipeline, including single-view, ETL, data roll-ups and materialized views.
Rapid and Scalable Development with MongoDB, PyMongo, and MingRick Copeland
This intermediate-level talk will teach you techniques using the popular NoSQL database MongoDB and the Python library Ming to write maintainable, high-performance, and scalable applications. We will cover everything you need to become an effective Ming/MongoDB developer from basic PyMongo queries to high-level object-document mapping setups in Ming.
MongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDBMongoDB
Query performance can either be a constant headache or the unsung hero of an application. MongoDB provides extremely powerful querying capabilities when used properly. As a senior member of the support team I will share more common mistakes observed and some tips and tricks to avoiding them.
MongoDB .local Munich 2019: Tips and Tricks++ for Querying and Indexing MongoDBMongoDB
Query performance can either be a constant headache or the unsung hero of an application. MongoDB provides extremely powerful querying capabilities when used properly. As a member of the solutions architecture team I will share more common mistakes observed and some tips and tricks to avoiding them.
This talk is focused on tuning analysing and optimizing MongoDB query and index with the use of Database Profiler and "explain()" function.
Also, performance of database can also be impacted by configuring the underline ( Linux ) OS with some recommended settings which do not come by default.
JavaScript Objects and OOP Programming with JavaScriptLaurence Svekis ✔
Get this Course
https://www.udemy.com/javascript-objects-oop/?couponCode=SLIDESHARE
Use objects to create amazing things with JavaScript power up your applications OOP JavaScript coding
In a real life almost any project deals with the
tree structures. Different kinds of taxonomies,
site structures etc require modeling of
hierarchy relations.
Typical approaches used
● Model Tree Structures with Child References
● Model Tree Structures with Parent References
● Model Tree Structures with an Array of Ancestors
● Model Tree Structures with Materialized Paths
● Model Tree Structures with Nested Sets
MongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDBMongoDB
Query performance can either be a constant headache or the unsung hero of an application. MongoDB provides extremely powerful querying capabilities when used properly. As a senior member of the support team I will share more common mistakes observed and some tips and tricks to avoiding them.
MongoDB .local Munich 2019: Tips and Tricks++ for Querying and Indexing MongoDBMongoDB
Query performance can either be a constant headache or the unsung hero of an application. MongoDB provides extremely powerful querying capabilities when used properly. As a member of the solutions architecture team I will share more common mistakes observed and some tips and tricks to avoiding them.
This talk is focused on tuning analysing and optimizing MongoDB query and index with the use of Database Profiler and "explain()" function.
Also, performance of database can also be impacted by configuring the underline ( Linux ) OS with some recommended settings which do not come by default.
JavaScript Objects and OOP Programming with JavaScriptLaurence Svekis ✔
Get this Course
https://www.udemy.com/javascript-objects-oop/?couponCode=SLIDESHARE
Use objects to create amazing things with JavaScript power up your applications OOP JavaScript coding
In a real life almost any project deals with the
tree structures. Different kinds of taxonomies,
site structures etc require modeling of
hierarchy relations.
Typical approaches used
● Model Tree Structures with Child References
● Model Tree Structures with Parent References
● Model Tree Structures with an Array of Ancestors
● Model Tree Structures with Materialized Paths
● Model Tree Structures with Nested Sets
URLs are not meant to be given to the clients but they should be discovered through the interaction with the server inside the representation of the resources. But thinking about URLs it's like thinking about names and relations between your domain resources. Creating a good URL grammar helps a good resource design. A good resource design is more stable and more extensible.
Node.js is one of those technologies that should not exist. Definitely, theoretically, is not supposed to have this kind of success. But like the bumblebee he don't know he can't and so it goes :-)
Back to Basics: My First MongoDB ApplicationMongoDB
This Back to Basics webinar series will introduce you to NoSQL and the MongoDB database. You will find out what MongoDB is, why you would use it, and what you would use it for.
Map/Confused? A practical approach to Map/Reduce with MongoDBUwe Printz
Talk given at MongoDb Munich on 16.10.2012 about the different approaches in MongoDB for using the Map/Reduce algorithm. The talk compares the performance of built-in MongoDB Map/Reduce, group(), aggregate(), find() and the MongoDB-Hadoop Adapter using a practical use case.
Building a Scalable Inbox System with MongoDB and Javaantoinegirbal
Many user-facing applications present some kind of news feed/inbox system. You can think of Facebook, Twitter, or Gmail as different types of inboxes where the user can see data of interest, sorted by time, popularity, or other parameter. A scalable inbox is a difficult problem to solve: for millions of users, varied data from many sources must be sorted and presented within milliseconds. Different strategies can be used: scatter-gather, fan-out writes, and so on. This session presents an actual application developed by 10gen in Java, using MongoDB. This application is open source and is intended to show the reference implementation of several strategies to tackle this common challenge. The presentation also introduces many MongoDB concepts.
Relational databases are central to web applications, but they have also been the primary source of pain when it comes to scale and performance. Recently, non-relational databases (also referred to as NoSQL) have arrived on the scene. This session explains not only what MongoDB is and how it works, but when and how to gain the most benefit.
Back to Basics, webinar 2: La tua prima applicazione MongoDBMongoDB
Questo è il secondo webinar della serie Back to Basics che ti offrirà un'introduzione al database MongoDB. In questo webinar ti dimostreremo come creare un'applicazione base per il blogging in MongoDB.
What went wrong for my clients in the past 6 years trying to implement Microservice Architectures? This is a retrospective, a list of things we must to avoid to gainable with this kind of software architecture.
Not so many years have passed since we started programming computers and even less since programming computers has been recognised as a profession. Even still, so many things depend on the quality of our work. What does it mean to be professional? What are we expected to do? Are we up for the task? I will talk about my journey of becoming the programmer of my dreams, the obstacles I've faced and the strategies that I've applied to overcome them
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on the notifications, alerts, and approval requests using Slack for Bonterra Impact Management. The solutions covered in this webinar can also be deployed for Microsoft Teams.
Interested in deploying notification automations for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
Generating a custom Ruby SDK for your web service or Rails API using Smithyg2nightmarescribd
Have you ever wanted a Ruby client API to communicate with your web service? Smithy is a protocol-agnostic language for defining services and SDKs. Smithy Ruby is an implementation of Smithy that generates a Ruby SDK using a Smithy model. In this talk, we will explore Smithy and Smithy Ruby to learn how to generate custom feature-rich SDKs that can communicate with any web service, such as a Rails JSON API.
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 3. In this session, we will cover desktop automation along with UI automation.
Topics covered:
UI automation Introduction,
UI automation Sample
Desktop automation flow
Pradeep Chinnala, Senior Consultant Automation Developer @WonderBotz and UiPath MVP
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
30. conventions are fun to play with
(list of tags per day)
> db.user_scores.find(
{"_id": /^4d873ce631f238241d00000d-‐day-‐20091106-‐/}, {"_id": 1}
).map(function(document) {
return document._id.replace(
"4d873ce631f238241d00000d-‐day-‐20091106-‐", ""
)
})
[
"advertising",
"art",
"artist",
"blogging",
"culture",
"html",
"illustration",
"information",
...
]
31. conventions are fun to play with
(anchored regexp uses indexes)
> db.user_scores.find(
{"_id": /^4d873ce631f238241d00000d-‐day-‐20091106-‐/}, {"_id": 1}
).explain()
{
"cursor" : "BtreeCursor _id_ multi",
"nscanned" : 15,
"nscannedObjects" : 15,
"n" : 15,
"millis" : 0,
"indexBounds" : {
"_id" : [
[
"4d873ce631f238241d00000d-‐day-‐20091106-‐",
"4d873ce631f238241d00000d-‐day-‐20091106."
],
[
/^4d873ce631f238241d00000d-‐day-‐20091106-‐/,
/^4d873ce631f238241d00000d-‐day-‐20091106-‐/
]
]
32. conventions are fun to play with
(anchored regexp uses indexes)
> db.user_scores.find(
{"_id": /4d873ce631f238241d00000d-‐day-‐20091106-‐/}, {"_id": 1}
).explain()
{
"cursor" : "BtreeCursor _id_ multi",
"nscanned" : 109349,
"nscannedObjects" : 15,
"n" : 15,
"millis" : 217,
"indexBounds" : {
"_id" : [
...
]
}
}
33. query & use “group”
design method to
do small
computations
without
fetching
related
documents
34. group to compute data in mongo
(inject client side)
days = [ 20091110, 20091111, 20091112 ]
scores_id = %r{^4d87d00931f2380c7700000d-day-(#{days.join("|")})$}
scores = db["user_scores"].find(:_id => scores_id)
pomodori = scores.inject(0) do |pomodori, scores|
pomodori + scores["pomodori"]
end
puts "Pomodori in days #{days.join(",")}: #{pomodori}"
35. group to compute data in mongo
(inject client side)
days = [ 20091110, 20091111, 20091112 ]
scores_id = %r{^4d87d00931f2380c7700000d-day-(#{days.join("|")})$}
scores = db["user_scores"].find(:_id => scores_id)
pomodori = scores.inject(0) do |pomodori, scores|
$ ruby src/inject_for_reduce.rb
pomodori + scores["pomodori"]
Pomodori in days 20091110,20091111,20091112: 36
end
puts "Pomodori in days #{days.join(",")}: #{pomodori}"
36. group to compute data in mongo
(group server side)
days = [ 20091110, 20091111, 20091112 ]
scores_id = %r{^4d87d00931f2380c7700000d-day-(#{days.join("|")})$}
result = db["user_scores"].group(
:cond => { :_id => scores_id },
:initial => { :pomodori => 0 },
:reduce => <<-EOF
function(document, result) {
result.pomodori += document.pomodori
}
EOF
)
puts "Pomodori in days #{days.join(",")}: #{result.first["pomodori"]}"
37. group to compute data in mongo
(group server side)
days = [ 20091110, 20091111, 20091112 ]
scores_id = %r{^4d87d00931f2380c7700000d-day-(#{days.join("|")})$}
result = db["user_scores"].group(
:cond => { :_id => scores_id },
:initial => { :pomodori => 0 },
:reduce => <<-EOF $ ruby src/group_for_reduce.rb
Pomodori in days 20091110,20091111,20091112: 36
function(document, result) {
result.pomodori += document.pomodori
}
EOF
)
puts "Pomodori in days #{days.join(",")}: #{result.first["pomodori"]}"
38. group to compute data in mongo
(ex. sum pomodori by tag “ruby”)
result = db["user_scores"].group(
:cond => {
:_id => /^4d87d00931f2380c7700000d-day-d{8}-ruby$/
},
:initial => { :pomodori => 0, :days => 0 },
:reduce => <<-EOF
function(document, result) {
result.days += 1
result.pomodori += document.pomodori
}
EOF
).first
puts "In #{result["days"]} days, #{result["pomodori"]} done for ruby"
39. group to compute data in mongo
(ex. sum pomodori by tag “ruby”)
result = db["user_scores"].group(
:cond => {
:_id => /^4d87d00931f2380c7700000d-day-d{8}-ruby$/
},
:initial => { :pomodori => 0, :days => 0 },
:reduce => <<-EOF
function(document, result) {
$ ruby src/group_for_ruby_tag.rb
In 43 days, 45 pomodori
result.days += 1
result.pomodori += document.pomodori
}
EOF
).first
puts "In #{result["days"]} days, #{result["pomodori"]} pomodori"
40. group to compute data in mongo
(ex. sum pomodori by tag “ruby”)
> db.user_scores.find({
"_id": /^4d87d00931f2380c7700000d-‐day-‐d{8}-‐ruby$/
}).explain()
{
"cursor" : "BtreeCursor _id_ multi",
"nscanned" : 43,
"nscannedObjects" : 43,
"n" : 43,
"millis" : 3,
"indexBounds" : {
"_id" : [...]
}
}
41. query &
design create indexes
on arrays to
create local
reverse
indexes in
documents
42. reverse index in place
(an array could be indexed)
> db.tasks.find({ "tags": { $in: [ "nosqlday" ] } })
{ "_id" : ObjectId("4d7de446175ca8243d000004"),
"tags" : [ "nosqlday" ],
"description" : "#nosqlday keynote",
"is_recurrent" : false,
"estimated" : 0,
"worked_in" : [
"Mon Mar 14 2011 00:00:00 GMT+0100 (CET)",
"Tue Mar 15 2011 00:00:00 GMT+0100 (CET)"
],
"done_at" : "Tue Mar 15 2011 13:05:03 GMT+0100 (CET)",
"todo_at" : null,
"created_at" : "Mon Mar 14 2011 10:47:50 GMT+0100 (CET)",
"updated_at" : "Tue Mar 15 2011 13:05:03 GMT+0100 (CET)",
"keywords": [ "nosqldai", "keynot" ],
"user_id": ObjectId("4d53996c137ce423ff000001"),
"annotations" : [ ]
}
43. reverse index in place
(an array could be indexed)
> db.tasks.getIndexes()
[
{
"name" : "_id_",
"ns" : "app435386.tasks",
"key" : {
"_id" : 1
}
},
{
"name" : "tags_1",
"ns" : "app435386.tasks",
"key" : {
"tags" : 1
},
"unique" : false
},
...
]
44. reverse index in place
(container for deduced data, array)
db["orders"].insert({
:placed_at => [
now.strftime("%Y"), # year: "2011"
now.strftime("%Y%m"), # month: "201103"
now.strftime("%Yw%U"), # week: "2011w11"
now.strftime("%Y%m%d") # day: "20110316"
],
:user_id => user,
:items => items_in_order.map{|item| item[:id]},
:total => items_in_order.inject(0){|total,item| total += item[:price]}
})
# ...
db["orders"].ensure_index([["placed_at", Mongo::DESCENDING]])
45. reverse index in place
(container for deduced data, array)
> db.orders.findOne()
{ "_id" : ObjectId("4d88bf1f31f23812de0003fd"),
"placed_at" : [ "2011", "201103", "2011w11", "20110316" ],
"user_id" : ObjectId("4d88bf1f31f23812de0003e9"),
"items" : [
ObjectId("4d88bf1f31f23812de0003da"),
ObjectId("4d88bf1f31f23812de000047"),
ObjectId("4d88bf1f31f23812de000078"),
ObjectId("4d88bf1f31f23812de000068"),
ObjectId("4d88bf1f31f23812de000288")
],
"total" : 3502
}
54. plain dates are good too
> db.orders.find({
"placed_at": {
$gte: new Date(2011,2,10),
$lt: new Date(2011,2,11)
}
}).explain()
{
"cursor" : "BtreeCursor placed_at_-‐1",
"nscanned" : 53,
"nscannedObjects" : 53,
"n" : 53,
"millis" : 0,
"indexBounds" : {
"placed_at" : [
[
"Fri Mar 11 2011 00:00:00 GMT+0100 (CET)",
"Thu Mar 10 2011 00:00:00 GMT+0100 (CET)"
]
]
}
55. plain dates are good too, but...
(total sold on this year’s mondays)
# find all mondays of the year
now = Time.now.beginning_of_year
now += 1.day until now.monday?
mondays = [ now ]
mondays << now += 7.days while now.year == Time.now.year
# find all orders placed on mondays
query = {
:$or => mondays.map do |day|
{ :placed_at => {
:$gte => day.beginning_of_day,
:$lte => day.end_of_day
}
}
end
}
puts query
56. plain dates are good too, but...
(total sold on this year’s mondays)
# find all mondays of the year
now = Time.now.beginning_of_year
now += 1.day until now.monday?
mondays = [ now ]
mondays << now += 7.days while now.year == Time.now.year
$ ruby src/orders_on_mondays.rb
# find all orders placed on mondays
{:$or=>[
query = { {:placed_at=>{
:$or => mondays.map do |day|
:$gte=>2011-‐01-‐03 00:00:00 +0100,
{ :placed_at => { :$lte=>2011-‐01-‐03 23:59:59 +0100
}},
:$gte => day.beginning_of_day,
{:placed_at=>{
:$lte => day.end_of_day
:$gte=>2011-‐01-‐10 00:00:00 +0100,
:$lte=>2011-‐01-‐10 23:59:59 +0100
} }},
} {:placed_at=>{
:$gte=>2011-‐01-‐17 00:00:00 +0100,
end :$lte=>2011-‐01-‐17 23:59:59 +0100
} }},
...
]}
puts query
57. plain dates are good too, but...
(it works but it’s too slooow)
db["orders"].find({
:$or => mondays.map do |day|
{ :placed_at => {
:$gte => day.beginning_of_day,
:$lte => day.end_of_day
}
}
end
})
58. plain dates are good too, but...
(why it’s too slow)
> db.orders.find({
$or: [
"placed_at":{ $gte: new Date(2011,2,3), $lt: new Date(2011,2,4) },
"placed_at":{ $gte: new Date(2011,2,10), $lt: new Date(2011,2,11) }
]
}).explain()
{
"clauses" : [{
"cursor" : "BtreeCursor placed_at_-‐1",
"indexBounds" : {
"placed_at" : [[
"Tue Mar 3 2011 00:00:00 GMT+0100 (CET)",
"Wed Mar 4 2011 00:00:00 GMT+0100 (CET)"
]]}
}, {
"cursor" : "BtreeCursor placed_at_-‐1",
"indexBounds" : {
"placed_at" : [[
"Tue Mar 10 2011 00:00:00 GMT+0100 (CET)",
"Wed Mar 11 2011 00:00:00 GMT+0100 (CET)"
59. with destructured dates
(total sold on mondays this year)
> db.orders.findOne()
{ "_id" : ObjectId("4d88bf1f31f23812de0003fd"),
"placed_at" : [ "2011", "201103", "2011w11", "20110316" ],
"user_id" : ObjectId("4d88bf1f31f23812de0003e9"),
"items" : [
ObjectId("4d88bf1f31f23812de0003da"),
ObjectId("4d88bf1f31f23812de000047"),
ObjectId("4d88bf1f31f23812de000078"),
ObjectId("4d88bf1f31f23812de000068"),
ObjectId("4d88bf1f31f23812de000288")
],
"total" : 3502
}
60. with destructured dates
(total sold on mondays this year)
now = Time.now.beginning_of_year
now += 1.day until now.monday?
mondays = [ now ]
mondays << now += 7.days while now.year == Time.now.year
orders = db["orders"].find({
:placed_at => {
:$in => mondays.map {|day| day.strftime("%Y%m%d")}
}
})
puts orders.explain
61. with destructured dates
(total sold on mondays this year)
now = Time.now.beginning_of_year
now += 1.day until now.monday?
mondays = [ now ]
mondays << now += 7.days while now.year == Time.now.year
orders = db["orders"].find({
$ ruby src/orders_on_mondays.rb
:placed_at => {
{ "cursor"=>"BtreeCursor placed_at_-‐1 multi",
:$in => mondays.map "nscanned"=>744,
{|day| day.strftime("%Y%m%d")}
} "nscannedObjects"=>744,
"n"=>744,
}) "millis"=>1,
"indexBounds"=>{
"placed_at"=>[
puts orders.explain ["20120102", "20120102"], ["20111226", "20111226"],
["20111219", "20111219"], ["20111212", "20111212"],
["20111205", "20111205"], ["20111128", "20111128"],
["20111121", "20111121"], ...
]
}
}
83. map/reduce hits per day
(we have raw events)
> db.visit_events.findOne()
{
"_id" : ObjectId("4d89fc6531f2381d2c00000b"),
"url" : "8aa8b68e0b849f70df6dbb3031c6182b",
"user_id" : ObjectId("4d89fc6531f2381d2c000005"),
"at" : "Thu Jan 13 2011 08:00:06 GMT+0100 (CET)"
}
84. map/reduce hits per day
(generate data WITH something like)
def generate_events(visits, db, now)
visits.times do |time|
now += BETWEEN_VISITS.sample.seconds
db["visit_events"].insert(
:url => Digest::MD5.hexdigest(URLS.sample),
:user_id => USERS.sample[:id],
:at => now
)
end
end
generate_events(10_000, db, now)
87. map/reduce hits per day
(implement format in place)
MAP = <<-EOF
function() {
Date.prototype.format = function(format) {
...
}
emit([ this.url, this.at.format("Ymd") ].join("-"), { "hits": 1 })
}
EOF
REDUCE = <<-EOF
function(key, values) {
var hits = 0
for(var index in values) hits += values[index]["hits"]
return { "hits": hits }
}
EOF
88. map/reduce hits per day
(implement format only if needed)
MAP = <<-EOF
function() {
if (!Date.prototype.format) {
Date.prototype.format = function(format) {
...
}
}
emit([ this.url, this.at.format("Ymd") ].join("-"), { "hits": 1 })
}
EOF
REDUCE = <<-EOF
function(key, values) {
var hits = 0
for(var index in values) hits += values[index]["hits"]
return { "hits": hits }
}
EOF
89. map/reduce hits per day
(implement format once and for all)
db[Mongo::DB::SYSTEM_JS_COLLECTION].save(
:_id => "formatDate",
:value => BSON::Code.new(
<<-EOF
function(date, format) {
if (!Date.prototype.format) {
Date.prototype.format = function(format) { ... }
}
return date.format(format)
}
EOF
)
)
MAP = <<-EOF
function() {
emit([ this.url, formatDate(this.at, "Ymd") ].join("-"), {"hits":1})
}
EOF
90. map/reduce hits per day
(implement format once and for all)
db[Mongo::DB::SYSTEM_JS_COLLECTION].save(
:_id => "load",
:value => BSON::Code.new(
<<-EOF
function(module) {
if ((module === "date") && !Date.prototype.format) {
Date.prototype.format = function(format) { ... }
}
return true
}
EOF
)
)
MAP = <<-EOF
function() {
load("date") && emit(
[ this.url, this.at.format("Ymd") ].join("-"),
{ "hits": 1 }
)
}
EOF
91. map/reduce hits per day
(ok, but could be taking too long)
MAP = <<-EOF
function() {
emit([ this.url, this.at.format("Ymd") ].join("-"), { "hits": 1 })
}
EOF
REDUCE = <<-EOF $ ruby src/incremental_mr.rb
function(key, values)
{
{ "result"=>"visits",
var hits = 0 "timeMillis"=>4197,
for(var index in values) hits += values[index]["hits"]
"timing"=> {
"mapTime"=>3932,
return { "hits": hits }
"emitLoop"=>4170,
} "total"=>4197
EOF },
"counts"=> {
"input"=>10000,
result = db["visit_events"].map_reduce(
"emit"=>10000,
"output"=>200
MAP, REDUCE, :out => "visits", :raw =>
}, true, :verbose => true
) "ok"=>1.0
}
puts result.inspect
92. map/reduce hits per day
(ok, every time we need to start over)
> db.visits.find()
{ "_id" : "019640ff7952425b1b8695605459d223-‐20110316",
"value" : { "hits" : 47 }
}
{ "_id" : "019640ff7952425b1b8695605459d223-‐20110317",
"value" : { "hits" : 49 }
}
{ "_id" : "019640ff7952425b1b8695605459d223-‐20110318",
"value" : { "hits" : 59 }
}
{ "_id" : "019640ff7952425b1b8695605459d223-‐20110319",
"value" : { "hits" : 37 }
}
93. map/reduce hits per day
(incremental with savepoints)
visit-elements visit
collection collection
map/reduce
on last changed upsert
documents
temporary
collection
94. map/reduce hits per day
(incremental with savepoints)
db.create_collection("visit_events",
:capped => true,
visit-elements
:max => 50_000,
:size => 5_000_000 collection
)
map/reduce
on last changed
documents
temporary
collection
99. map/reduce hits per day
(incremental with savepoints)
def savepoint(db)
db["visits"].find_one(:_id => "savepoint") or
{ "at" => BSON::ObjectId.from_time(10.years.ago) }
end
def from_last_updated(db)
savepoint["at"]
end
def to_last_inserted(db)
db["visit_events"].find.sort([:_id, Mongo::DESCENDING]).first["_id"]
end