SlideShare una empresa de Scribd logo
1 de 34
Descargar para leer sin conexión
Introducion to Datastore
Assoc.Prof. Dr.Thanachart Numnonda
 Asst.Prof. Thanisa Kruawaisayawan

    Mini Master of Java Technology
                KMITL
               July 2010
Agenda
What is DataStore?

Using DataStore

JPA in DataStore
What is DataStore?
What is Datastore?
Google App Engine Datastore is a schema-less persistence
  system, whose fundamental persistence unit is called Entity, c
  omposed by an immutable Key and a collection of mutable pr
  operties.
Entities can be created, updated, deleted, loaded by key and
  queried for properties values.
DataStore is consistent and transactional, with support to
  current transaction.
The DataStore
The Datastore is not a relational database nor a
 façade.
Relational database technology doesn’t scale
 horizontally
   – Connection pools, shared caching are a problem
The Datastore is one of many public APIs used for
 accessing Google’s
The DataStore
The DataStore
The DataStore : Operations
Transactions and Index are based on MegaTable.
File persistence it's done with Google File System
 (GFS).
It's distributed by Chubby, a lock service for loosely-
 coupled distributed systems.
BigTable
BigTable is a compressed, high performance, and
 proprietary database system built on Google File
 System (GFS), Chubby Lock Service, and a few other
 Google programs
Currently not distributed or used outside of Google.
BigTable development began in 2004. and is now used
 by a number of Google application Google Earth,
 Google Map, Gmail, Youtube, etc..
BigTable : Design
BigTable is a fast and extremely large-scale DBMS.
It is a sparse, distributed multi-dimensional sorted map,
 sharing characteristics of both row-oriented and column-
 oriented databases.
  sparse because only "not null" values are persisted
  distributed in Google cloud
  persistent on Google File System
  multidimensional in columns values
  ordered lexicographically by key
BigTable : Design
Tables are optimized for GFS by being split into
 multiple tablets - segments of the table.
BigTable is designed to scale into the petabyte.
Each table has multiple dimensions (one of which is a
 feld for time, allowing for versioning and garbage
 collection).
It allows an infnite number of rows and columns.
Google File System
GFS is a proprietary distributed fle system developed
 by Google.
It is designed to provide effcient, reliable access to
 data using large clusters of commodity hardware.
GFS grew out of an earlier Google effort, BigFiles,
 developed by Larry Page and Sergey Brin in the early
 days of Google, while it was still located in Stanford.
Using DataStore
DataStore Operations
Datastore operations are defned around entities (data
 models) which are objects with one or more properties
  Types: string, user, Boolean, and so on
  Entities may be recursive or self-referential
Entity relationships are one-to-many or many-to-many.
Entities may be fxed or grow as needed.
DataStore Storage Model
Every entity is of a particular kind
Entities in a kind need not have the same properties
  One entity may have different “columns” from another in
   the same kind!
Unique IDs are automatically assigned unless the user
 defnes a key_name
Compare DataStore with Others
DataStore Storage Model
Basic unit of storage is an Entity consisting of
   Kind (table)
   Key (primary key)
   Entity Group (partition)
   0..N typed Properties (columns)
Datastore Quotas
Each call to Datastore counts towards the quota
The amount of data cannot exceed the billable
      Includes properties and keys but not the indices
CPU and Datastore CPU time quotas apply
Using the Datastore
Applications may access the Datastore using the JDO
 or the JPA classes.
The JDO and JPA classes are abstracted using the
 DataNucleus API
  Open source
   Not very popular
   Support for Java standards
   Poor documentation
JPA in DataStore
Setting Up JPA
The JPA and datastore JARs must be in the app's
 war/WEB-INF/lib/ directory.
A confguration fle named persistence.xml must be in
 the app's war/WEB-INF/classes/META-INF/ directory,
A confguration fle tells JPA to use the App Engine
 datastore.
The appengine-api.jar must also be in the war/WEB-
 INF/lib/ directory.
persistence.xml: Example
<?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
 <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
   http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
    http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
    <persistence-unit name="thaijavaappPU" transaction-type="RESOURCE_LOCAL">
     <persistence-unit name="thaijavaappPU" transaction-type="RESOURCE_LOCAL">

  <provider>org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider
   <provider>org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider
  </provider>
   </provider>
   <non-jta-data-source/>
    <non-jta-data-source/>
  <properties>
   <properties>
      <property name="datanucleus.ConnectionURL" value="appengine"/>
       <property name="datanucleus.ConnectionURL" value="appengine"/>
      <property name="datanucleus.NontransactionalRead" value="true"/>
       <property name="datanucleus.NontransactionalRead" value="true"/>
      <property name="datanucleus.NontransactionalWrite" value="true"/>
       <property name="datanucleus.NontransactionalWrite" value="true"/>
    </properties>
     </properties>
  </persistence-unit>
   </persistence-unit>
