> > Unfortunately, if the matrix ISN'T sparse, that technique > is horribly > > inefficient. If the matrix is full, the client should convert pid > > names to index numbers (sort the PID names, use binary > search to get > > the index), and then store the costs in a conventional > float[N][N] array. > > Could this be done on the fly while reading the JSON data > structures from the network? ...
Is there an existing JSON parser libary that supports such "on-the-fly" parsing (stream-like)? The libraries I have looked at so far typically parse a buffer with the whole JSON data. > > And, of course, that technique is wasteful for a sparse cost matrix. > > > > So the client has to guess how "sparse" the cost matrix really is. > > ... or do I have to read all the JSON stuff into a temporary > buffer, then decide whether to go for a hash or an array. If > the array, do pid name -> index mapping, identify the highest > index, allocate array and eventually fill it? That would be 3 > passes or more? Out of my head, I'd think that multiple passes will be needed when using standard JSON libraries. Obviously, an ALTO implementation can implement own JSON parsing logic, but we'd better not assume this. Michael _______________________________________________ alto mailing list [email protected] https://www.ietf.org/mailman/listinfo/alto
