Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IGNITE-23674: Sql. Expose underlying schema used by RowFactory #4724

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ interface RowFactory<RowT> {
* @return Instantiation defined representation.
*/
RowT create(InternalTuple tuple);

/**
* Returns an instance of a row schema used by this factory.
*
* @return RowSchema.
*/
RowSchema rowSchema();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public RowWrapper create() {
/** {@inheritDoc} */
@Override
public RowWrapper create(Object... fields) {
assert fields.length == schemaLen;
assert fields.length == rowSchema.fields().size();

return new ObjectsArrayRowWrapper(rowSchema, fields);
}
Expand All @@ -178,6 +178,12 @@ public RowWrapper create(InternalTuple tuple) {

return new BinaryTupleRowWrapper(rowSchema, tuple);
}

/** {@inheritDoc} */
@Override
public RowSchema rowSchema() {
return rowSchema;
}
};
}

Expand Down Expand Up @@ -214,7 +220,8 @@ int columnsCount() {
}

@Override
@Nullable Object get(int field) {
@Nullable
Object get(int field) {
return row[field];
}

Expand Down Expand Up @@ -376,7 +383,8 @@ int columnsCount() {
}

@Override
@Nullable Object get(int field) {
@Nullable
Object get(int field) {
Comment on lines +386 to +387
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@Nullable
Object get(int field) {
@Nullable Object get(int field) {

NativeType nativeType = RowSchemaTypes.toNativeType(rowSchema.fields().get(field));

if (nativeType == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@
import org.apache.ignite.internal.sql.engine.exec.ExecutionContext;
import org.apache.ignite.internal.sql.engine.exec.QueryTaskExecutorImpl;
import org.apache.ignite.internal.sql.engine.exec.RowHandler;
import org.apache.ignite.internal.sql.engine.exec.RowHandler.RowBuilder;
import org.apache.ignite.internal.sql.engine.exec.TxAttributes;
import org.apache.ignite.internal.sql.engine.exec.mapping.FragmentDescription;
import org.apache.ignite.internal.sql.engine.framework.ArrayRowHandler;
import org.apache.ignite.internal.sql.engine.framework.NoOpTransaction;
import org.apache.ignite.internal.testframework.IgniteAbstractTest;
import org.apache.ignite.internal.testframework.IgniteTestUtils;
Expand Down Expand Up @@ -338,35 +336,6 @@ public void closeRewindableRoot() {
}
}

static RowHandler.RowFactory<Object[]> rowFactory() {
return new RowHandler.RowFactory<>() {
@Override
public RowHandler<Object[]> handler() {
return ArrayRowHandler.INSTANCE;
}

@Override
public RowBuilder<Object[]> rowBuilder() {
throw new UnsupportedOperationException();
}

@Override
public Object[] create() {
throw new AssertionError();
}

@Override
public Object[] create(Object... fields) {
return fields;
}

@Override
public Object[] create(InternalTuple tuple) {
throw new UnsupportedOperationException();
}
};
}

static TupleFactory tupleFactoryFromSchema(BinaryTupleSchema schema) {
return new BinaryTupleFactory(schema);
}
Expand Down
Loading