Java Code Examples for org.eclipse.rdf4j.model.Statement#getPredicate()

The following examples show how to use org.eclipse.rdf4j.model.Statement#getPredicate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExploreServlet.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Gets whether this is the first time the result quad has been seen.
 *
 * @param patternPredicate the predicate asked for, or null if another quad element was asked for
 * @param patternObject    the object asked for, or null if another quad element was asked for
 * @param result           the result statement to determine if we've already seen
 * @param patternContext   the context asked for, or null if another quad element was asked for
 * @return true, if this is the first time the quad has been seen, false otherwise
 */
private boolean isFirstTimeSeen(Statement result, IRI patternPredicate, Value patternObject,
		Resource... patternContext) {
	Resource resultSubject = result.getSubject();
	IRI resultPredicate = result.getPredicate();
	Value resultObject = result.getObject();
	boolean firstTimeSeen;
	if (1 == patternContext.length) {
		// I.e., when context matches explore value.
		Resource ctx = patternContext[0];
		firstTimeSeen = !(ctx.equals(resultSubject) || ctx.equals(resultPredicate) || ctx.equals(resultObject));
	} else if (null != patternObject) {
		// I.e., when object matches explore value.
		firstTimeSeen = !(resultObject.equals(resultSubject) || resultObject.equals(resultPredicate));
	} else if (null != patternPredicate) {
		// I.e., when predicate matches explore value.
		firstTimeSeen = !(resultPredicate.equals(resultSubject));
	} else {
		// I.e., when subject matches explore value.
		firstTimeSeen = true;
	}
	return firstTimeSeen;
}
 
Example 2
Source File: ExtensibleStatementHelper.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public ExtensibleStatement fromStatement(Statement statement, boolean inferred) {
	if (statement instanceof ExtensibleStatement
			&& ((ExtensibleStatement) statement).isInferred() == inferred) {
		return (ExtensibleStatement) statement;
	}

	if (statement.getContext() != null) {
		return new ExtensibleContextStatement(statement.getSubject(), statement.getPredicate(),
				statement.getObject(), statement.getContext(), inferred);
	}

	return new ExtensibleStatementImpl(statement.getSubject(), statement.getPredicate(), statement.getObject(),
			inferred);

}
 
Example 3
Source File: ForwardChainingRDFSInferencerConnection.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private int applyRuleX1() throws SailException {
	int nofInferred = 0;

	String prefix = RDF.NAMESPACE + "_";
	Iterable<Statement> iter = newThisIteration.getStatements(null, null, null);

	for (Statement st : iter) {
		IRI predNode = st.getPredicate();
		String predURI = predNode.toString();

		if (predURI.startsWith(prefix) && isValidPredicateNumber(predURI.substring(prefix.length()))) {
			boolean added = addInferredStatement(predNode, RDF.TYPE, RDFS.CONTAINERMEMBERSHIPPROPERTY);
			if (added) {
				nofInferred++;
			}
		}
	}

	return nofInferred;
}
 
Example 4
Source File: RepositoryConnectionTest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testPreparedGraphQuery() throws Exception {
	testCon.begin();
	testCon.add(alice, name, nameAlice, context2);
	testCon.add(alice, mbox, mboxAlice, context2);
	testCon.add(context2, publisher, nameAlice);
	testCon.add(bob, name, nameBob, context1);
	testCon.add(bob, mbox, mboxBob, context1);
	testCon.add(context1, publisher, nameBob);
	testCon.commit();
	StringBuilder queryBuilder = new StringBuilder(128);
	queryBuilder.append(" CONSTRUCT *");
	queryBuilder.append(" FROM {} foaf:name {name};");
	queryBuilder.append("         foaf:mbox {mbox}");
	queryBuilder.append(" USING NAMESPACE foaf = <" + FOAF_NS + ">");
	GraphQuery query = testCon.prepareGraphQuery(QueryLanguage.SERQL, queryBuilder.toString());
	query.setBinding(NAME, nameBob);

	try (GraphQueryResult result = query.evaluate();) {
		assertThat(result).isNotNull();
		assertThat(result.hasNext()).isTrue();
		while (result.hasNext()) {
			Statement st = result.next();
			IRI predicate = st.getPredicate();
			assertThat(predicate).isIn(name, mbox);
			Value object = st.getObject();
			if (name.equals(predicate)) {
				assertEquals("unexpected value for name: " + object, nameBob, object);
			} else {
				assertThat(predicate).isEqualTo(mbox);
				assertEquals("unexpected value for mbox: " + object, mboxBob, object);
			}
		}
	}
}
 
Example 5
Source File: RDFSailRemover.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void handleStatement(Statement st) throws RDFHandlerException {
	Resource subj = st.getSubject();
	IRI pred = st.getPredicate();
	Value obj = st.getObject();
	Resource ctxt = st.getContext();

	try {
		if (enforcesContext()) {
			con.removeStatement(uc, subj, pred, obj, contexts);
		} else {
			if (ctxt == null) {
				final Set<IRI> removeGraphs = uc.getDataset().getDefaultRemoveGraphs();
				if (!removeGraphs.isEmpty()) {
					IRI[] ctxts = removeGraphs.toArray(new IRI[removeGraphs.size()]);
					con.removeStatement(uc, subj, pred, obj, ctxts);
				} else {
					con.removeStatement(uc, subj, pred, obj);
				}
			} else {
				con.removeStatement(uc, subj, pred, obj, ctxt);
			}
		}
	} catch (SailException e) {
		throw new RDFHandlerException(e);
	}
}
 
Example 6
Source File: UnorderedSelect.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public CloseableIteration<Tuple, SailException> iterator() {
	return new LoggingCloseableIteration(this, validationExecutionLogger) {

		CloseableIteration<? extends Statement, SailException> statements = connection.getStatements(subject,
				predicate, object, true);

		@Override
		public void close() throws SailException {
			statements.close();
		}

		@Override
		boolean localHasNext() throws SailException {
			return statements.hasNext();
		}

		@Override
		Tuple loggingNext() throws SailException {

			Statement next = statements.next();
			if (outputPattern == OutputPattern.SubjectObject) {
				return new Tuple(next.getSubject(), next.getObject());
			}
			if (outputPattern == OutputPattern.SubjectPredicateObject) {
				return new Tuple(next.getSubject(), next.getPredicate(), next.getObject());
			}
			if (outputPattern == OutputPattern.ObjectPredicateSubject) {
				return new Tuple(next.getObject(), next.getPredicate(), next.getSubject());
			}

			throw new IllegalStateException("Unkown output pattern: " + outputPattern);
		}

		@Override
		public void remove() throws SailException {

		}
	};
}
 
Example 7
Source File: Schema.java    From rya with Apache License 2.0 5 votes vote down vote up
/**
 * Does this triple/statement encode potentially relevant schema
 * information?
 */
public static boolean isSchemaTriple(Statement triple) {
    IRI pred = triple.getPredicate();
    // Triples with certain predicates are schema triples,
    if (schemaPredicates.contains(pred)) {
        return true;
    }
    // And certain type assertions are schema triples.
    else if (pred.equals(RDF.TYPE)) {
        if (schemaTypes.contains(triple.getObject())) {
            return true;
        }
    }
    return false;
}
 
Example 8
Source File: RdfToRyaConversions.java    From rya with Apache License 2.0 5 votes vote down vote up
/**
 * Converts a {@link Statement} into a {@link RyaStatement} representation
 * of the {@code statement}.
 * @param statement the {@link Statement} to convert.
 * @return the {@link RyaStatement} representation of the {@code statement}.
 */
public static RyaStatement convertStatement(final Statement statement) {
    if (statement == null) {
        return null;
    }
    final Resource subject = statement.getSubject();
    final IRI predicate = statement.getPredicate();
    final Value object = statement.getObject();
    final Resource context = statement.getContext();
    return new RyaStatement(
            convertResource(subject),
            convertIRI(predicate),
            convertValue(object),
            convertResource(context));
}
 
Example 9
Source File: DirectTypeHierarchyInferencer.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void checkUpdatedStatement(Statement st) {
	IRI pred = st.getPredicate();

	if (pred.equals(RDF.TYPE) || pred.equals(RDFS.SUBCLASSOF) || pred.equals(RDFS.SUBPROPERTYOF)) {
		updateNeeded = true;
	}
}
 
Example 10
Source File: Models.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static boolean statementsMatch(Statement st1, Statement st2, Map<Resource, Resource> bNodeMapping) {
	IRI pred1 = st1.getPredicate();
	IRI pred2 = st2.getPredicate();

	if (!pred1.equals(pred2)) {
		// predicates don't match
		return false;
	}

	Resource subj1 = st1.getSubject();
	Resource subj2 = st2.getSubject();

	if (bnodeValueMatching(bNodeMapping, subj1, subj2)) {
		return false;
	}

	Value obj1 = st1.getObject();
	Value obj2 = st2.getObject();

	if (bnodeValueMatching(bNodeMapping, obj1, obj2)) {
		return false;
	}

	Resource context1 = st1.getContext();
	Resource context2 = st2.getContext();

	// no match if in different contexts
	if (context1 == null) {
		return context2 == null;
	} else if (context2 == null) {
		return false;
	}

	if (bnodeValueMatching(bNodeMapping, context1, context2)) {
		return false;
	}

	return true;
}
 
