Search code examples
ignite

Order of the iterations of entries in an Ignite cache and seek method


What is the ordering of the keys in an Ignite cache (without using indexing) and is it possible to do the equivalent of the following RocksDB snippet

    try (final RocksIterator rocksIterator =
            rocksDB.newIterator(columnFamilyHandleList.get(1))) {
        for (rocksIterator.seek(prefixKey);

i.e. jump to the next entry starting with a given byte[] or String?


Solution

  • The way you'd do that in Ignite is by using SQL.

            var query = new SqlFieldsQuery("select x,y,z from table where z like ? order by x").setArgs("prefix%");
            try (var cursor = cache.query(query)) {
                for (var r : cursor) {
                    Long id = (Long) r.get(0);
                    BigDecimal value = (BigDecimal) r.get(1);
                    String name = (String) r.get(2);
                }
            }