BinaryObject with '.' (dots) in field names

classic Classic list List threaded Threaded
4 messages Options
scottmf scottmf
Reply | Threaded
Open this post in threaded view
|

BinaryObject with '.' (dots) in field names

Hi, Running the code below doesn't work properly unless I change the field names from using to '.' (dots) to use '_' (underscores).

Questions:

1. What are the restrictions around field names? In other words, are there other characters that i can't use?
2. Is there a way to work around this and use dots in the field names?

thanks!

        Ignite ignite = Ignition.start();
        String id = "id";
        String name = "name";
        String orgId = "org.id";
        String orgName = "org.name";
        String orgOwner = "org.owner";

        CacheConfiguration<Object, BinaryObject> cfg = new CacheConfiguration<>();
        cfg.setName("deployment");

        LinkedHashMap<String, String> fields = new LinkedHashMap<>();
        fields.put("id", "java.lang.String");
        fields.put("name", "java.lang.String");
        fields.put("org.id", "java.lang.String");
        fields.put("org.name", "java.lang.String");
        fields.put("org.owner", "java.lang.String");

        QueryEntity queryEntity = new QueryEntity();
        queryEntity.setKeyType("java.lang.String");
        queryEntity.setValueType("deployment");
        queryEntity.setFields(fields);

        cfg.setQueryEntities(Collections.singleton(queryEntity));

        IgniteCache<Object, BinaryObject> deployment = ignite.getOrCreateCache(cfg).withKeepBinary();
        BinaryObject binaryObject = ignite.binary().builder("deployment")
            .setField("id", id)
            .setField("name", name)
            .setField("org.id", orgId)
            .setField("org.name", orgName)
            .setField("org.owner", orgOwner)
            .build();
        deployment.put(id, binaryObject);

        Object o = deployment.get("id");
        System.err.println("cache -> " + o);
        FieldsQueryCursor<List<?>> query = deployment.query(new SqlFieldsQuery("select * from deployment"));
        System.err.println(query.getAll());
output:
cache -> deployment [idHash=1984294974, hash=1137170470, id=id, name=name, org.id=org.id, org.name=org.name, org.owner=org.owner]
[[null, null, null]]


Sent from the Apache Ignite Users mailing list archive at Nabble.com.
akurbanov akurbanov
Reply | Threaded
Open this post in threaded view
|

Re: BinaryObject with '.' (dots) in field names

Hello Scott,

I would recommend to stick with the underscore character, as the dot (.) is
reserved for the nested object to be referenced in the QueryEntity. When you
mark the query entity field with "org.id", it expects that there is an field
with name "org" in this object that has nested field "id".

The field names in the query will be flattened and in this case you will end
up with 3 fields in your QueryEntity type descriptor instead of expected 5
fields: "id", "name" and "owner" which will all have the same parent object
"org" that is missing in this object (the field should be a BinaryObject
field named "org" with 3 nested fields), thus, the returned data will be
evaluated as nulls.

Best regards,
Anton



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
scottmf scottmf
Reply | Threaded
Open this post in threaded view
|

Re: BinaryObject with '.' (dots) in field names

Thanks Anton.

We can deal with it by using a placeholder for the dot when interacting with
ignite.  (Since in our notation we already have dots)

Going back to the questions,

1. It sounds like we cannot work around this limitation since it is a
reserved character, is that correct?
2. Are there any other characters that we should be aware of besides the '.'
?

thanks.



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
akurbanov akurbanov
Reply | Threaded
Open this post in threaded view
|

Re: BinaryObject with '.' (dots) in field names

Hello Scott,

Unfortunately, there is no workaround available to safely use dot within
BinaryObject field name.

I am not aware of any other things, dot seems to be the only one symbol that
affects how BinaryObject is aligned.

Best regards,
Anton



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/