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

Java AndP类代码示例

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

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



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

示例1: handleConnectiveP

import org.apache.tinkerpop.gremlin.process.traversal.util.AndP; //导入依赖的package包/类
private static QueryBuilder handleConnectiveP(String key, ConnectiveP predicate){
    List<P> predicates = predicate.getPredicates();
    List<QueryBuilder> queries = predicates.stream().map(p -> {
        if (p instanceof ConnectiveP) return handleConnectiveP(key, (ConnectiveP) p);
        Object pValue = p.getValue();
        BiPredicate pBiPredicate = p.getBiPredicate();
        return predicateToQuery(key, pValue, pBiPredicate);
    }).collect(Collectors.toList());

    BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
    if (predicate instanceof AndP)
        queries.forEach(boolQueryBuilder::must);
    else if (predicate instanceof OrP)
        queries.forEach(boolQueryBuilder::should);
    else throw new IllegalArgumentException("Connective predicate not supported by unipop");

    return boolQueryBuilder;
}
 
开发者ID:unipop-graph,项目名称:unipop,代码行数:19,代码来源:FilterHelper.java


示例2: handleConnectiveP

import org.apache.tinkerpop.gremlin.process.traversal.util.AndP; //导入依赖的package包/类
private Condition handleConnectiveP(String key, ConnectiveP predicate) {
    List<P> predicates = predicate.getPredicates();
    List<Condition> queries = predicates.stream().map(p -> {
        if (p instanceof ConnectiveP) return handleConnectiveP(key, (ConnectiveP) p);
        Object pValue = p.getValue();
        BiPredicate pBiPredicate = p.getBiPredicate();
        return predicateToQuery(key, pValue, pBiPredicate);
    }).collect(Collectors.toList());
    Condition condition = queries.get(0);
    if (predicate instanceof AndP){
        for (int i = 1; i < queries.size(); i++) {
            condition = condition.and(queries.get(i));
        }
    }
    else if (predicate instanceof OrP){
        for (int i = 1; i < queries.size(); i++) {
            condition = condition.or(queries.get(i));
        }
    }
    else throw new IllegalArgumentException("Connective predicate not supported by unipop");
    return condition;
}
 
开发者ID:unipop-graph,项目名称:unipop,代码行数:23,代码来源:JdbcPredicatesTranslator.java


示例3: write

