Giter Club home page Giter Club logo

nosql-1's Introduction

Technologie NoSQL

Terminy akceptacji zaproszenia do GitHub classroom oraz rozliczania się z projektów na zaliczenie i egzamin.

Projekt Deadline
GitHub Classroom 01.03.2018
Moje dane 07.03.2018
Zaliczenie 10.04.2018
Egzamin 22.05.2018

Projekty na zaliczenie i egzamin oddane do tygodnia po wyznaczonym terminie – ocena obniżona; oddane później – egzamin poprawkowy.

🆕 Projekt „Moje dane”

Niestety nie mogę zaliczyć zdecydowanej większości projektów, bo autorzy nie zastosowali się wymagań opisanych w pliku labs.adoc. Dlatego w weekend w pliku umieszczę kilka wskazówek, które powinny ułatwić napisanie skryptów, wykonanie rachunków i tabelki.

Materiały do wykładów

Opracowane notatki z wykładu S. Tuszyńskiego „Kontenery Docker na komputerach w laboratoriach”.

Zaczynamy:

  1. The MongoDB 3.6 Manual:
  2. The mongo Shell
  3. MongoDB CRUD Operations
  4. Indexes:
  5. Expressive Query Language in MongoDB 3.6.
  6. MongoDB Tutorial Series – How to Investigate MongoDB Query Performance.
  7. Aggregation.
  8. Replication
  9. Data Models
  10. Drivers Manuals:

Narzędzia

  1. jq – a lightweight and flexible command-line JSON processor.
  2. VisiData – a terminal spreadsheet multitool for discovering and arranging data.
  3. CSVKit – a suite of command-line tools for converting to and working with CSV.

Projekt na zaliczenie

Aplikacja, zawierająca kilka skryptów, uruchamianych z linii poleceń korzystająca z MongoDB Drivers dla jednego z języków: C, C++, C#, Java, Node.js, Perl, Python, Scala lub Ruby.

Przykład takiej aplikacji „Sample app for the MongoDB Ruby driver” (mój fork).

Plik README.{md,adoc,rst,html} (w jednym z wymienionych notacji) powinien zawierać dokumentację projektu, imię i nazwisko autora. Powinien on zawierać grafiki, mapki, linki do stron HTML itp. wygenerowane za pomocą skryptów aplikacji, powinny być utworzone indeksy, oczywiście o ile mają one sens.

Dane należy zapisać w replica set; zob. Convert a Standalone to a Replica Set.

Projekty na egzamin

Agregacje korzystające z:

Obliczenia należy przeprowadzić w kontenerach Docker.

Do uruchamiania agregacji należy użyć skryptów napisanych w Bash lub jednym z języków Node.js, Python lub Ruby. Wyniki agregacji można przekształcać za pomocą poleceń powłoki Bash, programu jq, R lub innych programów zainstalowanych.

Plik README.{md,adoc,html} (w jednym z wymienionych foramtów) powinien zawierać dokumentację projektu oraz imiona i nazwiska autorów. Wyniki agregacji należy zilustrować grafikami, mapkami, stronami HTML opisem itp.

Praca w zespołach: przeczytać Fork and Pull Request Workflow.

Simple Rules for Reproducible Computations

Provide public access to scripts, runs, and results:

  1. Version control all custom scripts:
    • avoid writing code
    • write thin scripts and use standard tools and use standard UNIX commands to chain things together.
  2. Avoid manual data manipulation steps:
    • use a build system, for example make, and have all results produced automatically by build targets
    • if it’s not automated, it’s not part of the project, i.e. have an idea for a graph or an analysis? automate its generation
  3. Use a markup, for example Markdown, or AsciiDoctor to create reports for analysis and presentation output products.

Plus two more rules:

  1. Record all intermediate results, when possible in standardized formats.
  2. Connect textual statements to underlying results.

Uwaga: Jeśli to ma sens, to dane należy uporządkować i w bazie danych zapisać tidy dataset. Oczywiście, wcześniej należy przeczytać ten artykuł: Hadley Wickham, Tidy data w którym wyjaśniono co to oznacza.

Praca z gigabajtowymi plikami danych

Przykład: Spakowany plik RC_2015-01.bz2 zajmuje na dysku 5_452_413_560 B, czyli ok. 5.5 GB. Każda linijka pliku to jeden obiekt JSON, komentarz z serwisu Reddit, z tekstem komentarza, autorem, itd. Wszystkich komentarzy/JSON-ów powinno być 53_851_542.

bunzip2 --stdout RC_2015-01.bz2 | head -1 | jq .
time bunzip2 --stdout RC_2015-01.bz2 | rl --count 1000 > RC_2015-01_1000.json
# real   ∞ s
# user   ∞ s
# sys	0m12 s
time bunzip2 -c RC_2015-01.bz2 | mongoimport --drop --host 127.0.0.1 -d test -c reddit
# 2015-10-09T19:49:35.698+0200	test.reddit	29.5 GB
# 2015-10-09T19:49:35.698+0200	imported 53851542 documents

# real  38m40.629s
# user  56m37.200s
# sys   1m17.074s

Gnome System Monitor.

RC mongoimport

Plik restaurants.json zawiera informacje o restauracjach w Nowym Jorku.

curl -s https://raw.githubusercontent.com/mongodb/docs-assets/geospatial/neighborhoods.json \
| gzip --stdout  > restaurants.json.gz

#                          use   shuf -n 1  on Linux
gunzip -c restaurants.json.gz | gshuf -n 1  # macOS, brew install coreutils (gshuf)
gunzip -c restaurants.json.gz | rl    -c 1  # macOS, brew install randomize-lines

IMPORTANT: Unikamy zapisywania plików na dysku. Zwłaszcza dużych plików!

curl -s 'https://inf.ug.edu.pl/plan/?format=json' \
| mongoimport --drop --jsonArray -c plan

curl -s 'https://inf.ug.edu.pl/plan/?format=json' \
| jq -c '.[]' \
| mongoimport --drop -c plan

curl -s https://raw.githubusercontent.com/mongodb/docs-assets/geospatial/restaurants.json \
| gshuf -n 100 \
| mongoimport --drop -c restaurants100

curl -s https://raw.githubusercontent.com/mongodb/docs-assets/geospatial/neighborhoods.json \
| mongoimport --drop -c restaurants
  • git-sizer – compute various size metrics for a Git repository, flagging those that might cause problems.
  • BFG Repo-Cleaner – removes large or troublesome blobs like git-filter-branch does, but faster.

Analyzing Query Performance

db.restaurants.find( {name: /Feast/} ).explain("executionStats").executionStats
db.restaurants.explain("executionStats").find( {name: /Feast/} ).count()

db.restaurants.find( {name: /Feast/} ).explain("executionStats").serverInfo

Do mniej dokładnych pomiarów można użyć polecenia Bash time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.