Example 11
Source File: LinkedHashModel.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Iterator<ModelStatement> find(Statement st) {
	Resource subj = st.getSubject();
	IRI pred = st.getPredicate();
	Value obj = st.getObject();
	Resource ctx = st.getContext();
	return matchPattern(subj, pred, obj, ctx);
}
 
Example 12
Source File: MemoryOverflowModel.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void writeObject(ObjectOutputStream s) throws IOException {
	// Write out any hidden serialization magic
	s.defaultWriteObject();
	// Write in size
	Model delegate = getDelegate();
	s.writeInt(delegate.size());
	// Write in all elements
	for (Statement st : delegate) {
		Resource subj = st.getSubject();
		IRI pred = st.getPredicate();
		Value obj = st.getObject();
		Resource ctx = st.getContext();
		s.writeObject(new ContextStatementImpl(subj, pred, obj, ctx));
	}
}
 
Example 13
Source File: AbstractRDFInserter.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void handleStatement(Statement st) throws RDFHandlerException {
	Resource subj = st.getSubject();
	IRI pred = st.getPredicate();
	Value obj = st.getObject();
	Resource ctxt = st.getContext();

	if (!preserveBNodeIDs) {
		if (subj instanceof BNode) {
			subj = mapBNode((BNode) subj);
		}

		if (obj instanceof BNode) {
			obj = mapBNode((BNode) obj);
		}

		if (!enforcesContext() && ctxt instanceof BNode) {
			ctxt = mapBNode((BNode) ctxt);
		}
	}

	try {
		addStatement(subj, pred, obj, ctxt);
	} catch (RDF4JException e) {
		throw new RDFHandlerException(e);
	}
}
 
Example 14
Source File: BufferedGroupingRDFHandler.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void processBuffer() throws RDFHandlerException {
	// primary grouping per context.
	for (Resource context : contexts) {
		Model contextData = bufferedStatements.filter(null, null, null, context);
		Set<Resource> subjects = contextData.subjects();
		for (Resource subject : subjects) {
			Set<IRI> processedPredicates = new HashSet<>();

			// give rdf:type preference over other predicates.
			for (Statement typeStatement : contextData.getStatements(subject, RDF.TYPE, null)) {
				super.handleStatement(typeStatement);
			}

			processedPredicates.add(RDF.TYPE);

			// retrieve other statement from this context with the same
			// subject, and output them grouped by predicate
			for (Statement subjectStatement : contextData.getStatements(subject, null, null)) {
				IRI predicate = subjectStatement.getPredicate();
				if (!processedPredicates.contains(predicate)) {
					for (Statement toWrite : contextData.getStatements(subject, predicate, null)) {
						super.handleStatement(toWrite);
					}
					processedPredicates.add(predicate);
				}

			}
		}
	}
	bufferedStatements.clear();
	contexts.clear();
}
 
Example 15
Source File: RDFXMLPrettyWriter.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void consumeStatement(Statement st) throws RDFHandlerException {
	Resource subj = st.getSubject();
	IRI pred = st.getPredicate();
	Value obj = st.getObject();

	try {
		if (!headerWritten) {
			writeHeader();
		}

		if (!nodeStack.isEmpty() && !subj.equals(nodeStack.peek().getValue())) {
			// Different subject than we had before, empty the stack
			// until we find it
			popStacks(subj);
		}

		// Stack is either empty or contains the same subject at top

		if (nodeStack.isEmpty()) {
			// Push subject
			nodeStack.push(new Node(subj));
		}

		// Stack now contains at least one element
		Node topSubject = nodeStack.peek();

		// Check if current statement is a type statement and use a typed node
		// element is possible
		// FIXME: verify that an XML namespace-qualified name can be created
		// for the type URI
		if (pred.equals(RDF.TYPE) && obj instanceof IRI && !topSubject.hasType() && !topSubject.isWritten()) {
			// Use typed node element
			topSubject.setType((IRI) obj);
		} else {
			if (!nodeStack.isEmpty() && pred.equals(nodeStack.peek().nextLi())) {
				pred = RDF.LI;
				nodeStack.peek().incrementNextLi();
			}

			// Push predicate and object
			predicateStack.push(pred);
			nodeStack.push(new Node(obj));
		}
	} catch (IOException e) {
		throw new RDFHandlerException(e);
	}
}
 
