@@ -152,25 +152,36 @@ func ParseOneLine(snapshot string, var_names []string) (map[string]string, error
152152
153153func PopulateSnap (ss_value map [string ]string ) (schema.Web100Snap , error ) {
154154 var snap = & schema.Web100Snap {}
155+ var startTimeUsec int64
156+
157+ // First, extract StartTimeUsec value before all others so we can combine
158+ // it with StartTimeStamp below.
159+ if valueStr , ok := ss_value ["StartTimeUsec" ]; ok {
160+ value , err := strconv .ParseInt (valueStr , 10 , 64 )
161+ if err == nil {
162+ startTimeUsec = value
163+ }
164+ }
165+
166+ // Process every other snap key.
155167 for key := range ss_value {
156168 // Skip cid and PollTime. They are SideStream-specific fields, not web100 variables.
157169 if key == "cid" || key == "PollTime" {
158170 continue
159171 }
160- // We do special handling for this variable
172+ // Skip StartTimeUsec because this is not part of the Web100Snap struct.
161173 if key == "StartTimeUsec" {
162- // TODO: func CalculateStartTimeStamp() to get correct StartTimeStamp value.
163174 continue
164175 }
165176 x := reflect .ValueOf (snap ).Elem ().FieldByName (key )
166177
167178 switch x .Type ().String () {
168179 case "int64" :
169- value , err := strconv .Atoi (ss_value [key ])
180+ value , err := strconv .ParseInt (ss_value [key ], 10 , 64 )
170181 if err != nil {
171182 return * snap , err
172183 }
173- x .SetInt (int64 ( value ) )
184+ x .SetInt (value )
174185 case "string" :
175186 x .Set (reflect .ValueOf (ss_value [key ]))
176187 case "bool" :
@@ -183,6 +194,9 @@ func PopulateSnap(ss_value map[string]string) (schema.Web100Snap, error) {
183194 }
184195 }
185196 }
197+ // Combine the StartTimeStamp and StartTimeUsec values.
198+ snap .StartTimeStamp = snap .StartTimeStamp * 1000000 + startTimeUsec
199+
186200 // TODO: check whether snap has valid LocalAddress, RemAddress. Return error if not.
187201 return * snap , nil
188202}
0 commit comments