Skip to content

Commit

Permalink
IGNITE-23818 Test tuple from table deserialization (#4815)
Browse files Browse the repository at this point in the history
  • Loading branch information
valepakh authored Dec 6, 2024
1 parent 0ea50af commit cdd4145
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,21 @@ void changeExecutingJobPriority(boolean local) {
assertThat(execution.cancelAsync(), willBe(true));
}

@Test
void tupleSerialization() {
Ignite entryNode = node(0);
ClusterNode executeNode = clusterNode(node(1));

// Execute the job on remote node to trigger serialization
Integer result = entryNode.compute().execute(
JobTarget.node(executeNode),
JobDescriptor.builder(TupleJob.class).units(units()).build(),
Tuple.create().set("COUNT", 1)
);

assertThat(result, is(1));
}

static String concatJobClassName() {
return ConcatJob.class.getName();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.ignite.internal.compute;

import static java.util.concurrent.CompletableFuture.completedFuture;

import java.util.concurrent.CompletableFuture;
import org.apache.ignite.compute.ComputeJob;
import org.apache.ignite.compute.JobExecutionContext;
import org.apache.ignite.table.Tuple;

/**
* Returns a value of the "COUNT" column as an integer.
*/
public class TupleJob implements ComputeJob<Tuple, Integer> {
@Override
public CompletableFuture<Integer> executeAsync(JobExecutionContext jobExecutionContext, Tuple arg) {
return completedFuture(arg.intValue("COUNT"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ void nestedTuplesArgumentSerialization(int targetNodeIdx) {
static class TupleResultJob implements ComputeJob<Integer, Tuple> {
@Override
public @Nullable CompletableFuture<Tuple> executeAsync(JobExecutionContext context, @Nullable Integer key) {
// todo: There is no table for some reason in context.ignite().
return completedFuture(Tuple.create().set(COLUMN_VAL, "hi"));
return context.ignite().tables().tableAsync(TABLE_NAME)
.thenApply(table -> table.keyValueView().get(null, Tuple.create().set(COLUMN_KEY, key)));
}
}

Expand Down

0 comments on commit cdd4145

Please sign in to comment.