|
@@ -326,11 +326,19 @@ namespace STEP {
|
|
// -------------------------------------------------------------------------------
|
|
// -------------------------------------------------------------------------------
|
|
class LIST : public DataType
|
|
class LIST : public DataType
|
|
{
|
|
{
|
|
|
|
+ public:
|
|
|
|
+
|
|
|
|
+ ~LIST() {
|
|
|
|
+ BOOST_FOREACH(const DataType* dt, members) {
|
|
|
|
+ delete dt;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
public:
|
|
public:
|
|
|
|
|
|
// access a particular list index, throw std::range_error for wrong indices
|
|
// access a particular list index, throw std::range_error for wrong indices
|
|
const DataType* operator[] (size_t index) const {
|
|
const DataType* operator[] (size_t index) const {
|
|
- return members[index].get();
|
|
|
|
|
|
+ return members[index];
|
|
}
|
|
}
|
|
|
|
|
|
size_t GetSize() const {
|
|
size_t GetSize() const {
|
|
@@ -346,7 +354,8 @@ namespace STEP {
|
|
|
|
|
|
|
|
|
|
private:
|
|
private:
|
|
- typedef std::vector< boost::shared_ptr<const DataType> > MemberList;
|
|
|
|
|
|
+ // no smart pointer type to avoid any overhead
|
|
|
|
+ typedef std::vector< const DataType* > MemberList;
|
|
MemberList members;
|
|
MemberList members;
|
|
};
|
|
};
|
|
|
|
|
|
@@ -394,6 +403,11 @@ namespace STEP {
|
|
return converters.find(name) != converters.end();
|
|
return converters.find(name) != converters.end();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ const char* GetStaticStringForToken(const std::string& token) const {
|
|
|
|
+ ConverterMap::const_iterator it = converters.find(token);
|
|
|
|
+ return it == converters.end() ? NULL : (*it).first.c_str();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
template <size_t N>
|
|
template <size_t N>
|
|
const ConversionSchema& operator=( const SchemaEntry (& schemas)[N]) {
|
|
const ConversionSchema& operator=( const SchemaEntry (& schemas)[N]) {
|
|
@@ -579,7 +593,7 @@ namespace STEP {
|
|
friend class DB;
|
|
friend class DB;
|
|
public:
|
|
public:
|
|
|
|
|
|
- LazyObject(DB& db, uint64_t id,uint64_t line,const std::string& type,const std::string& args);
|
|
|
|
|
|
+ LazyObject(DB& db, uint64_t id, uint64_t line, const char* type,const char* args);
|
|
~LazyObject();
|
|
~LazyObject();
|
|
|
|
|
|
public:
|
|
public:
|
|
@@ -636,17 +650,24 @@ namespace STEP {
|
|
return type != atype;
|
|
return type != atype;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ uint64_t GetID() const {
|
|
|
|
+ return id;
|
|
|
|
+ }
|
|
|
|
+
|
|
private:
|
|
private:
|
|
|
|
|
|
void LazyInit() const;
|
|
void LazyInit() const;
|
|
|
|
|
|
private:
|
|
private:
|
|
|
|
|
|
- const uint64_t id, line;
|
|
|
|
- const std::string type;
|
|
|
|
|
|
+ mutable uint64_t id;
|
|
|
|
+ const char* const type;
|
|
DB& db;
|
|
DB& db;
|
|
|
|
|
|
- const EXPRESS::LIST* conv_args;
|
|
|
|
|
|
+ union {
|
|
|
|
+ mutable const EXPRESS::LIST* conv_args;
|
|
|
|
+ mutable const char* args;
|
|
|
|
+ };
|
|
mutable Object* obj;
|
|
mutable Object* obj;
|
|
};
|
|
};
|
|
|
|
|
|
@@ -815,21 +836,24 @@ namespace STEP {
|
|
|
|
|
|
public:
|
|
public:
|
|
|
|
|
|
- // objects indexed by ID
|
|
|
|
- typedef std::map<uint64_t,boost::shared_ptr<const LazyObject> > ObjectMap;
|
|
|
|
|
|
+ // objects indexed by ID - this can grow pretty large (i.e some hundred million
|
|
|
|
+ // entries), so use raw pointers to avoid *any* overhead.
|
|
|
|
+ typedef std::map<uint64_t,const LazyObject* > ObjectMap;
|
|
|
|
|
|
// objects indexed by their declarative type, but only for those that we truly want
|
|
// objects indexed by their declarative type, but only for those that we truly want
|
|
typedef std::set< const LazyObject*> ObjectSet;
|
|
typedef std::set< const LazyObject*> ObjectSet;
|
|
typedef std::map<std::string, ObjectSet > ObjectMapByType;
|
|
typedef std::map<std::string, ObjectSet > ObjectMapByType;
|
|
|
|
|
|
|
|
+ // list of types for which to keep inverse indices for all references
|
|
|
|
+ // that the respective objects keep.
|
|
|
|
+ // the list keeps pointers to strings in static storage
|
|
|
|
+ typedef std::set<const char*> InverseWhitelist;
|
|
|
|
+
|
|
// references - for each object id the ids of all objects which reference it
|
|
// references - for each object id the ids of all objects which reference it
|
|
|
|
+ // this is used to simulate STEP inverse indices for selected types.
|
|
typedef std::step_unordered_multimap<uint64_t, uint64_t > RefMap;
|
|
typedef std::step_unordered_multimap<uint64_t, uint64_t > RefMap;
|
|
typedef std::pair<RefMap::const_iterator,RefMap::const_iterator> RefMapRange;
|
|
typedef std::pair<RefMap::const_iterator,RefMap::const_iterator> RefMapRange;
|
|
|
|
|
|
- // list of types for which to keep inverse indices for all references
|
|
|
|
- // the respective objects keep.
|
|
|
|
- typedef std::set<std::string> InverseWhitelist;
|
|
|
|
-
|
|
|
|
private:
|
|
private:
|
|
|
|
|
|
DB(boost::shared_ptr<StreamReaderLE> reader)
|
|
DB(boost::shared_ptr<StreamReaderLE> reader)
|
|
@@ -838,6 +862,14 @@ namespace STEP {
|
|
, evaluated_count()
|
|
, evaluated_count()
|
|
{}
|
|
{}
|
|
|
|
|
|
|
|
+ public:
|
|
|
|
+
|
|
|
|
+ ~DB() {
|
|
|
|
+ BOOST_FOREACH(ObjectMap::value_type& o, objects) {
|
|
|
|
+ delete o.second;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
public:
|
|
public:
|
|
|
|
|
|
uint64_t GetObjectCount() const {
|
|
uint64_t GetObjectCount() const {
|
|
@@ -869,7 +901,7 @@ namespace STEP {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- bool KeepInverseIndicesForType(const std::string& type) const {
|
|
|
|
|
|
+ bool KeepInverseIndicesForType(const char* const type) const {
|
|
return inv_whitelist.find(type) != inv_whitelist.end();
|
|
return inv_whitelist.find(type) != inv_whitelist.end();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -878,7 +910,7 @@ namespace STEP {
|
|
const LazyObject* GetObject(uint64_t id) const {
|
|
const LazyObject* GetObject(uint64_t id) const {
|
|
const ObjectMap::const_iterator it = objects.find(id);
|
|
const ObjectMap::const_iterator it = objects.find(id);
|
|
if (it != objects.end()) {
|
|
if (it != objects.end()) {
|
|
- return (*it).second.get();
|
|
|
|
|
|
+ return (*it).second;
|
|
}
|
|
}
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
@@ -932,12 +964,12 @@ namespace STEP {
|
|
return splitter;
|
|
return splitter;
|
|
}
|
|
}
|
|
|
|
|
|
- void InternInsert(boost::shared_ptr<const LazyObject> lz) {
|
|
|
|
- objects[lz->id] = lz;
|
|
|
|
|
|
+ void InternInsert(const LazyObject* lz) {
|
|
|
|
+ objects[lz->GetID()] = lz;
|
|
|
|
|
|
const ObjectMapByType::iterator it = objects_bytype.find( lz->type );
|
|
const ObjectMapByType::iterator it = objects_bytype.find( lz->type );
|
|
if (it != objects_bytype.end()) {
|
|
if (it != objects_bytype.end()) {
|
|
- (*it).second.insert(lz.get());
|
|
|
|
|
|
+ (*it).second.insert(lz);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -954,7 +986,9 @@ namespace STEP {
|
|
|
|
|
|
void SetInverseIndicesToTrack( const char* const* types, size_t N ) {
|
|
void SetInverseIndicesToTrack( const char* const* types, size_t N ) {
|
|
for(size_t i = 0; i < N;++i) {
|
|
for(size_t i = 0; i < N;++i) {
|
|
- inv_whitelist.insert(types[i]);
|
|
|
|
|
|
+ const char* const sz = schema->GetStaticStringForToken(types[i]);
|
|
|
|
+ ai_assert(sz);
|
|
|
|
+ inv_whitelist.insert(sz);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|