Skip to content

Commit

Permalink
Merge pull request brianfrankcooper#308 from busbey/pr-183
Browse files Browse the repository at this point in the history
[orientdb] rebased PR183: "Upgraded OrientDB"

closes brianfrankcooper#183
  • Loading branch information
busbey committed Jul 8, 2015
2 parents ee436f4 + 0054150 commit 35720bb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion orientdb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<dependency>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-core</artifactId>
<version>1.0.1</version>
<version>1.7.10</version>
</dependency>
</dependencies>
</project>
37 changes: 23 additions & 14 deletions orientdb/src/main/java/com/yahoo/ycsb/db/OrientDBClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,11 @@

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.db.document.ODatabaseDocumentTx;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
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.record.ORecordInternal;
import com.orientechnologies.orient.core.record.impl.ODocument;
Expand All @@ -25,6 +20,12 @@
import com.yahoo.ycsb.DBException;
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.
*
Expand All @@ -40,8 +41,8 @@
*/
public class OrientDBClient extends DB {

private ODatabaseDocumentTx db;
private static final String CLASS = "usertable";
private ODatabaseDocumentTx db;
private ODictionary<ORecordInternal<?>> dictionary;

/**
Expand All @@ -51,7 +52,12 @@ public void init() throws DBException {
// initialize OrientDB driver
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 password = props.getProperty("orientdb.password", "admin");
Boolean newdb = Boolean.parseBoolean(props.getProperty("orientdb.newdb", "false"));
Expand Down Expand Up @@ -206,13 +212,16 @@ public int update(String table, String key, HashMap<String, ByteIterator> values
*/
public int scan(String table, String startkey, int recordcount, Set<String> fields, Vector<HashMap<String, ByteIterator>> result) {
try {
final Collection<ODocument> documents = dictionary.getIndex().getEntriesMajor(startkey, true, recordcount);
for (ODocument document : documents) {
final HashMap<String, ByteIterator> entry = new HashMap<String, ByteIterator>(fields.size());
result.add(entry);
final OIndexCursor entries = dictionary.getIndex().iterateEntriesMajor(startkey, true, true);
while (entries.hasNext()) {
final Entry<Object, OIdentifiable> entry = entries.nextEntry();
final ODocument document = entry.getValue().getRecord();

final HashMap<String, ByteIterator> map = new HashMap<String, ByteIterator>();
result.add(map);

for (String field : fields)
entry.put(field, new StringByteIterator((String) document.field(field)));
map.put(field, new StringByteIterator((String) document.field(field)));
}

return 0;
Expand Down

0 comments on commit 35720bb

Please sign in to comment.