import org.apache.tinkerpop.gremlin.process.traversal.util.AndP; //导入依赖的package包/类
@Override
public <O extends OutputShim> void write(final KryoShim<?, O> kryo, final O output, final P p) {
    output.writeString(p instanceof ConnectiveP ?
            (p instanceof AndP ? "and" : "or") :
            p.getBiPredicate().toString());
    if (p instanceof ConnectiveP || p.getValue() instanceof Collection) {
        output.writeByte((byte) 0);
        final Collection<?> coll = p instanceof ConnectiveP ?
                ((ConnectiveP<?>) p).getPredicates() : (Collection) p.getValue();
        output.writeInt(coll.size());
        coll.forEach(v -> kryo.writeClassAndObject(output, v));
    } else {
        output.writeByte((byte) 1);
        kryo.writeClassAndObject(output, p.getValue());
    }
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:17,代码来源:GryoSerializersV1d0.java


示例4: serialize

import org.apache.tinkerpop.gremlin.process.traversal.util.AndP; //导入依赖的package包/类
@Override
public void serialize(final P p, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider)
        throws IOException {
    jsonGenerator.writeStartObject();
    jsonGenerator.writeStringField(GraphSONTokens.PREDICATE,
            p instanceof ConnectiveP ?
                    p instanceof AndP ?
                            GraphSONTokens.AND :
                            GraphSONTokens.OR :
                    p.getBiPredicate().toString());
    if (p instanceof ConnectiveP) {
        jsonGenerator.writeArrayFieldStart(GraphSONTokens.VALUE);
        for (final P<?> predicate : ((ConnectiveP<?>) p).getPredicates()) {
            jsonGenerator.writeObject(predicate);
        }
        jsonGenerator.writeEndArray();
    } else
        jsonGenerator.writeObjectField(GraphSONTokens.VALUE, p.getValue());

    jsonGenerator.writeEndObject();
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:22,代码来源:TraversalSerializersV3d0.java


示例5: optimizeBetween

import org.apache.tinkerpop.gremlin.process.traversal.util.AndP; //导入依赖的package包/类
private List<HasContainer> optimizeBetween(ReplacedStep<?, ?> replacedStep, List<HasContainer> hasContainers) {
    List<HasContainer> result = new ArrayList<>();
    for (HasContainer hasContainer : hasContainers) {
        if (hasContainerKeyNotIdOrLabel(hasContainer) && hasContainer.getPredicate() instanceof AndP) {
            AndP<?> andP = (AndP) hasContainer.getPredicate();
            List<? extends P<?>> predicates = andP.getPredicates();
            if (predicates.size() == 2) {
                if (predicates.get(0).getBiPredicate() == Compare.gte && predicates.get(1).getBiPredicate() == Compare.lt) {
                    replacedStep.addHasContainer(hasContainer);
                    result.add(hasContainer);
                }
            }
        }
    }
    return result;
}
 
开发者ID:pietermartin,项目名称:sqlg,代码行数:17,代码来源:BaseStrategy.java


示例6: optimizeInside

import org.apache.tinkerpop.gremlin.process.traversal.util.AndP; //导入依赖的package包/类
private List<HasContainer> optimizeInside(ReplacedStep<?, ?> replacedStep, List<HasContainer> hasContainers) {
    List<HasContainer> result = new ArrayList<>();
    for (HasContainer hasContainer : hasContainers) {
        if (hasContainerKeyNotIdOrLabel(hasContainer) && hasContainer.getPredicate() instanceof AndP) {
            AndP<?> andP = (AndP) hasContainer.getPredicate();
            List<? extends P<?>> predicates = andP.getPredicates();
            if (predicates.size() == 2) {
                if (predicates.get(0).getBiPredicate() == Compare.gt && predicates.get(1).getBiPredicate() == Compare.lt) {
                    replacedStep.addHasContainer(hasContainer);
                    result.add(hasContainer);
                }
            }
        }
    }
    return result;
}
 
开发者ID:pietermartin,项目名称:sqlg,代码行数:17,代码来源:BaseStrategy.java


示例7: addHasContainer

import org.apache.tinkerpop.gremlin.process.traversal.util.AndP; //导入依赖的package包/类
@Override
public void addHasContainer(final HasContainer hasContainer) {
    if (hasContainer.getPredicate() instanceof AndP) {
        for (final P<?> predicate : ((AndP<?>) hasContainer.getPredicate()).getPredicates()) {
            this.addHasContainer(new HasContainer(hasContainer.getKey(), predicate));
        }
    } else
        this.hasContainers.add(hasContainer);
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:10,代码来源:TinkerGraphStep.java


示例8: makeHasContainers

import org.apache.tinkerpop.gremlin.process.traversal.util.AndP; //导入依赖的package包/类
public static HasContainer[] makeHasContainers(final String key, final P<?> predicate) {
    if (predicate instanceof AndP) {
        final List<P<?>> predicates = ((AndP) predicate).getPredicates();
        final HasContainer[] hasContainers = new HasContainer[predicates.size()];
        for (int i = 0; i < predicates.size(); i++) {
            hasContainers[i] = new HasContainer(key, predicates.get(i));
        }
        return hasContainers;
    } else {
        return new HasContainer[]{new HasContainer(key, predicate)};
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:13,代码来源:HasContainer.java


示例9: explodeConnective

import org.apache.tinkerpop.gremlin.process.traversal.util.AndP; //导入依赖的package包/类
public PredicatesHolder explodeConnective(HasContainer has) {
    if (has.getBiPredicate() instanceof ConnectiveP) {
        List<P> predicates = ((ConnectiveP) has.getBiPredicate()).getPredicates();
        PredicatesHolder.Clause clause = has.getPredicate() instanceof AndP ?
                PredicatesHolder.Clause.And : PredicatesHolder.Clause.Or;
        Set<HasContainer> hasContainers = predicates.stream()
                .map(p -> new HasContainer(has.getKey(), p)).collect(Collectors.toSet());
        return PredicatesHolderFactory.createFromPredicates(clause, hasContainers);
    }
    return PredicatesHolderFactory.predicate(has);
}
 
开发者ID:unipop-graph,项目名称:unipop,代码行数:12,代码来源:DateFieldPropertySchema.java


示例10: read

import org.apache.tinkerpop.gremlin.process.traversal.util.AndP; //导入依赖的package包/类
@Override
public <I extends InputShim> P read(final KryoShim<I, ?> kryo, final I input, final Class<P> clazz) {
    final String predicate = input.readString();
    final boolean isCollection = input.readByte() == (byte) 0;
    final Object value;
    if (isCollection) {
        value = new ArrayList();
        final int size = input.readInt();
        for (int ix = 0; ix < size; ix++) {
            ((List) value).add(kryo.readClassAndObject(input));
        }
    } else {
        value = kryo.readClassAndObject(input);
    }

    try {
        if (predicate.equals("and") || predicate.equals("or"))
            return predicate.equals("and") ? new AndP((List<P>) value) : new OrP((List<P>) value);
        else if (value instanceof Collection) {
            if (predicate.equals("between"))
                return P.between(((List) value).get(0), ((List) value).get(1));
            else if (predicate.equals("inside"))
                return P.inside(((List) value).get(0), ((List) value).get(1));
            else if (predicate.equals("outside"))
                return P.outside(((List) value).get(0), ((List) value).get(1));
            else if (predicate.equals("within"))
                return P.within((Collection) value);
            else if (predicate.equals("without"))
                return P.without((Collection) value);
            else
                return (P) P.class.getMethod(predicate, Collection.class).invoke(null, (Collection) value);
        } else
            return (P) P.class.getMethod(predicate, Object.class).invoke(null, value);
    } catch (final Exception e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:38,代码来源:GryoSerializersV1d0.java


示例11: serialize

import org.apache.tinkerpop.gremlin.process.traversal.util.AndP; //导入依赖的package包/类
@Override
public void serialize(final P p, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider)
        throws IOException {
    jsonGenerator.writeStartObject();
    jsonGenerator.writeStringField(GraphSONTokens.PREDICATE,
            p instanceof ConnectiveP ?
                    p instanceof AndP ?
                            GraphSONTokens.AND :
                            GraphSONTokens.OR :
                    p.getBiPredicate().toString());
    if (p instanceof ConnectiveP) {
        jsonGenerator.writeArrayFieldStart(GraphSONTokens.VALUE);
        for (final P<?> predicate : ((ConnectiveP<?>) p).getPredicates()) {
            jsonGenerator.writeObject(predicate);
        }
        jsonGenerator.writeEndArray();
    } else {
        if (p.getValue() instanceof Collection) {
            jsonGenerator.writeArrayFieldStart(GraphSONTokens.VALUE);
            for (final Object object : (Collection) p.getValue()) {
                jsonGenerator.writeObject(object);
            }
            jsonGenerator.writeEndArray();
        } else
            jsonGenerator.writeObjectField(GraphSONTokens.VALUE, p.getValue());
    }
    jsonGenerator.writeEndObject();
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:29,代码来源:TraversalSerializersV2d0.java


示例12: makeHasContainers

import org.apache.tinkerpop.gremlin.process.traversal.util.AndP; //导入依赖的package包/类
/**
 * @deprecated As of release 3.2.4. Providers should handle composite {@link P#and} predicates and not rely on splitting.
 */
@Deprecated
public static HasContainer[] makeHasContainers(final String key, final P<?> predicate) {
    if (predicate instanceof AndP) {
        final List<P<?>> predicates = ((AndP) predicate).getPredicates();
        final HasContainer[] hasContainers = new HasContainer[predicates.size()];
        for (int i = 0; i < predicates.size(); i++) {
            hasContainers[i] = new HasContainer(key, predicates.get(i));
        }
        return hasContainers;
    } else {
        return new HasContainer[]{new HasContainer(key, predicate)};
    }
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:17,代码来源:HasContainer.java


示例13: shouldComposeCorrectly

import org.apache.tinkerpop.gremlin.process.traversal.util.AndP; //导入依赖的package包/类
@Test
public void shouldComposeCorrectly() {
    assertEquals(P.eq(1), P.eq(1));
    assertEquals(P.eq(1).and(P.eq(2)), new AndP<>(Arrays.asList(P.eq(1), P.eq(2))));
    assertEquals(P.eq(1).and(P.eq(2).and(P.eq(3))), new AndP<>(Arrays.asList(P.eq(1), P.eq(2), P.eq(3))));
    assertEquals(P.eq(1).and(P.eq(2).and(P.eq(3).and(P.eq(4)))), new AndP<>(Arrays.asList(P.eq(1), P.eq(2), P.eq(3), P.eq(4))));
    assertEquals(P.eq(1).or(P.eq(2).or(P.eq(3).or(P.eq(4)))), new OrP<>(Arrays.asList(P.eq(1), P.eq(2), P.eq(3), P.eq(4))));
    assertEquals(P.eq(1).or(P.eq(2).and(P.eq(3).or(P.eq(4)))), new OrP<>(Arrays.asList(P.eq(1), new AndP<>(Arrays.asList(P.eq(2), new OrP<>(Arrays.asList(P.eq(3), P.eq(4))))))));
    assertEquals(P.eq(1).and(P.eq(2).or(P.eq(3).and(P.eq(4)))), new AndP<>(Arrays.asList(P.eq(1), new OrP<>(Arrays.asList(P.eq(2), new AndP<>(Arrays.asList(P.eq(3), P.eq(4))))))));
    assertEquals(P.eq(1).and(P.eq(2).and(P.eq(3).or(P.eq(4)))), new AndP<>(Arrays.asList(P.eq(1), P.eq(2), new OrP<>(Arrays.asList(P.eq(3), P.eq(4))))));
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:12,代码来源:PTest.java


示例14: and

import org.apache.tinkerpop.gremlin.process.traversal.util.AndP; //导入依赖的package包/类
@Override
public P<V> and(final Predicate<? super V> predicate) {
    if (!(predicate instanceof P))
        throw new IllegalArgumentException("Only P predicates can be and'd together");
    return new AndP<>(Arrays.asList(this, (P<V>) predicate));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:7,代码来源:P.java


示例15: inside

import org.apache.tinkerpop.gremlin.process.traversal.util.AndP; //导入依赖的package包/类
public static <V> P<V> inside(final V first, final V second) {
    return new AndP<V>(Arrays.asList(new P(Compare.gt, first), new P(Compare.lt, second)));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:4,代码来源:P.java


示例16: between

import org.apache.tinkerpop.gremlin.process.traversal.util.AndP; //导入依赖的package包/类
public static <V> P<V> between(final V first, final V second) {
    return new AndP<V>(Arrays.asList(new P(Compare.gte, first), new P(Compare.lt, second)));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:4,代码来源:P.java


示例17: inside

import org.apache.tinkerpop.gremlin.process.traversal.util.AndP; //导入依赖的package包/类
public static <V> P<V> inside(final V first, final V second) {
    return new AndP<>(Arrays.asList(new P(DatePredicate.gt, first), new P(DatePredicate.lt, second)));
}
 
开发者ID:unipop-graph,项目名称:unipop,代码行数:4,代码来源:Date.java


示例18: between

import org.apache.tinkerpop.gremlin.process.traversal.util.AndP; //导入依赖的package包/类
public static <V> P<V> between(final V first, final V second) {
    return new AndP<>(Arrays.asList(new P(DatePredicate.gte, first), new P(DatePredicate.lt, second)));
}
 
开发者ID:unipop-graph,项目名称:unipop,代码行数:4,代码来源:Date.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java Document类代码示例发布时间:2022-05-23
下一篇:
Java HttpConnectCallback类代码示例发布时间: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