本文整理匯總了Java中org.openrdf.query.BindingSet.size方法的典型用法代碼示例。如果您正苦於以下問題:Java BindingSet.size方法的具體用法?Java BindingSet.size怎麽用?Java BindingSet.size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openrdf.query.BindingSet
的用法示例。
在下文中一共展示了BindingSet.size方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handleTuple
import org.openrdf.query.BindingSet; //導入方法依賴的package包/類
@Override
public void handleTuple( BindingSet set, ValueFactory fac ) {
// we can *sometimes* use a binding set instead of getResult().add(...)
// *) if it has only three elements of the type Resource URI Value,
boolean ok = false;
if ( 3 == set.size() ) {
String[] names = new String[3];
getBindingNames().toArray( names );
Resource subject = null;
URI predicate = null;
Value object = set.getValue( names[2] );
if ( set.hasBinding( names[0] )
&& set.getValue( names[0] ) instanceof Resource ) {
subject = Resource.class.cast( set.getValue( names[0] ) );
}
if ( set.hasBinding( names[1] )
&& set.getValue( names[1] ) instanceof URI ) {
predicate = URI.class.cast( set.getValue( names[1] ) );
}
if ( !( null == subject || null == predicate || null == object ) ) {
ok = true;
result.add( subject, predicate, object );
}
}
if ( !ok ) {
Logger.getLogger( getClass() ).error( "use getResults().add() instead" );
}
}
示例2: handleSolution
import org.openrdf.query.BindingSet; //導入方法依賴的package包/類
@Override
public void handleSolution(final BindingSet arg0) throws TupleQueryResultHandlerException {
count++;
if(!bsSizeSet) {
bindingSize = arg0.size();
bsSizeSet = true;
}
System.out.println(arg0);
}
示例3: getConstrainedStarQuery
import org.openrdf.query.BindingSet; //導入方法依賴的package包/類
public static StarQuery getConstrainedStarQuery(final StarQuery query, final BindingSet bs) {
if(bs.size() == 0) {
return query;
}
final Set<String> bindingNames = bs.getBindingNames();
final Set<String> unCommonVarNames = query.getUnCommonVars();
final Set<String> intersectVar = Sets.intersection(bindingNames, unCommonVarNames);
if (!query.commonVarConstant()) {
final Value v = bs.getValue(query.getCommonVarName());
if (v != null) {
query.commonVar.setValue(v);
}
}
for(final String s: intersectVar) {
try {
query.nodeColumnCond[query.varPos.get(s)] = query.setValue(query.nodeColumnCond[query.varPos.get(s)], bs.getValue(s));
} catch (final RyaTypeResolverException e) {
e.printStackTrace();
}
}
return query;
}
示例4: replaceVariables
import org.openrdf.query.BindingSet; //導入方法依賴的package包/類
/**
* Replaces some variables of this queries with the constant values specified, returning the
* resulting <tt>SelectQuery</tt> object.
*
* @param bindings
* the bindings to apply
* @return the resulting <tt>SelectQuery</tt> object (possibly <tt>this</tt> if no change is
* required).
*/
public SelectQuery replaceVariables(final BindingSet bindings) {
if (bindings.size() == 0) {
return this;
}
// TODO: check whether the visitor code (taken from BindingAssigner) is enough, especially
// w.r.t. variables appearing in projection nodes (= SELECT clause).
final TupleExpr newExpression = this.expression.clone();
newExpression.visit(new QueryModelVisitorBase<RuntimeException>() {
@Override
public void meet(final Var var) {
if (!var.hasValue() && bindings.hasBinding(var.getName())) {
final Value value = bindings.getValue(var.getName());
var.setValue(value);
}
}
});
try {
return from(newExpression, this.dataset);
} catch (final ParseException ex) {
throw new Error("Unexpected error - replacing variables made the query invalid (!)",
ex);
}
}
示例5: getCommonVars
import org.openrdf.query.BindingSet; //導入方法依賴的package包/類
public static Set<String> getCommonVars(final StarQuery query, final BindingSet bs) {
final Set<String> starQueryVarNames = Sets.newHashSet();
if(bs == null || bs.size() == 0) {
return Sets.newHashSet();
}
final Set<String> bindingNames = bs.getBindingNames();
starQueryVarNames.addAll(query.getUnCommonVars());
if(!query.commonVarConstant()) {
starQueryVarNames.add(query.getCommonVarName());
}
return Sets.intersection(bindingNames, starQueryVarNames);
}
示例6: evaluate
import org.openrdf.query.BindingSet; //導入方法依賴的package包/類
@Override
public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(final BindingSet bindings) throws QueryEvaluationException {
final List<BindingSet> list = new ArrayList<>();
try {
final Collection<Event> searchEvents;
final String subj;
//if the provided binding set has the subject already, set it to the constant subject.
if(!subjectConstant.isPresent() && bindings.hasBinding(subjectVar.get())) {
subjectConstant = Optional.of(bindings.getValue(subjectVar.get()).stringValue());
} else if(bindings.size() != 0) {
list.add(bindings);
}
// If the subject needs to be filled in, check if the subject variable is in the binding set.
if(subjectConstant.isPresent()) {
// if it is, fetch that value and then fetch the entity for the subject.
subj = subjectConstant.get();
searchEvents = eventStore.search(Optional.of(new RyaURI(subj)), Optional.of(geoFilters), Optional.of(temporalFilters));
} else {
searchEvents = eventStore.search(Optional.empty(), Optional.of(geoFilters), Optional.of(temporalFilters));
}
for(final Event event : searchEvents) {
final MapBindingSet resultSet = new MapBindingSet();
if(event.getGeometry().isPresent()) {
final Geometry geo = event.getGeometry().get();
final Value geoValue = ValueFactoryImpl.getInstance().createLiteral(geo.toText());
final Var geoObj = geoPattern.getObjectVar();
resultSet.addBinding(geoObj.getName(), geoValue);
}
final Value temporalValue;
if(event.isInstant() && event.getInstant().isPresent()) {
final Optional<TemporalInstant> opt = event.getInstant();
DateTime dt = opt.get().getAsDateTime();
dt = dt.toDateTime(DateTimeZone.UTC);
final String str = dt.toString(TemporalInstantRfc3339.FORMATTER);
temporalValue = ValueFactoryImpl.getInstance().createLiteral(str);
} else if(event.getInterval().isPresent()) {
temporalValue = ValueFactoryImpl.getInstance().createLiteral(event.getInterval().get().getAsPair());
} else {
temporalValue = null;
}
if(temporalValue != null) {
final Var temporalObj = temporalPattern.getObjectVar();
resultSet.addBinding(temporalObj.getName(), temporalValue);
}
list.add(resultSet);
}
} catch (final ObjectStorageException e) {
throw new QueryEvaluationException("Failed to evaluate the binding set", e);
}
return new CollectionIteration<>(list);
}