use of org.apache.jena.hadoop.rdf.types.CharacteristicSetWritable in project jena by apache.
the class CharacteristicTests method characteristic_set_writable_01.
/**
* Tests characteristic sets
*
* @throws IOException
*/
@Test
public void characteristic_set_writable_01() throws IOException {
CharacteristicSetWritable set = new CharacteristicSetWritable();
// Add some characteristics
CharacteristicWritable cw1 = new CharacteristicWritable(NodeFactory.createURI("http://example.org"));
CharacteristicWritable cw2 = new CharacteristicWritable(NodeFactory.createURI("http://example.org/other"));
set.add(cw1);
set.add(cw2);
this.checkCharacteristicSet(set, 2, new long[] { 1, 1 });
this.checkRoundTrip(set);
}
use of org.apache.jena.hadoop.rdf.types.CharacteristicSetWritable in project jena by apache.
the class AbstractCharacteristicSetGeneratingReducer method combinations.
/**
* Calculate all available combinations of N elements from the given
* characteristics
*
* @param cs
* Characteristics
* @param len
* Desired number of elements
* @param startPosition
* Start position
* @param result
* Result array to fill
* @param context
* Context to write completed combinations to
* @throws IOException
* @throws InterruptedException
*/
protected final void combinations(List<CharacteristicWritable> cs, int len, int startPosition, CharacteristicWritable[] result, Context context) throws IOException, InterruptedException {
if (len == 0) {
CharacteristicSetWritable set = new CharacteristicSetWritable(result);
context.write(set, NullWritable.get());
if (this.tracing) {
LOG.trace("Key = {}", set);
}
return;
}
for (int i = startPosition; i <= cs.size() - len; i++) {
result[result.length - len] = cs.get(i);
combinations(cs, len - 1, i + 1, result, context);
}
}
use of org.apache.jena.hadoop.rdf.types.CharacteristicSetWritable in project jena by apache.
the class CharacteristicSetReducer method reduce.
@Override
protected void reduce(CharacteristicSetWritable key, Iterable<CharacteristicSetWritable> values, Context context) throws IOException, InterruptedException {
Iterator<CharacteristicSetWritable> iter = values.iterator();
CharacteristicSetWritable output = new CharacteristicSetWritable(0);
if (this.tracing) {
LOG.trace("Key = {}", key);
}
while (iter.hasNext()) {
CharacteristicSetWritable set = iter.next();
if (this.tracing) {
LOG.trace("Value = {}", set);
}
output.add(set);
}
context.write(output, NullWritable.get());
}
use of org.apache.jena.hadoop.rdf.types.CharacteristicSetWritable in project jena by apache.
the class CharacteristicTests method characteristic_set_writable_03.
/**
* Tests characteristic sets
*
* @throws IOException
*/
@Test
public void characteristic_set_writable_03() throws IOException {
CharacteristicSetWritable set1 = new CharacteristicSetWritable();
CharacteristicSetWritable set2 = new CharacteristicSetWritable();
// Add some characteristics
CharacteristicWritable cw1 = new CharacteristicWritable(NodeFactory.createURI("http://example.org"));
CharacteristicWritable cw2 = new CharacteristicWritable(NodeFactory.createURI("http://example.org/other"));
set1.add(cw1);
set2.add(cw2);
this.checkCharacteristicSet(set1, 1, new long[] { 1 });
this.checkCharacteristicSet(set2, 1, new long[] { 1 });
this.checkRoundTrip(set1);
this.checkRoundTrip(set2);
Assert.assertNotEquals(set1, set2);
}
use of org.apache.jena.hadoop.rdf.types.CharacteristicSetWritable in project jena by apache.
the class CharacteristicTests method characteristic_set_writable_02.
/**
* Tests characteristic sets
*
* @throws IOException
*/
@Test
public void characteristic_set_writable_02() throws IOException {
CharacteristicSetWritable set = new CharacteristicSetWritable();
// Add some characteristics
CharacteristicWritable cw1 = new CharacteristicWritable(NodeFactory.createURI("http://example.org"));
CharacteristicWritable cw2 = new CharacteristicWritable(NodeFactory.createURI("http://example.org"), 2);
set.add(cw1);
set.add(cw2);
this.checkCharacteristicSet(set, 1, new long[] { 3 });
this.checkRoundTrip(set);
}
Aggregations