Search code examples
orientdborientjs

How to create abstract class in OrientJS with the default cluster settings?


When I create a class with OrientJS Class API, e.g. db.class.create('Story', 'E');, it creates automatically multiple clusters depending on how many CPU cores it has at the server side. This is the desired behavior.

But when creating an abstract class, it has to pass something to the cluster parameter. If null is used, i.e. db.class.create('Category', 'V', null, true);, it creates a class in cluster [-1]. I searched around but didn't find any statement about cluster -1. It seems like a special cluster because several classes can have the [-1] at the same time.

How can I create an abstract class but still have it distributed to multiple clusters?


Solution

  • Answer the silly question myself.

    An abstract class will have no records in it, therefore cluster distribution is an irrelevant topic for an abstract class. Cluster [-1] is a dedicated dummy class for all the abstract classes.

    It is not documented but a valid point, that assigning null to the cluster parameter when creating an abstract class with db.class.create. Because in the SQL statement construction code of OrientJS:

    if (cluster) {
        query += ' CLUSTER ' + cluster;
    }