Joe
Joe

Reputation: 13091

How to list all cache names and all column names inside one cache in Apache Ignite 2.1?

Is there a java code or SQL example to list all caches existing in Apache Ignite?

Also is there a java code or SQL example to list columns within one cache in Apache Ignite?

Upvotes: 1

Views: 1098

Answers (1)

alexmagnus
alexmagnus

Reputation: 1006

org.apache.ignite.Ignite#cacheNames lists all the available caches.

You can obtain information about columns from QueryEntries set for a cache via CacheConfiguration#setQueryEntities or CacheConfiguration#setIndexedTypes.
Just call Collection<QueryEntity> queryEntities = cache.getConfiguration(CacheConfiguration.class).getQueryEntities(); and then call QueryEntity#getFieldson the QueryEntity of your interest.

As well you can obtain information about extracted query fields while using SqlFieldsQuery.

FieldsQueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery(query));
for (int i = 0; i < cursor.getColumnsCount(); ++i) {
    String fieldName = cursor.getFieldName(i);
    // ...
}

Upvotes: 1

Related Questions