</persistence>
 </persistence>
Getting an EntityManager Instance
An app interacts with JPA using an instance of the EntityManager.

import javax.persistence.EntityManagerFactory;
 import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
 import javax.persistence.Persistence;
public class EMF {{
 public class EMF

     private static final EntityManagerFactory emfInstance ==
      private static final EntityManagerFactory emfInstance
      Persistence.createEntityManagerFactory("transactions-optional");
       Persistence.createEntityManagerFactory("transactions-optional");

     public static EntityManagerFactory get() {{
      public static EntityManagerFactory get()
         return emfInstance;
          return emfInstance;
     }}
}}
Entity Class : Example
@Entity
 @Entity
public class GuestList implements Serializable {{
 public class GuestList implements Serializable
     ……
     @Id
      @Id
     private String id;
      private String id;

     @Basic
      @Basic
     private User author;
      private User author;
     private String content;
      private String content;
     @Temporal(javax.persistence.TemporalType.DATE)
      @Temporal(javax.persistence.TemporalType.DATE)
     private Date visitDate;
      private Date visitDate;
     ……
     // Getter and Setter methods
      // Getter and Setter methods
}}
Queries and Indices
A query operates on every entity of a given kind.
     Specify zero or more sort orders
     Specify zero or more flters on property values
Indices are defned in the App Engine confguration fles
     Results are fetched directly from these indices; no indices are
      created on the fly
     WEB-INF/datastore-indexes.xml - non-standard fles
Normalization is not recommended
     Optimization techniques for RDBMSs may result in poor
      Datastore performance!
Query : Example
EntityManager em == EMF.get().createEntityManager();
 EntityManager em    EMF.get().createEntityManager();
try {{
 try
     Query query == em.createQuery("SELECT oo FROM GuestList AS o");
      Query query    em.createQuery("SELECT    FROM GuestList AS o");
     @SuppressWarnings("unchecked")
      @SuppressWarnings("unchecked")
     List<GuestList> results == (List<GuestList>) query.getResultList();
      List<GuestList> results     (List<GuestList>) query.getResultList();
     for (Object obj :: results) {{
      for (Object obj    results)
              GuestList guest == (GuestList) obj;
               GuestList guest    (GuestList) obj;
         String nickname == guest.getAuthor().getNickname();
          String nickname    guest.getAuthor().getNickname();
         out.println(nickname ++ "" "" ++ guest.getId());
          out.println(nickname             guest.getId());
   }}
}} catch(Exception ex) {{
    catch(Exception ex)
     out.println(ex);
      out.println(ex);
}}
Entity Relationships
Models association between entities.
There are four types of relationship multiplicities:
     @OneToOne
     @OneToMany
     @ManyToOne
Supports unidirectional as well as bidirectional relationships
     Unidirectional relationship: Entity A references B, but B doesn't
      reference A.
Example : ManyToOne Mapping
Example : OneToMany Mapping
Transactions and Entity Groups
Transaction = Group of Datastore operations that either
 succeed or fail
Entity groups are required because all grouped entities are
 stored in the same Datastore node
An entity may be either created or modifed once per
 transaction
Transactions may fail if a different user or process tries an
 update in the same group at the same time
Users decide whether to retry or roll the transaction back
Transaction in JPA : Example
Book book == em.find(Book.class, "9780596156732");
 Book book    em.find(Book.class, "9780596156732");
BookReview bookReview == new BookReview();
 BookReview bookReview    new BookReview();
bookReview.rating == 5;
 bookReview.rating    5;
book.getBookReviews().add(bookReview);
 book.getBookReviews().add(bookReview);
Transaction txn == em.getTransaction();
 Transaction txn    em.getTransaction();
txn.begin();
 txn.begin();
try {{
 try
   book == em.merge(book);
    book    em.merge(book);
    txn.commit();
     txn.commit();
}} finally {{
    finally
     if (txn.isActive()) {{
      if (txn.isActive())
          txn.rollback();
           txn.rollback();
     }}
}}
Unsupported Features of JPA
Owned many-to-many relationships, and unowned
 relationships.
"Join" queries.
Aggregation queries (group by, having, sum, avg, max, min)
Polymorphic queries.
Resources
Google App Engine for Java HOWTO, Andrew Lombardi, Mar
 2010
