Giter VIP home page Giter VIP logo

Comments (9)

ptupitsyn avatar ptupitsyn commented on June 12, 2024

If you use GetRawWriter, it will work with key/value API, but not with SQL.

the attributes of Address type is not getting saved to Employee table

Please share the code. What do you mean by "not getting saved to Employee table" - how do you see that?

from ignite.

satishviswanathan avatar satishviswanathan commented on June 12, 2024

@ptupitsyn Thank you for your response. This is what I have been trying to do.

DDL statement. I have created the following table by executing the DDL statement from Database Manager (DBeaver).

CREATE TABLE IF NOT EXISTS employee (
  id int,
name varchar,
companyid varchar,
age int,
city varchar,
street varchar,
streetnumber int,
flatnumber int,
  PRIMARY KEY (id)
) WITH "template=partitioned,backups=1,WRITE_SYNCHRONIZATION_MODE=FULL_SYNC,CACHE_GROUP=Employee,CACHE_NAME=Employee,KEY_TYPE=int,VALUE_TYPE=Employee";

After that I have executed the following program to create an employee record , however the address details are not getting saved
ignite-sample.zip

Employee Table view

image

from ignite.

ptupitsyn avatar ptupitsyn commented on June 12, 2024

Address.WriteBinary uses GetRawWriter, which does not work with SQL.

Basically there is no mapping between field names and values, just some bytes, Ignite does not know where the City value is an so on.

Fix Address class to use IBinaryWriter with field names like you do in Employee.

We have an example with this approach: https://github.com/apache/ignite/blob/079f49d1a5acbed0bdb0a25d3674fecd71769bfe/modules/platforms/dotnet/examples/Thick/Sql/Sql/Program.cs

P.S. When sharing code, please avoid including binaries (bin, obj).

from ignite.

satishviswanathan avatar satishviswanathan commented on June 12, 2024

@ptupitsyn Thank you for your help.
I did try as shown in example but let me check again. One difference was I started as a Ignite client. I'm still trying to figure out the difference between Ignite.Start() and Ignite.StartClient(). That was one difference from what I did when compared to the example.

from ignite.

ptupitsyn avatar ptupitsyn commented on June 12, 2024

still trying to figure out the difference between Ignite.Start() and Ignite.StartClient()

  • Ignition.Start() creates an embedded server node, which becomes a part of the cluster, stores data, executes computations, etc. This is a powerful mode but may require a lot of resources.
  • Ignition.StartClient() starts a lightweight thin client. It has some limitations compared to embedded mode, but is a lot quicker to start, does not require Java and consumes little resources

We recommend the thin client by default, but the API is very similar and you can switch back and forth if the requirements change.

For IBinarizable and SQL there is no difference, both modes work exactly the same.

from ignite.

satishviswanathan avatar satishviswanathan commented on June 12, 2024

@ptupitsyn Thank you that cleared by confusions.

However this issue still persist, the Address fields are not updated. Although the data is not serialized to these fields, I can see the values are there in the cache. Is it because while creating the table using the ddl statement we have the VALUE_TYPE as Employee and the ignite server is unware of the "Address" type ?

Attaching the sample code with the updated implementation
ignite-sample.zip

from ignite.

ptupitsyn avatar ptupitsyn commented on June 12, 2024

Adding address object column to your DDL script fixes the issue.

SQL engine does not drill down the nested object if there is no matching column.

from ignite.

satishviswanathan avatar satishviswanathan commented on June 12, 2024

DL statement.

CREATE TABLE IF NOT EXISTS synim_tab.employee (
id int,
name varchar,
companyid varchar,
age int,
city varchar,
street varchar,
streetnumber int,
flatnumber int,
PRIMARY KEY (id)
) WITH "template=partitioned,backups=1,WRITE_SYNCHRONIZATION_MODE=FULL_SYNC,CACHE_GROUP=Employee,CACHE_NAME=Employee,KEY_TYPE=int,VALUE_TYPE=Employee";

What would be the data type of address ?If I add address as a column then how are this fields of address (city, streetnumber, flatnumber) going to be mapped ?

from ignite.

ptupitsyn avatar ptupitsyn commented on June 12, 2024
CREATE TABLE IF NOT EXISTS employee (
  id int,
  name varchar,
  address object,
  companyid varchar,
  age int,
  city varchar,
  street varchar,
  streetnumber int,
  flatnumber int,
  PRIMARY KEY (id)
) WITH "template=partitioned,backups=1,WRITE_SYNCHRONIZATION_MODE=FULL_SYNC,CACHE_GROUP=Employee,CACHE_NAME=Employee,KEY_TYPE=int,VALUE_TYPE=Employee";

Just add address object column and run your code, it will work.

from ignite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.