
- •Москва 2012
- •Введение
- •Nosql решения
- •Отличительные особенности nosql
- •Общие сведения о NoSql моделирования данных
- •Сравнение sql и NoSql от Oracle
- •Подготовка Oracle sql
- •Подготовка Oracle NoSql
- •Сравнение производительности
- •Сравнение производительности для выборки с условием
- •Сравнение производительности
- •Список использованной литературы
- •Приложение 1 .Java классы
Список использованной литературы
http://highlyscalable.wordpress.com/2012/03/01/nosql-data-modeling-techniques/
http://docs.oracle.com/cd/NOSQL/html/GettingStartedGuide
Том Кайт, Oracle для профессионалов
http://www.oracle.com/oms/oracleday/od11-bi-bigdata-1366231.pdf
http://www.jroller.com/dmdevito/entry/thinking_about_nosql_databases_classification
http://jsman.ru/mongo-book/Glava-1-Osnovy.html
http://oracle-nosql.blogspot.ru/2012_07_01_archive.html
http://habrahabr.ru/post/152477/
Приложение 1 .Java классы
Вспомогательный класс SimpleOperations.java
public class SimpleOperations {
private KVStore myStore;
String port = "5000";
String host = "localhost";
String store = "kvstore";
long time = 0;
long time1 = 0;
long time2 = 0;
public SimpleOperations(String Store, String Host, String Port) {
this.host = Host;
this.port = Port;
this.store = Store;
time = 0;
time1 =0;
time2 =0;
}
public void Init() {
KVStoreConfig kconfig = new KVStoreConfig(store, host + ":" + port);
myStore = KVStoreFactory.getStore(kconfig);
System.out.println("Store Opened");
}
public void put(String sKey, String data)
throws FileNotFoundException, IOException {
Key myKey = ParseKey(sKey);
Value myValue = Value.createValue(data.getBytes());
long start = System.nanoTime();
myStore.put(myKey, myValue);
time += System.nanoTime() - start;
}
public String get(String sKey) {
Key myKey = ParseKey(sKey);
String myValue = null;
try {
long start = System.nanoTime();
ValueVersion vValue = myStore.get(myKey);
time1 += System.nanoTime() - start;
Value value = vValue.getValue();
myValue = new String(value.getValue());
} catch (RequestTimeoutException re) {
System.out.println(re.getTimeoutMs());
} catch (FaultException fe) {
System.out.println("Unknown error");
} catch (NullPointerException ne) {
System.out.println("Key does not exist");
} finally {
}
return myValue;
}
public void SelectWhere(String sKey) {
Key myKey = ParseKey(sKey);
try {
int i=0;
long start = System.nanoTime();
Iterator<KeyValueVersion> myrecords =
myStore.storeIterator(Direction.UNORDERED, 0, myKey, null, Depth.PARENT_AND_DESCENDANTS);
time2 += System.nanoTime() - start;
while (myrecords.hasNext()) {
start = System.nanoTime();
Key key = myrecords.next().getKey();
ValueVersion vv = myStore.get(key);
time2 += System.nanoTime() - start;
i++;
}
System.out.println("get time: " + String.format("%,12d", time2/1000000)+" count: " + i);
} catch (RequestTimeoutException re) {
System.out.println(re.getTimeoutMs());
} catch (FaultException fe) {
} finally {
}
}
public void SelectWhereFullMajor(String sKey) {
Key myKey = ParseKey(sKey);
try {
// Initialize Matrix
SortedMap<Key, ValueVersion> myrecords = null;
long start = System.nanoTime();
myrecords = myStore.multiGet(myKey, null, Depth.PARENT_AND_DESCENDANTS);//, Consistency.ABSOLUTE, 1, TimeUnit.DAYS);
System.out.println("get time: " + String.format("%,12d", (System.nanoTime() - start)/1000000) + " count: " + myrecords.size());
} catch (RequestTimeoutException re) {
System.out.println(re.getTimeoutMs());
} catch (FaultException fe) {
} finally {
}
}
public void putConditionalMany(String sKey, int module, int count)
throws FileNotFoundException, IOException {
int i = 0, j = 0;
for (i = 0; i < module; i++) {
for (j = 0; j < count; j++) {
put(sKey + i + "/" + j, "testValue" + i);
}
}
System.out.println("Put time: " + String.format("%,12d", time / 1000000));
}
public void SelectConditionalWhereFullMajor(String sKey, String start, String end) {
Key myKey = ParseKey(sKey);
try {
SortedMap<Key, ValueVersion> myrecords = null;
long starttime = System.nanoTime();
KeyRange range = new KeyRange(start, true, end, true);
myrecords = myStore.multiGet(myKey, range, Depth.PARENT_AND_DESCENDANTS);//, Consistency.ABSOLUTE, 1, TimeUnit.DAYS);
for (SortedMap.Entry<Key, ValueVersion> entry : myrecords.entrySet()) {
ValueVersion vv = entry.getValue();
Value v = vv.getValue();
Key myKeyOut = entry.getKey();
String data = new String(v.getValue());
List<String> majorPath1 = myKeyOut.getMajorPath();
List<String> minorPath1 = myKeyOut.getMinorPath();
System.out.println(majorPath1 + " - " + minorPath1 + ":" + data);
}
System.out.println("get time: " + String.format("%,12d", (System.nanoTime() - starttime) / 1000000) + " count: " + myrecords.size());
} catch (RequestTimeoutException re) {
System.out.println(re.getTimeoutMs());
} catch (FaultException fe) {
} finally {
}
}
public void putMany(String sKey,int start, int count) throws FileNotFoundException, IOException {
int i = 0;
for (i = start; i <start+ count; i++) {
put(sKey + i, "testValue" + i);
}
System.out.println("Put time: " + String.format("%,12d", time/1000000));
}
public Key ParseKey(String keysString2) {
int endstring;
Key myKey = Key.createKey("");
if (keysString2.indexOf(":") != -1) {
endstring = keysString2.indexOf(":") - 1;
} else {
endstring = keysString2.length();
}
String keysString = keysString2.substring(0, endstring);
List<String> majorComponents = new ArrayList<>();
List<String> minorComponents = new ArrayList<>();
String[] keysArray = keysString.split("/");
boolean isMajor = true;
for (int i = 0; i < keysArray.length; i++) {
if (keysArray[i].equals("-")) {
isMajor = false;
continue;
}
if (isMajor) {
majorComponents.add(keysArray[i]);
} else {
minorComponents.add(keysArray[i]);
}
}
if ((majorComponents.size() > 0) && (minorComponents.size() > 0)) {
myKey = Key.createKey(majorComponents, minorComponents);
} else if ((majorComponents.size() > 0) & (minorComponents.size() <= 0)) {
myKey = Key.createKey(majorComponents);
} else {
System.out.println("Error");
}
return myKey;
}
}
Главный класс OracleNosql.java
public class OracleNosql {
static String port = "5000";
static String host = "localhost";
static String store = "kvstore";
public static void main(String[] args)
throws FileNotFoundException, IOException {
SimpleOperations nosql = new SimpleOperations(store, host, port);
nosql.Init();
nosql.putMany("test/1/stress/-/",0,1000);
nosql.putMany("test/2/stress/-/",0,10000);
nosql.putMany("test/3/stress/-/",0,50000);
nosql.putMany("test/4/stress/-/",0,100000);
nosql.putMany("test/5/stress/-/",0,200000);
nosql.putMany("test/6/stress/-/",0,500000);
nosql.putMany("test/7/stress/-/",0,800000);
nosql.putMany("test/8/stress/-/",0,1000000);
nosql.putMany("test/9/stress/-/",0,1500000);
nosql.putMany("test/10/stress/-/",0,2000000);
nosql.putMany("test/11/stress/-/",0,3000000);
nosql.SelectWhereFullMajor("test/1/stress/-/");
nosql.SelectWhereFullMajor("test/2/stress/-/");
nosql.SelectWhereFullMajor("test/3/stress/-/");
nosql.SelectWhereFullMajor("test/4/stress/-/");
nosql.SelectWhereFullMajor("test/5/stress/-/");
nosql.SelectWhereFullMajor("test/6/stress/-/");
nosql.SelectWhereFullMajor("test/7/stress/-/");
nosql.SelectWhere("test/8/");
nosql.SelectWhere("test/9/");
nosql.SelectWhere("test/10/");
nosql.SelectWhere("test/11/");
}
}