jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
anomaly_base.cpp
Go to the documentation of this file.
1 // Jubatus: Online machine learning framework for distributed environment
2 // Copyright (C) 2012 Preferred Networks and Nippon Telegraph and Telephone Corporation.
3 //
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License version 2.1 as published by the Free Software Foundation.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 
17 #include "anomaly_base.hpp"
18 
19 #include <algorithm>
20 #include <cmath>
21 #include <string>
22 #include <vector>
23 
24 #include "jubatus/util/lang/cast.h"
25 #include "../common/vector_util.hpp"
26 
27 using jubatus::util::lang::lexical_cast;
28 
29 namespace jubatus {
30 namespace core {
31 namespace anomaly {
32 
34 }
35 
37 }
38 
40  uint64_t max_id = 0;
41  std::vector<std::string> ids;
42  get_all_row_ids(ids);
43  for (std::vector<std::string>::const_iterator it = ids.begin();
44  it != ids.end(); ++it) {
45  try {
46  uint64_t id = lexical_cast<uint64_t>(*it);
47  if (id > max_id) {
48  max_id = id;
49  }
50  } catch (const std::bad_cast& e) {
51  // Do nothing for non-numeric IDs
52  continue;
53  }
54  }
55  return max_id;
56 }
57 
58 } // namespace anomaly
59 } // namespace core
60 } // namespace jubatus
virtual void get_all_row_ids(std::vector< std::string > &ids) const =0