l

    Lilly

    1 year ago
    Hi, I want to filter data that comes from a bluetooth device. The data I get from this device is a bunch of "Parameter", so after parsing this data I have a list of sth like this: { key: "Parameter1", data: { <a bunch of bytes> } The amount of "Parameter" is at least 100. The problem I have is that I need to group these 100 "Parameter" by specific criteria for my UI. For example 30 "Parameter" are of type "Status", but I don't have the information which Parameter is of which type. My old approach uses a List with the possible "Status" "Parameter" and while iterating over the whole "Parameter" list, I do the filtering. I have multiple such groups. I'm looking for a solution where I have just one big table where I can query from, e.g. "get all Pareameter of type Status". My initial idea was a database but this might be overpowered. So my second idea is to use a json file and perform some filter when deserialize. Can you guys give me an advice, how to solve this properly? When you think, JSON is suffiecient for this, can the serialization lib perform filtering on deserialization? EDIT: tl;tr: I get uncomplete data from a remote device but want to reorganize (filter/group) this data by specific missing criteria that I don't have and that I need to grab from a database or a file
    Nikky

    Nikky

    1 year ago
    are those separate executables? if they are in the same executable why would you serialize that to a string/file and parse it again? your old approach seems sensible i would try to keep it in memory maybe
    groupBy
    the parameter type so you have a data structure like:
    Map<ParameterType, List<Parameter>>
    that should make lookups slightly nicer if each key can only appear once.. then you can convert the list of pairs to a map as well
    l

    Lilly

    1 year ago
    @Nikky
    are those separate executables?
    No. Just imagine you have connected to a bluetooth classic device and you get a bunch of bytearrays ("packets") whereas one packet has a specific format: ParameterName as String, ParameterNameLength as Int, DataLength as Int, Data as ByteArray --> this represents 1 Parameter When all packets have been arrived, I parse them to get a
    Map<String, ByteArray>
    . The problem is that I get hundreds of Parameter but not grouped, e.g. grouped by Parameter that are not "Configurable" and are just "Status" Parameter. You have to know that the communication is bidirectional, that says, after modifying the configurable Parameters (some are just 0x00 or 0x01 boolean flags to enable/disable something on the bt device), I have to send them back to the device. I have problems with the huge amount of Parameter and grouping them for the UI. How do I know which of them are for example of category "Status" and which are "Configurable". I would have to name every single "Status" Parameter. That is what I'm currently doing. I have a List of Status Parameter in memory, a list of Configurable Parameter and so on (I have multiple such lists, cluttered across the app). I'm looking for a solution to have just 1 big table (data structure) where all Parameter are listed but with more information and where I can apply complex grouping, filtering, so I don't need to have multiple lists all over the app to do grouping/filtering. This one big table can be a database or a JSON file and the access would be a one-way (read-only). I thought the serialization lib is also for deserialization. I don't want to serialize anything