Skip to content
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

[In-Progress] GORA-698 Implement Geode Store #294

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions gora-geode/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<parent>
<artifactId>gora</artifactId>
<groupId>org.apache.gora</groupId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>gora-geode</artifactId>
<name>Apache Gora :: Geode</name>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>

<dependencies>
<!-- Gora Internal Dependencies -->
<dependency>
<groupId>org.apache.gora</groupId>
<artifactId>gora-core</artifactId>
</dependency>

<dependency>
<groupId>org.apache.gora</groupId>
<artifactId>gora-core</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
</dependency>

<!-- Hadoop Dependencies -->
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
</dependency>

<!-- Geode Dependencies -->
<dependency>
<groupId>org.apache.geode</groupId>
<artifactId>geode-core</artifactId>
</dependency>

<!-- Logging Dependencies -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>

<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<exclusions>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- 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>
<scope>test</scope>
</dependency>

</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* 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.
*/

package org.apache.gora.geode.query;

import org.apache.gora.persistency.impl.PersistentBase;
import org.apache.gora.query.impl.QueryBase;
import org.apache.gora.store.DataStore;

/**
* {@link GeodeQuery} is the primary class
* responsible for representing a cache manipulation query.
*/
public class GeodeQuery<K, T extends PersistentBase> extends QueryBase<K, T> {

public GeodeQuery() {
super(null);
}

public GeodeQuery(DataStore<K, T> dataStore) {
super(dataStore);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/**
* 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.
*/

package org.apache.gora.geode.query;

import org.apache.gora.geode.store.GeodeStore;
import org.apache.gora.persistency.impl.PersistentBase;
import org.apache.gora.query.Query;
import org.apache.gora.query.impl.ResultBase;
import org.apache.gora.store.DataStore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.Iterator;
import java.util.NavigableSet;

/**
* {@link GeodeResult} is the primary class
* responsible for representing result set of a cache manipulation query
* {@link org.apache.gora.geode.query.GeodeQuery}
*/
public class GeodeResult<K, T extends PersistentBase> extends ResultBase<K, T> {

private static final Logger LOG = LoggerFactory.getLogger(GeodeResult.class);
private NavigableSet<K> cacheKeySet;
private Iterator<K> iterator;
private int current;

public GeodeResult(DataStore<K, T> dataStore, Query<K, T> query) {
super(dataStore, query);
}

public GeodeResult(DataStore<K, T> dataStore, Query<K, T> query, NavigableSet<K> cacheKeySet) {
super(dataStore, query);
this.cacheKeySet = cacheKeySet;
this.iterator = cacheKeySet.iterator();
this.current = 0;
}

public GeodeStore<K, T> getDataStore() {
return (GeodeStore<K, T>) super.getDataStore();
}

@Override
public float getProgress() throws IOException {
if (cacheKeySet.size() == 0) {
return 1;
}
return ((float) current / (float) cacheKeySet.size());
}

@Override
protected boolean nextInner() throws IOException {
if (!iterator.hasNext()) {
return false;
}
key = iterator.next();
LOG.info("Results set pointer is now moved to key {}.", key);
persistent = dataStore.get(key);
this.current++;
return true;
}

@Override
public int size() {
int totalSize = cacheKeySet.size();
int intLimit = (int) this.limit;
return intLimit > 0 && totalSize > intLimit ? intLimit : totalSize;
}
}
Loading
Loading