The Softer Side Of Schemas, Max Ross, May 2009
Official Google App Engine Tutorial,
 http://code.google.com/appengine/docs/java/gettingstarted/
Programming Google App Engine, Don Sanderson, O'Reilly,
 2010
Thank you

  thananum@gmail.com
  twitter.com/thanachart
www.facebook.com/thanachart
  www.thaijavadev.com

Más contenido relacionado

La actualidad más candente

Database Design and Normalization Techniques
Database Design and Normalization TechniquesDatabase Design and Normalization Techniques
Database Design and Normalization TechniquesNishant Munjal
 
Query optimization in SQL
Query optimization in SQLQuery optimization in SQL
Query optimization in SQLAbdul Rehman
 
Database , 8 Query Optimization
Database , 8 Query OptimizationDatabase , 8 Query Optimization
Database , 8 Query OptimizationAli Usman
 
Chapter 6 relational data model and relational
Chapter  6  relational data model and relationalChapter  6  relational data model and relational
Chapter 6 relational data model and relationalJafar Nesargi
 
Characteristic of dabase approach
Characteristic of dabase approachCharacteristic of dabase approach
Characteristic of dabase approachLuina Pani
 
Database System Concepts and Architecture
Database System Concepts and ArchitectureDatabase System Concepts and Architecture
Database System Concepts and Architecturesontumax
 
Query optimization
Query optimizationQuery optimization
Query optimizationPooja Dixit
 
Entity Relationship Diagrams
Entity Relationship DiagramsEntity Relationship Diagrams
Entity Relationship Diagramssadique_ghitm
 
11. transaction sql
11. transaction sql11. transaction sql
11. transaction sqlUmang Gupta
 
Introduction of sql server indexing
Introduction of sql server indexingIntroduction of sql server indexing
Introduction of sql server indexingMahabubur Rahaman
 
Oracle architecture with details-yogiji creations
Oracle architecture with details-yogiji creationsOracle architecture with details-yogiji creations
Oracle architecture with details-yogiji creationsYogiji Creations
 
6. Integrity and Security in DBMS
6. Integrity and Security in DBMS6. Integrity and Security in DBMS
6. Integrity and Security in DBMSkoolkampus
 
Database Keys & Relationship
Database Keys & RelationshipDatabase Keys & Relationship
Database Keys & RelationshipBellal Hossain
 
DBMS Assignments Questions
DBMS Assignments QuestionsDBMS Assignments Questions
DBMS Assignments QuestionsSara Sahu
 

La actualidad más candente (20)

Database Design and Normalization Techniques
Database Design and Normalization TechniquesDatabase Design and Normalization Techniques
Database Design and Normalization Techniques
 
Query optimization in SQL
Query optimization in SQLQuery optimization in SQL
Query optimization in SQL
 
Database , 8 Query Optimization
Database , 8 Query OptimizationDatabase , 8 Query Optimization
Database , 8 Query Optimization
 
Chapter 6 relational data model and relational
Chapter  6  relational data model and relationalChapter  6  relational data model and relational
Chapter 6 relational data model and relational
 
Characteristic of dabase approach
Characteristic of dabase approachCharacteristic of dabase approach
Characteristic of dabase approach
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
 
Database Basics
Database BasicsDatabase Basics
Database Basics
 
Recovery techniques
Recovery techniquesRecovery techniques
Recovery techniques
 
Database System Concepts and Architecture
Database System Concepts and ArchitectureDatabase System Concepts and Architecture
Database System Concepts and Architecture
 
Query optimization
Query optimizationQuery optimization
Query optimization
 
Entity Relationship Diagrams
Entity Relationship DiagramsEntity Relationship Diagrams
Entity Relationship Diagrams
 
11. transaction sql
11. transaction sql11. transaction sql
11. transaction sql
 
Introduction of sql server indexing
Introduction of sql server indexingIntroduction of sql server indexing
Introduction of sql server indexing
 
Oracle architecture with details-yogiji creations
Oracle architecture with details-yogiji creationsOracle architecture with details-yogiji creations
Oracle architecture with details-yogiji creations
 
6. Integrity and Security in DBMS
6. Integrity and Security in DBMS6. Integrity and Security in DBMS
6. Integrity and Security in DBMS
 
Database & Database Users
Database & Database UsersDatabase & Database Users
Database & Database Users
 
Use case diagram
Use case diagramUse case diagram
Use case diagram
 
Database Keys & Relationship
Database Keys & RelationshipDatabase Keys & Relationship
Database Keys & Relationship
 
DBMS Assignments Questions
DBMS Assignments QuestionsDBMS Assignments Questions
DBMS Assignments Questions
 