Example 16
Source File: Schema.java    From rya with Apache License 2.0 4 votes vote down vote up
/**
 * Incorporate a new triple into the schema.
 */
public void processTriple(Statement triple) {
    Resource s = triple.getSubject();
    IRI p = triple.getPredicate();
    Value o = triple.getObject();
    if (isSchemaTriple(triple)) {
        // For a type statement to be schema information, it must yield
        // some boolean information about a property.
        if (p.equals(RDF.TYPE)) {
            if (schemaTypes.contains(o)) {
                addPropertyType((IRI) s, (Resource) o);
            }
        }

        // Domain/range
        else if (p.equals(RDFS.DOMAIN)) {
            // Don't add trivial domain owl:Thing
            if (!o.equals(OWL.THING)) {
                getProperty(s).addDomain(getClass(o));
            }
        }
        else if (p.equals(RDFS.RANGE)) {
            // Don't add trivial range owl:Thing
            if (!o.equals(OWL.THING)) {
                getProperty(s).addRange(getClass(o));
            }
        }

        // Sub/super relations
        else if (p.equals(RDFS.SUBCLASSOF)) {
            // Everything is a subclass of owl#Thing, we don't need to
            // store that information
            if (!o.equals(OWL.THING)) {
                getClass(s).addSuperClass(getClass(o));
            }
        }
        else if (p.equals(RDFS.SUBPROPERTYOF)) {
            getProperty(s).addSuperProperty(getProperty(o));
        }

        // Equivalence relations
        else if (p.equals(OWL.EQUIVALENTCLASS)) {
            getClass(s).addEquivalentClass(getClass(o));
        }
        else if (p.equals(OWL.EQUIVALENTPROPERTY)) {
            getProperty(s).addEquivalentProperty(getProperty(o));
        }

        // Inverse properties
        else if (p.equals(OWL.INVERSEOF)) {
            getProperty(s).addInverse(getProperty(o));
            getProperty(o).addInverse(getProperty(s));
        }

        // Complementary classes
        else if (p.equals(OWL.COMPLEMENTOF)) {
            getClass(s).addComplement(getClass(o));
            getClass(o).addComplement(getClass(s));
        }

        // Disjoint classes and properties
        else if (p.equals(OWL.DISJOINTWITH)) {
            getClass(s).addDisjoint(getClass(o));
            getClass(o).addDisjoint(getClass(s));
        }
        else if (p.equals(OWL2.PROPERTYDISJOINTWITH)) {
            getProperty(s).addDisjoint(getProperty(o));
            getProperty(o).addDisjoint(getProperty(s));
        }

        // Property restriction info
        else if (p.equals(OWL.ONPROPERTY)) {
            getClass(s).addProperty(getProperty(o));
        }
        else if (p.equals(OWL.SOMEVALUESFROM)) {
            getClass(s).addSvf(getClass(o));
        }
        else if (p.equals(OWL.ALLVALUESFROM)) {
            getClass(s).addAvf(getClass(o));
        }
        else if (p.equals(OWL2.ONCLASS)) {
            getClass(s).addClass(getClass(o));
        }
        else if (p.equals(OWL.HASVALUE)) {
            getClass(s).addValue(o);
        }
        else if (p.equals(OWL.MAXCARDINALITY)) {
            getClass(s).setMaxCardinality(o);
        }
        else if (p.equals(OWL2.MAXQUALIFIEDCARDINALITY)) {
            getClass(s).setMaxQualifiedCardinality(o);
        }
    }
}
 
