use of org.jooq.Record1 in project jOOQ by jOOQ.
the class QuantifiedComparisonCondition method accept0.
@SuppressWarnings({ "unchecked" })
private final void accept0(Context<?> ctx) {
boolean quantifiedArray = query.array instanceof Param<?>;
boolean emulateOperator;
switch(comparator) {
case LIKE:
case NOT_LIKE:
case LIKE_IGNORE_CASE:
case NOT_LIKE_IGNORE_CASE:
emulateOperator = escape != null || NO_SUPPORT_QUANTIFIED_LIKE.contains(ctx.dialect());
break;
case SIMILAR_TO:
case NOT_SIMILAR_TO:
emulateOperator = escape != null || NO_SUPPORT_QUANTIFIED_SIMILAR_TO.contains(ctx.dialect());
break;
default:
emulateOperator = false;
break;
}
// arrays, such as x = any(?::int[]) in PostgreSQL
if (quantifiedArray && SUPPORTS_QUANTIFIED_ARRAYS.contains(ctx.dialect()) && !emulateOperator) {
accept1(ctx);
} else if (query.values != null || quantifiedArray) {
ctx.visit(DSL.condition(query.quantifier == Quantifier.ALL ? Operator.AND : Operator.OR, query.values != null ? map(query.values, v -> comparisonCondition(comparator, (Field<String>) v)) : map(((Param<? extends Object[]>) query.array).getValue(), v -> v instanceof Field ? comparisonCondition(comparator, (Field<String>) v) : comparisonCondition(comparator, v))));
} else if ((query.array != null || query.query != null) && emulateOperator) {
Field<String> pattern = DSL.field(name("pattern"), VARCHAR);
Condition cond;
Field<Boolean> lhs;
switch(comparator) {
case NOT_LIKE:
case NOT_SIMILAR_TO:
case NOT_LIKE_IGNORE_CASE:
cond = comparisonCondition(inverse(comparator), pattern);
lhs = inline(false);
break;
case LIKE:
case SIMILAR_TO:
case LIKE_IGNORE_CASE:
cond = comparisonCondition(comparator, pattern);
lhs = inline(true);
break;
default:
throw new IllegalStateException();
}
Table<?> t = query.array != null ? new ArrayTable(query.array).asTable("t", "pattern") : new AliasedSelect<>(query.query, true, true, name("pattern")).as("t");
Select<Record1<Boolean>> select = select(DSL.field(cond)).from(t);
ctx.visit(lhs.eq(query.quantifier.apply(select)));
} else {
accept1(ctx);
}
}
use of org.jooq.Record1 in project zipkin by openzipkin.
the class AggregateDependencies method apply.
@Override
public List<DependencyLink> apply(DSLContext context) {
// Subquery on trace IDs to prevent only matching the part of the trace that exists within
// the interval: we want all of the trace.
SelectConditionStep<Record1<Long>> traceIDs = context.selectDistinct(ZIPKIN_SPANS.TRACE_ID).from(ZIPKIN_SPANS).where(startTsBegin == startTsEnd ? ZIPKIN_SPANS.START_TS.lessOrEqual(startTsEnd) : ZIPKIN_SPANS.START_TS.between(startTsBegin, startTsEnd));
// Lazy fetching the cursor prevents us from buffering the whole dataset in memory.
Cursor<Record> cursor = context.selectDistinct(schema.dependencyLinkerFields).from(ZIPKIN_SPANS.leftJoin(ZIPKIN_ANNOTATIONS).on(ZIPKIN_SPANS.TRACE_ID.eq(ZIPKIN_ANNOTATIONS.TRACE_ID).and(ZIPKIN_SPANS.ID.eq(ZIPKIN_ANNOTATIONS.SPAN_ID))).and(ZIPKIN_ANNOTATIONS.A_KEY.in("lc", "cs", "ca", "sr", "sa", "ma", "mr", "ms", "error"))).where(ZIPKIN_SPANS.TRACE_ID.in(traceIDs)).groupBy(schema.dependencyLinkerGroupByFields).fetchLazy();
Iterator<Iterator<Span>> traces = new DependencyLinkV2SpanIterator.ByTraceId(cursor.iterator(), schema.hasTraceIdHigh);
if (!traces.hasNext())
return Collections.emptyList();
DependencyLinker linker = new DependencyLinker();
List<Span> nextTrace = new ArrayList<>();
while (traces.hasNext()) {
Iterator<Span> i = traces.next();
while (i.hasNext()) nextTrace.add(i.next());
linker.putTrace(nextTrace);
nextTrace.clear();
}
return linker.link();
}
use of org.jooq.Record1 in project waltz by khartec.
the class FlowDiagramService method makeForPhysicalSpecification.
private Long makeForPhysicalSpecification(EntityReference ref, String userId, String providedTitle) {
PhysicalSpecification spec = physicalSpecificationDao.getById(ref.id());
Select<Record1<Long>> logicalFlowSelector = logicalFlowIdSelectorFactory.apply(mkOpts(ref, HierarchyQueryScope.EXACT));
List<LogicalFlow> logicalFlows = logicalFlowDao.findBySelector(logicalFlowSelector);
List<PhysicalFlow> physicalFlows = physicalFlowDao.findBySpecificationId(ref.id());
List<EntityReference> nodes = logicalFlows.stream().flatMap(f -> Stream.of(f.source(), f.target())).distinct().collect(toList());
List<FlowDiagramEntity> entities = ListUtilities.concat(map(logicalFlows, d -> mkDiagramEntity(d)), map(physicalFlows, d -> mkDiagramEntity(d)), newArrayList(mkDiagramEntity(spec)), map(nodes, d -> mkDiagramEntity(d)));
String title = isEmpty(providedTitle) ? spec.name() + " flows" : providedTitle;
return mkNewFlowDiagram(title, userId, entities, emptyList());
}
use of org.jooq.Record1 in project waltz by khartec.
the class FacetService method getApplicationKindTallies.
public List<Tally<String>> getApplicationKindTallies(IdSelectionOptions options) {
// we don't want the facets to apply and filter out non selected kinds, so we default to all kinds
IdSelectionOptions appOptions = mkOpts(options.entityReference(), options.scope());
Select<Record1<Long>> appSelector = applicationIdSelectorFactory.apply(appOptions);
return applicationDao.countByApplicationKind(appSelector);
}
use of org.jooq.Record1 in project waltz by khartec.
the class ChangeUnitIdSelectorFactory method mkByAppSelector.
private Select<Record1<Long>> mkByAppSelector(IdSelectionOptions options) {
Select<Record1<Long>> appSelector = applicationIdSelectorFactory.apply(options);
Condition sourceRef = LOGICAL_FLOW.SOURCE_ENTITY_KIND.eq(EntityKind.APPLICATION.name()).and(LOGICAL_FLOW.SOURCE_ENTITY_ID.in(appSelector));
Condition targetRef = LOGICAL_FLOW.TARGET_ENTITY_KIND.eq(EntityKind.APPLICATION.name()).and(LOGICAL_FLOW.TARGET_ENTITY_ID.in(appSelector));
return DSL.select(CHANGE_UNIT.ID).from(CHANGE_UNIT).innerJoin(PHYSICAL_FLOW).on(PHYSICAL_FLOW.ID.eq(CHANGE_UNIT.SUBJECT_ENTITY_ID).and(CHANGE_UNIT.SUBJECT_ENTITY_KIND.eq(EntityKind.PHYSICAL_FLOW.name()))).innerJoin(LOGICAL_FLOW).on(LOGICAL_FLOW.ID.eq(PHYSICAL_FLOW.LOGICAL_FLOW_ID)).where(sourceRef.or(targetRef));
}
Aggregations