use of com.hazelcast.sql.impl.row.JetSqlRow in project hazelcast by hazelcast.
the class SlidingWindowAggregatePhysicalRel method outputValueMapping.
@SuppressWarnings("checkstyle:MagicNumber")
public KeyedWindowResultFunction<? super Object, ? super JetSqlRow, ?> outputValueMapping() {
int[] windowBoundsIndexMask = new int[getRowType().getFieldCount()];
QueryDataType descriptorType = HazelcastTypeUtils.toHazelcastType(timestampExpression.getType());
for (Integer index : windowStartIndexes) {
windowBoundsIndexMask[index] = -1;
}
for (Integer index : windowEndIndexes) {
windowBoundsIndexMask[index] = -2;
}
for (int i = 0, j = 0; i < windowBoundsIndexMask.length; i++) {
if (windowBoundsIndexMask[i] >= 0) {
windowBoundsIndexMask[i] = j++;
}
}
return (start, end, ignoredKey, result, isEarly) -> insertWindowBound(result, start, end, descriptorType, windowBoundsIndexMask);
}
use of com.hazelcast.sql.impl.row.JetSqlRow in project hazelcast by hazelcast.
the class JoinScanProcessorSupplier method join.
private static boolean join(@Nonnull List<JetSqlRow> rows, @Nonnull JetSqlRow left, @Nonnull List<JetSqlRow> rights, @Nonnull Expression<Boolean> condition, @Nonnull ExpressionEvalContext evalContext) {
boolean matched = false;
for (JetSqlRow right : rights) {
JetSqlRow joined = ExpressionUtil.join(left, right, condition, evalContext);
if (joined != null) {
rows.add(joined);
matched = true;
}
}
return matched;
}
use of com.hazelcast.sql.impl.row.JetSqlRow in project hazelcast by hazelcast.
the class JoinByPrimitiveKeyProcessorSupplier method get.
@Nonnull
@Override
public Collection<? extends Processor> get(int count) {
List<Processor> processors = new ArrayList<>(count);
for (int i = 0; i < count; i++) {
String mapName = this.mapName;
KvRowProjector projector = rightRowProjectorSupplier.get(evalContext, extractors);
Processor processor = new AsyncTransformUsingServiceOrderedP<>(ServiceFactories.nonSharedService(SecuredFunctions.iMapFn(mapName)), null, MAX_CONCURRENT_OPS, (IMap<Object, Object> map, JetSqlRow left) -> {
Object key = left.get(leftEquiJoinIndex);
if (key == null) {
return inner ? null : completedFuture(null);
}
return map.getAsync(key).toCompletableFuture();
}, (left, value) -> {
JetSqlRow joined = join(left, left.get(leftEquiJoinIndex), value, projector, condition, evalContext);
return joined != null ? singleton(joined) : inner ? null : singleton(left.extendedRow(projector.getColumnCount()));
});
processors.add(processor);
}
return processors;
}
use of com.hazelcast.sql.impl.row.JetSqlRow in project hazelcast by hazelcast.
the class UpdatingEntryProcessor method process.
@Override
public Long process(Map.Entry<Object, Object> entry) {
if (entry.getValue() == null) {
return 0L;
} else {
JetSqlRow row = rowProjectorSupplier.get(evalContext, extractors).project(entry.getKey(), entry.getValue());
Object value = valueProjectorSupplier.get(evalContext).project(row);
if (value == null) {
throw QueryException.error("Cannot assign null to value");
} else {
entry.setValue(value);
return 1L;
}
}
}
use of com.hazelcast.sql.impl.row.JetSqlRow in project hazelcast by hazelcast.
the class RowProjectorProcessorSupplier method get.
@Nonnull
@Override
public Collection<? extends Processor> get(int count) {
List<Processor> processors = new ArrayList<>(count);
for (int i = 0; i < count; i++) {
ResettableSingletonTraverser<JetSqlRow> traverser = new ResettableSingletonTraverser<>();
KvRowProjector projector = projectorSupplier.get(evalContext, extractors);
Processor processor = new TransformP<LazyMapEntry<Object, Object>, JetSqlRow>(entry -> {
traverser.accept(projector.project(entry.getKeyData(), entry.getValueData()));
return traverser;
});
processors.add(processor);
}
return processors;
}
Aggregations