Example 17
Source File: SchemaCachingRDFSInferencerConnection.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
void processForSchemaCache(Statement statement) {
	sail.acquireExclusiveWriteLock();

	final IRI predicate = statement.getPredicate();
	final Value object = statement.getObject();
	final Resource subject = statement.getSubject();

	if (predicate.equals(RDFS.SUBCLASSOF)) {
		sail.addSubClassOfStatement(statement);
		schemaChange = true;
	} else if (predicate.equals(RDF.TYPE) && object.equals(RDF.PROPERTY)) {
		sail.addProperty(subject);
		schemaChange = true;
	} else if (predicate.equals(RDFS.SUBPROPERTYOF)) {
		sail.addSubPropertyOfStatement(statement);
		schemaChange = true;
	} else if (predicate.equals(RDFS.RANGE)) {
		sail.addRangeStatement(statement);
		schemaChange = true;
	} else if (predicate.equals(RDFS.DOMAIN)) {
		sail.addDomainStatement(statement);
		schemaChange = true;
	} else if (predicate.equals(RDF.TYPE) && object.equals(RDFS.CLASS)) {
		sail.addSubClassOfStatement(
				sail.getValueFactory().createStatement(subject, RDFS.SUBCLASSOF, RDFS.RESOURCE));
		schemaChange = true;
	} else if (predicate.equals(RDF.TYPE) && object.equals(RDFS.DATATYPE)) {
		sail.addSubClassOfStatement(
				sail.getValueFactory().createStatement(subject, RDFS.SUBCLASSOF, RDFS.LITERAL));
		schemaChange = true;
	} else if (predicate.equals(RDF.TYPE) && object.equals(RDFS.CONTAINERMEMBERSHIPPROPERTY)) {
		sail.addSubPropertyOfStatement(
				sail.getValueFactory().createStatement(subject, RDFS.SUBPROPERTYOF, RDFS.MEMBER));
		schemaChange = true;
	} else if (predicate.equals(RDF.TYPE)) {
		if (!sail.hasType(((Resource) object))) {
			sail.addType((Resource) object);
			schemaChange = true;
		}
	}

	if (!sail.hasProperty(predicate)) {
		sail.addProperty(predicate);
		schemaChange = true;
	}

}
 
Example 18
Source File: SchemaCachingRDFSInferencerConnection.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private boolean isSchemaStatement(Statement st) {
	final IRI predicate = st.getPredicate();
	return schemaPredicates.contains(predicate);
}
 
Example 19
Source File: Schema.java    From rya with Apache License 2.0 4 votes vote down vote up
/**
 * Determine whether a fact is contained in the Schema object
 * relationships or implied by schema rules.
 * @return  True if this schema contains the semantics of the triple
 */
public boolean containsTriple(Statement triple) {
    // The schema certainly doesn't contain it if it's not a
    // schema-relevant triple at all.
    if (isSchemaTriple(triple)) {
        Resource s = triple.getSubject();
        IRI p = triple.getPredicate();
        Value o = triple.getObject();
        // If this is telling us something about a property:
        if (properties.containsKey(s)) {
            OwlProperty prop = properties.get(s);
            // Property types:
            if (p.equals(RDF.TYPE)) {
                if ((o.equals(OWL.TRANSITIVEPROPERTY)
                        && prop.isTransitive())
                    || (o.equals(OWL2.IRREFLEXIVEPROPERTY)
                        && prop.isIrreflexive())
                    || (o.equals(OWL.SYMMETRICPROPERTY)
                        && prop.isSymmetric())
                    || (o.equals(OWL2.ASYMMETRICPROPERTY)
                        && prop.isAsymmetric())
                    || (o.equals(OWL.FUNCTIONALPROPERTY)
                        && prop.isFunctional())
                    || (o.equals(OWL.INVERSEFUNCTIONALPROPERTY)
                        && prop.isInverseFunctional())) {
                    return true;
                }
            }
            // Relationships with other properties:
            if ((p.equals(RDFS.SUBPROPERTYOF)
                    && prop.getSuperProperties().contains(o))
                || (p.equals(OWL2.PROPERTYDISJOINTWITH)
                    && prop.getDisjointProperties().contains(o))
                || (p.equals(OWL.EQUIVALENTPROPERTY)
                    && prop.getEquivalentProperties().contains(o))
                || (p.equals(OWL.INVERSEOF)
                    && prop.getInverseProperties().contains(o))) {
                return true;
            }
            // Relationships with classes:
            if ((p.equals(RDFS.DOMAIN)
                    && prop.getDomain().contains(o))
                || (p.equals(RDFS.RANGE)
                    && prop.getRange().contains(o))) {
                return true;
            }
        }
        // If this is about a class relationship:
        if (classes.containsKey(s)) {
            OwlClass subject = classes.get(s);
            if ((p.equals(OWL.EQUIVALENTCLASS)
                    && (subject.getEquivalentClasses().contains(o)))
                || (p.equals(OWL.DISJOINTWITH)
                    && (subject.getDisjointClasses().contains(o)))
                || (p.equals(OWL.COMPLEMENTOF)
                    && (subject.getComplementaryClasses().contains(o)))
                || (p.equals(RDFS.SUBCLASSOF)
                    && (subject.getSuperClasses().contains(o)))) {
                return true;
            }
        }
    }
    return false;
}
 
