use of com.hazelcast.sql.impl.row.JetSqlRow in project hazelcast by hazelcast.
the class SqlHashJoinP method join.
private Traverser<JetSqlRow> join(JetSqlRow leftRow) {
ObjectArrayKey joinKeys = ObjectArrayKey.project(leftRow, joinInfo.leftEquiJoinIndices());
Collection<JetSqlRow> matchedRows = hashMap.get(joinKeys);
List<JetSqlRow> output = matchedRows.stream().map(right -> ExpressionUtil.join(leftRow, right, joinInfo.nonEquiCondition(), evalContext)).filter(Objects::nonNull).collect(Collectors.toList());
if (joinInfo.isLeftOuter() && output.isEmpty()) {
return Traversers.singleton(leftRow.extendedRow(rightInputColumnCount));
}
return Traversers.traverseIterable(output);
}
use of com.hazelcast.sql.impl.row.JetSqlRow in project hazelcast by hazelcast.
the class SqlTestSupport method compareRowLists.
/**
* Compares two lists. The lists are expected to contain elements of type
* Object[]. Useful for {@link TestSupport#outputChecker(BiPredicate)}.
*/
public static boolean compareRowLists(List<?> expected, List<?> actual) {
if (expected.size() != actual.size()) {
return false;
}
for (int i = 0; i < expected.size(); i++) {
JetSqlRow expectedItem = (JetSqlRow) expected.get(i);
JetSqlRow actualItem = (JetSqlRow) actual.get(i);
if (!Objects.equals(expectedItem, actualItem)) {
return false;
}
}
return true;
}
use of com.hazelcast.sql.impl.row.JetSqlRow in project hazelcast by hazelcast.
the class ExpressionUtilTest method test_join.
private void test_join(Expression<Boolean> predicate, Object[] leftRow, Object[] rightRow, Object[] expected) {
JetSqlRow joined = ExpressionUtil.join(new JetSqlRow(TEST_SS, leftRow), new JetSqlRow(TEST_SS, rightRow), predicate, createExpressionEvalContext());
assertThat(joined == null ? null : joined.getValues()).isEqualTo(expected);
}
use of com.hazelcast.sql.impl.row.JetSqlRow in project hazelcast by hazelcast.
the class WindowUtilsTest method check_addWindowBounds.
/**
* Calls WindowUtils.addWindowBounds with a record with the given
* {@code timestamp} and window policy. Asserts that the returned
* traverser contains the given {@code outputWindows}.
*/
private void check_addWindowBounds(Object timestamp, long windowSize, long slideBy, Object... outputWindows) {
// noinspection SimplifiableAssertion
assertTrue(outputWindows.length % 2 == 0);
Traverser<JetSqlRow> traverser = WindowUtils.addWindowBounds(new JetSqlRow(TEST_SS, new Object[] { timestamp }), 0, slidingWinPolicy(windowSize, slideBy));
for (int i = 0; i < outputWindows.length; i += 2) {
Object[] expected = new Object[] { timestamp, outputWindows[i], outputWindows[i + 1] };
assertArrayEquals(expected, traverser.next().getValues());
}
assertNull(traverser.next());
}
use of com.hazelcast.sql.impl.row.JetSqlRow in project hazelcast by hazelcast.
the class SqlMetadataTest method testRow.
@Test
public void testRow() {
SqlColumnMetadata column0Metadata = new SqlColumnMetadata("a", SqlColumnType.INTEGER, true);
SqlColumnMetadata column1Metadata = new SqlColumnMetadata("b", SqlColumnType.VARCHAR, true);
SqlRow row = new SqlRowImpl(new SqlRowMetadata(Arrays.asList(column0Metadata, column1Metadata)), new JetSqlRow(TEST_SS, new Object[] { 1, "2" }));
assertEquals("[a INTEGER=1, b VARCHAR=2]", row.toString());
}
Aggregations