use of org.apache.gora.query.PartitionQuery in project gora by apache.
the class FileBackedDataStoreBase method getPartitions.
@Override
public List<PartitionQuery<K, T>> getPartitions(Query<K, T> query) throws IOException {
List<InputSplit> splits = null;
List<PartitionQuery<K, T>> queries = null;
splits = GoraMapReduceUtils.getSplits(getConf(), inputPath);
queries = new ArrayList<>(splits.size());
for (InputSplit split : splits) {
queries.add(new FileSplitPartitionQuery<>(query, (FileSplit) split));
}
return queries;
}
use of org.apache.gora.query.PartitionQuery in project gora by apache.
the class TestGoraInputFormat method testGetSplits.
/**
* First, asserts that the attempt to obtain splits results in
* greater than 0 splits which can be used for computation.
* We then check that the partition query (obtained by using the
* splits) has the same fields as we would expect by directly
* accessing the fields of an Employee object.
* @throws IOException
* @throws InterruptedException
*/
@Test
@SuppressWarnings("rawtypes")
public void testGetSplits() throws IOException, InterruptedException {
List<InputSplit> splits = getInputSplits();
assertTrue(splits.size() > 0);
InputSplit split = splits.get(0);
PartitionQuery query = ((GoraInputSplit) split).getQuery();
assertTrue(Arrays.equals(getEmployeeFieldNames(), query.getFields()));
}
use of org.apache.gora.query.PartitionQuery in project gora by apache.
the class CassandraStore method getPartitions.
/**
* {@inheritDoc}
*/
@Override
public List<PartitionQuery<K, T>> getPartitions(Query<K, T> query) throws GoraException {
try {
List<PartitionQuery<K, T>> partitions = new ArrayList<>();
PartitionWSQueryImpl<K, T> pqi = new PartitionWSQueryImpl<>(query);
pqi.setDataStore(this);
partitions.add(pqi);
return partitions;
} catch (Exception e) {
throw new GoraException(e);
}
}
use of org.apache.gora.query.PartitionQuery in project gora by apache.
the class PigGoraInputFormat method getSplits.
@Override
public List<InputSplit> getSplits(JobContext context) throws IOException, InterruptedException {
List<PartitionQuery<K, T>> partitionsQueries = this.dataStore.getPartitions(query);
List<InputSplit> splits = new ArrayList<>(partitionsQueries.size());
for (PartitionQuery<K, T> queryForSplit : partitionsQueries) {
splits.add(new GoraInputSplit(context.getConfiguration(), queryForSplit));
}
return splits;
}
use of org.apache.gora.query.PartitionQuery in project gora by apache.
the class JCacheStore method getPartitions.
@Override
public List<PartitionQuery<K, T>> getPartitions(Query<K, T> query) throws IOException {
List<PartitionQuery<K, T>> partitions = new ArrayList<>();
try {
Member[] clusterMembers = new Member[hazelcastInstance.getCluster().getMembers().size()];
this.hazelcastInstance.getCluster().getMembers().toArray(clusterMembers);
for (Member member : clusterMembers) {
JCacheResult<K, T> result = ((JCacheResult<K, T>) query.execute());
ConcurrentSkipListSet<K> memberOwnedCacheEntries = new ConcurrentSkipListSet<>();
while (result.next()) {
K key = result.getKey();
Partition partition = hazelcastInstance.getPartitionService().getPartition(key);
if (partition.getOwner().getUuid().equals(member.getUuid())) {
memberOwnedCacheEntries.add(key);
}
}
PartitionQueryImpl<K, T> partition = new PartitionQueryImpl<>(query, memberOwnedCacheEntries.first(), memberOwnedCacheEntries.last(), member.getSocketAddress().getHostString());
partition.setConf(this.getConf());
partitions.add(partition);
}
} catch (java.lang.Exception ex) {
LOG.error("Exception occurred while partitioning the query based on Hazelcast partitions.", ex);
return null;
}
LOG.info("Query is partitioned to {} number of partitions.", partitions.size());
return partitions;
}
Aggregations