Object oriented database
Object oriented databaseObject oriented database
Object oriented database
 

Similar a Introduction to Datastore

Java Web Programming on Google Cloud Platform [2/3] : Datastore
Java Web Programming on Google Cloud Platform [2/3] : DatastoreJava Web Programming on Google Cloud Platform [2/3] : Datastore
Java Web Programming on Google Cloud Platform [2/3] : DatastoreIMC Institute
 
Hibernate Training Session1
Hibernate Training Session1Hibernate Training Session1
Hibernate Training Session1Asad Khan
 
S03 hybrid app_and_gae_datastore_v1.0
S03 hybrid app_and_gae_datastore_v1.0S03 hybrid app_and_gae_datastore_v1.0
S03 hybrid app_and_gae_datastore_v1.0Sun-Jin Jang
 
Patni Hibernate
Patni   HibernatePatni   Hibernate
Patni Hibernatepatinijava
 
Slice: OpenJPA for Distributed Persistence
Slice: OpenJPA for Distributed PersistenceSlice: OpenJPA for Distributed Persistence
Slice: OpenJPA for Distributed PersistencePinaki Poddar
 
Configuring jpa in a Spring application
Configuring jpa in a  Spring applicationConfiguring jpa in a  Spring application
Configuring jpa in a Spring applicationJayasree Perilakkalam
 
App Grid Dev With Coherence
App Grid Dev With CoherenceApp Grid Dev With Coherence
App Grid Dev With CoherenceJames Bayer
 
Application Grid Dev with Coherence
Application Grid Dev with CoherenceApplication Grid Dev with Coherence
Application Grid Dev with CoherenceJames Bayer
 
App Grid Dev With Coherence
App Grid Dev With CoherenceApp Grid Dev With Coherence
App Grid Dev With CoherenceJames Bayer
 
Spring Data JPA in detail with spring boot
Spring Data JPA in detail with spring bootSpring Data JPA in detail with spring boot
Spring Data JPA in detail with spring bootrinky1234
 

Similar a Introduction to Datastore (20)

Java Web Programming on Google Cloud Platform [2/3] : Datastore
Java Web Programming on Google Cloud Platform [2/3] : DatastoreJava Web Programming on Google Cloud Platform [2/3] : Datastore
Java Web Programming on Google Cloud Platform [2/3] : Datastore
 
ORM JPA
ORM JPAORM JPA
ORM JPA
 
Hibernate Training Session1
Hibernate Training Session1Hibernate Training Session1
Hibernate Training Session1
 
S03 hybrid app_and_gae_datastore_v1.0
S03 hybrid app_and_gae_datastore_v1.0S03 hybrid app_and_gae_datastore_v1.0
S03 hybrid app_and_gae_datastore_v1.0
 
Patni Hibernate
Patni   HibernatePatni   Hibernate
Patni Hibernate
 
Data access
Data accessData access
Data access
 
.Net template solution architecture
.Net template solution architecture.Net template solution architecture
.Net template solution architecture
 
Hibernate
HibernateHibernate
Hibernate
 
Slice: OpenJPA for Distributed Persistence
Slice: OpenJPA for Distributed PersistenceSlice: OpenJPA for Distributed Persistence
Slice: OpenJPA for Distributed Persistence
 
Configuring jpa in a Spring application
Configuring jpa in a  Spring applicationConfiguring jpa in a  Spring application
Configuring jpa in a Spring application
 
WPF and Databases
WPF and DatabasesWPF and Databases
WPF and Databases
 
Hibernate
HibernateHibernate
Hibernate
 
JavaEE Spring Seam
JavaEE Spring SeamJavaEE Spring Seam
JavaEE Spring Seam
 
Spring data requery
Spring data requerySpring data requery
Spring data requery
 
App Grid Dev With Coherence
App Grid Dev With CoherenceApp Grid Dev With Coherence
App Grid Dev With Coherence
 
Application Grid Dev with Coherence
Application Grid Dev with CoherenceApplication Grid Dev with Coherence
Application Grid Dev with Coherence
 
App Grid Dev With Coherence
App Grid Dev With CoherenceApp Grid Dev With Coherence
App Grid Dev With Coherence
 
Spring Data JPA in detail with spring boot
Spring Data JPA in detail with spring bootSpring Data JPA in detail with spring boot
Spring Data JPA in detail with spring boot
 
MyBatis
MyBatisMyBatis
MyBatis
 
Struts2
Struts2Struts2
Struts2
 

Más de Software Park Thailand

Software Park Thailand Newsletter (Thai) Vol2/2556
Software Park Thailand Newsletter (Thai) Vol2/2556Software Park Thailand Newsletter (Thai) Vol2/2556
Software Park Thailand Newsletter (Thai) Vol2/2556Software Park Thailand
 
Software Park Newsletter Thai Vol 3/25561
Software Park Newsletter Thai Vol 3/25561Software Park Newsletter Thai Vol 3/25561
Software Park Newsletter Thai Vol 3/25561Software Park Thailand
 
Solfware park Newsletter Vol 3/2013 Eng Version
Solfware park Newsletter Vol 3/2013 Eng VersionSolfware park Newsletter Vol 3/2013 Eng Version
Solfware park Newsletter Vol 3/2013 Eng VersionSoftware Park Thailand
 
Software Park Thailand Newsletter Vol 3/2556
Software Park Thailand Newsletter Vol 3/2556Software Park Thailand Newsletter Vol 3/2556
Software Park Thailand Newsletter Vol 3/2556Software Park Thailand
 
Software Park Thailand Newsletter (Eng) Vol3/2012
Software Park Thailand Newsletter (Eng) Vol3/2012Software Park Thailand Newsletter (Eng) Vol3/2012
Software Park Thailand Newsletter (Eng) Vol3/2012Software Park Thailand
 
Software Park Thailand Newsletter (Eng) Vol5/2013
Software Park Thailand Newsletter (Eng) Vol5/2013Software Park Thailand Newsletter (Eng) Vol5/2013
Software Park Thailand Newsletter (Eng) Vol5/2013Software Park Thailand
 
Software Park Thailand Newsletter (Thai) Vol4/2555
Software Park Thailand Newsletter (Thai) Vol4/2555Software Park Thailand Newsletter (Thai) Vol4/2555
Software Park Thailand Newsletter (Thai) Vol4/2555Software Park Thailand
 
Thai ICT Trad Mission CommunicAsia 2013 (18-21 June 2013)
Thai ICT Trad Mission CommunicAsia 2013 (18-21 June 2013)Thai ICT Trad Mission CommunicAsia 2013 (18-21 June 2013)
Thai ICT Trad Mission CommunicAsia 2013 (18-21 June 2013)Software Park Thailand
 
Smart Industry Vo.22/2556"E-transaction กระตุ้นธุรกิจอีคอมเมิร์สโต"
Smart Industry Vo.22/2556"E-transaction กระตุ้นธุรกิจอีคอมเมิร์สโต"Smart Industry Vo.22/2556"E-transaction กระตุ้นธุรกิจอีคอมเมิร์สโต"
Smart Industry Vo.22/2556"E-transaction กระตุ้นธุรกิจอีคอมเมิร์สโต"Software Park Thailand
 
Software Park Newsletter 2/2554 "แท็บเล็ต สมาร์ทโพน โมบายแอพพลิเคชั่น ดาวเด่น...
Software Park Newsletter 2/2554 "แท็บเล็ต สมาร์ทโพน โมบายแอพพลิเคชั่น ดาวเด่น...Software Park Newsletter 2/2554 "แท็บเล็ต สมาร์ทโพน โมบายแอพพลิเคชั่น ดาวเด่น...
Software Park Newsletter 2/2554 "แท็บเล็ต สมาร์ทโพน โมบายแอพพลิเคชั่น ดาวเด่น...Software Park Thailand
 
Software Park Newsletter Vol. 4/2012 English Version
Software Park Newsletter Vol. 4/2012 English VersionSoftware Park Newsletter Vol. 4/2012 English Version
Software Park Newsletter Vol. 4/2012 English VersionSoftware Park Thailand
 
Thai IT Business Develop,emt Delegation to Tokyo, Japan, 2012
Thai IT Business Develop,emt Delegation to Tokyo, Japan, 2012Thai IT Business Develop,emt Delegation to Tokyo, Japan, 2012
Thai IT Business Develop,emt Delegation to Tokyo, Japan, 2012Software Park Thailand
 
Thai IT Trade Delegation to Tokyo, Japan 11-16 November 2012
Thai IT Trade Delegation to Tokyo, Japan 11-16 November 2012Thai IT Trade Delegation to Tokyo, Japan 11-16 November 2012
Thai IT Trade Delegation to Tokyo, Japan 11-16 November 2012Software Park Thailand
 
Thai IT Business Development Delegation to Tokyo, Japan: November 2012
Thai IT Business Development Delegation to Tokyo, Japan: November 2012 Thai IT Business Development Delegation to Tokyo, Japan: November 2012
Thai IT Business Development Delegation to Tokyo, Japan: November 2012 Software Park Thailand
 

Más de Software Park Thailand (20)