Example 20
Source File: HalyardStats.java    From Halyard with Apache License 2.0 4 votes vote down vote up
@Override
protected void map(ImmutableBytesWritable key, Result value, Context output) throws IOException, InterruptedException {
    byte region = key.get()[key.getOffset()];
    List<Statement> stmts = null;
    int hashShift;
    if (region < HalyardTableUtils.CSPO_PREFIX) {
        hashShift = 1;
    } else {
        hashShift = HalyardTableUtils.KEY_SIZE + 1;
        if (!matchAndCopyKey(key.get(), key.getOffset() + 1, lastCtxFragment) || region != lastRegion) {
            cleanup(output);
            stmts = HalyardTableUtils.parseStatements(value, ssf);
            graph = (IRI) stmts.get(0).getContext();
        }
        if (update && region == HalyardTableUtils.CSPO_PREFIX) {
            if (Arrays.equals(statsContextHash, lastCtxFragment)) {
                if (sail == null) {
                    Configuration conf = output.getConfiguration();
                    sail = new HBaseSail(conf, conf.get(SOURCE), false, 0, true, 0, null, null);
                    sail.initialize();
                }
                if (stmts == null) {
                    stmts = HalyardTableUtils.parseStatements(value, ssf);
                }
                for (Statement st : stmts) {
                    if (statsContext.equals(st.getContext()) && matchingGraphContext(st.getSubject())) {
                        sail.removeStatement(null, st.getSubject(), st.getPredicate(), st.getObject(), st.getContext());
                        removed++;
                    }
                }
                lastRegion = region;
                return; //do no count removed statements
            }
        }
    }
    boolean hashChange = !matchAndCopyKey(key.get(), key.getOffset() + hashShift, lastKeyFragment) || region != lastRegion || lastGraph != graph;
    if (hashChange) {
        cleanupSubset(output);
        if (stmts == null) {
            stmts = HalyardTableUtils.parseStatements(value, ssf);
        }
        Statement stmt = stmts.get(0);
        switch (region) {
            case HalyardTableUtils.SPO_PREFIX:
            case HalyardTableUtils.CSPO_PREFIX:
                distinctSubjects++;
                Resource subj = stmt.getSubject();
                if (subj instanceof IRI) {
                    distinctIRIReferenceSubjects++;
                } else {
                    distinctBlankNodeSubjects++;
                }
                subsetType = VOID_EXT.SUBJECT;
                subsetId = subj;
                break;
            case HalyardTableUtils.POS_PREFIX:
            case HalyardTableUtils.CPOS_PREFIX:
                properties++;
                subsetType = VOID.PROPERTY;
                subsetId = stmt.getPredicate();
                break;
            case HalyardTableUtils.OSP_PREFIX:
            case HalyardTableUtils.COSP_PREFIX:
                distinctObjects++;
                Value obj = stmt.getObject();
                if (obj instanceof IRI) {
                    distinctIRIReferenceObjects++;
                } else if (obj instanceof BNode) {
                    distinctBlankNodeObjects++;
                } else {
                    distinctLiterals++;
                }
                subsetType = VOID_EXT.OBJECT;
                subsetId = obj;
                break;
            default:
                throw new IOException("Unknown region #" + region);
        }
    }
    switch (region) {
        case HalyardTableUtils.SPO_PREFIX:
        case HalyardTableUtils.CSPO_PREFIX:
            triples += value.rawCells().length;
            break;
        case HalyardTableUtils.POS_PREFIX:
        case HalyardTableUtils.CPOS_PREFIX:
            if (Arrays.equals(TYPE_HASH, lastKeyFragment) && (!matchAndCopyKey(key.get(), key.getOffset() + hashShift + HalyardTableUtils.KEY_SIZE, lastClassFragment) || hashChange)) {
                classes++;
            }
            break;
        default:
    }
    subsetCounter += value.rawCells().length;
    setCounter += value.rawCells().length;
    lastRegion = region;
    lastGraph = graph;
    if ((counter++ % 100000) == 0) {
        output.setStatus(MessageFormat.format("reg:{0} {1} t:{2} s:{3} p:{4} o:{5} c:{6} r:{7}", region, counter, triples, distinctSubjects, properties, distinctObjects, classes, removed));
    }
}