• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java FunctionCall类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.openrdf.query.algebra.FunctionCall的典型用法代码示例。如果您正苦于以下问题:Java FunctionCall类的具体用法?Java FunctionCall怎么用?Java FunctionCall使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FunctionCall类属于org.openrdf.query.algebra包,在下文中一共展示了FunctionCall类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: meet

import org.openrdf.query.algebra.FunctionCall; //导入依赖的package包/类
@Override
public void meet(final Filter node) throws Exception {
    super.meet(node);

    final ValueExpr arg = node.getCondition();
    if (arg instanceof FunctionCall) {
        final FunctionCall fc = (FunctionCall) arg;
        if (RANGE.stringValue().equals(fc.getURI())) {
            //range(?var, start, end)
            final List<ValueExpr> valueExprs = fc.getArgs();
            if (valueExprs.size() != 3) {
                throw new QueryEvaluationException("org.apache:range must have 3 parameters: variable, start, end");
            }
            final Var var = (Var) valueExprs.get(0);
            final ValueConstant startVc = (ValueConstant) valueExprs.get(1);
            final ValueConstant endVc = (ValueConstant) valueExprs.get(2);
            final Value start = startVc.getValue();
            final Value end = endVc.getValue();
            rangeValues.put(var, new RangeValue(start, end));
            node.setCondition(new ValueConstant(BooleanLiteralImpl.TRUE));
        }
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:24,代码来源:FilterRangeVisitor.java


示例2: meet

import org.openrdf.query.algebra.FunctionCall; //导入依赖的package包/类
public void meet(Filter node) {
    if (node.getCondition() instanceof FunctionCall) {
        try {
            Optional<PeriodicQueryNode> optNode = getPeriodicQueryNode((FunctionCall) node.getCondition(), node.getArg());
            if (optNode.isPresent()) {
                if (count > 0) {
                    throw new IllegalArgumentException("Query cannot contain more than one PeriodicQueryNode");
                }
                periodicNode = optNode.get();
                node.replaceWith(periodicNode);
                count++;
                periodicNode.visit(this);
            } else {
                super.meet(node);
            }
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage());
        }
    } else {
        super.meet(node);
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:23,代码来源:PeriodicQueryUtil.java


示例3: meet

import org.openrdf.query.algebra.FunctionCall; //导入依赖的package包/类
@Override
public void meet(final Filter node) throws QueryRulesetException {
    final ValueExpr condition = node.getCondition();
    // If the condition is a function call, and we don't know about the function, don't try to test for it.
    if (condition instanceof FunctionCall) {
        final String uri = ((FunctionCall) condition).getURI();
        if (FunctionRegistry.getInstance().get(uri) == null) {
            // Just extract statement patterns from the child as if there were no filter.
            node.getArg().visit(this);
        }
    }
    // Otherwise, assume we can test for it: extract rules from below this node, and add the condition to each one.
    else {
        final RulesetVisitor childVisitor = new RulesetVisitor();
        node.getArg().visit(childVisitor);
        for (final CopyRule rule : childVisitor.rules) {
            rule.addCondition(condition);
            rules.add(rule);
        }
        superclasses.addAll(childVisitor.superclasses);
        superproperties.addAll(childVisitor.superproperties);
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:24,代码来源:QueryRuleset.java


示例4: extractArguments

import org.openrdf.query.algebra.FunctionCall; //导入依赖的package包/类
private Value[] extractArguments(final String matchName, final FunctionCall call) {
    final Value args[] = new Value[call.getArgs().size() - 1];
    int argI = 0;
    for (int i = 0; i != call.getArgs().size(); ++i) {
        final ValueExpr arg = call.getArgs().get(i);
        if (argI == i && arg instanceof Var && matchName.equals(((Var)arg).getName())) {
            continue;
        }
        if (arg instanceof ValueConstant) {
            args[argI] = ((ValueConstant)arg).getValue();
        } else if (arg instanceof Var && ((Var)arg).hasValue()) {
            args[argI] = ((Var)arg).getValue();
        } else {
            throw new IllegalArgumentException("Query error: Found " + arg + ", expected a Literal, BNode or URI");
        }
        ++argI;
    }
    return args;
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:20,代码来源:FilterFunctionOptimizer.java


示例5: extractArguments

import org.openrdf.query.algebra.FunctionCall; //导入依赖的package包/类
/**
 * Extracts the arguments used in a {@link FunctionCall}.
 * @param matchName - The variable name to match to arguments used in the {@link FunctionCall}.
 * @param call - The {@link FunctionCall} to match against.
 * @return - The {@link Value}s matched.
 */
public static Object[] extractArguments(final String matchName, final FunctionCall call) {
    final Object[] args = new Object[call.getArgs().size() - 1];
    int argI = 0;
    for (int i = 0; i != call.getArgs().size(); ++i) {
        final ValueExpr arg = call.getArgs().get(i);
        if (argI == i && arg instanceof Var && matchName.equals(((Var)arg).getName())) {
            continue;
        }
        if (arg instanceof ValueConstant) {
            args[argI] = ((ValueConstant)arg).getValue();
        } else if (arg instanceof Var && ((Var)arg).hasValue()) {
            args[argI] = ((Var)arg).getValue();
        } else {
            args[argI] = arg;
        }
        ++argI;
    }
    return args;
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:26,代码来源:GeoParseUtils.java


示例6: EventQueryNode

import org.openrdf.query.algebra.FunctionCall; //导入依赖的package包/类
/**
 * Constructs an instance of {@link EventQueryNode}.
 * @param usedFilters
 *
 * @param type - The type of {@link Event} this node matches. (not null)
 * @param patterns - The query StatementPatterns that are solved using an
 *   Event of the Type. (not null)
 * @param entities - The {@link EventStorage} that will be searched to match
 *   {@link BindingSet}s when evaluating a query. (not null)
 */
private EventQueryNode(final EventStorage eventStore, final StatementPattern geoPattern, final StatementPattern temporalPattern, final Collection<IndexingExpr> geoFilters, final Collection<IndexingExpr> temporalFilters, final Collection<FunctionCall> usedFilters) throws IllegalStateException {
    this.geoPattern = requireNonNull(geoPattern);
    this.temporalPattern = requireNonNull(temporalPattern);
    this.geoFilters = requireNonNull(geoFilters);
    this.temporalFilters = requireNonNull(temporalFilters);
    this.eventStore = requireNonNull(eventStore);
    this.usedFilters = requireNonNull(usedFilters);
    bindingNames = new HashSet<>();

    // Subject based preconditions.
    verifySameSubjects(getPatterns());
    // Predicate based preconditions.
    verifyAllPredicatesAreConstants(getPatterns());

    // The Subject may either be constant or a variable.
    final Var subject = patterns.iterator().next().getSubjectVar();
    subjectIsConstant = subject.isConstant();
    if(subjectIsConstant) {
        subjectConstant = Optional.of( subject.getValue().toString() );
        subjectVar = Optional.empty();
    } else {
        subjectConstant = Optional.empty();
        subjectVar = Optional.of( subject.getName() );
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:36,代码来源:EventQueryNode.java


示例7: getPeriodicQueryNode

import org.openrdf.query.algebra.FunctionCall; //导入依赖的package包/类
/**
 * Returns a PeriodicQueryNode for all {@link FunctionCall}s that represent PeriodicQueryNodes, otherwise
 * an empty Optional is returned.
 * @param functionCall - FunctionCall taken from a {@lin TupleExpr}
 * @param arg - TupleExpr that will be the argument of the PeriodicQueryNode if it is created
 * @return - Optional containing a PeriodicQueryNode if FunctionCall represents PeriodicQueryNode and empty Optional otherwise
 * @throws Exception
 */
public static Optional<PeriodicQueryNode> getPeriodicQueryNode(FunctionCall functionCall, TupleExpr arg) throws Exception {

    if (functionCall.getURI().equals(PeriodicQueryURI)) {
        return Optional.of(parseAndSetValues(functionCall.getArgs(), arg));
    }

    return Optional.empty();
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:17,代码来源:PeriodicQueryUtil.java


示例8: periodicNodeNotPresentTest

import org.openrdf.query.algebra.FunctionCall; //导入依赖的package包/类
@Test
public void periodicNodeNotPresentTest() throws Exception {
    
    List<ValueExpr> values = Arrays.asList(new Var("time"), new ValueConstant(vf.createLiteral(12.0)), new ValueConstant(vf.createLiteral(6.0)), new ValueConstant(vf.createURI(PeriodicQueryUtil.temporalNameSpace + "hours")));
    FunctionCall func = new FunctionCall("uri:func", values);
    Optional<PeriodicQueryNode> node1 = PeriodicQueryUtil.getPeriodicQueryNode(func, new Join());
    Assert.assertEquals(false, node1.isPresent());
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:9,代码来源:PeriodicQueryUtilTest.java


示例9: periodicNodePresentTest

import org.openrdf.query.algebra.FunctionCall; //导入依赖的package包/类
@Test
public void periodicNodePresentTest() throws Exception {
    
    List<ValueExpr> values = Arrays.asList(new Var("time"), new ValueConstant(vf.createLiteral(12.0)), new ValueConstant(vf.createLiteral(6.0)), new ValueConstant(vf.createURI(PeriodicQueryUtil.temporalNameSpace + "hours")));
    FunctionCall func = new FunctionCall(PeriodicQueryUtil.PeriodicQueryURI, values);
    Optional<PeriodicQueryNode> node1 = PeriodicQueryUtil.getPeriodicQueryNode(func, new Join());
    Assert.assertEquals(true, node1.isPresent());
    
    PeriodicQueryNode node2 = new PeriodicQueryNode(12*60*60*1000L, 6*3600*1000L, TimeUnit.MILLISECONDS, "time", new Join());
    
    Assert.assertEquals(true, periodicNodesEqualIgnoreArg(node1.get(), node2));
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:13,代码来源:PeriodicQueryUtilTest.java


示例10: periodicNodeFractionalDurationTest

import org.openrdf.query.algebra.FunctionCall; //导入依赖的package包/类
@Test
public void periodicNodeFractionalDurationTest() throws Exception {
    
    List<ValueExpr> values = Arrays.asList(new Var("time"), new ValueConstant(vf.createLiteral(1)), new ValueConstant(vf.createLiteral(.5)), new ValueConstant(vf.createURI(PeriodicQueryUtil.temporalNameSpace + "hours")));
    FunctionCall func = new FunctionCall(PeriodicQueryUtil.PeriodicQueryURI, values);
    Optional<PeriodicQueryNode> node1 = PeriodicQueryUtil.getPeriodicQueryNode(func, new Join());
    Assert.assertEquals(true, node1.isPresent());
    
    double window = 1*60*60*1000;
    double period = .5*3600*1000;
    
    PeriodicQueryNode node2 = new PeriodicQueryNode((long) window, (long) period, TimeUnit.MILLISECONDS, "time", new Join());
    
    Assert.assertEquals(true, periodicNodesEqualIgnoreArg(node1.get(), node2));
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:16,代码来源:PeriodicQueryUtilTest.java


示例11: meet

import org.openrdf.query.algebra.FunctionCall; //导入依赖的package包/类
@Override
public void meet(final FunctionCall fn) {
    final URI fun = new URIImpl(fn.getURI());
    final Var result = IndexingFunctionRegistry.getResultVarFromFunctionCall(fun, fn.getArgs());
    if (result != null && !searchProperties.contains(result)) {
        searchProperties.add(result);
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:9,代码来源:FilterFunctionOptimizer.java


示例12: equalsInstantAfterInterval_onlyOneGeo

import org.openrdf.query.algebra.FunctionCall; //导入依赖的package包/类
@Test
public void equalsInstantAfterInterval_onlyOneGeo() throws Exception {
    final String query =
      "PREFIX geo: <http://www.opengis.net/ont/geosparql#>"
    + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>"
    + "SELECT ?point ?wkt "
    + "WHERE { "
      + "  ?point geo:asWKT ?wkt . "
      + "  FILTER(geof:sfWithin(?wkt, \"POLYGON((-3 -2, -3 2, 1 2, 1 -2, -3 -2))\"^^geo:wktLiteral)) "
    + "}";
    final List<IndexingExpr> geoFilters = new ArrayList<>();
    final List<StatementPattern> sps = getSps(query);
    final List<FunctionCall> filters = getFilters(query);
    for(final FunctionCall filter : filters) {
        //should only be one.
        final Var objVar = IndexingFunctionRegistry.getResultVarFromFunctionCall(new URIImpl(filter.getURI()), filter.getArgs());
        final IndexingExpr expr = new IndexingExpr(new URIImpl(filter.getURI()), sps.get(0), extractArguments(objVar.getName(), filter));
        geoFilters.add(expr);
    }
    final List<IndexingExpr> temporalFilters = new ArrayList<>();
    final DBObject actual = adapter.getFilterQuery(geoFilters, temporalFilters);
    final String expectedString =
        "{ "
        + "\"location\" : { "
          + "\"$geoWithin\" : { "
            + "\"$geometry\" : { "
              + "\"coordinates\" : [ [ [ -3.0 , -2.0] , [ -3.0 , 2.0] , [ 1.0 , 2.0] , [ 1.0 , -2.0] , [ -3.0 , -2.0]]] , "
              + "\"type\" : \"Polygon\""
            + "}"
          + "}"
        + "}"
      + "}";
    final DBObject expected = (DBObject) JSON.parse(expectedString);
    assertEqualMongo(expected, actual);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:36,代码来源:GeoTemporalMongoDBStorageStrategyTest.java


示例13: equalsInstantAfterInterval_onlyOneTemporal

import org.openrdf.query.algebra.FunctionCall; //导入依赖的package包/类
@Test
public void equalsInstantAfterInterval_onlyOneTemporal() throws Exception {
    final String query =
      "PREFIX time: <http://www.w3.org/2006/time#> \n"
    + "PREFIX tempo: <tag:rya-rdf.org,2015:temporal#> \n"
    + "SELECT ?event ?time "
    + "WHERE { "
      + "  ?event time:atTime ?time . "
      + "  FILTER(tempo:equals(?time, \"2015-12-30T12:00:00Z\")) . "
    + "}";
    final List<IndexingExpr> geoFilters = new ArrayList<>();
    final List<IndexingExpr> temporalFilters = new ArrayList<>();
    final List<StatementPattern> sps = getSps(query);
    final List<FunctionCall> filters = getFilters(query);
    for(final FunctionCall filter : filters) {
        //should only be one.
        final Var objVar = IndexingFunctionRegistry.getResultVarFromFunctionCall(new URIImpl(filter.getURI()), filter.getArgs());
        final IndexingExpr expr = new IndexingExpr(new URIImpl(filter.getURI()), sps.get(0), extractArguments(objVar.getName(), filter));
        temporalFilters.add(expr);
    }
    final DBObject actual = adapter.getFilterQuery(geoFilters, temporalFilters);
    final String expectedString =
    "{ "
    + "\"instant\" : {"
      + "\"$date\" : \"2015-12-30T12:00:00.000Z\""
    + "}"
  + "}";
    final DBObject expected = (DBObject) JSON.parse(expectedString);
    assertEqualMongo(expected, actual);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:31,代码来源:GeoTemporalMongoDBStorageStrategyTest.java


示例14: buildNode

import org.openrdf.query.algebra.FunctionCall; //导入依赖的package包/类
private EventQueryNode buildNode(final EventStorage store, final String query) throws Exception {
    final List<IndexingExpr> geoFilters = new ArrayList<>();
    final List<IndexingExpr> temporalFilters = new ArrayList<>();
    final List<StatementPattern> sps = getSps(query);
    final List<FunctionCall> filters = getFilters(query);
    for(final FunctionCall filter : filters) {
        final URI filterURI = new URIImpl(filter.getURI());
        final Var objVar = IndexingFunctionRegistry.getResultVarFromFunctionCall(filterURI, filter.getArgs());
        final IndexingExpr expr = new IndexingExpr(filterURI, sps.get(0), extractArguments(objVar.getName(), filter));
        if(IndexingFunctionRegistry.getFunctionType(filterURI) == FUNCTION_TYPE.GEO) {
            geoFilters.add(expr);
        } else {
            temporalFilters.add(expr);
        }
    }

    final StatementPattern geoPattern = sps.get(1);
    final StatementPattern temporalPattern = sps.get(0);

    return new EventQueryNode.EventQueryNodeBuilder()
        .setStorage(store)
        .setGeoPattern(geoPattern)
        .setTemporalPattern(temporalPattern)
        .setGeoFilters(geoFilters)
        .setTemporalFilters(temporalFilters)
        .setUsedFilters(filters)
        .build();
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:29,代码来源:EventQueryNode2IT.java


示例15: buildMaps

import org.openrdf.query.algebra.FunctionCall; //导入依赖的package包/类
private void buildMaps(final QuerySegment<EventQueryNode> node) {
    final List<QueryModelNode> unused = new ArrayList<>();
    for (final QueryModelNode pattern : node.getOrderedNodes()) {
        if(pattern instanceof FunctionCall) {
            discoverFilter((FunctionCall) pattern, unused);
        }
        if(pattern instanceof StatementPattern) {
            discoverPatterns((StatementPattern) pattern, unused);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:12,代码来源:GeoTemporalIndexSetProvider.java


示例16: discoverFilter

import org.openrdf.query.algebra.FunctionCall; //导入依赖的package包/类
private void discoverFilter(final FunctionCall filter, final List<QueryModelNode> unmatched) {
    try {
        filter.visit(new FilterVisitor());
    } catch (final Exception e) {
        LOG.error("Failed to match the filter object.", e);
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:8,代码来源:GeoTemporalIndexSetProvider.java


示例17: discoverPatterns

import org.openrdf.query.algebra.FunctionCall; //导入依赖的package包/类
private void discoverPatterns(final StatementPattern pattern, final List<QueryModelNode> unmatched) {
    final Var subj = pattern.getSubjectVar();
    final Var objVar = pattern.getObjectVar();

    patternMap.put(subj, pattern);
    objectPatterns.put(objVar, pattern);
    //check for existing filters.
    if(unmatchedFilters.containsKey(objVar)) {
        final Collection<FunctionCall> calls = unmatchedFilters.removeAll(objVar);
        for(final FunctionCall call : calls) {
            addFilter(call);
            matchedFilters.put(objVar, call);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:16,代码来源:GeoTemporalIndexSetProvider.java


示例18: meet

import org.openrdf.query.algebra.FunctionCall; //导入依赖的package包/类
@Override
public void meet(final FunctionCall call) throws Exception {
    filterURI = new URIImpl(call.getURI());
    final FUNCTION_TYPE type = IndexingFunctionRegistry.getFunctionType(filterURI);
    if(type == FUNCTION_TYPE.GEO || type == FUNCTION_TYPE.TEMPORAL) {
        final Var objVar = IndexingFunctionRegistry.getResultVarFromFunctionCall(filterURI, call.getArgs());
        if(objectPatterns.containsKey(objVar)) {
            filterMap.put(objVar, new IndexingExpr(filterURI, objectPatterns.get(objVar), GeoParseUtils.extractArguments(objVar.getName(), call)));
            matchedFilters.put(objVar, call);
        } else {
            unmatchedFilters.put(objVar, call);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:15,代码来源:GeoTemporalIndexSetProvider.java


示例19: meet

import org.openrdf.query.algebra.FunctionCall; //导入依赖的package包/类
@Override
public void meet(final FunctionCall n) {
    final String uri = n.getURI();
    String name = NAMES.get(uri);
    if (name == null && NAMES.values().contains(uri.toUpperCase())) {
        name = n.getURI().toUpperCase();
    }
    emit(name != null ? name : new URIImpl(uri)).emit("(").emit(n.getArgs(), ", ")
            .emit(")");
}
 
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:11,代码来源:SPARQLRenderer.java


示例20: meet

import org.openrdf.query.algebra.FunctionCall; //导入依赖的package包/类
@Override
public void meet(FunctionCall node) throws RuntimeException {
    NativeFunction nf = NativeFunctionRegistry.getInstance().get(node.getURI());
    if(node.getArgs().size() > 0 && nf.getReturnType() == ValueType.STRING) {
        node.getArgs().get(0).visit(this);
    }
    // otherwise stop here, the function call hides the type and language anyways
}
 
开发者ID:apache,项目名称:marmotta,代码行数:9,代码来源:LiteralTypeExpressionFinder.java



注:本文中的org.openrdf.query.algebra.FunctionCall类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DAttributePattern类代码示例发布时间:2022-05-23
下一篇:
Java Sound类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap