Well, the distance calculation depends on the distance_mode enum:

1 - per-km - distance values will be computed by computing the length of the shape between the two stops.  shape_dist_taveled values will be ignored (since they are unit-less) but instead the distance between lat-lon points belonging to the shape will be computed directly.  This is necessarily a bit approximate, but should hopefully give the rider a reasonably close value.
2 - per-zone - compute the number of zones traversed by an intinerary
3 - per-stop - compute the number of stops traversed by an itinerary

I'm not sure it makes sense to include a "units_traveled" for each pair of origin_id and destination_id values.  If you are going to be including the entire stop-to-stop fare matrix in the GTFS, why would you need distance-based pricing at that point?  You could just specify the price as a fare_attribute directly.