Smart industry Vol.33/2561
Smart industry Vol.33/2561Smart industry Vol.33/2561
Smart industry Vol.33/2561
 
Softwarepark news Vol.7/2561
Softwarepark news Vol.7/2561Softwarepark news Vol.7/2561
Softwarepark news Vol.7/2561
 
Software Park Thailand Newsletter (Thai) Vol2/2556
Software Park Thailand Newsletter (Thai) Vol2/2556Software Park Thailand Newsletter (Thai) Vol2/2556
Software Park Thailand Newsletter (Thai) Vol2/2556
 
Software Park Newsletter Thai Vol 3/25561
Software Park Newsletter Thai Vol 3/25561Software Park Newsletter Thai Vol 3/25561
Software Park Newsletter Thai Vol 3/25561
 
Smart Industry Vol.23
Smart Industry Vol.23Smart Industry Vol.23
Smart Industry Vol.23
 
Solfware park Newsletter Vol 3/2013 Eng Version
Solfware park Newsletter Vol 3/2013 Eng VersionSolfware park Newsletter Vol 3/2013 Eng Version
Solfware park Newsletter Vol 3/2013 Eng Version
 
Software Park Thailand Newsletter Vol 3/2556
Software Park Thailand Newsletter Vol 3/2556Software Park Thailand Newsletter Vol 3/2556
Software Park Thailand Newsletter Vol 3/2556
 
Software Park Thailand Newsletter (Eng) Vol3/2012
Software Park Thailand Newsletter (Eng) Vol3/2012Software Park Thailand Newsletter (Eng) Vol3/2012
Software Park Thailand Newsletter (Eng) Vol3/2012
 
Software Park Thailand Newsletter (Eng) Vol5/2013
Software Park Thailand Newsletter (Eng) Vol5/2013Software Park Thailand Newsletter (Eng) Vol5/2013
Software Park Thailand Newsletter (Eng) Vol5/2013
 
Software Park Thailand Newsletter (Thai) Vol4/2555
Software Park Thailand Newsletter (Thai) Vol4/2555Software Park Thailand Newsletter (Thai) Vol4/2555
Software Park Thailand Newsletter (Thai) Vol4/2555
 
Thai ICT Trad Mission CommunicAsia 2013 (18-21 June 2013)
Thai ICT Trad Mission CommunicAsia 2013 (18-21 June 2013)Thai ICT Trad Mission CommunicAsia 2013 (18-21 June 2013)
Thai ICT Trad Mission CommunicAsia 2013 (18-21 June 2013)
 
Smart Industry Vo.22/2556"E-transaction กระตุ้นธุรกิจอีคอมเมิร์สโต"
Smart Industry Vo.22/2556"E-transaction กระตุ้นธุรกิจอีคอมเมิร์สโต"Smart Industry Vo.22/2556"E-transaction กระตุ้นธุรกิจอีคอมเมิร์สโต"
Smart Industry Vo.22/2556"E-transaction กระตุ้นธุรกิจอีคอมเมิร์สโต"
 
Software newsletter
Software newsletterSoftware newsletter
Software newsletter
 
Smart industry Vol. 21/2556
Smart industry Vol. 21/2556Smart industry Vol. 21/2556
Smart industry Vol. 21/2556
 
Software Park Newsletter 2/2554 "แท็บเล็ต สมาร์ทโพน โมบายแอพพลิเคชั่น ดาวเด่น...
Software Park Newsletter 2/2554 "แท็บเล็ต สมาร์ทโพน โมบายแอพพลิเคชั่น ดาวเด่น...Software Park Newsletter 2/2554 "แท็บเล็ต สมาร์ทโพน โมบายแอพพลิเคชั่น ดาวเด่น...
Software Park Newsletter 2/2554 "แท็บเล็ต สมาร์ทโพน โมบายแอพพลิเคชั่น ดาวเด่น...
 
Software Park Newsletter Vol. 4/2012 English Version
Software Park Newsletter Vol. 4/2012 English VersionSoftware Park Newsletter Vol. 4/2012 English Version
Software Park Newsletter Vol. 4/2012 English Version
 
Thai IT Delegation to Japan 2012
Thai IT Delegation to Japan 2012Thai IT Delegation to Japan 2012
Thai IT Delegation to Japan 2012
 
Thai IT Business Develop,emt Delegation to Tokyo, Japan, 2012
Thai IT Business Develop,emt Delegation to Tokyo, Japan, 2012Thai IT Business Develop,emt Delegation to Tokyo, Japan, 2012
Thai IT Business Develop,emt Delegation to Tokyo, Japan, 2012
 
