• Nie Znaleziono Wyników

Ruby Object Database

N/A
N/A
Protected

Academic year: 2021

Share "Ruby Object Database"

Copied!
18
0
0

Pełen tekst

(1)

Ruby Object Database

github.com/apohllo/rod

Aleksander Pohl apohllo@o2.pl

apohllo.pl

Krakow Ruby Users Group

2nd, August 2011

(2)

Agenda

Introduction

Details

Help needed!

(3)

Agenda

Introduction

Details

Help needed!

(4)

Few words ’bout me

I PhD student at AGH-UST

I Assistant lecturer at Jagiellonian University

I Author of the Polish Introduction to Ruby apohllo.pl/dydaktyka/ruby/intro

I Maintainer of the Polish Rails Guides apohllo.pl/guides/index.html

I Mostly interested in Natural Language Processing (with Ruby) github.com/apohllo/rod github.com/apohllo/polish-spec github.com/apohllo/rlp-grammar github.com/apohllo/rlp-semantics github.com/apohllo/rlp-corpus

(5)

What ROD is not?

I isnot relational database (MySQL, Postgresql, SQLite)

I isnot normalized

I isnot object-relational mapper (ActiveRecord, Sequel,

DataMapper)

I isnot database server (Internet/Unix socket

communication)

I isnot in-memory database (Redis)

I isnot document database (MongoDB)

I isnot prevalence database (Madelein, Prevayler)

(6)

What is ROD?

I (Ruby) object database

I partially based on the network database model

I uses (almost) the same address space as the Ruby

process

I will use Oracle Berkeley DB as a backend

I designed for fast access to data which doesn’t fit into memory, but should be available on one node

I a kind of data warehouse

(7)

Why?

Think of a library (with books) or an encyclopedia. You don’t need all the information, but you might need any piece of it.

Object oriented access to:

I text corpora

hundreds of millions of text segments, with interlinks

I rich naturallanguage dictionaries for NLP

millions of text forms, hundreds of millions of relationships

I e.g. WordNet is stored as Berkeley DB

(8)

Agenda

Introduction

Details

Help needed!

(9)

Show me some code! – database and class

definitions

class MyDatabase < Rod::Database end

class Model < Rod::Model

database_class MyDatabase end

class User < Model

field :name, :string

field :surname, :string, :index => :btree, :sort => lambda {|s1,s2| p2 <=> p1 } field :age, :integer

has_one :account has_many :files

validates_presence_of :name, :surname

end

(10)

Class definitions

class Account < Model

field :email, :string

field :login, :string, :index => :hash field :password, :string

validates_presence_of :email, :login, :password

end

class File < Model

field :title, :string, :index => :btree field :data, :string

validates_presence_of :title

end

(11)

Object creation and storage

MyDatabase.create_database("data") user = User.new(:name => ’Fred’,

:surname => ’Smith’, :age => 22)

account = Account.new(:email => "fred@smith.org", :login => "fred",

:password => "password") file1 = File.new(:title => "Lady Gaga video") file2.data = "0012220001..."

file2 = File.new(:title => "Pink Floyd video") file2.data = "0012220001..." user.account = account user.files << file1 user.files << file2 user.store account.store file1.store file2.store MyDatabase.close_database

(12)

Object accessing

MyDatabase.open_database("data")

User.each do |user|

puts "Name: #{user.name} surname: #{user.surname}"

puts "login: #{user.account.login} e-mail: #{user.account.email}"

user.files.each do |file| puts "File: #{file.title}"

end end User[0]

# gives first user

User.find_by_surname("Smith") # gives Fred

User.find_all_by_surname("Smith") # gives [Fred]

File[0].user

# won’t work - the data is not normalized

(13)

Requirements

I Ruby 1.9 I RubyInline I english gem I ActiveModel I Berkeley DB

(14)

Features/future (1/2)

I nice Ruby interface which mimicks Active Record

I Ruby-to-C on-the-fly translation based on mmap and RubyInline (will be replaced with Berkeley DB)

I append of the database (new objects, new elements in plural associations)

I full CRUD (TBD)

I optimized for (reading) speed

I ActiveModel validations

I ActiveModel dirty tracking (TBD)

(15)

Features/future (2/2)

I weak reference collections for easy memory reclaims

I hash/btree indices for short start-up times and key-sort support (TBD)

I compatibility check of library version

I compatibility check of data model

I autogeneration of model (based on the database

metadata)

I automatic model migrations (addition/removal of properties so far)

I tested with Cucumber

(16)

Agenda

Introduction

Details

Help needed!

(17)

Help needed

I 52 issues on Github – much more to come

I design – review the architecture on project wiki

I testing – running of different OS

I testing – writing Cucumber specs

I this is really fun!

I a perfect candidate ;-)

I will have knowledge of Berkeley DB I will have knowledge of Ruby C API

I will be experienced in writing concurrent Ruby apps

(18)

Thank you!

Cytaty

Powiązane dokumenty

Wojewódzki Konkurs Chemiczny dla uczniów szkół podstawowych województwa wielkopolskiego w roku szkolnym 2020/2021..

Ponieważ od kilku lat kurs „BIBWEB” prowadzony był na platformie zdalnego nauczania Moodle, oprogramowanie to postanowio- no także wykorzystać przy realizacji projektu

• Funkcja operatora, której pierwszym argumentem jest typ podstawowy lub obiekt innej klasy nie może być metodą, musi być zdefiniowana jako funkcja zewnętrzna. • Przykład:

Деякі навчальні заклади і інші організації активно використовують web-орієнтовані навчальні комп’ютерні системи для надання освітніх послуг в

The tested properties included: vitreousness, test weight, thousand kernel weight, true density, geometric parameters (thickness, width, length), static friction coefficient of

• Dodanie w warstwie klienta umieszczonej w pakiecie Warstwa_klienta klasy ramka, reprezentującej interfejs graficzny użytkownika. Należy zachować hermetyzację klas z

b) wyświetlić za pomocą funkcji alert() tekst „oleg” z tego napisu (dwoma sposobami),. c) wyświetlić za pomocą funkcji alert() napis „kolacja” powstały z wyjściowego

Zadanie 2.(5 pkt.) Zmodyfikować skrypt z zadania 2 z zestawu 11 w ten sposób, że zamiast podawania danych przy pomocy funkcji prompt() będziemy wpisywać je do pól