The document discusses NoSQL databases and related systems. It provides a table comparing over 20 systems across features such as scale, indexing, transactions, joins/analytics, and data model. The key points are that scale is the primary motivation for NoSQL databases, which often sacrifice consistency in order to achieve high availability and partitioning across many servers. This relates to Brewer's CAP theorem, which states it is impossible to have all three of consistency, availability, and partitioning simultaneously in a distributed system.
This document discusses using JSON in Oracle Database 18c/19c. It begins with an introduction of the author and their experience. It then covers how JSON is used everywhere in databases and applications now. The main topic is using JSON as intended - as a data interchange format rather than for storage. It highlights the advantages of JSON over CSV and XML for data exchange. It also demonstrates how to transform between SQL and JSON data types and discusses some of the challenges around data formats and encoding.
This document discusses using JSON in Oracle Database 18c/19c. It begins by introducing the presenter and their background. It then covers storing and querying JSON in the database using various SQL and PL/SQL features like JSON_QUERY, JSON_OBJECT, and JSON_TABLE. The document discusses how different SQL data types are converted to JSON. It shows examples of converting rows to CSV, XML, and JSON formats for data exchange. In summary, the document provides an overview of Oracle Database's support for JSON focusing on using it properly for data exchange and storage.
An Intro to NoSQL Databases -- NoSQL databases will not become the new dominators. Relational will still be popular, and used in the majority of situations. They, however, will no longer be the automatic choice. (source : http://martinfowler.com/)
The document discusses the hype around NoSQL databases and provides guidance on selecting the right database solution. It summarizes different database types and evaluates databases based on characteristics like concurrency control, data storage, replication, and transaction support. The document advises profiling applications carefully before selecting a database and avoiding premature decoupling of data.
Slides from workshop held on 12/14 in Asbury Park, NJ
http://www.meetup.com/Jersey-Shore-Tech/events/148118762/?gj=ro2_e&a=ro2_gnl&rv=ro2_e&_af_eid=148118762&_af=event
comprehensive Introduction to NoSQL solutions inside the big data landscape. Graph store? Column store? key Value store? Document Store? redis or memcache? dynamo db? mongo db ? hbase? Cloud or open source?
This document provides an overview and comparison of several NoSQL databases, including Cassandra, DynamoDB, CosmosDB, and Spanner. Some key points of agreement are that eventual consistency is useful, automatic partitioning does not work, and SQL is an acceptable query language. The document discusses the data models, consistency levels, multi-region support, and notable features of each database. It provides recommendations that DynamoDB should generally be avoided due to limitations, and that Cassandra is preferable to CosmosDB given its wider availability and more predictable provisioning. The document emphasizes that there are no perfect solutions and only tradeoffs between different database options.
This document provides an overview and comparison of relational and NoSQL databases. Relational databases use SQL and have strict schemas while NoSQL databases are schema-less and include document, key-value, wide-column, and graph models. NoSQL databases provide unlimited horizontal scaling, very fast performance that does not deteriorate with growth, and flexible queries using map-reduce. Popular NoSQL databases include MongoDB, Cassandra, HBase, and Redis.
This document discusses using JSON in Oracle Database 18c/19c. It begins with an introduction of the author and their experience. It then covers how JSON is used everywhere in databases and applications now. The main topic is using JSON as intended - as a data interchange format rather than for storage. It highlights the advantages of JSON over CSV and XML for data exchange. It also demonstrates how to transform between SQL and JSON data types and discusses some of the challenges around data formats and encoding.
This document discusses using JSON in Oracle Database 18c/19c. It begins by introducing the presenter and their background. It then covers storing and querying JSON in the database using various SQL and PL/SQL features like JSON_QUERY, JSON_OBJECT, and JSON_TABLE. The document discusses how different SQL data types are converted to JSON. It shows examples of converting rows to CSV, XML, and JSON formats for data exchange. In summary, the document provides an overview of Oracle Database's support for JSON focusing on using it properly for data exchange and storage.
An Intro to NoSQL Databases -- NoSQL databases will not become the new dominators. Relational will still be popular, and used in the majority of situations. They, however, will no longer be the automatic choice. (source : http://martinfowler.com/)
The document discusses the hype around NoSQL databases and provides guidance on selecting the right database solution. It summarizes different database types and evaluates databases based on characteristics like concurrency control, data storage, replication, and transaction support. The document advises profiling applications carefully before selecting a database and avoiding premature decoupling of data.
Slides from workshop held on 12/14 in Asbury Park, NJ
http://www.meetup.com/Jersey-Shore-Tech/events/148118762/?gj=ro2_e&a=ro2_gnl&rv=ro2_e&_af_eid=148118762&_af=event
comprehensive Introduction to NoSQL solutions inside the big data landscape. Graph store? Column store? key Value store? Document Store? redis or memcache? dynamo db? mongo db ? hbase? Cloud or open source?
This document provides an overview and comparison of several NoSQL databases, including Cassandra, DynamoDB, CosmosDB, and Spanner. Some key points of agreement are that eventual consistency is useful, automatic partitioning does not work, and SQL is an acceptable query language. The document discusses the data models, consistency levels, multi-region support, and notable features of each database. It provides recommendations that DynamoDB should generally be avoided due to limitations, and that Cassandra is preferable to CosmosDB given its wider availability and more predictable provisioning. The document emphasizes that there are no perfect solutions and only tradeoffs between different database options.
This document provides an overview and comparison of relational and NoSQL databases. Relational databases use SQL and have strict schemas while NoSQL databases are schema-less and include document, key-value, wide-column, and graph models. NoSQL databases provide unlimited horizontal scaling, very fast performance that does not deteriorate with growth, and flexible queries using map-reduce. Popular NoSQL databases include MongoDB, Cassandra, HBase, and Redis.
The document discusses the NoSQL ecosystem. It provides a brief history of NoSQL databases from the late 1990s to today. It then lists and categorizes the major NoSQL databases. The rest of the document discusses interesting properties of NoSQL databases like data models, query models, transactions, and consistency. It also provides examples of real-world usage at companies like Netflix, Facebook, and Craigslist. Key takeaways are around developer accessibility, reuse of NoSQL components, and using the right tool for the job (polyglot persistence).
This document provides an overview of SQL and NoSQL databases. It defines SQL as a language used to communicate with relational databases, allowing users to query, manipulate, and retrieve data. NoSQL databases are defined as non-relational and allow for flexible schemas. The document compares key aspects of SQL and NoSQL such as data structure, querying, scalability and provides examples of popular SQL and NoSQL database systems. It concludes that both SQL and NoSQL databases will continue to be important with polyglot persistence, using the best database for each storage need.
Vote NO for MySQL - Election 2012: NoSQL. Researchers predict a dark future for MySQL. Significant market loss to come. Are things that bad, is MySQL falling behind? A look at NoSQL, an attempt to identify different kinds of NoSQL stores, their goals and how they compare to MySQL 5.6. Focus: Key Value Stores and Document Stores. MySQL versus NoSQL means looking behind the scenes, taking a step back and looking at the building blocks.
MongoDB Europe 2016 - Using MongoDB to Build a Fast and Scalable Content Repo...MongoDB
MongoDB can be used in the Nuxeo Platform as a replacement for more traditional SQL databases. Nuxeo's content repository, which is the cornerstone of this open source enterprise content management platform, integrates completely with MongoDB for data storage. This presentation will explain the motivation for using MongoDB and will emphasize the different implementation choices driven by the very nature of a NoSQL datastore like MongoDB. Learn how Nuxeo integrated MongoDB into the platform which resulted in increased performance (including actual benchmarks) and better response to some use cases.
This document provides an overview of NoSQL and MongoDB. It discusses trends driving the adoption of NoSQL databases like increasing data sizes, more connectedness, and individualization. It covers the different types of NoSQL databases and MongoDB in particular. Key concepts discussed include the CAP theorem, MongoDB's document-oriented data model, and basic CRUD operations in MongoDB using the shell.
Development to Production with Sharded MongoDB ClustersSeveralnines
Severalnines presentation at MongoDB Stockholm Conference.
Presentation covers:
- mongoDB sharding/clustering concepts
- recommended dev/test/prod setups
- how to verify your deployment
- how to avoid downtime
- what MongoDB metrics to watch
- when to scale
Galaxy Big Data with MariaDB 10 by Bernard Garros, Sandrine Chirokoff and Stéphane Varoqui.
Presented 26.6.2014 at the MariaDB Roadshow in Paris, France.
SwanseaCon 2017 presentation on Making MySQL Agile-ish. Relational Databases are not usually considered part of the Agile Programming movement but there are many new features in MySQL to make it easier to include it. This presentation covers how MySQL is moving to help support agile development while maintaining the traditional 'non agile' stability expected from a database.
In this talk from the Dublin Websummit 2014 AWS Technical Evangelist Danilo Poccia discusses NoSQL technology.
Includes an introduction to NoSQL DB and a discussion of when it is time to consider NoSQL.
Danilo also introduces Amazon DynamoDB as a NoSQL solution and talks through several case studies of customers that are using Amazon DynamoDB today.
The document provides an overview of different NoSQL database types, including key-value stores, document databases, column-oriented databases, graph databases, and caches. It discusses examples of databases for each type and common use cases. The document also covers querying graph databases, polyglot persistence using multiple database types, and concludes with when each database type is best suited and when not to use a NoSQL database.
This document provides an introduction to NoSQL and Cassandra. It begins with an introduction of the presenter and an overview of what will be covered. It then discusses the history of databases and why alternatives to relational databases were needed to address challenges of scaling to internet-level data volumes, varieties, and velocities. It introduces key NoSQL concepts like CAP theorem, BASE, and the different types of NoSQL databases before focusing on Cassandra. The document summarizes Cassandra's origins, capabilities, data model involving column families and super column families, and architecture.
1. Log structured merge trees store data in multiple levels with different storage speeds and costs, requiring data to periodically merge across levels.
2. This structure allows fast writes by storing new data in faster levels before merging to slower levels, and efficient reads by querying multiple levels and merging results.
3. The merging process involves loading, sorting, and rewriting levels to consolidate and propagate deletions and updates between levels.
Ingesting Over Four Million Rows Per Second With QuestDB Timeseries Database ...javier ramirez
How would you build a database to support sustained ingestion of several hundreds of thousands rows per second while running near real-time queries on top?
In this session I will go over some of the technical decisions and trade-offs we applied when building QuestDB, an open source time-series database developed mainly in JAVA, and how we can achieve over four million row writes per second on a single instance without blocking or slowing down the reads. There will be code and demos, of course.
We will also review a history of some of the changes we have gone over the past two years to deal with late and unordered data, non-blocking writes, read-replicas, or faster batch ingestion.
This document provides an overview of NoSQL databases. It discusses that NoSQL databases are non-relational and were created to overcome limitations of scaling relational databases. The document categorizes NoSQL databases into key-value stores, document databases, graph databases, XML databases, and distributed peer stores. It provides examples like MongoDB, Redis, CouchDB, and Cassandra. The document also explains concepts like CAP theorem, ACID properties, and reasons for using NoSQL databases like horizontal scaling, schema flexibility, and handling large amounts of data.
MySQL Day Paris 2018 - MySQL JSON Document StoreOlivier DASINI
NoSQL + SQL = MySQL
MySQL Document Store allows developers to work with SQL relational tables and schema-less JSON collections. To make that possible MySQL has created the X Dev API which puts a strong focus on CRUD by providing a fluent API allowing you to work with JSON documents in a natural way. The X Protocol is a highly extensible and is optimized for CRUD as well as SQL API operations.
MySQL Document store gives users maximum flexibility developing traditional SQL relational applications and NoSQL schema-free document database applications. This eliminates the need for a separate NoSQL document database. Developers can mix and match relational data and JSON documents in the same database as well as the same application. For example, both data models can be queried in the same application and results can be in table, tabular or JSON formats.
The MySQL Document Store architecture consists of the following components:
Native JSON Document Storage - MySQL provides a native JSON datatype is efficiently stored in binary with the ability to create virtual columns that can be indexed. JSON Documents are automatically validated.
X Plugin - The X Plugin enables MySQL to use the X Protocol and uses Connectors and the Shell to act as clients to the server.
X Protocol - The X Protocol is a new client protocol based on top of the Protobuf library, and works for both, CRUD and SQL operations.
X DevAPI - The X DevAPI is a new, modern, async developer API for CRUD and SQL operations on top of X Protocol. It introduces Collections as new Schema objects. Documents are stored in Collections and have their dedicated CRUD operation set.
MySQL Shell - The MySQL Shell is an interactive Javascript, Python, or SQL interface supporting development and administration for the MySQL Server. You can use the MySQL Shell to perform data queries and updates as well as various administration operations.
MySQL Connectors - The following MySQL Connectors support the X Protocol and enable you to use X DevAPI in your chosen language.
MySQL Connector/Node.js
MySQL Connector/PHP
MySQL Connector/Python
MySQL Connector/J
MySQL Connector/NET
MySQL Connector/C++
This document discusses graphs and graph analytics. It begins by defining what a graph is as G = (V,E) where V is a set of vertices and E is a set of edges. It then discusses real world examples of graphs like the web, social networks, and communication logs. It covers various graph analytics tasks like structural analysis to compute metrics like degree and centrality, traversals to find minimum spanning trees and maximum flow, and pattern matching to find subgraphs that match a given pattern. It also discusses different languages that can be used to express patterns over graph data like SPARQL, Datalog, and SQL.
The document discusses gradient descent and stochastic gradient descent algorithms for machine learning. It explains that gradient descent aims to minimize a cost function by iteratively updating model parameters in the direction of steepest descent. Stochastic gradient descent processes minibatches or individual training examples on each step rather than the full dataset, allowing for parallelization. Regularization terms like L1 and L2 norms are also discussed for preventing overfitting by enforcing constraints on model weights.
The document discusses the NoSQL ecosystem. It provides a brief history of NoSQL databases from the late 1990s to today. It then lists and categorizes the major NoSQL databases. The rest of the document discusses interesting properties of NoSQL databases like data models, query models, transactions, and consistency. It also provides examples of real-world usage at companies like Netflix, Facebook, and Craigslist. Key takeaways are around developer accessibility, reuse of NoSQL components, and using the right tool for the job (polyglot persistence).
This document provides an overview of SQL and NoSQL databases. It defines SQL as a language used to communicate with relational databases, allowing users to query, manipulate, and retrieve data. NoSQL databases are defined as non-relational and allow for flexible schemas. The document compares key aspects of SQL and NoSQL such as data structure, querying, scalability and provides examples of popular SQL and NoSQL database systems. It concludes that both SQL and NoSQL databases will continue to be important with polyglot persistence, using the best database for each storage need.
Vote NO for MySQL - Election 2012: NoSQL. Researchers predict a dark future for MySQL. Significant market loss to come. Are things that bad, is MySQL falling behind? A look at NoSQL, an attempt to identify different kinds of NoSQL stores, their goals and how they compare to MySQL 5.6. Focus: Key Value Stores and Document Stores. MySQL versus NoSQL means looking behind the scenes, taking a step back and looking at the building blocks.
MongoDB Europe 2016 - Using MongoDB to Build a Fast and Scalable Content Repo...MongoDB
MongoDB can be used in the Nuxeo Platform as a replacement for more traditional SQL databases. Nuxeo's content repository, which is the cornerstone of this open source enterprise content management platform, integrates completely with MongoDB for data storage. This presentation will explain the motivation for using MongoDB and will emphasize the different implementation choices driven by the very nature of a NoSQL datastore like MongoDB. Learn how Nuxeo integrated MongoDB into the platform which resulted in increased performance (including actual benchmarks) and better response to some use cases.
This document provides an overview of NoSQL and MongoDB. It discusses trends driving the adoption of NoSQL databases like increasing data sizes, more connectedness, and individualization. It covers the different types of NoSQL databases and MongoDB in particular. Key concepts discussed include the CAP theorem, MongoDB's document-oriented data model, and basic CRUD operations in MongoDB using the shell.
Development to Production with Sharded MongoDB ClustersSeveralnines
Severalnines presentation at MongoDB Stockholm Conference.
Presentation covers:
- mongoDB sharding/clustering concepts
- recommended dev/test/prod setups
- how to verify your deployment
- how to avoid downtime
- what MongoDB metrics to watch
- when to scale
Galaxy Big Data with MariaDB 10 by Bernard Garros, Sandrine Chirokoff and Stéphane Varoqui.
Presented 26.6.2014 at the MariaDB Roadshow in Paris, France.
SwanseaCon 2017 presentation on Making MySQL Agile-ish. Relational Databases are not usually considered part of the Agile Programming movement but there are many new features in MySQL to make it easier to include it. This presentation covers how MySQL is moving to help support agile development while maintaining the traditional 'non agile' stability expected from a database.
In this talk from the Dublin Websummit 2014 AWS Technical Evangelist Danilo Poccia discusses NoSQL technology.
Includes an introduction to NoSQL DB and a discussion of when it is time to consider NoSQL.
Danilo also introduces Amazon DynamoDB as a NoSQL solution and talks through several case studies of customers that are using Amazon DynamoDB today.
The document provides an overview of different NoSQL database types, including key-value stores, document databases, column-oriented databases, graph databases, and caches. It discusses examples of databases for each type and common use cases. The document also covers querying graph databases, polyglot persistence using multiple database types, and concludes with when each database type is best suited and when not to use a NoSQL database.
This document provides an introduction to NoSQL and Cassandra. It begins with an introduction of the presenter and an overview of what will be covered. It then discusses the history of databases and why alternatives to relational databases were needed to address challenges of scaling to internet-level data volumes, varieties, and velocities. It introduces key NoSQL concepts like CAP theorem, BASE, and the different types of NoSQL databases before focusing on Cassandra. The document summarizes Cassandra's origins, capabilities, data model involving column families and super column families, and architecture.
1. Log structured merge trees store data in multiple levels with different storage speeds and costs, requiring data to periodically merge across levels.
2. This structure allows fast writes by storing new data in faster levels before merging to slower levels, and efficient reads by querying multiple levels and merging results.
3. The merging process involves loading, sorting, and rewriting levels to consolidate and propagate deletions and updates between levels.
Ingesting Over Four Million Rows Per Second With QuestDB Timeseries Database ...javier ramirez
How would you build a database to support sustained ingestion of several hundreds of thousands rows per second while running near real-time queries on top?
In this session I will go over some of the technical decisions and trade-offs we applied when building QuestDB, an open source time-series database developed mainly in JAVA, and how we can achieve over four million row writes per second on a single instance without blocking or slowing down the reads. There will be code and demos, of course.
We will also review a history of some of the changes we have gone over the past two years to deal with late and unordered data, non-blocking writes, read-replicas, or faster batch ingestion.
This document provides an overview of NoSQL databases. It discusses that NoSQL databases are non-relational and were created to overcome limitations of scaling relational databases. The document categorizes NoSQL databases into key-value stores, document databases, graph databases, XML databases, and distributed peer stores. It provides examples like MongoDB, Redis, CouchDB, and Cassandra. The document also explains concepts like CAP theorem, ACID properties, and reasons for using NoSQL databases like horizontal scaling, schema flexibility, and handling large amounts of data.
MySQL Day Paris 2018 - MySQL JSON Document StoreOlivier DASINI
NoSQL + SQL = MySQL
MySQL Document Store allows developers to work with SQL relational tables and schema-less JSON collections. To make that possible MySQL has created the X Dev API which puts a strong focus on CRUD by providing a fluent API allowing you to work with JSON documents in a natural way. The X Protocol is a highly extensible and is optimized for CRUD as well as SQL API operations.
MySQL Document store gives users maximum flexibility developing traditional SQL relational applications and NoSQL schema-free document database applications. This eliminates the need for a separate NoSQL document database. Developers can mix and match relational data and JSON documents in the same database as well as the same application. For example, both data models can be queried in the same application and results can be in table, tabular or JSON formats.
The MySQL Document Store architecture consists of the following components:
Native JSON Document Storage - MySQL provides a native JSON datatype is efficiently stored in binary with the ability to create virtual columns that can be indexed. JSON Documents are automatically validated.
X Plugin - The X Plugin enables MySQL to use the X Protocol and uses Connectors and the Shell to act as clients to the server.
X Protocol - The X Protocol is a new client protocol based on top of the Protobuf library, and works for both, CRUD and SQL operations.
X DevAPI - The X DevAPI is a new, modern, async developer API for CRUD and SQL operations on top of X Protocol. It introduces Collections as new Schema objects. Documents are stored in Collections and have their dedicated CRUD operation set.
MySQL Shell - The MySQL Shell is an interactive Javascript, Python, or SQL interface supporting development and administration for the MySQL Server. You can use the MySQL Shell to perform data queries and updates as well as various administration operations.
MySQL Connectors - The following MySQL Connectors support the X Protocol and enable you to use X DevAPI in your chosen language.
MySQL Connector/Node.js
MySQL Connector/PHP
MySQL Connector/Python
MySQL Connector/J
MySQL Connector/NET
MySQL Connector/C++
This document discusses graphs and graph analytics. It begins by defining what a graph is as G = (V,E) where V is a set of vertices and E is a set of edges. It then discusses real world examples of graphs like the web, social networks, and communication logs. It covers various graph analytics tasks like structural analysis to compute metrics like degree and centrality, traversals to find minimum spanning trees and maximum flow, and pattern matching to find subgraphs that match a given pattern. It also discusses different languages that can be used to express patterns over graph data like SPARQL, Datalog, and SQL.
The document discusses gradient descent and stochastic gradient descent algorithms for machine learning. It explains that gradient descent aims to minimize a cost function by iteratively updating model parameters in the direction of steepest descent. Stochastic gradient descent processes minibatches or individual training examples on each step rather than the full dataset, allowing for parallelization. Regularization terms like L1 and L2 norms are also discussed for preventing overfitting by enforcing constraints on model weights.
This document discusses machine learning concepts including representation, evaluation, and optimization. It provides examples of document classification using supervised learning. Key points include:
- Representation refers to the model or classifier used, such as a decision tree. Evaluation measures how good the classifier is, such as using accuracy on a test set. Optimization searches for the best representation according to the evaluation.
- In document classification, documents are represented as vectors of word counts and the goal is to predict a label like topic. Accuracy on labeled test documents is used to evaluate classifiers.
- Decision trees are a way to represent conditional rules for classification. They are learned using an algorithm that selects attributes to split on based on information gain, reducing uncertainty
This document discusses various statistical concepts related to analyzing results from multiple studies, including effect sizes, p-values, meta-analysis, and issues that can arise such as publication bias, multiple hypothesis testing, and heterogeneity. It provides examples of how effect sizes are calculated, how meta-analyses combine results across studies, and statistical methods that can help address problems like multiple comparisons, including Bonferroni corrections and false discovery rate analysis. The document cautions that when analyzing large datasets, there is a risk of finding spurious correlations due to chance that may have no predictive value.
The document discusses the concept of scalability in computing. Operationally, scalability now means being able to utilize thousands of inexpensive computers. Formally, in the past scalability meant algorithms with polynomial time complexity, while now it means logarithmic time complexity, allowing data to be processed more efficiently as data sizes increase. The document provides examples of finding matching DNA sequences and word frequency analysis to illustrate how distributed and parallel algorithms can improve scalability.
This document discusses data models and databases. It begins by explaining the components of a data model: structures, constraints, and operations. It then defines what a database is as a collection of organized information for efficient retrieval. The document goes on to discuss relational databases and their advantages like sharing data, enforcing data models, scaling to large datasets, and flexibility. It covers concepts like declarative query languages, views, indexes, and using databases for analytics like matrix operations and experiment design.
Predictably Improve Your B2B Tech Company's Performance by Leveraging DataKiwi Creative
Harness the power of AI-backed reports, benchmarking and data analysis to predict trends and detect anomalies in your marketing efforts.
Peter Caputa, CEO at Databox, reveals how you can discover the strategies and tools to increase your growth rate (and margins!).
From metrics to track to data habits to pick up, enhance your reporting for powerful insights to improve your B2B tech company's marketing.
- - -
This is the webinar recording from the June 2024 HubSpot User Group (HUG) for B2B Technology USA.
Watch the video recording at https://youtu.be/5vjwGfPN9lw
Sign up for future HUG events at https://events.hubspot.com/b2b-technology-usa/
Analysis insight about a Flyball dog competition team's performanceroli9797
Insight of my analysis about a Flyball dog competition team's last year performance. Find more: https://github.com/rolandnagy-ds/flyball_race_analysis/tree/main
State of Artificial intelligence Report 2023kuntobimo2016
Artificial intelligence (AI) is a multidisciplinary field of science and engineering whose goal is to create intelligent machines.
We believe that AI will be a force multiplier on technological progress in our increasingly digital, data-driven world. This is because everything around us today, ranging from culture to consumer products, is a product of intelligence.
The State of AI Report is now in its sixth year. Consider this report as a compilation of the most interesting things we’ve seen with a goal of triggering an informed conversation about the state of AI and its implication for the future.
We consider the following key dimensions in our report:
Research: Technology breakthroughs and their capabilities.
Industry: Areas of commercial application for AI and its business impact.
Politics: Regulation of AI, its economic implications and the evolving geopolitics of AI.
Safety: Identifying and mitigating catastrophic risks that highly-capable future AI systems could pose to us.
Predictions: What we believe will happen in the next 12 months and a 2022 performance review to keep us honest.
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...Aggregage
This webinar will explore cutting-edge, less familiar but powerful experimentation methodologies which address well-known limitations of standard A/B Testing. Designed for data and product leaders, this session aims to inspire the embrace of innovative approaches and provide insights into the frontiers of experimentation!
Natural Language Processing (NLP), RAG and its applications .pptxfkyes25
1. In the realm of Natural Language Processing (NLP), knowledge-intensive tasks such as question answering, fact verification, and open-domain dialogue generation require the integration of vast and up-to-date information. Traditional neural models, though powerful, struggle with encoding all necessary knowledge within their parameters, leading to limitations in generalization and scalability. The paper "Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks" introduces RAG (Retrieval-Augmented Generation), a novel framework that synergizes retrieval mechanisms with generative models, enhancing performance by dynamically incorporating external knowledge during inference.
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data LakeWalaa Eldin Moustafa
Dynamic policy enforcement is becoming an increasingly important topic in today’s world where data privacy and compliance is a top priority for companies, individuals, and regulators alike. In these slides, we discuss how LinkedIn implements a powerful dynamic policy enforcement engine, called ViewShift, and integrates it within its data lake. We show the query engine architecture and how catalog implementations can automatically route table resolutions to compliance-enforcing SQL views. Such views have a set of very interesting properties: (1) They are auto-generated from declarative data annotations. (2) They respect user-level consent and preferences (3) They are context-aware, encoding a different set of transformations for different use cases (4) They are portable; while the SQL logic is only implemented in one SQL dialect, it is accessible in all engines.
#SQL #Views #Privacy #Compliance #DataLake
Learn SQL from basic queries to Advance queriesmanishkhaire30
Dive into the world of data analysis with our comprehensive guide on mastering SQL! This presentation offers a practical approach to learning SQL, focusing on real-world applications and hands-on practice. Whether you're a beginner or looking to sharpen your skills, this guide provides the tools you need to extract, analyze, and interpret data effectively.
Key Highlights:
Foundations of SQL: Understand the basics of SQL, including data retrieval, filtering, and aggregation.
Advanced Queries: Learn to craft complex queries to uncover deep insights from your data.
Data Trends and Patterns: Discover how to identify and interpret trends and patterns in your datasets.
Practical Examples: Follow step-by-step examples to apply SQL techniques in real-world scenarios.
Actionable Insights: Gain the skills to derive actionable insights that drive informed decision-making.
Join us on this journey to enhance your data analysis capabilities and unlock the full potential of SQL. Perfect for data enthusiasts, analysts, and anyone eager to harness the power of data!
#DataAnalysis #SQL #LearningSQL #DataInsights #DataScience #Analytics
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Data and AI
Discussion on Vector Databases, Unstructured Data and AI
https://www.meetup.com/unstructured-data-meetup-new-york/
This meetup is for people working in unstructured data. Speakers will come present about related topics such as vector databases, LLMs, and managing data at scale. The intended audience of this group includes roles like machine learning engineers, data scientists, data engineers, software engineers, and PMs.This meetup was formerly Milvus Meetup, and is sponsored by Zilliz maintainers of Milvus.
Enhanced Enterprise Intelligence with your personal AI Data Copilot.pdfGetInData
Recently we have observed the rise of open-source Large Language Models (LLMs) that are community-driven or developed by the AI market leaders, such as Meta (Llama3), Databricks (DBRX) and Snowflake (Arctic). On the other hand, there is a growth in interest in specialized, carefully fine-tuned yet relatively small models that can efficiently assist programmers in day-to-day tasks. Finally, Retrieval-Augmented Generation (RAG) architectures have gained a lot of traction as the preferred approach for LLMs context and prompt augmentation for building conversational SQL data copilots, code copilots and chatbots.
In this presentation, we will show how we built upon these three concepts a robust Data Copilot that can help to democratize access to company data assets and boost performance of everyone working with data platforms.
Why do we need yet another (open-source ) Copilot?
How can we build one?
Architecture and evaluation
The Building Blocks of QuestDB, a Time Series Databasejavier ramirez
Talk Delivered at Valencia Codes Meetup 2024-06.
Traditionally, databases have treated timestamps just as another data type. However, when performing real-time analytics, timestamps should be first class citizens and we need rich time semantics to get the most out of our data. We also need to deal with ever growing datasets while keeping performant, which is as fun as it sounds.
It is no wonder time-series databases are now more popular than ever before. Join me in this session to learn about the internal architecture and building blocks of QuestDB, an open source time-series database designed for speed. We will also review a history of some of the changes we have gone over the past two years to deal with late and unordered data, non-blocking writes, read-replicas, or faster batch ingestion.
2. WHEREWE ARE
Data science
1. Data Preparation (at scale)
2. Analytics
3. Communication
Databases
• Key ideas: Relational algebra, physical/logical data
independence
MapReduce
• Key ideas: Fault tolerance, no loading, direct programming on “in
site” data
2
3. Year
System/
Paper
Scale to
1000s
Primary
Index
Secondar
y
Indexes Transactions
Joins/
Analytics
Integrity
Constraint
s Views
Language/
Algebra
Data
model my label
1971 RDBMS O ✔ ✔ ✔ ✔ ✔ ✔ ✔ tables sql-like
2003 memcached ✔ ✔ O O O O O O key-val nosql
2004 MapReduce ✔ O O O ✔ O O O key-val batch
2005 CouchDB ✔ ✔ ✔ record MR O ✔ O document nosql
2006
BigTable/
Hbase ✔ ✔ ✔ record compat. w/MR / O O ext. record nosql
2007 MongoDB ✔ ✔ ✔ EC, record O O O O document nosql
2007 Dynamo ✔ ✔ O O O O O O ext. record nosql
2008 Pig ✔ O O O ✔ / O ✔ tables sql-like
2008 HIVE ✔ O O O ✔ ✔ O ✔ tables sql-like
2008 Cassandra ✔ ✔ ✔ EC, record O ✔ ✔ O key-val nosql
2009 Voldemort ✔ ✔ O EC, record O O O O key-val nosql
2009 Riak ✔ ✔ ✔ EC, record MR O key-val nosql
2010 Dremel ✔ O O O / ✔ O ✔ tables sql-like
2011 Megastore ✔ ✔ ✔ entity groups O / O / tables nosql
2011 Tenzing ✔ O O O O ✔ ✔ ✔ tables sql-like
2011 Spark/Shark ✔ O O O ✔ ✔ O ✔ tables sql-like
2012 Spanner ✔ ✔ ✔ ✔ ? ✔ ✔ ✔ tables sql-like
2013 Impala ✔ O O O ✔ ✔ O ✔ tables sql-like
NOSQL AND RELATED SYSTEM,BY FEATURE
3
4. SCALE IS THE PRIMARY MOTIVATION
4
Year
System/
Paper
Scale to
1000s
Primary
Index
Secondar
y
Indexes Transactions
Joins/
Analytics
Integrity
Constraint
s Views
Language/
Algebra
Data
model my label
1971 RDBMS O ✔ ✔ ✔ ✔ ✔ ✔ ✔ tables sql-like
2003 memcached ✔ ✔ O O O O O O key-val nosql
2004 MapReduce ✔ O O O ✔ O O O key-val batch
2005 CouchDB ✔ ✔ ✔ record MR O ✔ O document nosql
2006
BigTable
(Hbase) ✔ ✔ ✔ record compat. w/MR / O O ext. record nosql
2007 MongoDB ✔ ✔ ✔ EC, record O O O O document nosql
2007 Dynamo ✔ ✔ O O O O O O ext. record nosql
2008 Pig ✔ O O O ✔ / O ✔ tables sql-like
2008 HIVE ✔ O O O ✔ ✔ O ✔ tables sql-like
2008 Cassandra ✔ ✔ ✔ EC, record O ✔ ✔ O key-val nosql
2009 Voldemort ✔ ✔ O EC, record O O O O key-val nosql
2009 Riak ✔ ✔ ✔ EC, record MR O key-val nosql
2010 Dremel ✔ O O O / ✔ O ✔ tables sql-like
2011 Megastore ✔ ✔ ✔ entity groups O / O / tables nosql
2011 Tenzing ✔ O O O O ✔ ✔ ✔ tables sql-like
2011 Spark/Shark ✔ O O O ✔ ✔ O ✔ tables sql-like
2012 Spanner ✔ ✔ ✔ ✔ ? ✔ ✔ ✔ tables sql-like
2012 Accumulo ✔ ✔ ✔ record compat. w/MR / O O ext. record nosql
2013 Impala ✔ O O O ✔ ✔ O ✔ tables sql-like
5. 5
2) We also want to support updates1) We need to ensure
high availability
6. EXAMPLE
6
User: Sue
Friends: Joe, Kai, …
Status:“Headed to
new Bond flick”
Wall:“…”,“…”
User: Joe
Friends: Sue, …
Status:“I’m
sleepy”
Wall:“…”,“…”
Write: Update Sue’s status. Who sees the new status, and who sees
the old one?
Databases: “Everyone MUST see the same thing,either old or new,no
matter how long it takes.”
NoSQL: “For large applications,we can’t afford to wait that long,and
maybe it doesn’t matter anyway”
User: Kai
Friends: Sue, …
Status:“Done for
tonight”
Wall:“…”,“…”
8. TWO-PHASE COMMIT MOTIVATION
8
subordinate 1
1) user updates
their status
2) do it!
2) do it!
2) do it!
3) success!
3) success!
3) FAIL!
subordinate 2
subordinate 3
4) oops!
9. TWO-PHASE COMMIT
9
Phase 1:
• Coordinator Sends “Prepare to Commit”
• Subordinates make sure they can do so no
matter what
• Write the action to a log to tolerate failure
• Subordinates Reply “Ready to Commit”
Phase 2:
• If all subordinates ready, send “Commit”
• If anyone failed, send “Abort”
10. TWO-PHASE COMMIT
10
subordinate 1
1) user updates
their status
2) Prepare
2) Prepare
3) write
to log
4) ready
subordinate 2
subordinate 3
2) Prepare 3) write to
log
3) write to log
4) ready
4) ready
5) commit
5) commit
5) commit
11. “EVENTUAL CONSISTENCY”
11
Write conflicts will eventually propagate throughout the system
• D.Terry et al.,“Managing Update Conflicts in Bayou,a Weakly Connected
Replicated Storage System”, SOSP 1995
“We believe that applications must be aware that they may read weakly
consistent data and also that their write operations may conflict with
those of other users and applications.”
“Moreover, applications must be revolved m the detection and
resolution of conflicts since these naturally depend on the semantics of
the application.”
12. EVENTUAL CONSISTENCY
12
What the application sees in the meantime is
sensitive to replication mechanics and difficult to
predict
Contrast with RDBMS, Paxos: Immediate (or
“strong”) consistency, but there may be
deadlocks
13. 13
Year
System/
Paper
Scale to
1000s
Primary
Index
Secondar
y
Indexes Transactions
Joins/
Analytics
Integrity
Constraints Views
Language/
Algebra
Data
model my label
2003 memcached ✔ ✔ O O O O O O key-val nosql
2005 CouchDB ✔ ✔ ✔ record MR O ✔ O document nosql
2006
BigTable
(Hbase) ✔ ✔ ✔ record compat. w/MR / O O ext. record nosql
2007 MongoDB ✔ ✔ ✔ EC, record O O O O document nosql
2007 Dynamo ✔ ✔ O O O O O O key-val nosql
2008 Cassandra ✔ ✔ ✔ EC, record O ✔ ✔ O key-val nosql
2009 Voldemort ✔ ✔ O EC, record O O O O key-val nosql
2009 Riak ✔ ✔ ✔ EC, record MR O key-val nosql
2011 Megastore ✔ ✔ ✔ entity groups O / O / tables nosql
2012 Accumulo ✔ ✔ ✔ record compat. w/MR / O O ext. record nosql
2012 Spanner ✔ ✔ ✔ ✔ ? ✔ ✔ ✔ tables sql-like
14. CAP THEOREM [BREWER 2000,LYNCH 2002]
14
Consistency
• Do all applications see all the same data?
Availability
• If some nodes fail, does everything still work?
Partitioning
• If two sections of your system cannot talk to each other, can they make
forward progress on their own?
• If not, you sacrifice Availability
• If so, you might have to sacrific Consistency – can’t have everything
Conventional databases assume no partitioning –
clusters were assumed to be small and local
NoSQL systems may sacrifice consistency
16. 16
Rick Cattel’s clustering from
“Scalable SQL and NoSQL Data Stores”
SIGMOD Record,2010
extensible record
stores
document stores
key-value stores
Year
System/
Paper
Scale to
1000s
Primary
Index
Secondary
Indexes Transac9ons
Joins/
Analy9cs
Integrity
Constraints Views
Language/
Algebra
Data
model my label
1971 RDBMS O ✔ ✔ ✔ ✔ ✔ ✔ ✔ tables sql-like
2003 memcached ✔ ✔ O O O O O O key-val nosql
2004 MapReduce ✔ O O O ✔ O O O key-val batch
2005 CouchDB ✔ ✔ ✔ record MR O ✔ O document nosql
2006 BigTable (Hbase) ✔ ✔ ✔ record compat. w/MR / O O ext. record nosql
2007 MongoDB ✔ ✔ ✔ EC, record O O O O document nosql
2007 Dynamo ✔ ✔ O O O O O O key-val nosql
2008 Pig ✔ O O O ✔ / O ✔ tables sql-like
2008 HIVE ✔ O O O ✔ ✔ O ✔ tables sql-like
2008 Cassandra ✔ ✔ ✔ EC, record O ✔ ✔ O key-val nosql
2009 Voldemort ✔ ✔ O EC, record O O O O key-val nosql
2009 Riak ✔ ✔ ✔ EC, record MR O key-val nosql
2010 Dremel ✔ O O O / ✔ O ✔ tables sql-like
2011 Megastore ✔ ✔ ✔ enAty groups O / O / tables nosql
2011 Tenzing ✔ O O O O ✔ ✔ ✔ tables sql-like
2011 Spark/Shark ✔ O O O ✔ ✔ O ✔ tables sql-like
2012 Spanner ✔ ✔ ✔ ✔ ? ✔ ✔ ✔ tables sql-like
2012 Accumulo ✔ ✔ ✔ record compat. w/MR / O O ext. record nosql
2013 Impala ✔ O O O ✔ ✔ O ✔ tables sql-like
17. TERMINOLOGY
Document = nested values, extensible records (think XML or JSON)
Extensible record = families of attributes have a schema, but new
attributes may be added
Key-Value object = a set of key-value pairs. No schema, no
exposed nesting
17
Rick Cattel 2010
18. NOSQL FEATURES
Ability to horizontally scale “simple operation” throughput over
many servers
• Simple = key lookups, read/write of 1 or few records
The ability to replicate and partition data over many servers
• Consider “sharding” and “horizontal partitioning” to be synonyms
A simple API – no query language
A weaker concurrency model than ACID transactions
Efficient use of distributed indexes and RAM for data storage
The ability to dynamically add new attributes to data records
18
Rick Cattel 2010
19. ACIDV.S.BASE
ACID = Atomicity, Consistency, Isolation, and Durability
BASE = Basically Available, Soft state, Eventually consistent
19
Don’t use “BASE” – it didn’t stick.
Aside:
Consistency:“Any data written to the database
must be valid according to all defined
rules”
Rick Cattel 2010
20. MAJOR IMPACT SYSTEMS (RICK CATTEL)
• “Memcached demonstrated that in-memory indexes
can be highly scalable, distributing and replicating
objects over multiple nodes.”
• “Dynamo pioneered the idea of [using] eventual
consistency as a way to achieve higher availability and
scalability: data fetched are not guaranteed to be up-
to-date, but updates are guaranteed to be propagated
to all nodes eventually.”
• “BigTable demonstrated that persistent record storage
could be scaled to thousands of nodes, a feat that most
of the other systems aspire to.”
20
Rick Cattel 2010
21. 21
Year
System/
Paper
Scale to
1000s
Primar
y
Index
Secondar
y
Indexes Transactions
Joins/
Analytics
Integrity
Constraint
s Views
Language
/
Algebra
Data
model my label
1971 RDBMS O ✔ ✔ ✔ ✔ ✔ ✔ ✔ tables sql-like
2003 memcached ✔ ✔ O O O O O O key-val nosql
2004 MapReduce ✔ O O O ✔ O O O key-val batch
2005 CouchDB ✔ ✔ ✔ record MR O ✔ O document nosql
2006
BigTable
(Hbase) ✔ ✔ ✔ record
compat. w/
MR / O O ext. record nosql
2007 MongoDB ✔ ✔ ✔ EC, record O O O O document nosql
2007 Dynamo ✔ ✔ O O O O O O key-val nosql
2008 Pig ✔ O O O ✔ / O ✔ tables sql-like
2008 HIVE ✔ O O O ✔ ✔ O ✔ tables sql-like
2008 Cassandra ✔ ✔ ✔ EC, record O ✔ ✔ O key-val nosql
2009 Voldemort ✔ ✔ O EC, record O O O O key-val nosql
2009 Riak ✔ ✔ ✔ EC, record MR O key-val nosql
2010 Dremel ✔ O O O / ✔ O ✔ tables sql-like
2011 Megastore ✔ ✔ ✔ entity groups O / O / tables nosql
2011 Tenzing ✔ O O O O ✔ ✔ ✔ tables sql-like
2011 Spark/Shark ✔ O O O ✔ ✔ O ✔ tables sql-like
2012 Spanner ✔ ✔ ✔ ✔ ? ✔ ✔ ✔ tables sql-like
2012 Accumulo ✔ ✔ ✔ record
compat. w/
MR / O O ext. record nosql
2013 Impala ✔ O O O ✔ ✔ O ✔ tables sql-like
22. MEMCACHED
Main-memory caching service
• basic system: no persistence, replication, fault-tolerance
• Many extensions provide these features
• Ex: membrain, membase
Mature system, still in wide use
Important concept: consistent hashing
22
23. “REGULAR”HASHING
23
data keys
k0 = 367
k1 = 452
k2 = 776
… server 1 2 3 …. 64
Example: N=3
key 0 -> server 0
key 1 -> server 1
key 2 -> server 2
key 3 -> server 0
key 4 -> server 1
…
Assign M data keys to N servers
assign each key to server = k mod N
What happens if I increase the number of servers from N to 2N?
Every existing key needs to be remapped,and we’re screwed.
27. RICK CATTELL’S CLUSTERING
Key-Value Stores
• e.g., Memcached, Dynamo,Voldemort, Riak
Document Stores
• e.g., MongoDB, CouchDB
Extensible Record Store
• e.g., BigTable
27
28. MAJOR IMPACT SYSTEMS (RICK CATTEL)
• Memcached demonstrated that in-memory indexes
can be highly scalable, distributing and replicating
objects over multiple nodes.
• Dynamo pioneered the idea of [using] eventual
consistency as a way to achieve higher availability
and scalability: data fetched are not guaranteed to be
up-to-date, but updates are guaranteed to be
propagated to all nodes eventually.
• BigTable demonstrated that persistent record
storage could be scaled to thousands of nodes, a
feat that most of the other systems aspire to.
28
29. NOSQL FEATURES (RICK CATTEL)
Ability to horizontally scale “simple operation” throughput over
many servers
• Simple = key lookups, read/write of 1 or few records
The ability to replicate and partition data over many servers
• Consider “sharding” and “horizontal partitioning” to be synonyms
A simple API
A weaker concurrency model than ACID transactions
Efficient use of distributed indexes and RAM for data storage
The ability to dynamically add new attributes to data records
29
30. A DIFFERENT (NON-DISJOINT) CLUSTERING
Parallel Relational Databases
• Teradata, Greenplum, Netezza, Aster Data Systems,Vertica, …
• (Not MySQL or PostgreSQL)
NoSQL systems
• “Key-value stores”,“Document Stores” and “Extensible Record
Stores”
• Cassandra, CouchDB, MongoDB, BigTable/Hbase/Accumulo
MapReduce-based systems
• Hadoop, Pig, HIVE
Cloud services
• DynamoDB, SimpleDB, S3, Megastore, BigQuery
• CouchBase,
30
32. ROUGH DECISION PROCEDURE
Hadoop (locally managed)
• Java?
• Large unstructured files?
• Relatively small number of tasks?
• System administration support?
• Need to / want to roll your own algorithms?
32
33. ROUGH DECISION PROCEDURE
Hadoop derivatives (Pig, HIVE)
• Same as Hadoop, with
• A high-level language
• Support for multi-step workflows
33
34. ROUGH DECISION PROCEDURE
NoSQL
• One object at a time manipulation?
• Lots of concurrent users/apps?
• Can you live without joins?
• System administration?
• Need interactive response times?
• e.g., you’re powering a web application
34
36. ROADMAP
Intro
Decision procedures
Key-Value Store Example:
• memcached
Document Store Example:
• CouchDB
Extensible Record Store Example:
• Apache Hbase / Google BigTable
Discriminators
• Programming Model
• Consistency, Latency
• Cloud vs. Local
36
37. MEMCACHED
Main-memory caching service
• basic system: no persistence, replication, fault-
tolerance
• Many extensions provide these features
• Ex: membrain, membase
Mature system, still in wide use
Important concept: consistent hashing
37
38. “REGULAR”HASHING
38
data keys
k0 = 367
k1 = 452
k2 = 776
… server 1 2 3 …. 64
Example: N=3
key 0 -> server 0
key 1 -> server 1
key 2 -> server 2
key 3 -> server 0
key 4 -> server 1
…
Assign M data keys to N servers
assign each key to server = k mod N
What happens if I increase the number of servers from N to 2N?
Every existing key needs to be remapped,and we’re screwed.
39. ROADMAP
Intro
Decision procedures
Key-Value Store Example:
• memcached
Document Store Example:
• CouchDB
Extensible Record Store Example:
• Apache Hbase / Google BigTable
Discriminators
• Programming Model
• Consistency, Latency
• Cloud vs. Local
39
40. COUCHDB:DATA MODEL
Document-oriented
• Document = set of key/value pairs
• Ex:
40
{
"Subject": "I like Plankton"
"Author": "Rusty"
"PostedDate": "5/23/2006"
"Tags": ["plankton", "baseball",
"decisions"]
"Body": "I decided today that I don't like
baseball. I like plankton."
}
41. COUCHDB:UPDATES
ACID
• Atomic, Consistent, Isolated, Durable
Lock-free concurrency
• Optimistic – attempts to edit dirty data fail
No transactions
• Transaction: Sequence of related updates
• Entire sequence considered ACID
41
43. ROADMAP
Intro
Decision procedures
Key-Value Store Example:
• memcached
Document Store Example:
• CouchDB
Extensible Record Store Example:
• Apache Hbase / Google BigTable
Discriminators
• Programming Model
• Consistency, Latency
• Cloud vs. Local
43
44. GOOGLE BIGTABLE
OSDI paper in 2006
• Some overlap with the authors of the MapReduce
paper
Complementary to MapReduce
• Recall:What is MapReduce *not* designed for?
44
46. ROWS
Data is sorted lexicographically by row key
Row key range broken into tablets
• Recall:What was Teradata’s model of distribution?
A tablet is the unit of distribution and load
balancing
46
47. COLUMN FAMILIES
Column names of the form family:qualifier
“family” is the basic unit of
• access control
• memory accounting
• disk accounting
Typically all columns in a family the same type
47
48. TIMESTAMPS
Each cell can be versioned
Each new version increments the timestamp
Policies:
• “keep only latest n versions”
• “keep only versions since time t”
48
49. TABLET MANAGEMENT
Master assigns tablets to tablet servers
Tablet server manages reads and writes from its
tablets
Clients communicate directly with tablet server
Tablet server splits tablets that have grown too large.
49
51. WRITE PROCESSING
51
recent sequence of updates in
memtable
minor compaction: write memtable
buffer to a new
SSTable
major compaction: rewrite all
SSTables into one
SSTable; clean
deletes
52. OTHER TRICKS
Compression
• specified by clients
Bloom filters
• fast set membership test for (row, column) pair
• reduces disk accesses during reads
Locality Groups
• Groups of column families frequently accessed together
Immutability
• SSTables (disk chunks) are immutable
• Only the memtable needs to support concurrent updates (via
copy-on-write)
52
53. HBASE
Implementation of Google BigTable
Compatible with Hadoop
• TableInputFormat allows reading of BigTable data in
the map phase
• One mapper per tablet
• Aside: Speculative Execution?
53
55. JOINS
Ex: Show all comments by “Sue” on any blog post by “Jim”
Method 1:
• Lookup all blog posts by Jim
• For each post, lookup all comments and filter for “Sue”
Method 2:
• Lookup all comments by Sue
• For each comment, lookup all posts and filter for “Jim”
Method 3:
• Filter comments by Sue, filter posts by Jim,
• Sort all comments by blog id, sort all blogs by blog id
• Pull one from each list to find matches
55
56. PROGRAMMING MODELS:MY TERMINOLOGY
Lookup
• put/get objects by key only
• Ex: Cassandra
Filter
• Non-key access.
• No joins. Single-relation access only. May look like SQL.
• Ex: SimpleDB, Google Megastore
MapReduce
• Two functions define a distributed program: Map and Reduce
RA-like
• A set of operators akin to the Relational Algebra
• Ex: Pig, MS DryadLINQ
SQL-like
• Declarative language
• Includes joins
• Ex: HIVE, Google BigQuery
56
57. CLOUD SERVICES
Product Provider Prog.
Model
Storage
Cost
Compute
Cost
IO Cost
Megastore Google Filter $0.15 /
GB / mo.
$0.10 /
corehour
$.10 / GB in,
$.12 / GB out
BigQuery Google SQL-like Closed
beta
Closed beta Closed beta
Microsoft
Table
Microsoft Lookup $0.15 /
GB / mo.
$0.12 / hour
and up
$.10 / GB in,
$.15 / GB out
Elastic
MapReduce
Amazon MR,
RA-like,
SQL
$0.093 /
GB / mo.
$0.10 / hour
and up
$0.10 / GB in,
$0.15 / GB out
(1st GB free)
SimpleDB Amazon Filter $0.093 /
GB / mo.
1st 25 hours
free, $0.14
after that
$0.10 / GB in,
$0.15 / GB out
(1st GB free)
57
http://escience.washington.edu/blog
58. CAP THEOREM [BREWER 2000,LYNCH 2002]
Consistency
• Do all applications see all the same data?
Availability
• If some nodes fail, does everything still work?
Partitioning
• If your nodes can’t talk to each other, does everything still work?
CAP Theorem: Choose two, or sacrifice latency
Databases: Consistency, Availability
NoSQL: Availability, Partitioning
But: Some counterevidence – “NewSQL”
58
60. “EVENTUAL CONSISTENCY”
Write conflicts will eventually propagate throughout the system
• D.Terry et al.,“Managing Update Conflicts in Bayou,a Weakly Connected
Replicated Storage System”, SOSP 1995
60
“We believe that applications must be aware that they may read weakly
consistent data and also that their write operations may conflict with
those of other users and applications.”
“Moreover, applications must be revolved m the detection and
resolution of conflicts since these naturally depend on the semantics of
the application.”
61. EVENTUAL CONSISTENCY
What the application sees in the meantime is sensitive to
replication mechanics and difficult to predict
Contrast with RDBMS, Paxos: Immediate (or “strong”)
consistency, but there may be deadlocks
61
62. "What information consumes is rather obvious: it consumes the
attention of its recipients. Hence a wealth of information creates a
poverty of attention, and a need to allocate that attention efficiently
among the overabundance of information sources that might consume
it."
-- Herbert Simon
62
63. 63
Year
System/
Paper
Scale to
1000s
Primary
Index
Secondary
Indexes Transac9ons
Joins/
Analy9cs
Integrity
Constraints Views
Language/
Algebra
Data
model my label
1971 RDBMS O ✔ ✔ ✔ ✔ ✔ ✔ ✔ tables sql-like
2003 memcached ✔ ✔ O O O O O O key-val nosql
2004 MapReduce ✔ O O O ✔ O O O key-val batch
2005 CouchDB ✔ ✔ ✔ record MR O ✔ O document nosql
2006 BigTable (Hbase) ✔ ✔ ✔ record compat. w/MR / O O ext. record nosql
2007 MongoDB ✔ ✔ ✔ EC, record O O O O document nosql
2007 Dynamo ✔ ✔ O O O O O O key-val nosql
2008 Pig ✔ O O O ✔ / O ✔ tables sql-like
2008 HIVE ✔ O O O ✔ ✔ O ✔ tables sql-like
2008 Cassandra ✔ ✔ ✔ EC, record O ✔ ✔ O key-val nosql
2009 Voldemort ✔ ✔ O EC, record O O O O key-val nosql
2009 Riak ✔ ✔ ✔ EC, record MR O key-val nosql
2010 Dremel ✔ O O O / ✔ O ✔ tables sql-like
2011 Megastore ✔ ✔ ✔ enAty groups O / O / tables nosql
2011 Tenzing ✔ O O O O ✔ ✔ ✔ tables sql-like
2011 Spark/Shark ✔ O O O ✔ ✔ O ✔ tables sql-like
2012 Spanner ✔ ✔ ✔ ✔ ? ✔ ✔ ✔ tables sql-like
2012 Accumulo ✔ ✔ ✔ record compat. w/MR / O O ext. record nosql
2013 Impala ✔ O O O ✔ ✔ O ✔ tables sql-like
64. DYNAMODB
Key features:
Service Level Agreement (SLN): at the
99th percentile, and not on mean/median/variance (otherwise,
one penalizes the heavy users)
“Respond within 300ms for 99.9% of its requests”
64
65. DYNAMO (2)
Key features:
DHT with replication:
• Store value at k, k+1, …, k+N-1
• Eventual consistency through vector clocks
Reconciliation at read time:
• Writes never fail (“poor customer experience”)
• Conflict resolution:“last write wins” or application
specific
65
66. VECTOR CLOCKS
66
Each data item associated with
a list of (server, timestamp)
pairs indicating its version
history.
67. VECTOR CLOCKS EXAMPLE
A client writes D1 at server SX:
D1 ([SX,1])
Another client reads D1, writes back D2; also handled by SX:
D2 ([SX,2]) (D1 garbage collected)
Another client reads D2, writes back D3; handled by server SY:
D3 ([SX,2], [SY,1])
Another client reads D2, writes back D4; handled by server SZ:
D4 ([SX,2], [SZ,1])
Another client reads D3, D4: CONFLICT !
67
68. 68
Data 1 Data 2 Conflict?
([Sx,3],[Sy,6]) ([Sx,3],[Sz,2])
([Sx,3]) ([Sy,5])
([Sx,3],[Sy,6]) ([Sx,3],[Sy,6]),[Sz,2])
([Sx,3],[Sy,10])
([Sx,3],[Sy,10]) ([Sx,3],[Sy,20]),[Sz,2])
([Sx,3],[Sy,6]),[Sz,2])
69. CONFIGURABLE CONSISTENCY
R = Minumum number of nodes that participate in a successful
read
W = Minumum number of nodes that participate in a successful
write
N = Replication factor
If R +W > N, you can claim consistency
But R +W < N means lower latency.
69
70. 70
Year
System/
Paper
Scale to
1000s
Primary
Index
Secondary
Indexes Transac9ons
Joins/
Analy9cs
Integrity
Constraints Views
Language/
Algebra
Data
model my label
1971 RDBMS O ✔ ✔ ✔ ✔ ✔ ✔ ✔ tables sql-like
2003 memcached ✔ ✔ O O O O O O key-val nosql
2004 MapReduce ✔ O O O ✔ O O O key-val batch
2005 CouchDB ✔ ✔ ✔ record MR O ✔ O document nosql
2006 BigTable (Hbase) ✔ ✔ ✔ record compat. w/MR / O O ext. record nosql
2007 MongoDB ✔ ✔ ✔ EC, record O O O O document nosql
2007 Dynamo ✔ ✔ O O O O O O key-val nosql
2008 Pig ✔ O O O ✔ / O ✔ tables sql-like
2008 HIVE ✔ O O O ✔ ✔ O ✔ tables sql-like
2008 Cassandra ✔ ✔ ✔ EC, record O ✔ ✔ O key-val nosql
2009 Voldemort ✔ ✔ O EC, record O O O O key-val nosql
2009 Riak ✔ ✔ ✔ EC, record MR O key-val nosql
2010 Dremel ✔ O O O / ✔ O ✔ tables sql-like
2011 Megastore ✔ ✔ ✔ enAty groups O / O / tables nosql
2011 Tenzing ✔ O O O O ✔ ✔ ✔ tables sql-like
2011 Spark/Shark ✔ O O O ✔ ✔ O ✔ tables sql-like
2012 Spanner ✔ ✔ ✔ ✔ ? ✔ ✔ ✔ tables sql-like
2012 Accumulo ✔ ✔ ✔ record compat. w/MR / O O ext. record nosql
2013 Impala ✔ O O O ✔ ✔ O ✔ tables sql-like
71. COUCHDB:DATA MODEL
Document-oriented
• Document = set of key/value pairs
• Ex:
71
{
"Subject": "I like Plankton"
"Author": "Rusty"
"PostedDate": "5/23/2006"
"Tags": ["plankton", "baseball", "decisions"]
"Body": "I decided today that I don't like baseball. I
like plankton."
}
72. COUCHDB:UPDATES
Full Consistency within a document
Lock-free concurrency
• Optimistic – attempts to edit dirty data fail
No multi-row transactions
• Transaction: Sequence of related updates
• Entire sequence considered ACID
72
75. 75
Year
System/
Paper
Scale to
1000s
Primary
Index
Secondary
Indexes Transac9ons
Joins/
Analy9cs
Integrity
Constraints Views
Language/
Algebra
Data
model my label
1971 RDBMS O ✔ ✔ ✔ ✔ ✔ ✔ ✔ tables SQL-like
2003 memcached ✔ ✔ O O O O O O key-val lookup
2004 MapReduce ✔ O O O ✔ O O O key-val MR
2005 CouchDB ✔ ✔ ✔ record MR O ✔ O document filter/MR
2006 BigTable (Hbase) ✔ ✔ ✔ record compat. w/MR / O O ext. record filter/MR
2007 MongoDB ✔ ✔ ✔ EC, record O O O O document filter
2007 Dynamo ✔ ✔ O O O O O O key-val lookup
2008 Pig ✔ O O O ✔ / O ✔ tables RA-like
2008 HIVE ✔ O O O ✔ ✔ O ✔ tables SQL-like
2008 Cassandra ✔ ✔ ✔ EC, record O ✔ ✔ O key-val filter
2009 Voldemort ✔ ✔ O EC, record O O O O key-val lookup
2009 Riak ✔ ✔ ✔ EC, record MR O key-val filter
2010 Dremel ✔ O O O / ✔ O ✔ tables SQL-like
2011 Megastore ✔ ✔ ✔ enAty groups O / O / tables filter
2011 Tenzing ✔ O O O O ✔ ✔ ✔ tables SQL-like
2011 Spark/Shark ✔ O O O ✔ ✔ O ✔ tables SQL-like
2012 Spanner ✔ ✔ ✔ ✔ ? ✔ ✔ ✔ tables SQL-like
2012 Accumulo ✔ ✔ ✔ record compat. w/MR / O O ext. record filter
2013 Impala ✔ O O O ✔ ✔ O ✔ tables SQL-like
76. GOOGLE BIGTABLE
76
OSDI paper in 2006
• Some overlap with the authors of the MapReduce paper
Complementary to MapReduce
• Recall:What is MapReduce *not* designed for?
78. ROWS
78
Data is sorted lexicographically by row key
Row key range broken into tablets
• Recall:What was Teradata’s model of distribution?
A tablet is the unit of distribution and load
balancing
79. COLUMN FAMILIES
79
Column names of the form family:qualifier
“family” is the basic unit of
• access control
• memory accounting
• disk accounting
Typically all columns in a family the same type
80. TIMESTAMPS
80
Each cell can be versioned
Each new version increments the
timestamp
Policies:
• “keep only latest n versions”
• “keep only versions since time t”
81. TABLET MANAGEMENT
81
• Master assigns tablets to tablet servers
• Tablet server manages reads and writes from its
tablets
• Clients communicate directly with tablet server
• Tablet server splits tablets that have grown too
large.
83. WRITE PROCESSING
83
recent sequence of updates in
memtable
minor compaction: write memtable
buffer to a new
SSTable
major compaction: rewrite all
SSTables into one
SSTable; clean
deletes
84. OTHER TRICKS
Compression
• specified by clients
Bloom filters
• fast set membership test for (row, column) pair
• reduces disk accesses during reads
Locality Groups
• Groups of column families frequently accessed together
Immutability
• SSTables (disk chunks) are immutable
• Only the memtable needs to support concurrent updates (via
copy-on-write)
84
85. HBASE
Implementation of Google BigTable
Compatible with Hadoop
• TableInputFormat allows reading of BigTable data in
the map phase
• One mapper per tablet
• Aside: Speculative Execution?
85
86. MEGASTORE
Argues that loose consistency models complicate application
programming
Synchronous replication
Full transactions within a partition
86
[Baker, Bond, Corbett, et al. 2011]
87. SPANNER
87
Even though many projects happily use Bigtable [9], we have also
consistently received complaints from users that Bigtable can be
difficult to use for some kinds of applications: those that have
complex, evolving schemas, or those that want strong
consistency in the presence of wide-area replication.
“We believe it is better to have application programmers
deal with performance problems due to overuse of
transactions as bottlenecks arise, rather than always
coding around the lack of transactions.”
“Although Spanner is scalable in the number of nodes, the node-
local data structures have relatively poor performance on complex
SQL queries, because they were designed for simple key-value
accesses. Algorithms and data structures from DB literature could
improve singlenode performance a great deal.”
88. SPANNER DATA MODEL
Directory: set of contiguous keys with a shared prefix
88
Tables are interleaved to
create a hierarchy
CREATE TABLE Users {
uid INT64 NOT NULL,
email STRING
} PRIMARY KEY (uid), DIRECTORY;
CREATE TABLE Albums {
uid INT64 NOT NULL,
aid INT64 NOT NULL,
name STRING
} PRIMARY KEY (uid, aid),
INTERLEAVE IN PARENT Users
89. 89
Assigns data to
spanservers
Routes requests
from clients
Serves data
mostly status
info about
zones
Moves
directories for
load balancing
every few
minutes
Zone ~
BigTable
deployment
91. 91
Year
System/
Paper
Scale to
1000s
Primary
Index
Secondary
Indexes Transac9ons
Joins/
Analy9cs
Integrity
Constraints Views
Language/
Algebra
Data
model my label
1971 RDBMS O ✔ ✔ ✔ ✔ ✔ ✔ ✔ tables sql-like
2003 memcached ✔ ✔ O O O O O O key-val nosql
2004 MapReduce ✔ O O O ✔ O O O key-val batch
2005 CouchDB ✔ ✔ ✔ record MR O ✔ O document nosql
2006
BigTable
(Hbase) ✔ ✔ ✔ record compat. w/MR / O O ext. record nosql
2007 MongoDB ✔ ✔ ✔ EC, record O O O O document nosql
2007 Dynamo ✔ ✔ O O O O O O ext. record nosql
2008 Pig ✔ O O O ✔ / O ✔ tables sql-like
2008 HIVE ✔ O O O ✔ ✔ O ✔ tables sql-like
2008 Cassandra ✔ ✔ ✔ EC, record O ✔ ✔ O key-val nosql
2009 Voldemort ✔ ✔ O EC, record O O O O key-val nosql
2009 Riak ✔ ✔ ✔ EC, record MR O key-val nosql
2010 Dremel ✔ O O O / ✔ O ✔ tables sql-like
2011 Megastore ✔ ✔ ✔ enAty groups O / O / tables nosql
2011 Tenzing ✔ O O O ✔ ✔ ✔ ✔ tables sql-like
2011 Spark/Shark ✔ O O O ✔ ✔ O ✔ tables sql-like
2012 Spanner ✔ ✔ ✔ ✔ ? ✔ ✔ ✔ tables sql-like
2012 Accumulo ✔ ✔ ✔ record compat. w/MR / O O ext. record nosql
2013 Impala ✔ O O O ✔ ✔ O ✔ tables sql-like
Google’s Systems
92. HBase
GOOGLE BIG DATA SYSTEMS
92
BigTable
Dremel
Tenzing
2004
Pregel
Hadoop
2005
MapReduce
2006
2007
2008
2009
Spanner
Megastore
2010
2011
2012
non-Google open
source
implementation
direct influence /
shared features
compatible
implementation
of
93. MAPREDUCED-BASED SYSTEMS
93
Year
System/
Paper
Scale to
1000s
Primary
Index
Secondary
Indexes Transac9ons
Joins/
Analy9cs
Integrity
Constraints Views
Language/
Algebra
Data
model my label
1971 RDBMS O ✔ ✔ ✔ ✔ ✔ ✔ ✔ tables sql-like
2003 memcached ✔ ✔ O O O O O O key-val nosql
2004 MapReduce ✔ O O O ✔ O O O key-val batch
2005 CouchDB ✔ ✔ ✔ record MR O ✔ O document nosql
2006
BigTable
(Hbase) ✔ ✔ ✔ record compat. w/MR / O O ext. record nosql
2007 MongoDB ✔ ✔ ✔ EC, record O O O O document nosql
2007 Dynamo ✔ ✔ O O O O O O ext. record nosql
2008 Pig ✔ O O O ✔ / O ✔ tables sql-like
2008 HIVE ✔ O O O ✔ ✔ O ✔ tables sql-like
2008 Cassandra ✔ ✔ ✔ EC, record O ✔ ✔ O key-val nosql
2009 Voldemort ✔ ✔ O EC, record O O O O key-val nosql
2009 Riak ✔ ✔ ✔ EC, record MR O key-val nosql
2010 Dremel ✔ O O O / ✔ O ✔ tables sql-like
2011 Megastore ✔ ✔ ✔ enAty groups O / O / tables nosql
2011 Tenzing ✔ O O O ✔ ✔ ✔ ✔ tables sql-like
2011 Spark/Shark ✔ O O O ✔ ✔ O ✔ tables sql-like
2012 Spanner ✔ ✔ ✔ ✔ ? ✔ ✔ ✔ tables sql-like
2012 Accumulo ✔ ✔ ✔ record compat. w/MR / O O ext. record nosql
2013 Impala ✔ O O O ✔ ✔ O ✔ tables sql-like
95. 95
Year
System/
Paper
Scale to
1000s
Primary
Index
Secondary
Indexes Transac9ons
Joins/
Analy9cs
Integrity
Constraints Views
Language/
Algebra
Data
model my label
1971 RDBMS O ✔ ✔ ✔ ✔ ✔ ✔ ✔ tables sql-like
2003 memcached ✔ ✔ O O O O O O key-val nosql
2004 MapReduce ✔ O O O ✔ O O O key-val batch
2005 CouchDB ✔ ✔ ✔ record MR O ✔ O document nosql
2006
BigTable
(Hbase) ✔ ✔ ✔ record compat. w/MR / O O ext. record nosql
2007 MongoDB ✔ ✔ ✔ EC, record O O O O document nosql
2007 Dynamo ✔ ✔ O O O O O O ext. record nosql
2008 Pig ✔ O O O ✔ / O ✔ tables sql-like
2008 HIVE ✔ O O O ✔ ✔ O ✔ tables sql-like
2008 Cassandra ✔ ✔ ✔ EC, record O ✔ ✔ O key-val nosql
2009 Voldemort ✔ ✔ O EC, record O O O O key-val nosql
2009 Riak ✔ ✔ ✔ EC, record MR O key-val nosql
2010 Dremel ✔ O O O / ✔ O ✔ tables sql-like
2011 Megastore ✔ ✔ ✔ enAty groups O / O / tables nosql
2011 Tenzing ✔ O O O ✔ ✔ ✔ ✔ tables sql-like
2011 Spark/Shark ✔ O O O ✔ ✔ O ✔ tables sql-like
2012 Spanner ✔ ✔ ✔ ✔ ? ✔ ✔ ✔ tables sql-like
2012 Accumulo ✔ ✔ ✔ record compat. w/MR / O O ext. record nosql
2013 Impala ✔ O O O ✔ ✔ O ✔ tables sql-like
97. 97
A lot of these systems give up joins!
Year source
System/
Paper
Scale to
1000s
Primary
Index
Secondary
Indexes Transac9ons
Joins/
Analy9cs
Integrity
Constraints Views
Language/
Algebra
Data
model my label
1971 many RDBMS O ✔ ✔ ✔ ✔ ✔ ✔ ✔ tables SQL-like
2003 other memcached ✔ ✔ O O O O O O key-val lookup
2004 Google MapReduce ✔ O O O ✔ O O O key-val MR
2005 couchbase CouchDB ✔ ✔ ✔ record MR O ✔ O document filter/MR
2006 Google BigTable (Hbase) ✔ ✔ ✔ record compat. w/MR / O O ext. record filter/MR
2007 10gen MongoDB ✔ ✔ ✔ EC, record O O O O document filter
2007 Amazon Dynamo ✔ ✔ O O O O O O key-val lookup
2007 Amazon SimpleDB ✔ ✔ ✔ O O O O O ext. record filter
2008 Yahoo Pig ✔ O O O ✔ / O ✔ tables RA-like
2008 Facebook HIVE ✔ O O O ✔ ✔ O ✔ tables SQL-like
2008 Facebook Cassandra ✔ ✔ ✔ EC, record O ✔ ✔ O key-val filter
2009 other Voldemort ✔ ✔ O EC, record O O O O key-val lookup
2009 basho Riak ✔ ✔ ✔ EC, record MR O key-val filter
2010 Google Dremel ✔ O O O / ✔ O ✔ tables SQL-like
2011 Google Megastore ✔ ✔ ✔ enAty groups O / O / tables filter
2011 Google Tenzing ✔ O O O ✔ ✔ ✔ ✔ tables SQL-like
2011 Berkeley Spark/Shark ✔ O O O ✔ ✔ O ✔ tables SQL-like
2012 Google Spanner ✔ ✔ ✔ ✔ ? ✔ ✔ ✔ tables SQL-like
2012 Accumulo Accumulo ✔ ✔ ✔ record compat. w/MR / O O ext. record filter
2013 Cloudera Impala ✔ O O O ✔ ✔ O ✔ tables SQL-like
98. JOINS
98
Ex: Show all comments by “Sue” on any blog post by “Jim”
Method 1:
• Lookup all blog posts by Jim
• For each post, lookup all comments and filter for “Sue”
Method 2:
• Lookup all comments by Sue
• For each comment, lookup all posts and filter for “Jim”
Method 3:
• Filter comments by Sue, filter posts by Jim,
• Sort all comments by blog id, sort all blogs by blog id
• Pull one from each list to find matches
99. 99
Year
System/
Paper
Scale to
1000s
Primary
Index
Secondary
Indexes Transac9ons
Joins/
Analy9cs
Integrity
Constraints Views
Language/
Algebra
Data
model my label
1971 RDBMS O ✔ ✔ ✔ ✔ ✔ ✔ ✔ tables SQL-like
2003 memcached ✔ ✔ O O O O O O key-val lookup
2004 MapReduce ✔ O O O ✔ O O O key-val MR
2005 CouchDB ✔ ✔ ✔ record MR O ✔ O document filter/MR
2006 BigTable (Hbase) ✔ ✔ ✔ record compat. w/MR / O O ext. record filter/MR
2007 MongoDB ✔ ✔ ✔ EC, record O O O O document filter
2007 Dynamo ✔ ✔ O O O O O O key-val lookup
2008 Pig ✔ O O O ✔ / O ✔ tables RA-like
2008 HIVE ✔ O O O ✔ ✔ O ✔ tables SQL-like
2008 Cassandra ✔ ✔ ✔ EC, record O ✔ ✔ O key-val filter
2009 Voldemort ✔ ✔ O EC, record O O O O key-val lookup
2009 Riak ✔ ✔ ✔ EC, record MR O key-val filter
2010 Dremel ✔ O O O / ✔ O ✔ tables SQL-like
2011 Megastore ✔ ✔ ✔ enAty groups O / O / tables filter
2011 Tenzing ✔ O O O O ✔ ✔ ✔ tables SQL-like
2011 Spark/Shark ✔ O O O ✔ ✔ O ✔ tables SQL-like
2012 Spanner ✔ ✔ ✔ ✔ ? ✔ ✔ ✔ tables SQL-like
2012 Accumulo ✔ ✔ ✔ record compat. w/MR / O O ext. record filter
2013 Impala ✔ O O O ✔ ✔ O ✔ tables SQL-like
100. NOSQL CRITICISM
100
Two value propositions
• Performance:“I started with MySQL, but had a hard
time scaling it out in a distributed environment”
• Flexibility:“My data doesn’t conform to a rigid
schema”
Stonebraker CACM (blog 2)
101. NOSQL CRITICISM:FLEXIBILITY ARGUMENT
101
Who are the customers of NoSQL?
• Lots of startups
Very few enterprises.Why? most applications are traditional
OLTP on structured data; a few other applications around the
“edges”, but considered less important
Stonebraker CACM (blog 2)
102. NOSQL CRITICISM:FLEXIBILITY ARGUMENT
102
No ACID Equals No Interest
• Screwing up mission-critical data is no-no-no
Low-level Query Language is Death
• Remember CODASYL?
NoSQL means NoStandards
• One (typical) large enterprise has 10,000 databases.These need
accepted standards
Stonebraker CACM (blog 2)
103. WHAT IS PIG?
103
An engine for executing programs on top of Hadoop
It provides a language, Pig Latin, to specify these programs
An Apache open source project http://pig.apache.org/
104. WHY USE PIG?
104
Suppose you have user data in one
file, website data in another, and
you need to find the top 5 most
visited sites by users aged 18 -
25.
Load Users Load Pages
Filter by age
Join on name
Group on url
Count clicks
Order by clicks
Take top 5
105. IN MAPREDUCE
105
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.mapred.FileInputFormat;
import org.apache.hadoop.mapred.FileOutputFormat;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.KeyValueTextInputFormat;
import org.apache.hadoop.mapred.Mapper;
import org.apache.hadoop.mapred.MapReduceBase;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.RecordReader;
import org.apache.hadoop.mapred.Reducer;
import org.apache.hadoop.mapred.Reporter;
import org.apache.hadoop.mapred.SequenceFileInputFormat;
import org.apache.hadoop.mapred.SequenceFileOutputFormat;
import org.apache.hadoop.mapred.TextInputFormat;
import org.apache.hadoop.mapred.jobcontrol.Job;
import org.apache.hadoop.mapred.jobcontrol.JobControl;
import org.apache.hadoop.mapred.lib.IdentityMapper;
public class MRExample {
public static class LoadPages extends MapReduceBase
implements Mapper<LongWritable, Text, Text, Text> {
public void map(LongWritable k, Text val,
OutputCollector<Text, Text> oc,
Reporter reporter) throws IOException {
// Pull the key out
String line = val.toString();
int firstComma = line.indexOf(',');
String key = line.substring(0, firstComma);
String value = line.substring(firstComma + 1);
Text outKey = new Text(key);
// Prepend an index to the value so we know which file
// it came from.
Text outVal = new Text("1" + value);
oc.collect(outKey, outVal);
}
}
public static class LoadAndFilterUsers extends MapReduceBase
implements Mapper<LongWritable, Text, Text, Text> {
public void map(LongWritable k, Text val,
OutputCollector<Text, Text> oc,
Reporter reporter) throws IOException {
// Pull the key out
String line = val.toString();
int firstComma = line.indexOf(',');
String value = line.substring(firstComma + 1);
int age = Integer.parseInt(value);
if (age < 18 || age > 25) return;
String key = line.substring(0, firstComma);
Text outKey = new Text(key);
// Prepend an index to the value so we know which file
// it came from.
Text outVal = new Text("2" + value);
oc.collect(outKey, outVal);
}
}
public static class Join extends MapReduceBase
implements Reducer<Text, Text, Text, Text> {
public void reduce(Text key,
Iterator<Text> iter,
OutputCollector<Text, Text> oc,
Reporter reporter) throws IOException {
// For each value, figure out which file it's from and
store it
// accordingly.
List<String> first = new ArrayList<String>();
List<String> second = new ArrayList<String>();
while (iter.hasNext()) {
Text t = iter.next();
String value = t.toString();
if (value.charAt(0) == '1')
first.add(value.substring(1));
else second.add(value.substring(1));
reporter.setStatus("OK");
}
// Do the cross product and collect the values
for (String s1 : first) {
for (String s2 : second) {
String outval = key + "," + s1 + "," + s2;
oc.collect(null, new Text(outval));
reporter.setStatus("OK");
}
}
}
}
public static class LoadJoined extends MapReduceBase
implements Mapper<Text, Text, Text, LongWritable> {
public void map(
Text k,
Text val,
OutputCollector<Text, LongWritable> oc,
Reporter reporter) throws IOException {
// Find the url
String line = val.toString();
int firstComma = line.indexOf(',');
int secondComma = line.indexOf(',', firstComma);
String key = line.substring(firstComma, secondComma);
// drop the rest of the record, I don't need it anymore,
// just pass a 1 for the combiner/reducer to sum instead.
Text outKey = new Text(key);
oc.collect(outKey, new LongWritable(1L));
}
}
public static class ReduceUrls extends MapReduceBase
implements Reducer<Text, LongWritable, WritableComparable,
Writable> {
public void reduce(
Text key,
Iterator<LongWritable> iter,
OutputCollector<WritableComparable, Writable> oc,
Reporter reporter) throws IOException {
// Add up all the values we see
long sum = 0;
while (iter.hasNext()) {
sum += iter.next().get();
reporter.setStatus("OK");
}
oc.collect(key, new LongWritable(sum));
}
}
public static class LoadClicks extends MapReduceBase
implements Mapper<WritableComparable, Writable, LongWritable,
Text> {
public void map(
WritableComparable key,
Writable val,
OutputCollector<LongWritable, Text> oc,
Reporter reporter) throws IOException {
oc.collect((LongWritable)val, (Text)key);
}
}
public static class LimitClicks extends MapReduceBase
implements Reducer<LongWritable, Text, LongWritable, Text> {
int count = 0;
public void reduce(
LongWritable key,
Iterator<Text> iter,
OutputCollector<LongWritable, Text> oc,
Reporter reporter) throws IOException {
// Only output the first 100 records
while (count < 100 && iter.hasNext()) {
oc.collect(key, iter.next());
count++;
}
}
}
public static void main(String[] args) throws IOException {
JobConf lp = new JobConf(MRExample.class);
lp.setJobName("Load Pages");
lp.setInputFormat(TextInputFormat.class);
lp.setOutputKeyClass(Text.class);
lp.setOutputValueClass(Text.class);
lp.setMapperClass(LoadPages.class);
FileInputFormat.addInputPath(lp, new
Path("/user/gates/pages"));
FileOutputFormat.setOutputPath(lp,
new Path("/user/gates/tmp/indexed_pages"));
lp.setNumReduceTasks(0);
Job loadPages = new Job(lp);
JobConf lfu = new JobConf(MRExample.class);
lfu.setJobName("Load and Filter Users");
lfu.setInputFormat(TextInputFormat.class);
lfu.setOutputKeyClass(Text.class);
lfu.setOutputValueClass(Text.class);
lfu.setMapperClass(LoadAndFilterUsers.class);
FileInputFormat.addInputPath(lfu, new
Path("/user/gates/users"));
FileOutputFormat.setOutputPath(lfu,
new Path("/user/gates/tmp/filtered_users"));
lfu.setNumReduceTasks(0);
Job loadUsers = new Job(lfu);
JobConf join = new JobConf(MRExample.class);
join.setJobName("Join Users and Pages");
join.setInputFormat(KeyValueTextInputFormat.class);
join.setOutputKeyClass(Text.class);
join.setOutputValueClass(Text.class);
join.setMapperClass(IdentityMapper.class);
join.setReducerClass(Join.class);
FileInputFormat.addInputPath(join, new
Path("/user/gates/tmp/indexed_pages"));
FileInputFormat.addInputPath(join, new
Path("/user/gates/tmp/filtered_users"));
FileOutputFormat.setOutputPath(join, new
Path("/user/gates/tmp/joined"));
join.setNumReduceTasks(50);
Job joinJob = new Job(join);
joinJob.addDependingJob(loadPages);
joinJob.addDependingJob(loadUsers);
JobConf group = new JobConf(MRExample.class);
group.setJobName("Group URLs");
group.setInputFormat(KeyValueTextInputFormat.class);
group.setOutputKeyClass(Text.class);
group.setOutputValueClass(LongWritable.class);
group.setOutputFormat(SequenceFileOutputFormat.class);
group.setMapperClass(LoadJoined.class);
group.setCombinerClass(ReduceUrls.class);
group.setReducerClass(ReduceUrls.class);
FileInputFormat.addInputPath(group, new
Path("/user/gates/tmp/joined"));
FileOutputFormat.setOutputPath(group, new
Path("/user/gates/tmp/grouped"));
group.setNumReduceTasks(50);
Job groupJob = new Job(group);
groupJob.addDependingJob(joinJob);
JobConf top100 = new JobConf(MRExample.class);
top100.setJobName("Top 100 sites");
top100.setInputFormat(SequenceFileInputFormat.class);
top100.setOutputKeyClass(LongWritable.class);
top100.setOutputValueClass(Text.class);
top100.setOutputFormat(SequenceFileOutputFormat.class);
top100.setMapperClass(LoadClicks.class);
top100.setCombinerClass(LimitClicks.class);
top100.setReducerClass(LimitClicks.class);
FileInputFormat.addInputPath(top100, new
Path("/user/gates/tmp/grouped"));
FileOutputFormat.setOutputPath(top100, new
Path("/user/gates/top100sitesforusers18to25"));
top100.setNumReduceTasks(1);
Job limit = new Job(top100);
limit.addDependingJob(groupJob);
JobControl jc = new JobControl("Find top 100 sites for users
18 to 25");
jc.addJob(loadPages);
jc.addJob(loadUsers);
jc.addJob(joinJob);
jc.addJob(groupJob);
jc.addJob(limit);
jc.run();
}
}
170 lines of code, 4 hours to write
106. IN PIG LATIN
106
Users = load ‘users’ as (name, age);
Fltrd = filter Users by
age >= 18 and age <= 25;
Pages = load ‘pages’ as (user, url);
Jnd = join Fltrd by name, Pages by user;
Grpd = group Jnd by url;
Smmd = foreach Grpd generate group,
COUNT(Jnd) as clicks;
Srtd = order Smmd by clicks desc;
Top5 = limit Srtd 5;
store Top5 into ‘top5sites’;
9 lines of code, 15 minutes to write
107. PIG SYSTEM OVERVIEW
107
Pig Latin
program
A = LOAD 'file1' AS
(sid,pid,mass,px:double);
B = LOAD 'file2' AS
(sid,pid,mass,px:double);
C = FILTER A BY px < 1.0;
D = JOIN C BY sid,
B BY sid;
STORE g INTO 'output.txt';
Ensemble of
MapReduce
jobs
109. DATA MODEL
109
Atom: Integer, string, etc.
Tuple:
• Sequence of fields
• Each field of any type
Bag:
• A collection of tuples
• Not necessarily the same type
• Duplicates allowed
Map:
• String literal keys mapped to any type
Key distinction:
Allows Nesting
111. 111
t = <1, {<2,3>,<4,6>,<5,7>}, ['apache':'search']>
Each field has a name, possibly derived from the operator
f1:atom f2:bag f3:map
112. 112
t = <1, {<2,3>,<4,6>,<5,7>}, ['apache':'search']>
f1:atom f2:bag f3:map
expression result
$0 1
f2 Bag {<2,3>,<4,6>,<5,7>}
f2.$0 Bag {<2>,<4>,<5>}
f3#’apache’ Atom “search”
sum(f2.$0) 2+4+5
113. LOAD
113
Input is assumed to be a bag (sequence of tuples)
Assumes that every dataset is a sequence of tuples
Specify a parsing function with “USING”
Specify a schema with “AS”
A = LOAD 'myfile.txt' USING PigStorage('t') AS
(f1,f2,f3);
<1, 2, 3>
<4, 2, 1>
<8, 3, 4>
<4, 3, 3>
<7, 2, 5>
<8, 4, 3>
114. FILTER:GETTING RID OF DATA
Arbitrary boolean conditions
Regular expressions allowed
$0 matches apache
114
Y = FILTER A BY f1 == '8';
<1, 2, 3>
<4, 2, 1>
<8, 3, 4>
<4, 3, 3>
<7, 2, 5>
<8, 4, 3>
<8, 3, 4>
<8, 4, 3>
Y =A =
115. GROUP:GETTING DATA TOGETHER
115
first field will be named “group”
second field has name “A”
X = GROUP A BY f1;
<1, 2, 3>
<4, 2, 1>
<8, 3, 4>
<4, 3, 3>
<7, 2, 5>
<8, 4, 3>
A = X = <1, {<1, 2, 3>}>
<4, {<4, 2, 1>, <4, 3, 3>}>
<7, {<7, 2, 5>}>
<8, {<8, 3, 4>, <8, 4, 3>}>
116. DISTINCT:GETTING RID OF DUPLICATES
116
Y = DISTINCT A
<1, 2, 3>
<1, 2, 3>
<8, 3, 4>
A = <1, 2, 3>
<8, 3, 4>
Y =
Claim:
DISTINCT A == GROUP A BY (f1, f2, f3)
< <1, 2, 3>, {<1,2,3>} >
< <8, 3, 4>, {<8,3,4>} >
Not quite:
118. FOREACH:MANIPULATE EACH TUPLE
118
X = FOREACH A GENERATE f0, f1+f2;
Y = GROUP A BY f1;
Z = FOREACH X GENERATE group, X.($1, $2);
<1, {<2, 3>}>
<4, {<2, 1>, <3, 3>}>
<7, {<2, 5>}>
<8, {<3, 4>, <4, 3>}>
Z =<1, 2, 3>
<4, 2, 1>
<8, 3, 4>
<4, 3, 3>
<7, 2, 5>
<8, 4, 3>
A = <1, 5>
<4, 3>
<8, 7>
<4, 6>
<7, 7>
<8, 7>
X =
You can call UDFs
You can
manipulate nested
objects
119. USING THE FLATTEN KEYWORD
119
Y = GROUP A BY f1;
Z = FOREACH X GENERATE group, FLATTEN(X);
<1, 2, 3>
<4, 2, 1>
<4, 3, 3>
<7, 2, 5>
<8, 3, 4>
<8, 4, 3>
Z =<1, 2, 3>
<4, 2, 1>
<8, 3, 4>
<4, 3, 3>
<7, 2, 5>
<8, 4, 3>
A = <1, 5>
<4, 3>
<8, 7>
<4, 6>
<7, 7>
<8, 7>
X =
I don’t like this, because FLATTEN has no well
defined type. It’s “magic”
120. IN MAPREDUCE
120
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.mapred.FileInputFormat;
import org.apache.hadoop.mapred.FileOutputFormat;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.KeyValueTextInputFormat;
import org.apache.hadoop.mapred.Mapper;
import org.apache.hadoop.mapred.MapReduceBase;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.RecordReader;
import org.apache.hadoop.mapred.Reducer;
import org.apache.hadoop.mapred.Reporter;
import org.apache.hadoop.mapred.SequenceFileInputFormat;
import org.apache.hadoop.mapred.SequenceFileOutputFormat;
import org.apache.hadoop.mapred.TextInputFormat;
import org.apache.hadoop.mapred.jobcontrol.Job;
import org.apache.hadoop.mapred.jobcontrol.JobControl;
import org.apache.hadoop.mapred.lib.IdentityMapper;
public class MRExample {
public static class LoadPages extends MapReduceBase
implements Mapper<LongWritable, Text, Text, Text> {
public void map(LongWritable k, Text val,
OutputCollector<Text, Text> oc,
Reporter reporter) throws IOException {
// Pull the key out
String line = val.toString();
int firstComma = line.indexOf(',');
String key = line.substring(0, firstComma);
String value = line.substring(firstComma + 1);
Text outKey = new Text(key);
// Prepend an index to the value so we know which file
// it came from.
Text outVal = new Text("1" + value);
oc.collect(outKey, outVal);
}
}
public static class LoadAndFilterUsers extends MapReduceBase
implements Mapper<LongWritable, Text, Text, Text> {
public void map(LongWritable k, Text val,
OutputCollector<Text, Text> oc,
Reporter reporter) throws IOException {
// Pull the key out
String line = val.toString();
int firstComma = line.indexOf(',');
String value = line.substring(firstComma + 1);
int age = Integer.parseInt(value);
if (age < 18 || age > 25) return;
String key = line.substring(0, firstComma);
Text outKey = new Text(key);
// Prepend an index to the value so we know which file
// it came from.
Text outVal = new Text("2" + value);
oc.collect(outKey, outVal);
}
}
public static class Join extends MapReduceBase
implements Reducer<Text, Text, Text, Text> {
public void reduce(Text key,
Iterator<Text> iter,
OutputCollector<Text, Text> oc,
Reporter reporter) throws IOException {
// For each value, figure out which file it's from and
store it
// accordingly.
List<String> first = new ArrayList<String>();
List<String> second = new ArrayList<String>();
while (iter.hasNext()) {
Text t = iter.next();
String value = t.toString();
if (value.charAt(0) == '1')
first.add(value.substring(1));
else second.add(value.substring(1));
reporter.setStatus("OK");
}
// Do the cross product and collect the values
for (String s1 : first) {
for (String s2 : second) {
String outval = key + "," + s1 + "," + s2;
oc.collect(null, new Text(outval));
reporter.setStatus("OK");
}
}
}
}
public static class LoadJoined extends MapReduceBase
implements Mapper<Text, Text, Text, LongWritable> {
public void map(
Text k,
Text val,
OutputCollector<Text, LongWritable> oc,
Reporter reporter) throws IOException {
// Find the url
String line = val.toString();
int firstComma = line.indexOf(',');
int secondComma = line.indexOf(',', firstComma);
String key = line.substring(firstComma, secondComma);
// drop the rest of the record, I don't need it anymore,
// just pass a 1 for the combiner/reducer to sum instead.
Text outKey = new Text(key);
oc.collect(outKey, new LongWritable(1L));
}
}
public static class ReduceUrls extends MapReduceBase
implements Reducer<Text, LongWritable, WritableComparable,
Writable> {
public void reduce(
Text key,
Iterator<LongWritable> iter,
OutputCollector<WritableComparable, Writable> oc,
Reporter reporter) throws IOException {
// Add up all the values we see
long sum = 0;
while (iter.hasNext()) {
sum += iter.next().get();
reporter.setStatus("OK");
}
oc.collect(key, new LongWritable(sum));
}
}
public static class LoadClicks extends MapReduceBase
implements Mapper<WritableComparable, Writable, LongWritable,
Text> {
public void map(
WritableComparable key,
Writable val,
OutputCollector<LongWritable, Text> oc,
Reporter reporter) throws IOException {
oc.collect((LongWritable)val, (Text)key);
}
}
public static class LimitClicks extends MapReduceBase
implements Reducer<LongWritable, Text, LongWritable, Text> {
int count = 0;
public void reduce(
LongWritable key,
Iterator<Text> iter,
OutputCollector<LongWritable, Text> oc,
Reporter reporter) throws IOException {
// Only output the first 100 records
while (count < 100 && iter.hasNext()) {
oc.collect(key, iter.next());
count++;
}
}
}
public static void main(String[] args) throws IOException {
JobConf lp = new JobConf(MRExample.class);
lp.setJobName("Load Pages");
lp.setInputFormat(TextInputFormat.class);
lp.setOutputKeyClass(Text.class);
lp.setOutputValueClass(Text.class);
lp.setMapperClass(LoadPages.class);
FileInputFormat.addInputPath(lp, new
Path("/user/gates/pages"));
FileOutputFormat.setOutputPath(lp,
new Path("/user/gates/tmp/indexed_pages"));
lp.setNumReduceTasks(0);
Job loadPages = new Job(lp);
JobConf lfu = new JobConf(MRExample.class);
lfu.setJobName("Load and Filter Users");
lfu.setInputFormat(TextInputFormat.class);
lfu.setOutputKeyClass(Text.class);
lfu.setOutputValueClass(Text.class);
lfu.setMapperClass(LoadAndFilterUsers.class);
FileInputFormat.addInputPath(lfu, new
Path("/user/gates/users"));
FileOutputFormat.setOutputPath(lfu,
new Path("/user/gates/tmp/filtered_users"));
lfu.setNumReduceTasks(0);
Job loadUsers = new Job(lfu);
JobConf join = new JobConf(MRExample.class);
join.setJobName("Join Users and Pages");
join.setInputFormat(KeyValueTextInputFormat.class);
join.setOutputKeyClass(Text.class);
join.setOutputValueClass(Text.class);
join.setMapperClass(IdentityMapper.class);
join.setReducerClass(Join.class);
FileInputFormat.addInputPath(join, new
Path("/user/gates/tmp/indexed_pages"));
FileInputFormat.addInputPath(join, new
Path("/user/gates/tmp/filtered_users"));
FileOutputFormat.setOutputPath(join, new
Path("/user/gates/tmp/joined"));
join.setNumReduceTasks(50);
Job joinJob = new Job(join);
joinJob.addDependingJob(loadPages);
joinJob.addDependingJob(loadUsers);
JobConf group = new JobConf(MRExample.class);
group.setJobName("Group URLs");
group.setInputFormat(KeyValueTextInputFormat.class);
group.setOutputKeyClass(Text.class);
group.setOutputValueClass(LongWritable.class);
group.setOutputFormat(SequenceFileOutputFormat.class);
group.setMapperClass(LoadJoined.class);
group.setCombinerClass(ReduceUrls.class);
group.setReducerClass(ReduceUrls.class);
FileInputFormat.addInputPath(group, new
Path("/user/gates/tmp/joined"));
FileOutputFormat.setOutputPath(group, new
Path("/user/gates/tmp/grouped"));
group.setNumReduceTasks(50);
Job groupJob = new Job(group);
groupJob.addDependingJob(joinJob);
JobConf top100 = new JobConf(MRExample.class);
top100.setJobName("Top 100 sites");
top100.setInputFormat(SequenceFileInputFormat.class);
top100.setOutputKeyClass(LongWritable.class);
top100.setOutputValueClass(Text.class);
top100.setOutputFormat(SequenceFileOutputFormat.class);
top100.setMapperClass(LoadClicks.class);
top100.setCombinerClass(LimitClicks.class);
top100.setReducerClass(LimitClicks.class);
FileInputFormat.addInputPath(top100, new
Path("/user/gates/tmp/grouped"));
FileOutputFormat.setOutputPath(top100, new
Path("/user/gates/top100sitesforusers18to25"));
top100.setNumReduceTasks(1);
Job limit = new Job(top100);
limit.addDependingJob(groupJob);
JobControl jc = new JobControl("Find top 100 sites for users
18 to 25");
jc.addJob(loadPages);
jc.addJob(loadUsers);
jc.addJob(joinJob);
jc.addJob(groupJob);
jc.addJob(limit);
jc.run();
}
}
170 lines of code, 4 hours to write
121. IN PIG LATIN
121
Users = load ‘users’ as (name, age);
Fltrd = filter Users by
age >= 18 and age <= 25;
Pages = load ‘pages’ as (user, url);
Jnd = join Fltrd by name, Pages by
user;
Grpd = group Jnd by url;
Smmd = foreach Grpd generate group,
COUNT(Jnd) as clicks;
Srtd = order Smmd by clicks desc;
Top5 = limit Srtd 5;
store Top5 into ‘top5sites’;
9 lines of code, 15 minutes to write
122. COGROUP:GETTING DATA TOGETHER
122
<2, 4>
<8, 9>
<1, 3>
<2, 7>
<2, 9>
<4, 6>
<4, 9>
B =
C = COGROUP A BY f1, B BY $0;
<1, 2, 3>
<4, 2, 1>
<8, 3, 4>
<4, 3, 3>
<7, 2, 5>
<8, 4, 3>
A =
<1, {<1, 2, 3>}, {<1, 3>}>
<2, {}, {<2, 4>, <2, 7>, <2, 9>}>
<4, {<4, 2, 1>, <4, 3, 3>}, {<4, 6>,<4, 9>}>
<7, {<7, 2, 5>}, {}>
<8, {<8, 3, 4>, <8, 4, 3>}, {<8, 9>}>
C =
123. JOIN:A SPECIAL CASE OF COGROUP
123
COGROUP and JOIN can both on multiple datasets
• Think about why this works
C = JOIN A BY $0, B BY $0;
<2, 4>
<8, 9>
<1, 3>
<2, 7>
<2, 9>
<4, 6>
<4, 9>
B =<1, 2, 3>
<4, 2, 1>
<8, 3, 4>
<4, 3, 3>
<7, 2, 5>
<8, 4, 3>
A = <1, 2, 3, 1, 3>
<4, 2, 1, 4, 6>
<4, 2, 1, 4, 9>
<4, 3, 3, 4, 6>
<4, 3, 3, 4, 9>
<8, 3, 4, 8, 9>
<8, 4, 3, 8, 9>
C =
125. THREE SPECIAL JOIN ALGORITHMS
125
Replicated
• One table is very small, one is big
• Replicate the small one
Skewed
• When one join key is associated with most of the data, we’re in
trouble
• handle these cases differently
Merge
• If the two datasets are already grouped/sorted on the correct
attribute, we can compute the join in the Map phase
126. map map map map map map
• Each mapper pulls a copy of the small relation from HDFS
• Small relation must fit in main memory
• You’ll see this called “Broadcast Join” as well
REPLICATED JOIN
126
128. THE PROBLEM OF SKEW
128
Kwon 2012
One task takes 5X
longer than the
average! Very little
benefit to parallelism
If someone asks you
“What is the biggest
performance problem
with MapReduce in
practice?”
Say:“Stragglers!”
129. map map map map map map
reduce reduce reduce reduce r r r
SKEW JOIN
129
130. map map map map map map
• Each mapper already has local access to the records from
both relations, grouped and sorted by the join key.
• Just read in both relations from disk, in order.
MERGE JOIN
130
131. WHY COGROUP AND NOT JOIN?
131
JOIN is a two-step process
• Create groups with shared keys
• Produce joined tuples
COGROUP only performs the first step
• You might do different processing on the groups
• e.g., count the tuples
join_result = JOIN A BY $0, B BY $0;
temp = COGROUP A BY $0, B BY $0;
join_result = FOREACH temp GENERATE
FLATTEN(results), FLATTEN(revenue);
133. EXAMPLE
133
LOAD
A = LOAD ‘traffic.dat’ AS (ip, time, url);
B = GROUP A BY ip;
C = FOREACH B GENERATE group AS ip,
COUNT(A);
D = FILTER C BY ip IS ‘192.168.0.1’;
OR ip IS ‘192.168.0.0’;
STORE D INTO ‘local_traffic.dat’;
Adapted from slides by Oliver Kennedy,U of Buffalo
134. EXAMPLE
134
A = LOAD ‘traffic.dat’ AS (ip, time, url);
B = GROUP A BY ip;
C = FOREACH B GENERATE group AS ip,
COUNT(A);
D = FILTER C BY ip IS ‘192.168.0.1’;
OR ip IS ‘192.168.0.0’;
STORE D INTO ‘local_traffic.dat’;
LOAD
GROUP
Adapted from slides by Oliver Kennedy,U of Buffalo
135. EXAMPLE
135
LOAD
GROUP
FOREACH
A = LOAD ‘traffic.dat’ AS (ip, time, url);
B = GROUP A BY ip;
C = FOREACH B GENERATE group AS ip,
COUNT(A);
D = FILTER C BY ip IS ‘192.168.0.1’;
OR ip IS ‘192.168.0.0’;
STORE D INTO ‘local_traffic.dat’;
Adapted from slides by Oliver Kennedy,U of Buffalo
136. EXAMPLE
136
LOAD
GROUP
FOREACH
FILTER
A = LOAD ‘traffic.dat’ AS (ip, time, url);
B = GROUP A BY ip;
C = FOREACH B GENERATE group AS ip,
COUNT(A);
D = FILTER C BY ip IS ‘192.168.0.1’;
OR ip IS ‘192.168.0.0’;
STORE D INTO ‘local_traffic.dat’;
Adapted from slides by Oliver Kennedy,U of Buffalo
137. EXAMPLE
137
A = LOAD ‘traffic.dat’ AS (ip, time, url);
B = GROUP A BY ip;
C = FOREACH B GENERATE group AS ip,
COUNT(A);
D = FILTER C BY ip IS ‘192.168.0.1’;
OR ip IS ‘192.168.0.0’;
STORE D INTO ‘local_traffic.dat’;
LOAD
GROUP
FOREACH
FILTER
STORE
Algebraic
Optimization!
Adapted from slides by Oliver Kennedy,U of Buffalo
138. EXAMPLE
138
A = LOAD ‘traffic.dat’ AS (ip, time, url);
B = GROUP A BY ip;
C = FOREACH B GENERATE group AS ip,
COUNT(A);
D = FILTER C BY ip IS ‘192.168.0.1’;
OR ip IS ‘192.168.0.0’;
STORE D INTO ‘local_traffic.dat’;
Lazy Evaluation:
No work is done
until STORE
LOAD
FILTER
GROUP
FOREACH
STORE
Adapted from slides by Oliver Kennedy,U of Buffalo
139. EXAMPLE
139
Map
Reduce
Create a MR job for each
COGROUP
LOAD
FILTER
GROUP
FOREACH
STORE
Adapted from slides by Oliver Kennedy,U of Buffalo
140. EXAMPLE
140
Map
Reduce
Adapted from slides by Oliver Kennedy,U of Buffalo
1) Create a MR job for
each COGROUP
2) Add other commands
where possible
Certain commands
require their own MR job
(e.g., ORDER)
LOAD
FILTER
GROUP
FOREACH
STORE
141. REVIEW
NoSQL
• “NoSchema”,“NoTransactions”,“NoLanguage”
• A “reboot” of data systems focusing on just high-throughput
reads and writes
• But: A clear trend towards re-introducing schemas, languages,
transactions at full scale
• Google’s Spanner system, for example
Pig
• An RA-like language layer on Hadoop
• But not a pure relational data model
• “Schema-on-Read” rather than “Schema-on-write”
141