Thai IT Trade Delegation to Tokyo, Japan 11-16 November 2012
Thai IT Trade Delegation to Tokyo, Japan 11-16 November 2012Thai IT Trade Delegation to Tokyo, Japan 11-16 November 2012
Thai IT Trade Delegation to Tokyo, Japan 11-16 November 2012
 
Thai IT Business Development Delegation to Tokyo, Japan: November 2012
Thai IT Business Development Delegation to Tokyo, Japan: November 2012 Thai IT Business Development Delegation to Tokyo, Japan: November 2012
Thai IT Business Development Delegation to Tokyo, Japan: November 2012
 

Último

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 

Último (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

Introduction to Datastore

  • 1. Introducion to Datastore Assoc.Prof. Dr.Thanachart Numnonda Asst.Prof. Thanisa Kruawaisayawan Mini Master of Java Technology KMITL July 2010
  • 2. Agenda What is DataStore? Using DataStore JPA in DataStore
  • 4. What is Datastore? Google App Engine Datastore is a schema-less persistence system, whose fundamental persistence unit is called Entity, c omposed by an immutable Key and a collection of mutable pr operties. Entities can be created, updated, deleted, loaded by key and queried for properties values. DataStore is consistent and transactional, with support to current transaction.
  • 5. The DataStore The Datastore is not a relational database nor a façade. Relational database technology doesn’t scale horizontally – Connection pools, shared caching are a problem The Datastore is one of many public APIs used for accessing Google’s
  • 8. The DataStore : Operations Transactions and Index are based on MegaTable. File persistence it's done with Google File System (GFS). It's distributed by Chubby, a lock service for loosely- coupled distributed systems.
  • 9. BigTable BigTable is a compressed, high performance, and proprietary database system built on Google File System (GFS), Chubby Lock Service, and a few other Google programs Currently not distributed or used outside of Google. BigTable development began in 2004. and is now used by a number of Google application Google Earth, Google Map, Gmail, Youtube, etc..
  • 10. BigTable : Design BigTable is a fast and extremely large-scale DBMS. It is a sparse, distributed multi-dimensional sorted map, sharing characteristics of both row-oriented and column- oriented databases. sparse because only "not null" values are persisted distributed in Google cloud persistent on Google File System multidimensional in columns values ordered lexicographically by key
  • 11. BigTable : Design Tables are optimized for GFS by being split into multiple tablets - segments of the table. BigTable is designed to scale into the petabyte. Each table has multiple dimensions (one of which is a feld for time, allowing for versioning and garbage collection). It allows an infnite number of rows and columns.
  • 12. Google File System GFS is a proprietary distributed fle system developed by Google. It is designed to provide effcient, reliable access to data using large clusters of commodity hardware. GFS grew out of an earlier Google effort, BigFiles, developed by Larry Page and Sergey Brin in the early days of Google, while it was still located in Stanford.
  • 14. DataStore Operations Datastore operations are defned around entities (data models) which are objects with one or more properties Types: string, user, Boolean, and so on Entities may be recursive or self-referential Entity relationships are one-to-many or many-to-many. Entities may be fxed or grow as needed.
  • 15. DataStore Storage Model Every entity is of a particular kind Entities in a kind need not have the same properties One entity may have different “columns” from another in the same kind! Unique IDs are automatically assigned unless the user defnes a key_name
  • 17. DataStore Storage Model Basic unit of storage is an Entity consisting of Kind (table) Key (primary key) Entity Group (partition) 0..N typed Properties (columns)
  • 18. Datastore Quotas Each call to Datastore counts towards the quota The amount of data cannot exceed the billable  Includes properties and keys but not the indices CPU and Datastore CPU time quotas apply
  • 19. Using the Datastore Applications may access the Datastore using the JDO or the JPA classes. The JDO and JPA classes are abstracted using the DataNucleus API Open source  Not very popular  Support for Java standards  Poor documentation
  • 21. Setting Up JPA The JPA and datastore JARs must be in the app's war/WEB-INF/lib/ directory. A confguration fle named persistence.xml must be in the app's war/WEB-INF/classes/META-INF/ directory, A confguration fle tells JPA to use the App Engine datastore. The appengine-api.jar must also be in the war/WEB- INF/lib/ directory.
  • 22. persistence.xml: Example <?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> <persistence-unit name="thaijavaappPU" transaction-type="RESOURCE_LOCAL"> <persistence-unit name="thaijavaappPU" transaction-type="RESOURCE_LOCAL"> <provider>org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider <provider>org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider </provider> </provider> <non-jta-data-source/> <non-jta-data-source/> <properties> <properties> <property name="datanucleus.ConnectionURL" value="appengine"/> <property name="datanucleus.ConnectionURL" value="appengine"/> <property name="datanucleus.NontransactionalRead" value="true"/> <property name="datanucleus.NontransactionalRead" value="true"/> <property name="datanucleus.NontransactionalWrite" value="true"/> <property name="datanucleus.NontransactionalWrite" value="true"/> </properties> </properties> </persistence-unit> </persistence-unit> </persistence> </persistence>
  • 23. Getting an EntityManager Instance An app interacts with JPA using an instance of the EntityManager. import javax.persistence.EntityManagerFactory; import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence; import javax.persistence.Persistence; public class EMF {{ public class EMF private static final EntityManagerFactory emfInstance == private static final EntityManagerFactory emfInstance Persistence.createEntityManagerFactory("transactions-optional"); Persistence.createEntityManagerFactory("transactions-optional"); public static EntityManagerFactory get() {{ public static EntityManagerFactory get() return emfInstance; return emfInstance; }} }}
  • 24. Entity Class : Example @Entity @Entity public class GuestList implements Serializable {{ public class GuestList implements Serializable …… @Id @Id private String id; private String id; @Basic @Basic private User author; private User author; private String content; private String content; @Temporal(javax.persistence.TemporalType.DATE) @Temporal(javax.persistence.TemporalType.DATE) private Date visitDate; private Date visitDate; …… // Getter and Setter methods // Getter and Setter methods }}
  • 25. Queries and Indices A query operates on every entity of a given kind. Specify zero or more sort orders Specify zero or more flters on property values Indices are defned in the App Engine confguration fles Results are fetched directly from these indices; no indices are created on the fly WEB-INF/datastore-indexes.xml - non-standard fles Normalization is not recommended Optimization techniques for RDBMSs may result in poor Datastore performance!
  • 26. Query : Example EntityManager em == EMF.get().createEntityManager(); EntityManager em EMF.get().createEntityManager(); try {{ try Query query == em.createQuery("SELECT oo FROM GuestList AS o"); Query query em.createQuery("SELECT FROM GuestList AS o"); @SuppressWarnings("unchecked") @SuppressWarnings("unchecked") List<GuestList> results == (List<GuestList>) query.getResultList(); List<GuestList> results (List<GuestList>) query.getResultList(); for (Object obj :: results) {{ for (Object obj results) GuestList guest == (GuestList) obj; GuestList guest (GuestList) obj; String nickname == guest.getAuthor().getNickname(); String nickname guest.getAuthor().getNickname(); out.println(nickname ++ "" "" ++ guest.getId()); out.println(nickname guest.getId()); }} }} catch(Exception ex) {{ catch(Exception ex) out.println(ex); out.println(ex); }}
  • 27. Entity Relationships Models association between entities. There are four types of relationship multiplicities: @OneToOne @OneToMany @ManyToOne Supports unidirectional as well as bidirectional relationships Unidirectional relationship: Entity A references B, but B doesn't reference A.
  • 30. Transactions and Entity Groups Transaction = Group of Datastore operations that either succeed or fail Entity groups are required because all grouped entities are stored in the same Datastore node An entity may be either created or modifed once per transaction Transactions may fail if a different user or process tries an update in the same group at the same time Users decide whether to retry or roll the transaction back
  • 31. Transaction in JPA : Example Book book == em.find(Book.class, "9780596156732"); Book book em.find(Book.class, "9780596156732"); BookReview bookReview == new BookReview(); BookReview bookReview new BookReview(); bookReview.rating == 5; bookReview.rating 5; book.getBookReviews().add(bookReview); book.getBookReviews().add(bookReview); Transaction txn == em.getTransaction(); Transaction txn em.getTransaction(); txn.begin(); txn.begin(); try {{ try book == em.merge(book); book em.merge(book); txn.commit(); txn.commit(); }} finally {{ finally if (txn.isActive()) {{ if (txn.isActive()) txn.rollback(); txn.rollback(); }} }}
  • 32. Unsupported Features of JPA Owned many-to-many relationships, and unowned relationships. "Join" queries. Aggregation queries (group by, having, sum, avg, max, min) Polymorphic queries.
  • 33. Resources Google App Engine for Java HOWTO, Andrew Lombardi, Mar 2010 The Softer Side Of Schemas, Max Ross, May 2009 Official Google App Engine Tutorial, http://code.google.com/appengine/docs/java/gettingstarted/ Programming Google App Engine, Don Sanderson, O'Reilly, 2010
  • 34. Thank you thananum@gmail.com twitter.com/thanachart www.facebook.com/thanachart www.thaijavadev.com