Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
EventSequence.java
Go to the documentation of this file.
1 // Copyright 2012 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 package com.cloudera.impala.util;
16 
17 import java.util.List;
18 
19 import com.cloudera.impala.thrift.TEventSequence;
20 
21 import com.google.common.collect.Lists;
22 
27 public class EventSequence {
28  private final List<Long> timestamps_ = Lists.newArrayList();
29  private final List<String> labels_ = Lists.newArrayList();
30 
31  private final long startTime_;
32  private final String name_;
33 
34  public EventSequence(String name) {
35  name_ = name;
36  startTime_ = System.nanoTime();
37  }
38 
42  public void markEvent(String label) {
43  // Timestamps should be in ns resolution
44  timestamps_.add(System.nanoTime() - startTime_);
45  labels_.add(label);
46  }
47 
48  public TEventSequence toThrift() {
49  TEventSequence ret = new TEventSequence();
50  ret.timestamps = timestamps_;
51  ret.labels = labels_;
52  ret.name = name_;
53  return ret;
54  }
55 }
string name
Definition: cpu-info.cc:50