Skip to content
Snippets Groups Projects
Commit 35720bb2 authored by Sean Busbey's avatar Sean Busbey
Browse files

Merge pull request #308 from busbey/pr-183

[orientdb] rebased PR183: "Upgraded OrientDB"

closes #183 
parents ee436f43 00541505
No related branches found
No related tags found
No related merge requests found
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<dependency> <dependency>
<groupId>com.orientechnologies</groupId> <groupId>com.orientechnologies</groupId>
<artifactId>orientdb-core</artifactId> <artifactId>orientdb-core</artifactId>
<version>1.0.1</version> <version>1.7.10</version>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>
...@@ -7,16 +7,11 @@ ...@@ -7,16 +7,11 @@
package com.yahoo.ycsb.db; package com.yahoo.ycsb.db;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import java.util.Vector;
import com.orientechnologies.orient.core.config.OGlobalConfiguration; import com.orientechnologies.orient.core.config.OGlobalConfiguration;
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.dictionary.ODictionary; import com.orientechnologies.orient.core.dictionary.ODictionary;
import com.orientechnologies.orient.core.index.OIndexCursor;
import com.orientechnologies.orient.core.intent.OIntentMassiveInsert; import com.orientechnologies.orient.core.intent.OIntentMassiveInsert;
import com.orientechnologies.orient.core.record.ORecordInternal; import com.orientechnologies.orient.core.record.ORecordInternal;
import com.orientechnologies.orient.core.record.impl.ODocument; import com.orientechnologies.orient.core.record.impl.ODocument;
...@@ -25,6 +20,12 @@ import com.yahoo.ycsb.DB; ...@@ -25,6 +20,12 @@ import com.yahoo.ycsb.DB;
import com.yahoo.ycsb.DBException; import com.yahoo.ycsb.DBException;
import com.yahoo.ycsb.StringByteIterator; import com.yahoo.ycsb.StringByteIterator;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import java.util.Vector;
/** /**
* OrientDB client for YCSB framework. * OrientDB client for YCSB framework.
* *
...@@ -40,8 +41,8 @@ import com.yahoo.ycsb.StringByteIterator; ...@@ -40,8 +41,8 @@ import com.yahoo.ycsb.StringByteIterator;
*/ */
public class OrientDBClient extends DB { public class OrientDBClient extends DB {
private ODatabaseDocumentTx db;
private static final String CLASS = "usertable"; private static final String CLASS = "usertable";
private ODatabaseDocumentTx db;
private ODictionary<ORecordInternal<?>> dictionary; private ODictionary<ORecordInternal<?>> dictionary;
/** /**
...@@ -51,7 +52,12 @@ public class OrientDBClient extends DB { ...@@ -51,7 +52,12 @@ public class OrientDBClient extends DB {
// initialize OrientDB driver // initialize OrientDB driver
Properties props = getProperties(); Properties props = getProperties();
String url = props.getProperty("orientdb.url", "local:C:/temp/databases/ycsb"); String url;
if (System.getProperty("os.name").toLowerCase().contains("win"))
url = props.getProperty("orientdb.url", "plocal:C:/temp/databases/ycsb");
else
url = props.getProperty("orientdb.url", "plocal:/temp/databases/ycsb");
String user = props.getProperty("orientdb.user", "admin"); String user = props.getProperty("orientdb.user", "admin");
String password = props.getProperty("orientdb.password", "admin"); String password = props.getProperty("orientdb.password", "admin");
Boolean newdb = Boolean.parseBoolean(props.getProperty("orientdb.newdb", "false")); Boolean newdb = Boolean.parseBoolean(props.getProperty("orientdb.newdb", "false"));
...@@ -206,13 +212,16 @@ public class OrientDBClient extends DB { ...@@ -206,13 +212,16 @@ public class OrientDBClient extends DB {
*/ */
public int scan(String table, String startkey, int recordcount, Set<String> fields, Vector<HashMap<String, ByteIterator>> result) { public int scan(String table, String startkey, int recordcount, Set<String> fields, Vector<HashMap<String, ByteIterator>> result) {
try { try {
final Collection<ODocument> documents = dictionary.getIndex().getEntriesMajor(startkey, true, recordcount); final OIndexCursor entries = dictionary.getIndex().iterateEntriesMajor(startkey, true, true);
for (ODocument document : documents) { while (entries.hasNext()) {
final HashMap<String, ByteIterator> entry = new HashMap<String, ByteIterator>(fields.size()); final Entry<Object, OIdentifiable> entry = entries.nextEntry();
result.add(entry); final ODocument document = entry.getValue().getRecord();
final HashMap<String, ByteIterator> map = new HashMap<String, ByteIterator>();
result.add(map);
for (String field : fields) for (String field : fields)
entry.put(field, new StringByteIterator((String) document.field(field))); map.put(field, new StringByteIterator((String) document.field(field)));
} }
return 0; return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment