GithubHelp home page GithubHelp logo

nosql's Introduction

NoSql

Dane

Dane wykorzystywane w projekcie zostały pobrane z serwisu digg.com i zawierają listę 100 ostatnich wpisów (dane z 13.05.2012) nt. technologii. Dane te zostały pobrane przy pomocy programu napisanego w języku c# i zduplikowane dziesięciokrotnie, aby zwiększyć liczbę informacji w bazie (łącznie ~1000).

import

a) Aby uruchomić plik importu pliku *.json do bazy MongoDB z danymi testowymi należy wpisać:

  $ ./json2mongodb.sh test diggs technology.json

Gdzie test- nazwa bazy, diggs- nazwa kolekcji

b) Aby uruchomić plik importu pliku *.json do bazy CouchDB z danymi testowymi należy wpisać:

  $ ./json2couchdb.sh http://localhost:5984 test technology.json

Gdzie http://localhost:5984 - adres bazy wraz z portem, test- nazwa bazy

export

Import danych z bazy MongoDB do CouchDB znajduje się w pliku mongo2couch.sh

  $ ./mongo2couch.sh http://localhost:5984 test diggs

Gdzie http://localhost:5984 - adres bazy wraz z portem, test- nazwa bazy, diggs- nazwa kolekcji w MongoDB

przykład rekordu json

{
    "diggs":7,
    "status":"upcoming",
    "container":{
        "name":"Technology",
        "short_name":"technology"
    },
    "description":"With a digital camera we easily record beauties and exciting ...",
    "title":"Digital Camera Cleaning and Maintenance-Written by ComeToDeal online store",
    "submit_date":1334743149,
    "media":0,
    "comments":1,
    "thumbnail":{
        "src":"http://cdn3.diggstatic.com/story/digital_camera_cleaning_and_maintenance_written_by_cometodeal_online_store/t.png",
        "contentType":"image/png",
        "originalheight":300,
        "height":62,
        "width":62,
        "originalwidth":300
    },
    "topic":{
        "name":"Technology",
        "short_name":"technology"
    },
    "shorturl":{
        "short_url":"http://digg.com/news/technology/digital_camera_cleaning_and_maintenance_written_by_cometodeal_online_store",
        "view_count":0
    },
    "promote_date":null,
    "link":"http://cometodeal.wordpress.com/2012/04/18/digital-camera-cleaning-and-maintenance-written-by-cometodeal-online-store/",
    "href":"http://digg.com/news/technology/digital_camera_cleaning_and_maintenance_written_by_cometodeal_online_store",
    "id":"20120418095909:b7720394-e9e6-46ed-b6c2-912af258b15c"
}

map reduce

Funkcja MapReduce zwraca statystyki dotyczące ilości powtórzeń liczby wykopów na stronie.

MapReduce dla bazy MongoDB nazy uruchomić w następujący sposób:

  $ mongo mongoMapReduce.js --shell

Wyniki mp sprawdzamy przy pomocy:

db.res.find()

Wyniki:

{
	"result" : "res",
	"timeMillis" : 116,
	"counts" : {
		"input" : 101,
		"emit" : 101,
		"output" : 21
	},
	"ok" : 1,
}
> db.res.find()
{ "_id" : 1, "value" : 474 }
{ "_id" : 2, "value" : 133 }
{ "_id" : 3, "value" : 42 }
{ "_id" : 4, "value" : 85 }
{ "_id" : 5, "value" : 65 }
{ "_id" : 6, "value" : 31 }
{ "_id" : 7, "value" : 30 }
{ "_id" : 20, "value" : 10 }
{ "_id" : 21, "value" : 10 }
{ "_id" : 40, "value" : 10 }

has more

Z kolei MapReduce dla bazy CouchDB uruchamiamy przy pomocy node

  $ node couchMapReduce.js 

Wyniki dla couchMapReduce wyglądają następująco:

1: 474
2: 133
3: 42
4: 85
5: 65
6: 31
7: 30
20: 10
21: 10
40: 10

[...]

Link mający 1 digg wystąpił 47 razy, a mający 2 diggi wystąpił 14 razy, itd.

nosql's People

Contributors

kstachowicz avatar

Watchers

James Cloos avatar  avatar

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.