Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client.getInfo() should return human readable data #100

Closed
tgrall opened this issue Jun 8, 2020 · 3 comments
Closed

Client.getInfo() should return human readable data #100

tgrall opened this issue Jun 8, 2020 · 3 comments

Comments

@tgrall
Copy link
Contributor

tgrall commented Jun 8, 2020

The values returned by client.getInfo(); are binary content, the API should return a human readable one. (converting all maps in to proper datatype)

Schema:

    public final static String MOVIE_ID = "movie_id";
    public final static String TITLE = "title";
    public final static String GENRE = "genre";
    public final static String VOTES = "votes";
    public final static String RATING = "rating";
    public final static String RELEASE_YEAR = "release_year";
    public final static String PLOT = "plot";
    public final static String POSTER = "poster";

    public static Schema getSchema() {
        return new Schema()
                .addTextField(TITLE, 5.0)
                .addSortableTextField(PLOT, 1.0)
                .addSortableTagField(GENRE, ",")
                    .addSortableNumericField(RELEASE_YEAR)
                .addSortableNumericField(RATING)
                .addSortableNumericField(VOTES);
    }

Printed values:

{max_doc_id=0, sortable_values_size_mb=0, inverted_sz_mb=0, num_records=0, num_terms=0, records_per_doc_avg=-nan, cursor_stats=[[B@33cde8cd, 0, [B@28f06267, 0, [B@26c7a04, 128, [B@3b80575f, 0], bytes_per_record_avg=-nan, num_docs=0, offset_bits_per_record_avg=-nan, offset_vectors_sz_mb=0, doc_table_size_mb=0, gc_stats=[[B@67d75b62, [B@4c1ffea5, [B@2dc20178, [B@14c18130, [B@4990d481, [B@7a49f1c0, [B@473de630, [B@5f6d27e6, [B@1016d456, [B@2564f065, [B@dc09e9f, [B@3b24cad6, [B@1db61d80, [B@1f53218b], offsets_per_term_avg=-nan, key_table_size_mb=1.239776611328125e-05, total_inverted_index_blocks=0, fields=[[[B@16ee7098, [B@b816ae9, [B@26763c04, [B@20af1e38, [B@4520d005], [[B@45762c6a, [B@5277bedc, [B@af13474, [B@49127dd7, [B@3d730de3, [B@521dc5cf], [[B@514c096c, [B@bea3a57, [B@2ed332dc, [B@125cb974, [B@236ac53a], [[B@79086b82, [B@4efae3ad, [B@391a641f, [B@4cac3513], [[B@7642037f, [B@6f3c6191, [B@5ecdaf5, [B@284573f6], [[B@4e7ac47a, [B@424604cd, [B@211e5502, [B@22475814]], index_name=ms:search:index:movies, index_options=[]}

It should be something like:

[index_name, ms:search:index:movies, index_options, [], fields, [[title, type, TEXT, WEIGHT, 5], [plot, type, TEXT, WEIGHT, 1, SORTABLE], [genre, type, TAG, SEPARATOR, ,], [release_year, type, NUMERIC, SORTABLE], [rating, type, NUMERIC, SORTABLE], [votes, type, NUMERIC, SORTABLE]], num_docs, 0, max_doc_id, 0, num_terms, 0, num_records, 0, inverted_sz_mb, 0, total_inverted_index_blocks, 0, offset_vectors_sz_mb, 0, doc_table_size_mb, 0, sortable_values_size_mb, 0, key_table_size_mb, 1.239776611328125e-05, records_per_doc_avg, -nan, bytes_per_record_avg, -nan, offsets_per_term_avg, -nan, offset_bits_per_record_avg, -nan, gc_stats, [bytes_collected, 0, total_ms_run, 1384, total_cycles, 346, avarage_cycle_time_ms, 4, last_run_time_ms, 3, gc_numeric_trees_missed, 0, gc_blocks_denied, 0], cursor_stats, [global_idle, 0, global_total, 0, index_capacity, 128, index_total, 0]]

@tgrall
Copy link
Contributor Author

tgrall commented Jun 15, 2020

@gkorland :

  • I would like if you are ok to implement the encoding of complex ArrayList in Jedis iteft, simply adding the following method to redis.clients.jedis.util.SafeEncoder: (if you are ok I will log an issue in JRedis and submit a new PR)
  public static Object encodeMany(Object dataToEncode) {
    Object returnValue = dataToEncode;
    if (dataToEncode instanceof byte[]) {
      returnValue = SafeEncoder.encode((byte[]) dataToEncode);
    } else if (dataToEncode instanceof ArrayList) {
      ArrayList arrayToDecode = (ArrayList)dataToEncode;
      ArrayList returnValueArray = new ArrayList(arrayToDecode.size());
      for (Object arrayEntry : arrayToDecode) {
        returnValueArray.add(encodeMany(arrayEntry));
      }
      returnValue = returnValueArray;
    }
    return returnValue;
  }

This will allow JRedisSearch to simply have a one-line change.

I need first to update JRedisSearch to JRedis 3.3 (#101)

Are you ok with this plan?

  • Update to 3.3.x
  • USe the new Encoder method that will be in snapshot

@gkorland
Copy link
Contributor

I'm OK, please prepare a PR to Jedis, the problem is how are you going to test it on Jedis?

@tgrall
Copy link
Contributor Author

tgrall commented Jun 16, 2020

  • Ok, I will prepare the PR
  • for testing, not found the good command yet, I will search

moving this discussion to Jedis, when I have created the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants