-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GORA-437 implement couchdb datastore #74
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,235 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.apache.gora</groupId> | ||
<artifactId>gora</artifactId> | ||
<version>0.7-SNAPSHOT</version> | ||
<relativePath>../</relativePath> | ||
</parent> | ||
<artifactId>gora-couchdb</artifactId> | ||
<packaging>bundle</packaging> | ||
|
||
<name>Apache Gora :: CouchDB</name> | ||
<url>http://gora.apache.org</url> | ||
<description>The Apache Gora open source framework provides an in-memory data model and | ||
persistence for big data. Gora supports persisting to column stores, key value stores, | ||
document stores and RDBMSs, and analyzing the data with extensive Apache Hadoop MapReduce | ||
support.</description> | ||
<inceptionYear>2010</inceptionYear> | ||
<organization> | ||
<name>The Apache Software Foundation</name> | ||
<url>http://www.apache.org/</url> | ||
</organization> | ||
<issueManagement> | ||
<system>JIRA</system> | ||
<url>https://issues.apache.org/jira/browse/GORA</url> | ||
</issueManagement> | ||
<ciManagement> | ||
<system>Jenkins</system> | ||
<url>https://builds.apache.org/job/Gora-trunk/</url> | ||
</ciManagement> | ||
|
||
<properties> | ||
<osgi.import>*</osgi.import> | ||
<osgi.export>org.apache.gora.couchdb*;version="${project.version}";-noimport:=true</osgi.export> | ||
</properties> | ||
|
||
<profiles> | ||
<profile> | ||
<id>couchdb-with-test</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.4.2</version> | ||
<configuration> | ||
<skipTests>false</skipTests> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
|
||
<build> | ||
<directory>target</directory> | ||
<outputDirectory>target/classes</outputDirectory> | ||
<finalName>${project.artifactId}-${project.version}</finalName> | ||
<testOutputDirectory>target/test-classes</testOutputDirectory> | ||
<testSourceDirectory>src/test/java</testSourceDirectory> | ||
<sourceDirectory>src/main/java</sourceDirectory> | ||
<testResources> | ||
<testResource> | ||
<directory>${project.basedir}/src/test/conf</directory> | ||
<includes> | ||
<include>**/*</include> | ||
</includes> | ||
</testResource> | ||
</testResources> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.4.2</version> | ||
<configuration> | ||
<skipTests>true</skipTests> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>build-helper-maven-plugin</artifactId> | ||
<version>${build-helper-maven-plugin.version}</version> | ||
<executions> | ||
<execution> | ||
<phase>generate-sources</phase> | ||
<goals> | ||
<goal>add-source</goal> | ||
</goals> | ||
<configuration> | ||
<sources> | ||
<source>src/examples/java</source> | ||
</sources> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<repositories> | ||
<repository> | ||
<id>clojars.org</id> | ||
<url>http://clojars.org/repo</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<!-- Gora Internal Dependencies --> | ||
<dependency> | ||
<groupId>org.apache.gora</groupId> | ||
<artifactId>gora-core</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.gora</groupId> | ||
<artifactId>gora-core</artifactId> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
|
||
<dependency> | ||
<groupId>org.apache.gora</groupId> | ||
<artifactId>gora-core</artifactId> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<!-- END of Gora Internal Dependencies --> | ||
|
||
<dependency> | ||
<groupId>org.apache.hadoop</groupId> | ||
<artifactId>hadoop-client</artifactId> | ||
<scope>compile</scope> | ||
<optional>true</optional> | ||
</dependency> | ||
|
||
<!-- Apache CouchDB java client --> | ||
<dependency> | ||
<groupId>org.ektorp</groupId> | ||
<artifactId>org.ektorp</artifactId> | ||
<version>1.4.2</version> | ||
</dependency> | ||
|
||
|
||
<dependency> | ||
<groupId>org.apache.avro</groupId> | ||
<artifactId>avro</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
|
||
<!-- Misc Dependencies --> | ||
<dependency> | ||
<groupId>org.jdom</groupId> | ||
<artifactId>jdom</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.google.guava</groupId> | ||
<artifactId>guava</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
|
||
<!-- Logging Dependencies --> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-simple</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>log4j</groupId> | ||
<artifactId>log4j</artifactId> | ||
<scope>runtime</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>javax.jms</groupId> | ||
<artifactId>jms</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
|
||
<!-- END of Logging Dependencies --> | ||
|
||
<!-- Testing Dependencies --> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.hadoop</groupId> | ||
<artifactId>hadoop-minicluster</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>testcontainers</artifactId> | ||
<version>1.1.0</version> | ||
</dependency> | ||
|
||
<!-- END of Testing Dependencies --> | ||
</dependencies> | ||
|
||
</project> |
43 changes: 43 additions & 0 deletions
43
gora-couchdb/src/main/java/org/apache/gora/couchdb/query/CouchDBQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.gora.couchdb.query; | ||
|
||
import org.apache.gora.couchdb.store.CouchDBStore; | ||
import org.apache.gora.persistency.impl.PersistentBase; | ||
import org.apache.gora.query.Query; | ||
import org.apache.gora.query.impl.QueryBase; | ||
import org.apache.gora.store.DataStore; | ||
|
||
/** | ||
* CouchDB specific implementation of the {@link Query} interface. | ||
*/ | ||
public class CouchDBQuery<K, T extends PersistentBase> extends QueryBase<K, T> { | ||
|
||
final CouchDBStore store; | ||
|
||
/** | ||
* Constructor for the query | ||
* | ||
* @param dataStore Data store used | ||
* | ||
*/ | ||
public CouchDBQuery(DataStore<K, T> dataStore) { | ||
super(dataStore); | ||
store = (CouchDBStore) dataStore; | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
gora-couchdb/src/main/java/org/apache/gora/couchdb/query/CouchDBResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.gora.couchdb.query; | ||
|
||
import org.apache.gora.couchdb.store.CouchDBStore; | ||
import org.apache.gora.persistency.Persistent; | ||
import org.apache.gora.query.Query; | ||
import org.apache.gora.query.impl.ResultBase; | ||
import org.apache.gora.store.DataStore; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* CouchDB specific implementation of the {@link org.apache.gora.query.Result} | ||
* interface. | ||
*/ | ||
public class CouchDBResult<K, T extends Persistent> extends ResultBase<K, T> { | ||
|
||
/** | ||
* Result set containing query results | ||
*/ | ||
private List<Map> result; | ||
|
||
protected CouchDBStore dataStore; | ||
int position = 0; | ||
|
||
/** | ||
* Constructor for the result set | ||
* | ||
* @param dataStore Data store used | ||
* @param query Query used | ||
* @param result Result obtained from querying | ||
*/ | ||
public CouchDBResult(DataStore<K, T> dataStore, Query<K, T> query, List<Map> result) { | ||
super(dataStore, query); | ||
this.result = result; | ||
this.dataStore = (CouchDBStore) dataStore; | ||
} | ||
|
||
/** | ||
* Gets the next item | ||
*/ | ||
@Override | ||
protected boolean nextInner() throws IOException { | ||
if (result == null || result.size() <= 0 || position >= result.size()) { | ||
return false; | ||
} | ||
key = (K) result.get(position).get("_id"); | ||
persistent = (T) dataStore.newInstance(result.get(position++), query.getFields()); | ||
return persistent != null; | ||
} | ||
|
||
/** | ||
* Gets the items reading progress | ||
*/ | ||
@Override | ||
public float getProgress() throws IOException, InterruptedException { | ||
if (result != null && result.size() > 0) { | ||
return (float) position / (float) result.size(); | ||
} else { | ||
return 0; | ||
} | ||
} | ||
|
||
/** | ||
* Result set containing query results | ||
* | ||
* @return Result set containing query results | ||
*/ | ||
public List<Map> getResultData() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. javadoc |
||
return result; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
javadoc