Oracle NoSQL Database Examples
version 11gR2.2.0.26

schema
Class UserInfo

java.lang.Object
  extended by schema.UserInfo

 class UserInfo
extends Object

Holds the collection of user attributes that is stored as the Value for the "/user/EMAIL/-/info" Key. Illustrates the use of a multi-attribute Key/Value pair.

Memory and disk overhead is reduced when storing multiple attributes in a single Value, compared to storing each individual attribute as a separate Key/Value pair. The multi-attribute approach is appropriate when more than one attribute is often accessed at a time, and the attributes are generally small. When a large attribute is not typically accessed along with other attributes, it is generally better to store it as a separate Key/Value pair; for example, see the UserImage class.

This class implements serialization and deserialization of its attributes as a Value object. A Value object is used to access a Key/Value pair, and is really just a wrapper for a byte array.

To translate attributes to and from the byte array, the standard Java DataOutputStream and DataInputStream classes are used. It is important to minimize the size of the byte array, and DataOutput and DataInput provide low-level methods for optimizing the storage size. Of course, many other serialization techniques are available, and the use of DataOutputStream and DataInputStream is only used here as one example.

Standard Java serialization is not recommended because of the large per-object overhead that would be repeated in every Value containing objects of the same class. Even when using the Externalizable approach, the class name is stored with each object. This redundancy is not appropriate for large scale data storage.

In a real application, provisions should be made for schema versioning. Schema versioning is beyond the scope of this example and the serialization format used here contains no version information.


Constructor Summary
UserInfo(String email)
          Constructs a user object with its unique identifier, the email address.
 
Method Summary
(package private)  String getAddress()
          Returns the address attribute.
(package private)  String getEmail()
          Returns the email identifier.
(package private)  Gender getGender()
          Returns the gender attribute.
(package private)  String getName()
          Returns the name attribute.
(package private)  String getPhone()
          Returns the phone attribute.
(package private)  Key getStoreKey()
          Returns a Key that can be used to write or read the UserInfo.
(package private)  Value getStoreValue(Bindings bindings)
          Serializes user info attributes into the byte array of a Value.
(package private)  void setAddress(String address)
          Changes the address attribute.
(package private)  void setGender(Gender gender)
          Changes the gender attribute.
(package private)  void setName(String name)
          Changes the name attribute.
(package private)  void setPhone(String phone)
          Changes the phone attribute.
(package private)  void setStoreValue(Bindings bindings, Value value)
          Deserializes user info attributes from the byte array of a Value.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UserInfo

UserInfo(String email)
Constructs a user object with its unique identifier, the email address.

Method Detail

getEmail

String getEmail()
Returns the email identifier.


setName

void setName(String name)
Changes the name attribute.


getName

String getName()
Returns the name attribute.


setGender

void setGender(Gender gender)
Changes the gender attribute.


getGender

Gender getGender()
Returns the gender attribute.


setAddress

void setAddress(String address)
Changes the address attribute.


getAddress

String getAddress()
Returns the address attribute.


setPhone

void setPhone(String phone)
Changes the phone attribute.


getPhone

String getPhone()
Returns the phone attribute.


getStoreKey

Key getStoreKey()
Returns a Key that can be used to write or read the UserInfo.


getStoreValue

Value getStoreValue(Bindings bindings)
Serializes user info attributes into the byte array of a Value.


setStoreValue

void setStoreValue(Bindings bindings,
                   Value value)
Deserializes user info attributes from the byte array of a Value.


toString

public String toString()
Overrides:
toString in class Object

Oracle NoSQL Database Examples
version 11gR2.2.0.26

Copyright (c) 2011, 2013 Oracle and/or its affiliates. All rights reserved.