I'm learning elasticsearch now.
This slide is old, new version is here. -> http://blog.johtani.info/blog/2013/08/30/hold-first-elasticsearch-meetup-in-japan/
I'm learning elasticsearch now.
This slide is old, new version is here. -> http://blog.johtani.info/blog/2013/08/30/hold-first-elasticsearch-meetup-in-japan/
20. 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
21. N o S Q L って 素 敵 だ け ど ・ ・ ・
• 少数メンバーで運用するのは大変だったりする
• 例えばMongo Replica Setsを構成するには最低各DC
ゾーンに1台ずつ、Arbiter1台、計3台マシンが必要
• メモリやディスクI/Oに左右されたりする
22. A m a z o n D y n a m o D B
• キー・バリュー型のNoSQLデータベースサービス
• 管理不要で信頼性が高いデータベース
• データセンター間の自動同期レプリケーション
• 高速なアクセスが可能
• SSDを利用している
• ストレージ容量制限がない
• プロビジョンスループットだけを指定するだけ
• API(SDK)経由で利用できる
24. サ ポー ト す る デ ー タ 型 ( 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.
その他も実装中
26. 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
27. 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.
ごめんなさい。間に合いませんでした。後ほど
別途別の資料を用意します
29. 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
30. 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
31. 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);
32. 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
33. 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
34. 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
35. 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
36. 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
38. 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を作成するだけ
39. G e t I t e m
"検索キーを作成"
keyData := DModelTest1 new.
keyData id: uuid.
result := d getItem: keyData.
Used DynamoDB Local Sample