0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PhantomRangeMap.cc
Go to the documentation of this file.
1 /* -*- c++ -*-
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; version 3 of the
9  * License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
22 #include "Common/Compat.h"
23 
25 
26 #include "PhantomRangeMap.h"
27 
28 using namespace std;
29 using namespace Hypertable;
30 
31 
32 PhantomRangeMap::PhantomRangeMap(int plan_generation) :
33  m_plan_generation(plan_generation), m_state(0) {
34  m_tableinfo_map = make_shared<TableInfoMap>();
35 }
36 
37 void PhantomRangeMap::reset(int plan_generation) {
38  m_plan_generation = plan_generation;
39  m_state = 0;
40  for (Map::iterator iter = m_map.begin(); iter != m_map.end(); ++iter)
41  iter->second->purge_incomplete_fragments();
42 }
43 
44 
46  const RangeState &state, SchemaPtr schema,
47  const vector<int32_t> &fragments) {
48  if (m_map.find(spec) == m_map.end()) {
49  QualifiedRangeSpec copied_spec(m_arena, spec);
50  RangeState copied_state(m_arena, state);
51  m_map[copied_spec] =
52  make_shared<PhantomRange>(copied_spec, copied_state, schema, fragments);
53  }
54 }
55 
56 void PhantomRangeMap::get(const QualifiedRangeSpec &spec, PhantomRangePtr &phantom_range) {
57  Map::iterator it = m_map.find(spec);
58  if (it == m_map.end())
59  phantom_range = 0;
60  else
61  phantom_range = it->second;
62 }
63 
65  return m_state == 0;
66 }
67 
71 }
72 
75 }
76 
77 
80 }
81 
85 }
86 
89 }
90 
94 }
95 
98 }
STL namespace.
#define HT_ASSERT(_e_)
Definition: Logger.h:396
Declarations for QualifiedRangeSpec and QualifiedRangeSpecManaged.
Compatibility Macros for C/C++.
Hypertable definitions
void get(const QualifiedRangeSpec &range_spec, PhantomRangePtr &phantom_range)
Gets the phantom range if it is in map.
TableInfoMapPtr m_tableinfo_map
std::shared_ptr< PhantomRange > PhantomRangePtr
Shared smart pointer to PhantomRange.
Definition: PhantomRange.h:120
void reset(int plan_generation)
Qualified (with table identifier) range specification.
std::shared_ptr< Schema > SchemaPtr
Smart pointer to Schema.
Definition: Schema.h:465
Range state.
Definition: RangeState.h:48
void insert(const QualifiedRangeSpec &range, const RangeState &state, SchemaPtr schema, const vector< int32_t > &fragments)
Inserts a phantom range.