Share
Embed
How Smalltalker Works
第71回Smalltalk勉強会(ビアバッシュ)の資料。Smalltalk三昧だった1年。Smalltalkに何か還元します。
http://www.smalltalk-users.jp/Home/gao-zhi/dai71kaismalltalkbenkyoukai
newapplesho
December 25, 2014
Transcript
44 slides
-
H o w S m a l l t a
l k e r W o r k s S m a l l t a l k ࡾ ດ ͩ ͬ ͨ Ұ ˏnewapplesho -
2 0 1 4 5 ݄ h t t
p : / / w w w. s o r a b i t o . c o m SORABITOͷ্ཱͪ͛ -
։ ൃ ݴ ޠ 5% 5% 14% 5% 29% 43%
Smalltalk Ruby Java PHP Perl FileMaker -
2 0 1 4 7 ݄ ࢼ ݧ ӡ
༻ 2 0 1 4 9 ݄ ਖ਼ ࣜ ެ ։ h t t p s : / / m i k a t a c l o u d . c o m Serviceͷ্ཱͪ͛ -
L O V E I T O R L E
AV E I T. I L O V E S M A L LTA L K . SmalltalkΛ࠷׆༻ͨ͠ -
࠷ ษ ڧ ձ ͷ ใ Λ ࠷
׆ ༻ ͯ͠ ͍ Δ ਓ ͔ ͓ ͦ Β ͘ ɾ ɾ ɾ http://www.smalltalk-users.jp -
α ʔ Ϗ ε հ Ͱ શ ࠃ Ί
͙ Γ Smalltalkͷ͓͔͛Ͱ৭ʑ͋Γ·ͨ͠ -
ε ς Ω ͳ ͱ ͜ ΖͰ ൃ ද ͠
· ͠ ͨ ɻ I L O V E S M A L LTA L K Smalltalkͷ͓͔͛Ͱ৭ʑ͋Γ·ͨ͠ -
ʹ ͛Β Ε ͨ Γ ͠ · ͠
ͨ Smalltalkͷ͓͔͛Ͱ৭ʑ͋Γ·ͨ͠ -
ύΠ Λ ͳ ͛Β Ε ͨ Γ ͠ · ͠
ͨ Smalltalkͷ͓͔͛Ͱ৭ʑ͋Γ·ͨ͠ -
ͦ Μ ͳ S m a l l t a
l k ʹ ؐ ݩ ͠ ͨ ͍ ͍ ͪ ͝ Ҏ ֎ Ͱ ৄ͘͠ୈ42ճSmalltalkษڧձ -
S m a l l t a l k A
d v e n t C a l e n d a r 2 0 1 4 ʹ ઓ • 10୲͠·ͨ͠ • ਖ਼େมͰͨ͠ • ߘΕͯ͢Έ·ͤΜ http://qiita.com/advent-calendar/2014/smalltalk -
A W S S D K f o r S
m a l l t a l k M E R RY C H R I S T M A S -
ࠓ ճ ެ ։ ͢ Δ ͷ ࣄΛ࡞ͨ͠ͷαʔϏεʹಛԽͤͯ͞࡞ͬͯ͠·ͬ ͨΊɺۀ֎ͷ࣌ؒΛͬͯΓग़ͯ͠Ұൠެ։Ͱ͖Δ
ͷΛ४උ͠·ͨ͠ʢ͍ͣΕSDKશͯΛެ։͠· ͢ʣɻ https://mikatacloud.com/ AWS SDK for Smalltalk -
A W S S D K f o r S
m a l l t a l k M E R RY C H R I S T M A S DynamoDB -
N o S Q L ͬͯ ૉ ఢ ͩ ͚
Ͳ ɾ ɾ ɾ • গϝϯόʔͰӡ༻͢ΔͷେมͩͬͨΓ͢Δ • ྫ͑Mongo Replica SetsΛߏ͢Δʹ࠷֤DC κʔϯʹ̍ͣͭɺArbiter̍ɺܭ̏Ϛγϯ͕ඞཁ • ϝϞϦσΟεΫI/Oʹࠨӈ͞ΕͨΓ͢Δ -
A m a z o n D y n a
m o D B • ΩʔɾόϦϡʔܕͷNoSQLσʔλϕʔεαʔϏε • ཧෆཁͰ৴པੑ͕ߴ͍σʔλϕʔε • σʔληϯλʔؒͷࣗಈಉظϨϓϦέʔγϣϯ • ߴͳΞΫηε͕Մೳ • SSDΛར༻͍ͯ͠Δ • ετϨʔδ༰ྔ੍ݶ͕ͳ͍ • ϓϩϏδϣϯεϧʔϓοτ͚ͩΛࢦఆ͢Δ͚ͩ • APIʢSDKʣܦ༝Ͱར༻Ͱ͖Δ -
ࠓ ճ ެ ։ ͢ Δ ͷ • AWSͷ΄ͱΜͲͷαʔϏεʹΞΫηε͢ΔͨΊͷ
Signature V4 • DynamoDBͷଓΫϥΠΞϯτʢϨϕϧ APIɺΤ ϥʔॲཧະ࣮ʣ • DynamoDBͷ؆қΞΫηε൛ʢະʣ -
α ϙʔ τ ͢ Δ σ ʔ λ ܕ (
S U P P O R T S D ATA T Y P E S ) AWS SDK for SmalltalkͰରԠ͢ΔσʔλʔܕҎԼ * εΧϥʔσʔλܕ - จࣈྻɺ * ଟܕ - จࣈྻηοτɺηοτɻ Amazon DynamoDB for Smalltalk supports the following data types: * Scalar types – Number, String. * Multi-valued types – String Set, Number Set. ͦͷଞ࣮த -
ͩ ͬͯ ଞ ʹ Ε Δ ͜ ͱ ͕ ͳ
͍ ͔ Β Ͷ ͱ͍͏͜ͱͰ DynamoDB͏͔͠ͳ͍ʂ -
D y n a m o D B L o
c a l http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ Tools.DynamoDBLocal.html ͱΓ͋͑ͣࢼ͍ͨ͠ਓDynamoDB Local -
H o w t o i n s t a
l l The AWS SDK for Pharo Smalltalk enables Smalltalk developers to easily work with Amazon Web Services with Amazon DynamoDB. You can get started in minutes using Metacello and FileTree. ͝ΊΜͳ͍͞ɻؒʹ߹͍·ͤΜͰͨ͠ɻޙ΄Ͳ ผ్ผͷࢿྉΛ༻ҙ͠·͢ -
C re a t e Ta b l e s
dy := DynamoDBRawClient new. operationName := #CreateTable. requestBody := '{ "AttributeDefinitions": [ { "AttributeName": "id", "AttributeType": "S"} ], "TableName": "dmodeltest1", "KeySchema": [ { "AttributeName": "id", "KeyType": "HASH"}], "ProvisionedThroughput": { "ReadCapacityUnits": 10, "WriteCapacityUnits": 10} }'. resp := dy operationName: operationName entityContents: requestBody. Used DynamoDB Local Sample -
L i s t Ta b l e s dy
:= DynamoDBRawClient new. dy awsConfig accessKeyId:'YOURACCESSKEY'. dy awsConfig secretKey:'YOURSECRETKEY'. dy awsConfig useSSL: false. operationName := #ListTables. requestBody := '{}'. resp := dy operationName: operationName entityContents: requestBody. Json readFrom: (resp contents) readStream. Used DynamoDB Local Sample -
P u t I t e m ( J a
v a ) client = new AmazonDynamoDBClient(credentials); String tableName = "dmodeltest1"; Map<String, AttributeValue> item = new HashMap<String, AttributeValue>(); item.put("Id", new AttributeValue().withS("babe2d60c42a45fca9120d1c111d8844")); PutItemRequest putItemRequest = new PutItemRequest() .withTableName(tableName) .withItem(item); PutItemResult result = client.putItem(putItemRequest); -
P u t I t e m dy := DynamoDBRawClient
new. uuid := UUID new primMakeUUID hex. operationName := 'PutItem'. json := JsonObject new at:'TableName' put:'dmodeltest1';yourself. d:= DModelTest1 new. d id:uuid. mapper := DynamoDBMapper new. c := (mapper convertItem:d). json at:'Item' put: c . requestBody := json asJsonString . resp := dy operationName: operationName entityContents: requestBody. Used DynamoDB Local Sample -
G e t I t e m operationName := 'GetItem'.
json := JsonObject new at:'TableName' put:'dmodeltest1';yourself. d:= DModelTest1 new. d id:uuid. mapper := DynamoDBMapper new. c := (mapper convertItem:d). json at:'Key' put: c . requestBody := json asJsonString . resp := dy operationName: operationName entityContents: requestBody. result := Json readFrom: (resp contents) readStream. mapper loadItem: (result at:'Item') . Used DynamoDB Local Sample -
Q u e r y operationName := 'Query'. json :=
JsonObject new at:'TableName' put:'dmodeltest1';yourself. d:= DModelTest1 new. d data at:#id put:uuid. mapper := DynamoDBMapper new. c := (mapper convertItem:d). c := JsonObject new at: (c keys first) put: ((JsonObject new at:'AttributeValueList' put: (Array with: c anyOne); yourself ) at:'ComparisonOperator' put:'EQ'; yourself); yourself. json at:'KeyConditions' put: c . json at:'Select' put: 'ALL_ATTRIBUTES'. requestBody := json asJsonString . resp := dy operationName: operationName entityContents: requestBody. result := Json readFrom: (resp contents) readStream. (result at:'Count') > 0 ifTrue:[ ^ (result at:'Items') collect:[:v | mapper loadItem:v ]. ] . Used DynamoDB Local Sample -
D e l e t e I t e m
operationName := 'DeleteItem'. json := JsonObject new at:'TableName' put:'dmodeltest1';yourself. d:= DModelTest1 new. d id:uuid. mapper := DynamoDBMapper new. c := (mapper convertItem:d). json at:'Key' put: c . requestBody := json asJsonString. resp := dy operationName: operationName entityContents: requestBody. result := Json readFrom: (resp contents) readStream. Used DynamoDB Local Sample -
D e l e t e Ta b l e
operationName := #DeleteTable. requestBody := JsonObject new at:'TableName' put:'dmodeltest1'; asJsonString . resp := dy operationName: operationName entityContents: requestBody. Json readFrom: (resp contents) readStream. Used DynamoDB Local Sample -
P u t I t e m uuid := UUID
new primMakeUUID hex. d:= DModelTest1 new. d id: uuid. d save. Used DynamoDB Local Sample DynamoDBModelΛܧঝͨ͠ModelΛ࡞ DynamoDBModelͷDictionaryͷΠϯελϯεมdataʹ ΞΫηεͯ͠ModelΛ࡞͢Δ͚ͩ -
G e t I t e m "ݕࡧΩʔΛ࡞" keyData :=
DModelTest1 new. keyData id: uuid. result := d getItem: keyData. Used DynamoDB Local Sample -
ࠓ ޙ • DynamoDBվྑ൛ • S3 • EC2 • Elastic
Transcoder 2015ެ։༧ఆ ͨͩ͠ࢲͷϙέοτϚωʔͱ ૬ஊͩͬͨΓ͢Δ Amazon EC2 DynamoDB Amazon Elastic Transcoder S3 Bucket -
དྷ ͷ ։ ൃ ݴ ޠ 20% 15% 5%
15% 45% Smalltalk Ruby Java PHP Perl FileMaker Scala