IECoreArnoldPreview::Renderer : Cache shader hashes to avoid rehashing

--- src/GafferArnold/IECoreArnoldPreview/Renderer.cpp
+++ src/GafferArnold/IECoreArnoldPreview/Renderer.cpp
@@ -592,11 +592,23 @@
 		// Can be called concurrently with other get() calls.
 		ArnoldShaderPtr get( const IECore::ObjectVector *shader )
 		{
+			// Rehashing shaders is expensive, so we keep a map of ObjectVector addresses
+			// to hash values.  In order to ensure there isn't a tiny risk of freeing one
+			// of these addresses and constructing a different ObjectVector at the same
+			// location, the hash keys are shared pointers which will keep these
+			// ObjectVectors alive.  We clear them out before the render starts in clearUnused()
+			HashCache::accessor ha;
+			m_hashCache.insert( ha, shader );
+			if( ha->second == IECore::MurmurHash() )
+			{
+				ha->second = shader->Object::hash();
+			}
+
 			Cache::accessor a;
-			m_cache.insert( a, shader->Object::hash() );
+			m_cache.insert( a, ha->second );
 			if( !a->second )
 			{
-				const std::string namePrefix = "shader:" + shader->Object::hash().toString() + ":";
+				const std::string namePrefix = "shader:" + ha->second.toString() + ":";
 				a->second = new ArnoldShader( shader, m_nodeDeleter, namePrefix, m_parentNode );
 			}
 			return a->second;
@@ -605,6 +617,23 @@
 		// Must not be called concurrently with anything.
 		void clearUnused()
 		{
+			vector<IECore::ConstObjectVectorPtr> toEraseHash;
+			for( HashCache::iterator it = m_hashCache.begin(), eIt = m_hashCache.end(); it != eIt; ++it )
+			{
+				if( it->first->refCount() == 1 )
+				{
+					// Only one reference - this is ours, so
+					// nothing outside of the cache is using the
+					// object vector we're keeping alive to match
+					// the shader hash.
+					toEraseHash.push_back( it->first );
+				}
+			}
+			for( vector<IECore::ConstObjectVectorPtr>::const_iterator it = toEraseHash.begin(), eIt = toEraseHash.end(); it != eIt; ++it )
+			{
+				m_hashCache.erase( *it );
+			}
+
 			vector<IECore::MurmurHash> toErase;
 			for( Cache::iterator it = m_cache.begin(), eIt = m_cache.end(); it != eIt; ++it )
 			{
@@ -635,9 +664,11 @@
 		NodeDeleter m_nodeDeleter;
 		AtNode *m_parentNode;

+		typedef tbb::concurrent_hash_map<IECore::ConstObjectVectorPtr, IECore::MurmurHash> HashCache;
+		HashCache m_hashCache;
+
 		typedef tbb::concurrent_hash_map<IECore::MurmurHash, ArnoldShaderPtr> Cache;
 		Cache m_cache;
-
 };

 IE_CORE_DECLAREPTR( ShaderCache )


TS-1251 Adding ink_port.h include since this relies on it.

--- mgmt/cli/cliAppInit.cc
+++ mgmt/cli/cliAppInit.cc
@@ -53,6 +53,7 @@
 #include "ShowCmd.h"
 #include "ConfigCmd.h"
 #include "CliCreateCommands.h"
+#include "ink_port.h"

 #if HAVE_EDITLINE_READLINE_H
 #include <editline/readline.h>


Experimental change

Experimental change

--- src/estimate-ngram.cpp
+++ src/estimate-ngram.cpp
@@ -32,7 +32,7 @@
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.   //
 ////////////////////////////////////////////////////////////////////////////

-
+#include <fenv.h>

 #include <vector>
 #include <string>
@@ -209,6 +209,7 @@
   vector<double> perps;
   vector<double> logs;
 //   char buffer[BUFFERSIZE];
+  feenableexcept(FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW);
   double p;
   Logger::Log(1, "[LL] Loading eval set %s...\n", opts["text"]); // [i].c_str());
   NgramLM lm(order);


databaseExists.

databaseExists.

--- libcontextsubscriber/unit-tests/infocdbbackend/infocdbbackendunittest.cpp
+++ libcontextsubscriber/unit-tests/infocdbbackend/infocdbbackendunittest.cpp
@@ -32,6 +32,7 @@

 private slots:
     void initTestCase();
+    void databaseExists();
     void listKeys();
     void listPlugins();
     void listKeysForPlugin();
@@ -64,6 +65,11 @@
     utilSetEnv("CONTEXT_PROVIDERS", LOCAL_DIR);
     utilSetEnv("CONTEXT_CORE_DECLARATIONS", "/dev/null");
     backend = new InfoCdbBackend();
+}
+
+void InfoCdbBackendUnitTest::databaseExists()
+{
+    QCOMPARE(backend->databaseExists(), true);
 }

 void InfoCdbBackendUnitTest::listKeys()


tests/sstables: make sstable_reader return flat_mutation_reader

--- tests/sstable_datafile_test.cc
+++ tests/sstable_datafile_test.cc
@@ -51,6 +51,7 @@
 #include "simple_schema.hh"
 #include "memtable-sstable.hh"
 #include "tests/sstable_assertions.hh"
+#include "flat_mutation_reader_assertions.hh"

 #include <stdio.h>
 #include <ftw.h>
@@ -1000,13 +1001,13 @@
 }

 // mutation_reader for sstable keeping all the required objects alive.
-static mutation_reader sstable_reader(shared_sstable sst, schema_ptr s) {
-    return sst->as_mutation_source()(s);
-
-}
-
-static mutation_reader sstable_reader(shared_sstable sst, schema_ptr s, const dht::partition_range& pr) {
-    return sst->as_mutation_source()(s, pr);
+static flat_mutation_reader sstable_reader(shared_sstable sst, schema_ptr s) {
+    return sst->as_mutation_source().make_flat_mutation_reader(s, query::full_partition_range, s->full_slice());
+
+}
+
+static flat_mutation_reader sstable_reader(shared_sstable sst, schema_ptr s, const dht::partition_range& pr) {
+    return sst->as_mutation_source().make_flat_mutation_reader(s, pr, s->full_slice());
 }

 SEASTAR_TEST_CASE(compaction_manager_test) {
@@ -1128,9 +1129,7 @@
                 //   nadav - deleted partition
                 return open_sstable(s, "tests/sstables/tests-temporary", generation).then([s] (shared_sstable sst) {
                     auto reader = make_lw_shared(sstable_reader(sst, s)); // reader holds sst and s alive.
-                    return (*reader)().then([] (auto sm) {
-                        return mutation_from_streamed_mutation(std::move(sm));
-                    }).then([reader, s] (mutation_opt m) {
+                    return read_mutation_from_flat_mutation_reader(s, *reader).then([reader, s] (mutation_opt m) {
                         BOOST_REQUIRE(m);
                         BOOST_REQUIRE(m->key().equal(*s, partition_key::from_singular(*s, data_value(sstring("jerry")))));
                         BOOST_REQUIRE(!m->partition().partition_tombstone());
@@ -1141,9 +1140,7 @@
                         auto &cells = row.cells();
                         BOOST_REQUIRE(cells.cell_at(s->get_column_definition("age")->id).as_atomic_cell().value() == bytes({0,0,0,40}));
                         BOOST_REQUIRE(cells.cell_at(s->get_column_definition("height")->id).as_atomic_cell().value() == bytes({0,0,0,(char)170}));
-                        return (*reader)();
-                    }).then([] (auto sm) {
-                        return mutation_from_streamed_mutation(std::move(sm));
+                        return read_mutation_from_flat_mutation_reader(s, *reader);
                     }).then([reader, s] (mutation_opt m) {
                         BOOST_REQUIRE(m);
                         BOOST_REQUIRE(m->key().equal(*s, partition_key::from_singular(*s, data_value(sstring("tom")))));
@@ -1155,9 +1152,7 @@
                         auto &cells = row.cells();
                         BOOST_REQUIRE(cells.cell_at(s->get_column_definition("age")->id).as_atomic_cell().value() == bytes({0,0,0,20}));
                         BOOST_REQUIRE(cells.cell_at(s->get_column_definition("height")->id).as_atomic_cell().value() == bytes({0,0,0,(char)180}));
-                        return (*reader)();
-                    }).then([] (auto sm) {
-                        return mutation_from_streamed_mutation(std::move(sm));
+                        return read_mutation_from_flat_mutation_reader(s, *reader);
                     }).then([reader, s] (mutation_opt m) {
                         BOOST_REQUIRE(m);
                         BOOST_REQUIRE(m->key().equal(*s, partition_key::from_singular(*s, data_value(sstring("john")))));
@@ -1169,17 +1164,15 @@
                         auto &cells = row.cells();
                         BOOST_REQUIRE(cells.cell_at(s->get_column_definition("age")->id).as_atomic_cell().value() == bytes({0,0,0,20}));
                         BOOST_REQUIRE(cells.find_cell(s->get_column_definition("height")->id) == nullptr);
-                        return (*reader)();
-                    }).then([] (auto sm) {
-                        return mutation_from_streamed_mutation(std::move(sm));
+                        return read_mutation_from_flat_mutation_reader(s, *reader);
                     }).then([reader, s] (mutation_opt m) {
                         BOOST_REQUIRE(m);
                         BOOST_REQUIRE(m->key().equal(*s, partition_key::from_singular(*s, data_value(sstring("nadav")))));
                         BOOST_REQUIRE(m->partition().partition_tombstone());
                         auto &rows = m->partition().clustered_rows();
                         BOOST_REQUIRE(rows.calculate_size() == 0);
-                        return (*reader)();
-                    }).then([reader] (streamed_mutation_opt m) {
+                        return read_mutation_from_flat_mutation_reader(s, *reader);
+                    }).then([reader] (mutation_opt m) {
                         BOOST_REQUIRE(!m);
                     });
                 });
@@ -1318,9 +1311,9 @@
         auto reader = sstable_reader(sst, s); // reader holds sst and s alive.
         auto keys = make_lw_shared<std::vector<partition_key>>();

-        return do_with(std::move(reader), [generations, s, keys] (mutation_reader& reader) {
+        return do_with(std::move(reader), [generations, s, keys] (flat_mutation_reader& reader) {
             return do_for_each(*generations, [&reader, s, keys] (unsigned long generation) mutable {
-                return reader().then([generation, keys] (streamed_mutation_opt m) {
+                return read_mutation_from_flat_mutation_reader(s, reader).then([generation, keys] (mutation_opt m) {
                     BOOST_REQUIRE(m);
                     keys->push_back(m->key());
                 });
@@ -1631,7 +1624,7 @@
             return reusable_sst(s, "tests/sstables/tests-temporary", 47).then([s] (auto sstp) mutable {
                 auto reader = make_lw_shared(sstable_reader(sstp, s));
                 return repeat([reader] {
-                    return (*reader)().then([] (streamed_mutation_opt m) {
+                    return (*reader)().then([] (mutation_fragment_opt m) {
                         if (!m) {
                             return make_ready_future<stop_iteration>(stop_iteration::yes);
                         }
@@ -2366,9 +2359,7 @@

         auto assert_that_produces_dead_cell = [&] (auto& sst, partition_key& key) {
             auto reader = make_lw_shared(sstable_reader(sst, s));
-            (*reader)().then([&key] (auto sm) {
-                return mutation_from_streamed_mutation(std::move(sm));
-            }).then([reader, s, &key] (mutation_opt m) {
+            read_mutation_from_flat_mutation_reader(s, *reader).then([reader, s, &key] (mutation_opt m) {
                 BOOST_REQUIRE(m);
                 BOOST_REQUIRE(m->key().equal(*s, key));
                 auto& rows = m->partition().clustered_rows();
@@ -2378,7 +2369,7 @@
                 BOOST_REQUIRE_EQUAL(cells.size(), 1);
                 BOOST_REQUIRE(!cells.cell_at(s->get_column_definition("value")->id).as_atomic_cell().is_live());
                 return (*reader)();
-            }).then([reader, s] (streamed_mutation_opt m) {
+            }).then([reader, s] (mutation_fragment_opt m) {
                 BOOST_REQUIRE(!m);
             }).get();
         };
@@ -2541,9 +2532,7 @@
     auto f = sst->load();
     return f.then([sst, s] {
         auto reader = make_lw_shared(sstable_reader(sst, s));
-        return (*reader)().then([] (auto sm) {
-            return mutation_from_streamed_mutation(std::move(sm));
-        }).then([reader, s] (mutation_opt m) {
+        return read_mutation_from_flat_mutation_reader(s, *reader).then([reader, s] (mutation_opt m) {
             BOOST_REQUIRE(m);
             BOOST_REQUIRE(m->key().equal(*s, partition_key::from_singular(*s, 0)));
             auto& rows = m->partition().clustered_rows();
@@ -2554,7 +2543,7 @@
             BOOST_REQUIRE_EQUAL(cells.size(), 1);
             BOOST_REQUIRE_EQUAL(cells.cell_at(s->get_column_definition("e")->id).as_atomic_cell().value(), int32_type->decompose(5));
             return (*reader)();
-        }).then([reader, s] (streamed_mutation_opt m) {
+        }).then([reader, s] (mutation_fragment_opt m) {
             BOOST_REQUIRE(!m);
         });
     });
@@ -2604,12 +2593,14 @@
                 auto newsst = (*new_tables)[0];
                 BOOST_REQUIRE(newsst->generation() == 52);
                 auto reader = make_lw_shared(sstable_reader(newsst, s));
-                return (*reader)().then([s, reader, key] (streamed_mutation_opt m) {
+                return (*reader)().then([s, reader, key] (mutation_fragment_opt m) {
                     BOOST_REQUIRE(m);
+                    BOOST_REQUIRE(m->is_partition_start());
                     auto pkey = partition_key::from_exploded(*s, {to_bytes(key)});
-                    BOOST_REQUIRE(m->key().equal(*s, pkey));
+                    BOOST_REQUIRE(m->as_partition_start().key().key().equal(*s, pkey));
+                    reader->next_partition();
                     return (*reader)();
-                }).then([reader] (streamed_mutation_opt m) {
+                }).then([reader] (mutation_fragment_opt m) {
                     BOOST_REQUIRE(!m);
                 });
             }).then([cm, cf, cl_stats] {});
@@ -2620,22 +2611,24 @@
 void test_sliced_read_row_presence(shared_sstable sst, schema_ptr s, const query::partition_slice& ps,
     std::vector<std::pair<partition_key, std::vector<clustering_key>>> expected)
 {
-    auto reader = sst->as_mutation_source()(s, query::full_partition_range, ps);
+    auto reader = sst->as_mutation_source().make_flat_mutation_reader(s, query::full_partition_range, ps);

     partition_key::equality pk_eq(*s);
     clustering_key::equality ck_eq(*s);

-    auto smopt = reader().get0();
-    while (smopt) {
+    auto mfopt = reader().get0();
+    while (mfopt) {
+        BOOST_REQUIRE(mfopt->is_partition_start());
         auto it = std::find_if(expected.begin(), expected.end(), [&] (auto&& x) {
-            return pk_eq(x.first, smopt->key());
+            return pk_eq(x.first, mfopt->as_partition_start().key().key());
         });
         BOOST_REQUIRE(it != expected.end());
         auto expected_cr = std::move(it->second);
         expected.erase(it);

-        auto mfopt = (*smopt)().get0();
-        while (mfopt) {
+        mfopt = reader().get0();
+        BOOST_REQUIRE(mfopt);
+        while (!mfopt->is_end_of_partition()) {
             if (mfopt->is_clustering_row()) {
                 auto& cr = mfopt->as_clustering_row();
                 auto it = std::find_if(expected_cr.begin(), expected_cr.end(), [&] (auto&& x) {
@@ -2647,11 +2640,12 @@
                 BOOST_REQUIRE(it != expected_cr.end());
                 expected_cr.erase(it);
             }
-            mfopt = (*smopt)().get0();
+            mfopt = reader().get0();
+            BOOST_REQUIRE(mfopt);
         }
         BOOST_REQUIRE(expected_cr.empty());

-        smopt = reader().get0();
+        mfopt = reader().get0();
     }
     BOOST_REQUIRE(expected.empty());
 }
@@ -2772,16 +2766,16 @@
             .with_column("r", int32_type)
             .build();
         clustering_key::equality ck_eq(*s);
+        auto pkey = partition_key::from_exploded(*s, { int32_type->decompose(0) });
+        auto dkey = dht::global_partitioner().decorate_key(*s, std::move(pkey));

         auto sst = make_sstable(s, "tests/sstables/wrong_range_tombstone_order", 1, sstables::sstable::version_types::ka, big);
         sst->load().get0();
         auto reader = sstable_reader(sst, s);

-        auto smopt = reader().get0();
-        BOOST_REQUIRE(smopt);
-
         using kind = mutation_fragment::kind;
-        assert_that_stream(std::move(*smopt))
+        assert_that(std::move(reader))
+            .produces_partition_start(dkey)
             .produces(kind::range_tombstone, { 0 })
             .produces(kind::clustering_row, { 1 })
             .produces(kind::clustering_row, { 1, 1 })
@@ -2797,10 +2791,8 @@
             .produces(kind::range_tombstone, { 2, 1 })
             .produces(kind::range_tombstone, { 2, 2 })
             .produces(kind::range_tombstone, { 2, 2 })
+            .produces_partition_end()
             .produces_end_of_stream();
-
-        smopt = reader().get0();
-        BOOST_REQUIRE(!smopt);
     });
 }

@@ -2844,11 +2836,11 @@
             sst->load().get();
             auto reader = sstable_reader(sst, s);

-            auto smopt = reader().get0();
-            BOOST_REQUIRE(smopt);
-            auto& sm = *smopt;
-
-            auto mfopt = sm().get0();
+            auto mfopt = reader().get0();
+            BOOST_REQUIRE(mfopt);
+            BOOST_REQUIRE(mfopt->is_partition_start());
+
+            mfopt = reader().get0();
             BOOST_REQUIRE(mfopt);
             BOOST_REQUIRE(mfopt->is_clustering_row());
             const clustering_row* cr = &mfopt->as_clustering_row();
@@ -2876,7 +2868,7 @@
                 }
             });

-            mfopt = sm().get0();
+            mfopt = reader().get0();
             BOOST_REQUIRE(mfopt);
             BOOST_REQUIRE(mfopt->is_clustering_row());
             cr = &mfopt->as_clustering_row();
@@ -2889,11 +2881,12 @@
                 }
             });

-            mfopt = sm().get0();
+            mfopt = reader().get0();
+            BOOST_REQUIRE(mfopt);
+            BOOST_REQUIRE(mfopt->is_end_of_partition());
+
+            mfopt = reader().get0();
             BOOST_REQUIRE(!mfopt);
-
-            smopt = reader().get0();
-            BOOST_REQUIRE(!smopt);
         });
 }

@@ -3264,15 +3257,17 @@
         auto sst = make_sstable(s, "tests/sstables/promoted_index_read", 1, sstables::sstable::version_types::ka, big);
         sst->load().get0();

+        auto pkey = partition_key::from_exploded(*s, { int32_type->decompose(0) });
+        auto dkey = dht::global_partitioner().decorate_key(*s, std::move(pkey));
+
         auto rd = sstable_reader(sst, s);
-        auto smopt = rd().get0();
-        BOOST_REQUIRE(smopt);
-
         using kind = mutation_fragment::kind;
-        assert_that_stream(std::move(*smopt))
+        assert_that(std::move(rd))
+                .produces_partition_start(dkey)
                 .produces(kind::range_tombstone, { 0 })
                 .produces(kind::clustering_row, { 0, 0 })
                 .produces(kind::clustering_row, { 0, 1 })
+                .produces_partition_end()
                 .produces_end_of_stream();
     });
 }
@@ -3640,10 +3635,8 @@
                 .with_range(query::clustering_range::make_singular(ck2))
                 .with_range(query::clustering_range::make_singular(ck3))
                 .build();
-            mutation_reader rd = ms(table.schema(), query::full_partition_range, slice);
-            streamed_mutation_opt smo = rd().get0();
-            BOOST_REQUIRE(bool(smo));
-            assert_that_stream(std::move(*smo)).has_monotonic_positions();
+            flat_mutation_reader rd = ms.make_flat_mutation_reader(table.schema(), query::full_partition_range, slice);
+            assert_that(std::move(rd)).has_monotonic_positions();
         }
     });
 }
@@ -3693,7 +3686,7 @@
         auto sst = make_sstable(dir.path, flat_mutation_reader_from_mutations(partitions, streamed_mutation::forwarding::no), cfg);

         auto ms = as_mutation_source(sst);
-        auto rd = ms(table.schema(),
+        auto rd = ms.make_flat_mutation_reader(table.schema(),
             query::full_partition_range,
             table.schema()->full_slice(),
             default_priority_class(),
@@ -3701,33 +3694,35 @@
             streamed_mutation::forwarding::yes,
             mutation_reader::forwarding::yes);

+        auto assertions = assert_that(std::move(rd));
         // Consume first partition completely so that index is stale
         {
-            streamed_mutation_opt smo = rd().get0();
-            BOOST_REQUIRE(bool(smo));
-            BOOST_REQUIRE_EQUAL(0, consume_all(*smo));
-            smo->fast_forward_to(position_range::all_clustered_rows()).get();
-            BOOST_REQUIRE_EQUAL(rows_per_part, consume_all(*smo));
+            assertions
+                .produces_partition_start(keys[0])
+                .fast_forward_to(position_range::all_clustered_rows());
+            for (auto i = 0; i < rows_per_part; i++) {
+                assertions.produces_row_with_key(table.make_ckey(i));
+            }
+            assertions.produces_end_of_stream();
         }

         {
             auto base = rows_per_part;
-            streamed_mutation_opt smo = rd().get0();
-            BOOST_REQUIRE(bool(smo));
-
-            assert_that_stream(std::move(*smo))
-                .fwd_to(position_range(
+            assertions
+                .next_partition()
+                .produces_partition_start(keys[1])
+                .fast_forward_to(position_range(
                     position_in_partition::for_key(table.make_ckey(base)),
                     position_in_partition::for_key(table.make_ckey(base + 3))))
                 .produces_row_with_key(table.make_ckey(base))
                 .produces_row_with_key(table.make_ckey(base + 1))
                 .produces_row_with_key(table.make_ckey(base + 2))
-                .fwd_to(position_range(
+                .fast_forward_to(position_range(
                     position_in_partition::for_key(table.make_ckey(base + 5)),
                     position_in_partition::for_key(table.make_ckey(base + 6))))
                 .produces_row_with_key(table.make_ckey(base + 5))
                 .produces_end_of_stream()
-                .fwd_to(position_range(
+                .fast_forward_to(position_range(
                     position_in_partition::for_key(table.make_ckey(base + rows_per_part)), // Skip all rows in current partition
                     position_in_partition::after_all_clustered_rows()))
                 .produces_end_of_stream();
@@ -3736,17 +3731,16 @@
         // Consume few fragments then skip
         {
             auto base = rows_per_part * 2;
-            streamed_mutation_opt smo = rd().get0();
-            BOOST_REQUIRE(bool(smo));
-
-            assert_that_stream(std::move(*smo))
-                .fwd_to(position_range(
+            assertions
+                .next_partition()
+                .produces_partition_start(keys[2])
+                .fast_forward_to(position_range(
                     position_in_partition::for_key(table.make_ckey(base)),
                     position_in_partition::for_key(table.make_ckey(base + 3))))
                 .produces_row_with_key(table.make_ckey(base))
                 .produces_row_with_key(table.make_ckey(base + 1))
                 .produces_row_with_key(table.make_ckey(base + 2))
-                .fwd_to(position_range(
+                .fast_forward_to(position_range(
                     position_in_partition::for_key(table.make_ckey(base + rows_per_part - 1)), // last row
                     position_in_partition::after_all_clustered_rows()))
                 .produces_row_with_key(table.make_ckey(base + rows_per_part - 1))
@@ -3755,17 +3749,18 @@

         // Consume nothing from the next partition
         {
-            streamed_mutation_opt smo = rd().get0();
-            BOOST_REQUIRE(bool(smo));
+            assertions
+                .next_partition()
+                .produces_partition_start(keys[3])
+                .next_partition();
         }

         {
             auto base = rows_per_part * 4;
-            streamed_mutation_opt smo = rd().get0();
-            BOOST_REQUIRE(bool(smo));
-
-            assert_that_stream(std::move(*smo))
-                .fwd_to(position_range(
+            assertions
+                .next_partition()
+                .produces_partition_start(keys[4])
+                .fast_forward_to(position_range(
                     position_in_partition::for_key(table.make_ckey(base + rows_per_part - 1)), // last row
                     position_in_partition::after_all_clustered_rows()))
                 .produces_row_with_key(table.make_ckey(base + rows_per_part - 1))
@@ -4192,7 +4187,7 @@

         std::set<mutation, mutation_decorated_key_less_comparator> merged;
         merged.insert(mutations.begin(), mutations.end());
-        auto rd = assert_that(sst->as_mutation_source()(s));
+        auto rd = assert_that(sst->as_mutation_source().make_flat_mutation_reader(s, query::full_partition_range));
         auto keys_read = 0;
         for (auto&& m : merged) {
             keys_read++;
@@ -4202,7 +4197,7 @@
         BOOST_REQUIRE(keys_read == keys_written);

         auto r = dht::partition_range::make({mutations.back().decorated_key(), true}, {mutations.back().decorated_key(), true});
-        assert_that(sst->as_mutation_source()(s, r))
+        assert_that(sst->as_mutation_source().make_flat_mutation_reader(s, r))
             .produces(slice(mutations, r))
             .produces_end_of_stream();
     });
@@ -4257,25 +4252,29 @@
             };

             {
-                auto smopt = reader().get0();
-                BOOST_REQUIRE(smopt);
-                auto& sm = *smopt;
-                verify_row(sm().get0(), 28545);
-                verify_row(sm().get0(), 27967);
-                verify_row(sm().get0(), 28342);
-                verify_row(sm().get0(), 28325);
-                BOOST_REQUIRE(!sm().get0());
+                auto mfopt = reader().get0();
+                BOOST_REQUIRE(mfopt);
+                BOOST_REQUIRE(mfopt->is_partition_start());
+                verify_row(reader().get0(), 28545);
+                verify_row(reader().get0(), 27967);
+                verify_row(reader().get0(), 28342);
+                verify_row(reader().get0(), 28325);
+                mfopt = reader().get0();
+                BOOST_REQUIRE(mfopt);
+                BOOST_REQUIRE(mfopt->is_end_of_partition());
             }

             {
-                auto smopt = reader().get0();
-                BOOST_REQUIRE(smopt);
-                auto& sm = *smopt;
-                verify_row(sm().get0(), 28386);
-                verify_row(sm().get0(), 28378);
-                verify_row(sm().get0(), 28129);
-                verify_row(sm().get0(), 28260);
-                BOOST_REQUIRE(!sm().get0());
+                auto mfopt = reader().get0();
+                BOOST_REQUIRE(mfopt);
+                BOOST_REQUIRE(mfopt->is_partition_start());
+                verify_row(reader().get0(), 28386);
+                verify_row(reader().get0(), 28378);
+                verify_row(reader().get0(), 28129);
+                verify_row(reader().get0(), 28260);
+                mfopt = reader().get0();
+                BOOST_REQUIRE(mfopt);
+                BOOST_REQUIRE(mfopt->is_end_of_partition());
             }

             BOOST_REQUIRE(!reader().get0());
@@ -4398,9 +4397,9 @@

         {
             auto slice = partition_slice_builder(*s).with_range(query::clustering_range::make_singular({ck})).build();
-            assert_that(sst->as_mutation_source()(s, dht::partition_range::make_singular(dk), slice))
+            assert_that(sst->as_mutation_source().make_flat_mutation_reader(s, dht::partition_range::make_singular(dk), slice))
                     .produces(m)
                     .produces_end_of_stream();
         }
     });
-}+}


fixing DistanceGrid

fixing DistanceGrid

Former-commit-id: f770f3538be4f1b407f0dbbe835111a348b2d528

--- modules/SofaVolumetricData/DistanceGrid.cpp
+++ modules/SofaVolumetricData/DistanceGrid.cpp
@@ -27,8 +27,7 @@
 #include <fstream>
 #include <sofa/helper/system/gl.h>
 #include <sofa/helper/gl/template.h>
-#include <sofa/core/topology/BaseMeshTopology.h>
-#include <sofa/core/objectmodel/Base.h>
+//#include <sofa/core/topology/BaseMeshTopology.h>
 //#ifdef SOFA_HAVE_FLOWVR
 #include <flowvr/render/mesh.h>
 //#endif
@@ -99,14 +98,13 @@

 DistanceGrid* DistanceGrid::load(const std::string& filename, double scale, double sampling, int nx, int ny, int nz, Coord pmin, Coord pmax)
 {
-    sofa::core::objectmodel::Base* base;
     double absscale=fabs(scale);
     if (filename == "#cube")
     {
         float dim = (float)scale;
         int np = 5;
         Coord bbmin(-dim, -dim, -dim), bbmax(dim,dim,dim);
-        //base->sout << "bbox = <"<<bbmin<<">-<"<<bbmax<<">"<<base->sendl;
+        //std::cout << "bbox = <"<<bbmin<<">-<"<<bbmax<<">"<<std::endl;
         if (pmin[0]<=pmax[0])
         {
             pmin = bbmin;
@@ -123,12 +121,12 @@
                 if (bbmax[c] > pmax[c]) pmax[c] = bbmax[c];
             }
         }
-        //base->sout << "Creating cube distance grid in <"<<pmin<<">-<"<<pmax<<">"<<base->sendl;
+        //std::cout << "Creating cube distance grid in <"<<pmin<<">-<"<<pmax<<">"<<std::endl;
         DistanceGrid* grid = new DistanceGrid(nx, ny, nz, pmin, pmax);
         grid->calcCubeDistance(dim, np);
         if (sampling)
             grid->sampleSurface(sampling);
-        //base->sout << "Distance grid creation DONE."<< base->sendl;
+        //std::cout << "Distance grid creation DONE."<< std::endl;
         return grid;
     }
     else if (filename.length()>4 && filename.substr(filename.length()-4) == ".raw")
@@ -156,14 +154,14 @@
         flowvr::render::Mesh mesh;
         if (!mesh.load(filename.c_str()))
         {
-            base->serr << "ERROR loading FlowVR mesh file "<<filename<<base->sendl;
+            std::cerr << "ERROR loading FlowVR mesh file "<<filename<<std::endl;
             return NULL;
         }
         //std::cout << "bbox = "<<mesh.bb<<std::endl;

         if (!mesh.getAttrib(flowvr::render::Mesh::MESH_DISTMAP))
         {
-            base->serr << "ERROR: FlowVR mesh "<<filename<<" does not contain distance information. Please use flowvr-distmap."<<base->sendl;
+            std::cerr << "ERROR: FlowVR mesh "<<filename<<" does not contain distance information. Please use flowvr-distmap."<<std::endl;
             return NULL;
         }
         nx = mesh.distmap->nx;
@@ -173,7 +171,7 @@
         ftl::Vec3f fpmax = ftl::transform(mesh.distmap->mat,ftl::Vec3f((float)(nx-1),(float)(ny-1),(float)(nz-1)))*(float)absscale;
         pmin = Coord(fpmin.ptr());
         pmax = Coord(fpmax.ptr());
-        //base->sout << "Copying "<<nx<<"x"<<ny<<"x"<<nz<<" distance grid in <"<<pmin<<">-<"<<pmax<<">"<<base->sendl;
+        //std::cout << "Copying "<<nx<<"x"<<ny<<"x"<<nz<<" distance grid in <"<<pmin<<">-<"<<pmax<<">"<<std::endl;
         DistanceGrid* grid = new DistanceGrid(nx, ny, nz, pmin, pmax);
         for (int i=0; i< grid->nxnynz; i++)
             grid->dists[i] = mesh.distmap->data[i]*scale;
@@ -187,7 +185,7 @@
                 if (mesh.getGP0(i) >= 0)
                     ++nbpos;
             }
-            //base->sout << "Copying "<<nbpos<<" mesh vertices."<<base->sendl;
+            //std::cout << "Copying "<<nbpos<<" mesh vertices."<<std::endl;
             grid->meshPts.resize(nbpos);
             int p = 0;
             for (int i=0; i<mesh.nbg(); i++)
@@ -200,7 +198,7 @@
         else
         {
             int nbpos = mesh.nbp();
-            //base->sout << "Copying "<<nbpos<<" mesh vertices."<<base->sendl;
+            //std::cout << "Copying "<<nbpos<<" mesh vertices."<<std::endl;
             grid->meshPts.resize(nbpos);
             for (int i=0; i<nbpos; i++)
                 grid->meshPts[i] = Coord(mesh.getPP(i).ptr())*absscale;
@@ -212,7 +210,7 @@
         }
         else
             grid->computeBBox();
-        //base->sout<< "Distance grid creation DONE."<<base->sendl;
+        //std::cout<< "Distance grid creation DONE."<<std::endl;
         return grid;
     }
 //#endif
@@ -221,7 +219,7 @@
         sofa::helper::io::Mesh* mesh = sofa::helper::io::Mesh::Create(filename);
         const sofa::helper::vector<Vector3> & vertices = mesh->getVertices();

-        //base->sout <<"Computing bbox."<< base->sendl;
+        //std::cout <<"Computing bbox."<< std::endl;

         Coord bbmin, bbmax;
         if (!vertices.empty())
@@ -237,7 +235,7 @@
             bbmin *= absscale;
             bbmax *= absscale;
         }
-        //base->sout << "bbox = <"<<bbmin<<">-<"<<bbmax<<">"<<base->sendl;
+        //std::cout << "bbox = <"<<bbmin<<">-<"<<bbmax<<">"<<std::endl;

         if (pmin[0]<=pmax[0])
         {
@@ -255,21 +253,21 @@
                 if (bbmax[c] > pmax[c]) pmax[c] = bbmax[c];
             }
         }
-        //base->sout << "Creating distance grid in <"<<pmin<<">-<"<<pmax<<">"<<base->sendl;
+        //std::cout << "Creating distance grid in <"<<pmin<<">-<"<<pmax<<">"<<std::endl;
         DistanceGrid* grid = new DistanceGrid(nx, ny, nz, pmin, pmax);
-        //base->sout << "Computing distance field."<<base->sendl;
+        //std::cout << "Computing distance field."<<std::endl;
         grid->calcDistance(mesh, scale);
         if (sampling)
             grid->sampleSurface(sampling);
         else
         {
-            //base->sout << "Copying "<<vertices.size()<<" mesh vertices."<<base->sendl;
+            //std::cout << "Copying "<<vertices.size()<<" mesh vertices."<<std::endl;
             grid->meshPts.resize(vertices.size());
             for(unsigned int i=0; i<vertices.size(); i++)
                 grid->meshPts[i] = vertices[i]*absscale;
         }
         grid->computeBBox();
-        //base->sout << "Distance grid creation DONE."<<base->sendl;
+        //std::cout << "Distance grid creation DONE."<<std::endl;
         delete mesh;
         return grid;
     }


Unicode was easy, turns out. Next: m4as break on file not null check

--- ssmp/libdialog.cpp
+++ ssmp/libdialog.cpp
@@ -39,7 +39,9 @@
 		QFileInfo f = di.fileInfo();
 		if(isAudioFile(f))//Add this song to the database
 		{
-			TagLib::FileName fname = fpath.toStdString().c_str();
+			wchar_t wname[200]; //TODO: Better way than static?
+			wname[fpath.toWCharArray(wname)] = 0;
+			TagLib::FileName fname(wname);
 			QMap<QString, QString> stmap;
 			QMap<QString, int> itmap;


Move assert to end

Move assert to end

Former-commit-id: fdde600858ac760a2913b8d2a55603bd05a420e0

--- src/StaticLibrary.cpp
+++ src/StaticLibrary.cpp
@@ -37,7 +37,6 @@
 void create_ar_file(const std::vector<std::string> &src_files,
                     const std::string &dst_file, bool deterministic) {
     std::ofstream ar(dst_file, std::ofstream::out | std::ofstream::binary);
-    user_assert(ar.good());
     ar << "!<arch>\x0A";
     for (const std::string &src_path : src_files) {
         FileStat stat = file_stat(src_path);
@@ -69,6 +68,7 @@
             ar << src.rdbuf();
         }
     }
+    user_assert(ar.good());
 }

 void static_library_test() {


OSX: fix compile warning

OSX: fix compile warning

--- starcross_test.cpp
+++ starcross_test.cpp
@@ -238,6 +238,7 @@
         nextStep.pulseCount = m_DirectionalPulseCount;
         break;
     case SCT_STATE_NORTH_RETURN:
+    case SCT_STATE_DONE:
         nextStep.state = SCT_STATE_DONE;
         nextStep.direction = NONE;
         nextStep.pulseCount = 0;


sserver: reset DiffController when current diff reachs the max value.

--- src/StratumSession.cc
+++ src/StratumSession.cc
@@ -186,6 +186,14 @@

   // too fast
   if (sharesCount > expectedCount * kRateHigh) {
+    // curDiff_ * 2 will be zero if curDiff_ >= 2^63,
+    // so give up the diff adjustment and log it.
+    if (curDiff_ >= kMaxDiff_) {
+      LOG(INFO) << "DiffController: current diff (" << curDiff_ << ") too high, reset the controller";
+      resetCurDiff(kMaxDiff_);
+      return kMaxDiff_;
+    }
+
     while (sharesNum_.sum(k) > expectedCount) {
       setCurDiff(curDiff_ * 2);
       sharesNum_.mapDivide(2.0);


TrackerPM: no black outside

TrackerPM: no black outside

--- TrackerPM/TrackerPM.cpp
+++ TrackerPM/TrackerPM.cpp
@@ -203,7 +203,13 @@
     }

 private:
-    void multiThreadProcessImages(OfxRectI procWindow)
+    void multiThreadProcessImage(OfxRectI procWindow)
+    {
+        multiThreadProcessImageMethod<eScoreSSD>(procWindow);
+    }
+
+    template<TrackerScoreEnum scoreType>
+    void multiThreadProcessImageMethod(const OfxRectI &procWindow)
     {
         assert(_refImg && _otherImg);
         double bestScore = std::numeric_limits<double>::infinity();
@@ -224,31 +230,19 @@
                 double score = 0;
                 for (int i = _patternWindow.y1; i < _patternWindow.y2; ++i) {
                     for (int j = _patternWindow.x1; j < _patternWindow.x2; ++j) {
-                        PIX *otherPix = (PIX *) _otherImg->getPixelAddress(x + j, y + i);
                         PIX *refPix = (PIX*) _refImg->getPixelAddress(_center.x + j, _center.y + i);

+                        // take nearest pixel in other image (more chance to get a track than with black)
+                        int otherx = x + j;
+                        int othery = y + i;
+                        otherx = std::max(_otherImg->getBounds().x1,std::min(otherx,_otherImg->getBounds().x2-1)); \
+                        othery = std::max(_otherImg->getBounds().y1,std::min(othery,_otherImg->getBounds().y2-1))
+                        PIX *otherPix = (PIX *) _otherImg->getPixelAddress(otherx, othery);
+
                         ///the search window & pattern window have been intersected to the reference image's bounds
-                        assert(refPix);
+                        assert(refPix && otherPix);

                         score = aggregate<scoreType>(score, refPix, otherPix);
-                        if (maxComp == 1) {
-                            ///compare raw alpha distance
-                            score += (otherPix ? *otherPix : 0 - *refPix) * (otherPix ? *otherPix : 0 - *refPix);
-                        } else {
-                            assert(maxComp >= 3);
-                            double r,g,b;
-                            if (otherPix) {
-                                r = refPix[0] - otherPix[0];
-                                g = refPix[1] - otherPix[1];
-                                b = refPix[2] - otherPix[2];
-                            } else {
-                                r = (refPix[0] - 0);
-                                g = (refPix[1] - 0);
-                                b = (refPix[2] - 0);
-                            }
-
-                            score += (r*r +  g*g + b*b);
-                        }
                     }
                 }
                 if (score < bestScore) {
@@ -260,6 +254,25 @@
         }

         _plugin->updateBestMatch(point, bestScore);
+    }
+
+    template<TrackerScoreEnum scoreType>
+    double aggregate(souble score, PIX* refPix, PIX* otherPix);
+
+    template<>
+    double aggregate<eScoreSSD>(double score, PIX* refPix, PIX* otherPix)
+    {
+        if (nComponents == 1) {
+            ///compare raw alpha distance
+            return score + (*otherPix - *refPix) * (*otherPix - *refPix);
+        } else {
+            assert(nComponents >= 3);
+            double r = refPix[0] - otherPix[0];
+            double g = refPix[1] - otherPix[1];
+            double b = refPix[2] - otherPix[2];
+
+            return score + (r*r +  g*g + b*b);
+        }
     }
 };


Removed dead code.

Removed dead code.

--- src/StringHelpers.cxx
+++ src/StringHelpers.cxx
@@ -13,7 +13,6 @@
 #include "Scintilla.h"

 #include "GUI.h"
-//~ #include "SString.h"
 #include "StringHelpers.h"

 bool StartsWith(GUI::gui_string const &s, GUI::gui_string const &start) {


Fix v1/v2 load semantics

Fix v1/v2 load semantics

--- src/MissionManager/FixedWingLandingComplexItem.cc
+++ src/MissionManager/FixedWingLandingComplexItem.cc
@@ -166,6 +166,14 @@

     int version = complexObject[JsonHelper::jsonVersionKey].toInt();
     if (version == 1) {
+        QList<JsonHelper::KeyValidateInfo> v1KeyInfoList = {
+            { _jsonLoiterAltitudeRelativeKey,   QJsonValue::Bool,  true },
+            { _jsonLandingAltitudeRelativeKey,  QJsonValue::Bool,  true },
+        };
+        if (!JsonHelper::validateKeys(complexObject, v1KeyInfoList, errorString)) {
+            return false;
+        }
+
         bool loiterAltitudeRelative = complexObject[_jsonLoiterAltitudeRelativeKey].toBool();
         bool landingAltitudeRelative = complexObject[_jsonLandingAltitudeRelativeKey].toBool();
         if (loiterAltitudeRelative != landingAltitudeRelative) {
@@ -176,13 +184,19 @@
         } else {
             _altitudesAreRelative = loiterAltitudeRelative;
         }
+        _valueSetIsDistance = true;
     } else if (version == 2) {
         QList<JsonHelper::KeyValidateInfo> v2KeyInfoList = {
             { _jsonAltitudesAreRelativeKey, QJsonValue::Bool,  true },
+            { _jsonValueSetIsDistanceKey,   QJsonValue::Bool,  true },
         };
         if (!JsonHelper::validateKeys(complexObject, v2KeyInfoList, errorString)) {
+            _ignoreRecalcSignals = false;
             return false;
         }
+
+        _altitudesAreRelative = complexObject[_jsonAltitudesAreRelativeKey].toBool();
+        _valueSetIsDistance = complexObject[_jsonValueSetIsDistanceKey].toBool();
     } else {
         errorString = tr("%1 complex item version %2 not supported").arg(jsonComplexItemTypeValue).arg(version);
         _ignoreRecalcSignals = false;
@@ -204,7 +218,8 @@

     _loiterRadiusFact.setRawValue(complexObject[_jsonLoiterRadiusKey].toDouble());
     _loiterClockwise = complexObject[_jsonLoiterClockwiseKey].toBool();
-    _altitudesAreRelative = complexObject[_jsonAltitudesAreRelativeKey].toBool();
+
+    _calcGlideSlope();

     _landingCoordSet = true;

@@ -328,6 +343,8 @@
     complexItem->_landingCoordinate.setLongitude(missionItemLand.param6());
     complexItem->_landingAltitudeFact.setRawValue(missionItemLand.param7());

+    complexItem->_calcGlideSlope();
+
     complexItem->_landingCoordSet = true;

     complexItem->_ignoreRecalcSignals = false;


Optimize SSI, early break in GC

Optimize SSI, early break in GC

--- src/backend/concurrency/ssi_txn_manager.cpp
+++ src/backend/concurrency/ssi_txn_manager.cpp
@@ -622,7 +622,7 @@
       if (end_cid == INVALID_TXN_ID) {
         // running transaction
         itr++;
-        continue;
+        break;
       }

       if (end_cid < min_begin) {


INTEGRATION: CWS qiq (1.40.92); FILE MERGED 2006/05/29 09:28:52 fs 1.40.92.1: quoteTableName and friends changed during #i51143#

--- extensions/source/bibliography/datman.cxx
+++ extensions/source/bibliography/datman.cxx
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: datman.cxx,v $
  *
- *  $Revision: 1.40 $
+ *  $Revision: 1.41 $
  *
- *  last change: $Author: kz $ $Date: 2006-01-05 14:55:50 $
+ *  last change: $Author: obo $ $Date: 2006-07-10 15:53:08 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -1142,9 +1142,11 @@
                     m_xParser.set( xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.SingleSelectQueryComposer" ) ) ), UNO_QUERY );

                 ::rtl::OUString aString(C2U("SELECT * FROM "));
-                sal_Bool bUseCatalogInSelect = ::dbtools::isDataSourcePropertyEnabled(xConnection,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseCatalogInSelect")),sal_True);
-                sal_Bool bUseSchemaInSelect = ::dbtools::isDataSourcePropertyEnabled(xConnection,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseSchemaInSelect")),sal_True);
-                aString += ::dbtools::quoteTableName(xMetaData,aActiveDataTable,::dbtools::eInDataManipulation,bUseCatalogInSelect,bUseSchemaInSelect);
+
+                ::rtl::OUString sCatalog, sSchema, sName;
+                ::dbtools::qualifiedNameComponents( xMetaData, aActiveDataTable, sCatalog, sSchema, sName, ::dbtools::eInDataManipulation );
+                aString += ::dbtools::composeTableNameForSelect( xConnection, sCatalog, sSchema, sName );
+
                 m_xParser->setElementaryQuery(aString);
                 BibConfig* pConfig = BibModul::GetConfig();
                 pConfig->setQueryField(getQueryField());
@@ -1340,9 +1342,11 @@
             // quote the table name which may contain catalog.schema.table
             Reference<XDatabaseMetaData> xMetaData(xConnection->getMetaData(),UNO_QUERY);
             aQuoteChar = xMetaData->getIdentifierQuoteString();
-            sal_Bool bUseCatalogInSelect = ::dbtools::isDataSourcePropertyEnabled(xConnection,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseCatalogInSelect")),sal_True);
-            sal_Bool bUseSchemaInSelect = ::dbtools::isDataSourcePropertyEnabled(xConnection,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseSchemaInSelect")),sal_True);
-            aString += ::dbtools::quoteTableName(xMetaData,aActiveDataTable,::dbtools::eInDataManipulation,bUseCatalogInSelect,bUseSchemaInSelect);
+
+            ::rtl::OUString sCatalog, sSchema, sName;
+            ::dbtools::qualifiedNameComponents( xMetaData, aActiveDataTable, sCatalog, sSchema, sName, ::dbtools::eInDataManipulation );
+            aString += ::dbtools::composeTableNameForSelect( xConnection, sCatalog, sSchema, sName );
+
             m_xParser->setElementaryQuery(aString);
             BibConfig* pConfig = BibModul::GetConfig();
             pConfig->setQueryField(getQueryField());
@@ -1410,9 +1414,11 @@
                     m_xParser.set( xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.SingleSelectQueryComposer" ) ) ), UNO_QUERY );

                 ::rtl::OUString aString(C2U("SELECT * FROM "));
-                sal_Bool bUseCatalogInSelect = ::dbtools::isDataSourcePropertyEnabled(xConnection,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseCatalogInSelect")),sal_True);
-                sal_Bool bUseSchemaInSelect = ::dbtools::isDataSourcePropertyEnabled(xConnection,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseSchemaInSelect")),sal_True);
-                aString += ::dbtools::quoteTableName(xMetaData,aActiveDataTable,::dbtools::eInDataManipulation,bUseCatalogInSelect,bUseSchemaInSelect);
+
+                ::rtl::OUString sCatalog, sSchema, sName;
+                ::dbtools::qualifiedNameComponents( xMetaData, aActiveDataTable, sCatalog, sSchema, sName, ::dbtools::eInDataManipulation );
+                aString += ::dbtools::composeTableNameForSelect( xConnection, sCatalog, sSchema, sName );
+
                 m_xParser->setElementaryQuery(aString);

                 BibConfig* pConfig = BibModul::GetConfig();


INTEGRATION: CWS dba03 (1.5.70); FILE MERGED 2003/03/14 12:21:35 fs 1.5.70.2: RESYNC: (1.5-1.5.28.1); FILE MERGED 2003/02/28 13:41:28 oj 1.5.70.1: #107842# remember type info

--- extensions/source/dbpilots/gridwizard.cxx
+++ extensions/source/dbpilots/gridwizard.cxx
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: gridwizard.cxx,v $
  *
- *  $Revision: 1.7 $
- *
- *  last change: $Author: hr $ $Date: 2003-03-25 16:03:28 $
+ *  $Revision: 1.8 $
+ *
+ *  last change: $Author: vg $ $Date: 2003-04-01 14:13:29 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -161,7 +161,6 @@
         if (!xColumnFactory.is() || !xColumnContainer.is())
             return;

-        static const ::rtl::OUString s_sFieldTypeProperty   = ::rtl::OUString::createFromAscii("Type");
         static const ::rtl::OUString s_sDataFieldProperty   = ::rtl::OUString::createFromAscii("DataField");
         static const ::rtl::OUString s_sLabelProperty       = ::rtl::OUString::createFromAscii("Label");
         static const ::rtl::OUString s_sWidthProperty       = ::rtl::OUString::createFromAscii("Width");
@@ -184,16 +183,9 @@
         {
             // get the information for the selected column
             sal_Int32 nFieldType = DataType::OTHER;
-            try
-            {
-                Reference< XPropertySet > xColumn;
-                rContext.xFields->getByName(*pSelectedFields) >>= xColumn;
-                xColumn->getPropertyValue(s_sFieldTypeProperty) >>= nFieldType;
-            }
-            catch(Exception&)
-            {
-                DBG_ERROR("OGridWizard::implApplySettings: unexpected exception while gathering column information!");
-            }
+            OControlWizardContext::TNameTypeMap::const_iterator aFind = rContext.aTypes.find(*pSelectedFields);
+            if ( aFind != rContext.aTypes.end() )
+                nFieldType = aFind->second;

             aFormFieldNames.push_back(*pSelectedFields);
             switch (nFieldType)


fixed typo in last check in

fixed typo in last check in

git-svn-id: 6df6a9299d9fe08e1e18eb0c01ae615f7df02338@1232 a83610d8-ad2a-0410-a6ab-fc0612d85776

--- src/lsd.cpp
+++ src/lsd.cpp
@@ -153,7 +153,7 @@
 	m_retry_count = 0;
 	asio::error_code ec;
 	m_socket.send_to(asio::buffer(msg.c_str(), msg.size() - 1)
-		, lsd_multicast_endpoint, ec);
+		, lsd_multicast_endpoint, 0, ec);
 	if (ec)
 	{
 		m_disabled = true;


#87187# - Removed obsolete include ( com/sun/star/ucb/CommandAbortedException.hpp )

--- extensions/source/plugin/base/xplugin.cxx
+++ extensions/source/plugin/base/xplugin.cxx
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: xplugin.cxx,v $
  *
- *  $Revision: 1.5 $
- *
- *  last change: $Author: pl $ $Date: 2001-06-12 09:02:29 $
+ *  $Revision: 1.6 $
+ *
+ *  last change: $Author: kso $ $Date: 2001-06-15 06:56:52 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -70,9 +70,6 @@
 #endif
 #ifndef _COM_SUN_STAR_LOADER_CANNOTACTIVATEFACTORYEXCEPTION_HPP_
 #include <com/sun/star/loader/CannotActivateFactoryException.hpp>
-#endif
-#ifndef _COM_SUN_STAR_UCB_COMMANDABORTEDEXCEPTION_HPP_
-#include <com/sun/star/ucb/CommandAbortedException.hpp>
 #endif

 #include <plugin/impl.hxx>


Use NanNew<Object> for Object::New

Use NanNew<Object> for Object::New

--- src/main.cc
+++ src/main.cc
@@ -7,7 +7,7 @@
 using namespace v8;

 void InitCurves(Handle<Object> exports) {
-	Local<Object> obj = Object::New();
+	Local<Object> obj = NanNew<Object>();
 	obj->Set(NanNew<String>("secp112r1"), NanNew<Number>(NID_secp112r1));
 	obj->Set(NanNew<String>("secp112r2"), NanNew<Number>(NID_secp112r2));
 	obj->Set(NanNew<String>("secp128r1"), NanNew<Number>(NID_secp128r1));


Prefer `return 1` over `exit(1)`

Prefer `return 1` over `exit(1)`

--- src/main.cc
+++ src/main.cc
@@ -304,7 +304,7 @@
                     const auto directory = opendir(path.data());
                     if (!directory) {
                         fprintf(stderr, "Failed to open directory at path (%s), failing with error (%s)\n", path.data(), strerror(errno));
-                        exit(1);
+                        return 1;
                     }

                     auto library_paths = std::vector<std::string>();


VFS-4116 Fixed metadata cache size initialization

--- src/main.cc
+++ src/main.cc
@@ -448,7 +448,7 @@
     const auto &rootUuid = configuration->rootUuid();
     fsLogic = std::make_unique<fslogic::Composite>(rootUuid, std::move(context),
         std::move(configuration), std::move(helpersCache),
-        options->areFileReadEventsDisabled(), options->getMetadataCacheSize(),
+        options->getMetadataCacheSize(), options->areFileReadEventsDisabled(),
         options->getProviderTimeout());

     res = multithreaded ? fuse_session_loop_mt(fuse) : fuse_session_loop(fuse);


Makefile updates

Makefile updates

--- src/main.cc
+++ src/main.cc
@@ -2,5 +2,6 @@
 #include "NTClient.h"

 int main(int argc, char** argv) {
+	NTClient nclient = NTClient("asd4wderg", "123asd123"); // Throw-away account
 	return 0;
 }


🐛 Fix a bug

🐛 Fix a bug

--- src/main.cc
+++ src/main.cc
@@ -237,7 +237,8 @@

                         for (const auto &entity : entities.value())
                             if (entity.type() == "bot_command") {
-                                bot_command command;
+                                std::experimental::optional<bot_command>
+                                    command;

                                 const std::string command_text =
                                     utility::conversions::utf16_to_utf8(
@@ -259,18 +260,21 @@
                                          command_text == about_command)
                                     command = bot_command::about;

-                                std::unique_lock<std::mutex> lock(map_mutex);
-                                const auto pair = message_queue_map.emplace(
-                                    chat_id,
-                                    std::make_shared<bot_command_queue>());
-                                lock.unlock();
-
-                                auto &queue = pair.first->second;
-                                queue->push(command);
-                                if (pair.second) {
-                                    std::thread consumer_thread(consumer,
-                                                                chat_id, queue);
-                                    consumer_thread.detach();
+                                if (command) {
+                                    std::unique_lock<std::mutex> lock(
+                                        map_mutex);
+                                    const auto pair = message_queue_map.emplace(
+                                        chat_id,
+                                        std::make_shared<bot_command_queue>());
+                                    lock.unlock();
+
+                                    auto &queue = pair.first->second;
+                                    queue->push(command.value());
+                                    if (pair.second) {
+                                        std::thread consumer_thread(
+                                            consumer, chat_id, queue);
+                                        consumer_thread.detach();
+                                    }
                                 }
                             }
                     }


Rename s/g_nodes/g_nodes_by_name/ variable

--- src/main.cc
+++ src/main.cc
@@ -158,7 +158,7 @@
 // These global variables are the in-memory directory tree of nodes.
 //
 // g_root_node being non-nullptr means that initialization is complete.
-static std::unordered_map<std::string, struct node*> g_nodes;
+static std::unordered_map<std::string, struct node*> g_nodes_by_name;
 static struct node* g_root_node = nullptr;

 // g_saved_readers is a cache of warm readers. libarchive is designed for
@@ -626,7 +626,7 @@
                  int64_t size,
                  time_t mtime,
                  mode_t mode) {
-  if (g_nodes.find(pathname) != g_nodes.end()) {
+  if (g_nodes_by_name.find(pathname) != g_nodes_by_name.end()) {
     fprintf(stderr, "fuse-archive: duplicate pathname in %s: %s\n",
             redact(g_archive_filename), redact(pathname.c_str()));
     return -EIO;
@@ -662,17 +662,17 @@
       node* n = new node(std::move(rel_pathname), index_within_archive, size,
                          mtime, leaf_mode);
       parent->add_child(n);
-      g_nodes.insert({std::move(abs_pathname), n});
+      g_nodes_by_name.insert({std::move(abs_pathname), n});
       break;
     }
     q = r + 1;

     // Insert an implicit branch node (a directory).
-    auto iter = g_nodes.find(abs_pathname);
-    if (iter == g_nodes.end()) {
+    auto iter = g_nodes_by_name.find(abs_pathname);
+    if (iter == g_nodes_by_name.end()) {
       node* n = new node(std::move(rel_pathname), -1, 0, mtime, branch_mode);
       parent->add_child(n);
-      g_nodes.insert(iter, {std::move(abs_pathname), n});
+      g_nodes_by_name.insert(iter, {std::move(abs_pathname), n});
       parent = n;
     } else if (!S_ISDIR(iter->second->mode)) {
       fprintf(
@@ -768,7 +768,7 @@
 insert_root_node() {
   static constexpr int64_t index_within_archive = -1;
   g_root_node = new node("", index_within_archive, 0, 0, S_IFDIR);
-  g_nodes["/"] = g_root_node;
+  g_nodes_by_name["/"] = g_root_node;
 }

 static int  //
@@ -870,8 +870,8 @@
 static int  //
 my_getattr(const char* pathname, struct stat* z) {
   TRY(post_initialize());
-  auto iter = g_nodes.find(pathname);
-  if (iter == g_nodes.end()) {
+  auto iter = g_nodes_by_name.find(pathname);
+  if (iter == g_nodes_by_name.end()) {
     return -ENOENT;
   }
   node* n = iter->second;
@@ -888,8 +888,8 @@
 static int  //
 my_open(const char* pathname, struct fuse_file_info* ffi) {
   TRY(post_initialize());
-  auto iter = g_nodes.find(pathname);
-  if (iter == g_nodes.end()) {
+  auto iter = g_nodes_by_name.find(pathname);
+  if (iter == g_nodes_by_name.end()) {
     return -ENOENT;
   } else if (S_ISDIR(iter->second->mode)) {
     return -EISDIR;
@@ -975,8 +975,8 @@
            off_t offset,
            struct fuse_file_info* ffi) {
   TRY(post_initialize());
-  auto iter = g_nodes.find(pathname);
-  if (iter == g_nodes.end()) {
+  auto iter = g_nodes_by_name.find(pathname);
+  if (iter == g_nodes_by_name.end()) {
     return -ENOENT;
   }
   node* n = iter->second;


ignoring ncurses kruft

ignoring ncurses kruft

--- src/main.cc
+++ src/main.cc
@@ -91,7 +91,7 @@
 				if ( ch == 0x05 ) {
 					/* 0x05 is ENQ - let's use it for our special sequence. */
 					nt.resize( 100, 30 );
-				} else {
+				} else if ( ch < 128 ) {
 					nt.type(ch);
 				}
 			} else {


Add a test case for filtering with large integer values

--- tests/unit/yamlFilterTests.cpp
+++ tests/unit/yamlFilterTests.cpp
@@ -42,6 +42,7 @@
     bmw1.props.add("wheel", 4);
     bmw1.props.add("drive", "all");
     bmw1.props.add("type", "car");
+    bmw1.props.add("serial", 4398046511104); // 2^42

     bike.props.clear();
     bike.props.add("name", "cb1100");
@@ -50,6 +51,7 @@
     bike.props.add("type", "bike");
     bike.props.add("series", "CB");
     bike.props.add("check", "available");
+    bike.props.add("serial", 4398046511105); // 2^42 + 1

     ctx.setGlobal("$geometry", Value(1));
     ctx.setGlobal("$zoom", Value("false"));
@@ -215,3 +217,13 @@
     REQUIRE(filter.eval(bike, ctx));

 }
+
+TEST_CASE( "yaml-filter-tests: predicate with large integers", "[filters][core][yaml]") {
+    init();
+    Filter filter = load("filter: { serial : [4398046511104] }");
+
+    REQUIRE(!filter.eval(civic, ctx));
+    REQUIRE(filter.eval(bmw1, ctx));
+    REQUIRE(!filter.eval(bike, ctx));
+
+}


AnalyserModel: added some background information to the `areEquivalentVariables()` method.

--- src/analysermodel.cpp
+++ src/analysermodel.cpp
@@ -380,6 +380,15 @@
 bool AnalyserModel::areEquivalentVariables(const VariablePtr &variable1,
                                            const VariablePtr &variable2)
 {
+    // We used to have a utilities method which implementation was:
+    //
+    //     return (variable1 == variable2)
+    //            || variable1->hasEquivalentVariable(variable2, true);
+    //
+    // However, a call to Variable::hasEquivalentVariable() can be time
+    // consuming. So, here, we stripped down the implementation of that method
+    // (and of others that it calls) and cache its results for future re-use.
+
     if (variable1 == variable2) {
         return true;
     }


CKeyStore::AddKey must return a boolean

CKeyStore::AddKey must return a boolean

--- src/keystore.cpp
+++ src/keystore.cpp
@@ -29,5 +29,6 @@
         mapKeys[key.GetPubKey()] = key.GetPrivKey();
         mapPubKeys[Hash160(key.GetPubKey())] = key.GetPubKey();
     }
+    return true;
 }


no need for the pointer fetishism

no need for the pointer fetishism

--- filter/source/graphicfilter/eras/eras.cxx
+++ filter/source/graphicfilter/eras/eras.cxx
@@ -40,7 +40,7 @@

 private:

-    SvStream*           mpOStm;
+    SvStream & m_rOStm;
     USHORT              mpOStmOldModus;

     BOOL                mbStatus;
@@ -61,18 +61,19 @@
     void                ImplPutByte( BYTE );    // RLE decoding

 public:
-                        RASWriter();
-                        ~RASWriter();
-
-    BOOL                WriteRAS( const Graphic& rGraphic, SvStream& rRAS, FilterConfigItem* pFilterConfigItem );
+    RASWriter(SvStream &rStream);
+    ~RASWriter();
+
+    BOOL WriteRAS( const Graphic& rGraphic, FilterConfigItem* pFilterConfigItem );
 };

 //=================== Methoden von RASWriter ==============================

-RASWriter::RASWriter() :
-    mbStatus    ( TRUE ),
-    mpAcc       ( NULL ),
-    mnRepCount  ( 0xffffffff )
+RASWriter::RASWriter(SvStream &rStream)
+    : m_rOStm(rStream)
+    , mbStatus(TRUE)
+    , mpAcc(NULL)
+    , mnRepCount( 0xffffffff )
 {
 }

@@ -92,11 +93,9 @@

 //  ------------------------------------------------------------------------

-BOOL RASWriter::WriteRAS( const Graphic& rGraphic, SvStream& rRAS, FilterConfigItem* pFilterConfigItem)
+BOOL RASWriter::WriteRAS( const Graphic& rGraphic, FilterConfigItem* pFilterConfigItem)
 {
     Bitmap  aBmp;
-
-    mpOStm = &rRAS;

     if ( pFilterConfigItem )
     {
@@ -122,8 +121,8 @@
     mpAcc = aBmp.AcquireReadAccess();
     if ( mpAcc )
     {
-        mpOStmOldModus = mpOStm->GetNumberFormatInt();
-        mpOStm->SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
+        mpOStmOldModus = m_rOStm.GetNumberFormatInt();
+        m_rOStm.SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );

         if ( ImplWriteHeader() )
         {
@@ -136,7 +135,7 @@
     else
         mbStatus = FALSE;

-    mpOStm->SetNumberFormatInt( mpOStmOldModus );
+    m_rOStm.SetNumberFormatInt( mpOStmOldModus );

     if ( xStatusIndicator.is() )
         xStatusIndicator->end();
@@ -158,17 +157,17 @@
     }
         if ( mbStatus && mnWidth && mnHeight && mnDepth )
     {
-        *mpOStm << (UINT32)0x59a66a95 << (UINT32)mnWidth << (UINT32)mnHeight
+        m_rOStm << (UINT32)0x59a66a95 << (UINT32)mnWidth << (UINT32)mnHeight
             << (UINT32)mnDepth
             << (UINT32)(( ( ( ( mnWidth * mnDepth ) + 15 ) >> 4 ) << 1 ) * mnHeight)
             << (UINT32)2;

         if ( mnDepth > 8 )
-            *mpOStm << (UINT32)0 << (UINT32)0;
+            m_rOStm << (UINT32)0 << (UINT32)0;
         else
         {

-            *mpOStm << (UINT32)1 << (UINT32)( mnColors * 3 );
+            m_rOStm << (UINT32)1 << (UINT32)( mnColors * 3 );
         }
     }
     else mbStatus = FALSE;
@@ -182,9 +181,9 @@
 {
     USHORT i;

-    for ( i = 0; i < mnColors; *mpOStm << mpAcc->GetPaletteColor( i++ ).GetRed() ) ;
-    for ( i = 0; i < mnColors; *mpOStm << mpAcc->GetPaletteColor( i++ ).GetGreen() ) ;
-    for ( i = 0; i < mnColors; *mpOStm << mpAcc->GetPaletteColor( i++ ).GetBlue() ) ;
+    for ( i = 0; i < mnColors; m_rOStm << mpAcc->GetPaletteColor( i++ ).GetRed() ) ;
+    for ( i = 0; i < mnColors; m_rOStm << mpAcc->GetPaletteColor( i++ ).GetGreen() ) ;
+    for ( i = 0; i < mnColors; m_rOStm << mpAcc->GetPaletteColor( i++ ).GetBlue() ) ;
 }

 // ------------------------------------------------------------------------
@@ -259,15 +258,15 @@
         {
             if ( mnRepCount == 0 )
             {
-                *mpOStm << (BYTE)mnRepVal;
+                m_rOStm << (BYTE)mnRepVal;
                 if ( mnRepVal == 0x80 )
-                    *mpOStm << (BYTE)0;
+                    m_rOStm << (BYTE)0;
             }
             else
             {
-                *mpOStm << (BYTE)0x80;
-                *mpOStm << (BYTE)mnRepCount;
-                *mpOStm << (BYTE)mnRepVal;
+                m_rOStm << (BYTE)0x80;
+                m_rOStm << (BYTE)mnRepCount;
+                m_rOStm << (BYTE)mnRepVal;
             }
             mnRepVal = nPutThis;
             mnRepCount = 0;
@@ -283,9 +282,9 @@

 extern "C" BOOL __LOADONCALLAPI GraphicExport( SvStream& rStream, Graphic& rGraphic, FilterConfigItem* pFilterConfigItem, BOOL )
 {
-    RASWriter aRASWriter;
-
-    return aRASWriter.WriteRAS( rGraphic, rStream, pFilterConfigItem );
+    RASWriter aRASWriter(rStream);
+
+    return aRASWriter.WriteRAS( rGraphic, pFilterConfigItem );
 }

 // ---------------


Check return value of read #6992

Check return value of read #6992

--- src/condor_starter.V6.1/find_child_proc.cpp
+++ src/condor_starter.V6.1/find_child_proc.cpp
@@ -47,7 +47,8 @@
 		return false;
 	}

-	if (read(fd, buf, 511) < 0) {
+	ssize_t num_read = read(fd, buf, 511);
+	if (num_read < 5) { // minimum # of bytes for legal stat line
 		close(fd);
 		return false;
 	}


Serialization: Serialize SPARC PTEs last so their nameOut() calls don't interfere with other serialization in the TLB.

--- src/arch/sparc/tlb.cc
+++ src/arch/sparc/tlb.cc
@@ -1363,11 +1363,6 @@
     SERIALIZE_SCALAR(cntr);
     SERIALIZE_ARRAY(free_list,  cntr);

-    for (int x = 0; x < size; x++) {
-        nameOut(os, csprintf("%s.PTE%d", name(), x));
-        tlb[x].serialize(os);
-    }
-
     SERIALIZE_SCALAR(c0_tsb_ps0);
     SERIALIZE_SCALAR(c0_tsb_ps1);
     SERIALIZE_SCALAR(c0_config);
@@ -1376,6 +1371,11 @@
     SERIALIZE_SCALAR(cx_config);
     SERIALIZE_SCALAR(sfsr);
     SERIALIZE_SCALAR(tag_access);
+
+    for (int x = 0; x < size; x++) {
+        nameOut(os, csprintf("%s.PTE%d", name(), x));
+        tlb[x].serialize(os);
+    }
 }

 void
@@ -1397,14 +1397,6 @@
     UNSERIALIZE_ARRAY(free_list,  cntr);
     for (int x = 0; x < cntr; x++)
         freeList.push_back(&tlb[free_list[x]]);
-
-    lookupTable.clear();
-    for (int x = 0; x < size; x++) {
-        tlb[x].unserialize(cp, csprintf("%s.PTE%d", section, x));
-        if (tlb[x].valid)
-            lookupTable.insert(tlb[x].range, &tlb[x]);
-
-    }

     UNSERIALIZE_SCALAR(c0_tsb_ps0);
     UNSERIALIZE_SCALAR(c0_tsb_ps1);
@@ -1414,6 +1406,14 @@
     UNSERIALIZE_SCALAR(cx_config);
     UNSERIALIZE_SCALAR(sfsr);
     UNSERIALIZE_SCALAR(tag_access);
+
+    lookupTable.clear();
+    for (int x = 0; x < size; x++) {
+        tlb[x].unserialize(cp, csprintf("%s.PTE%d", section, x));
+        if (tlb[x].valid)
+            lookupTable.insert(tlb[x].range, &tlb[x]);
+
+    }
 }

 void


drobniutka poprawka parsera

drobniutka poprawka parsera

--- framework/JPetCmdParser/JPetCmdParser.cpp
+++ framework/JPetCmdParser/JPetCmdParser.cpp
@@ -71,7 +71,7 @@
         {
             cerr << "Wrong type of file: " << fVariablesMap["type"].as< string >() << endl;
             cerr << "Possible options: hld or root" << endl;
-
+            exit(-1);
         }

     }


now arg-summarize always outputs sorted bed

--- src/arg-summarize.cpp
+++ src/arg-summarize.cpp
@@ -214,36 +214,63 @@
 }

+struct CompareBedLineEnd
+{
+    bool operator()(const BedLine *l1, const BedLine *l2) const
+    {
+      //could generalize and sort by start, but for this purpose we are only comparing entries with same start
+      assert(l1->start == l2->start);
+      if (l1->end == l2->end)
+	return (l1->sample < l2->sample);
+      return l1->end < l2->end;
+    }
+};

 void processNextBedLine(BedLine *line, IntervalIterator<vector<double> > *results,
 			vector<string> statname,
 			char *region_chrom, int region_start, int region_end) {
   static int counter=0;
-
-  if (line->stats.size() == 0)
-    scoreBedLine(line, statname);
-  if (region_chrom != NULL) {
-    assert(strcmp(region_chrom, line->chrom)==0);
-    if (line->end > region_end) line->end = region_end;
-    if (line->start < region_start) line->start = region_start;
-    assert(line->start < line->end);
+  static list<BedLine*> bedlist;
+
+  if (line != NULL) {
+    if (line->stats.size() == 0)
+      scoreBedLine(line, statname);
+    if (region_chrom != NULL) {
+      assert(strcmp(region_chrom, line->chrom)==0);
+      if (line->end > region_end) line->end = region_end;
+      if (line->start < region_start) line->start = region_start;
+      assert(line->start < line->end);
+    }
   }
   if (!summarize) {
-    printf("%s\t%i\t%i\t%i", line->chrom, line->start, line->end, line->sample);
-    for (unsigned int i=0; i < statname.size(); i++) {
-      if (statname[i]=="tree") {
-	printf("\t");
-	printf("%s", line->newick);
-      } else {
-	printf("\t%g", line->stats[i]);
-      }
-    }
-    printf("\n");
+    if (bedlist.size() > 0 &&
+	(line==NULL || bedlist.front()->start < line->start)) {
+      bedlist.sort(CompareBedLineEnd());
+      //      std::list<BedLine*>::sort(bedlist.begin(), bedlist.end(), compBedLineEnd);
+      for (list<BedLine*>::iterator it=bedlist.begin(); it != bedlist.end(); ++it) {
+	BedLine *l = *it;
+	printf("%s\t%i\t%i\t%i", l->chrom, l->start, l->end, l->sample);
+	for (unsigned int i=0; i < statname.size(); i++) {
+	  if (statname[i]=="tree") {
+	    printf("\t");
+	    printf("%s", l->newick);
+	  } else {
+	    printf("\t%g", l->stats[i]);
+	  }
+	}
+	printf("\n");
+	delete &*l;
+      }
+      bedlist.clear();
+    }
+    if (line != NULL) bedlist.push_back(line);
   } else {
-    results->append(line->chrom, line->start, line->end, line->stats);
-    counter++;
-    if (counter%100==0) {
-      checkResults(results);
+    if (line != NULL) {
+      results->append(line->chrom, line->start, line->end, line->stats);
+      counter++;
+      if (counter%100==0) {
+	checkResults(results);
+      }
     }
   }
 }
@@ -269,7 +296,8 @@
          be populated, either by parsing the newick or an SPR operation
          on previous tree.
        Parsed tree has recomb_node, recomb_time, coal_node, coal_time set
-         (recomb_node==NULL => no recomb at end of region)
+         (recomb_node==NULL => no recomb. Only happens in full tree at end
+	 of regions analyzed by arg-sample)

        Queue bedlineQueue contains pointers to this class, will be output to
          results in order (first in, first out).
@@ -351,28 +379,15 @@
       if (it == orig_trees.end()) {  //first tree from this sample
 	orig_tree = new Tree(string(newick), times);
 	orig_trees[sample] = orig_tree;
-	//	printf("ORIG: ");
-	//	orig_tree->print_newick(stdout);
-	//	printf("\n");
 	if (inds.size() > 0) {
 	  pruned_tree = orig_tree->copy();
-	  //	  orig_tree->node_map = *pruned_tree->prune(inds, true);
 	  orig_tree->node_map = pruned_tree->prune(inds, true);
 	  pruned_trees[sample] = pruned_tree;
-	  /*	  printf("PRUN: ");
-	  pruned_tree->print_newick(stdout);
-	  printf("\n");
-	  fflush(stdout);
-	  for (int i=0; i < orig_tree->nnodes; i++)
-	    printf("node_map[%i]=%i\n", i, orig_tree->node_map.nm[i]);
-	    fflush(stdout);*/
 	}
       } else {
 	int parse_tree = 0;
 	orig_tree = it->second;
 	if (orig_tree->recomb_node == NULL) {
-	  //	  printf("recomb_node is NULL; reading new tree\n"); fflush(stdout);
-	  assert(0);  // TODO: REMOVE THIS! IT IS OK TO BE HERE.
 	  parse_tree = 1;
 	  delete orig_tree;
 	  orig_tree = new Tree(string(newick), times);
@@ -381,42 +396,23 @@

 	// set recomb_node and coal_node to next spr events indicated in newick string
         orig_tree->update_spr(newick, times);
-	/*	printf("SPR1: ");
-	orig_tree->print_newick(stdout);
-	printf("\n");
-	printf("done apply_update_spr\n");
-	printf("update spr recomb_node=%i coal_node=%i\n",
-	       orig_tree->recomb_node==NULL ? -1 : orig_tree->recomb_node->name,
-	       orig_tree->coal_node==NULL ? -1 : orig_tree->coal_node->name);*/
 	if (inds.size() > 0) {
 	  it = pruned_trees.find(sample);
 	  assert(it != pruned_trees.end());
 	  pruned_tree = it->second;
 	  if (parse_tree) {
-	    assert(0); // TODO: DELETE THIS TOO. IT IS USUALLY OK TO BE HERE.
-	    delete pruned_tree;
 	    pruned_tree = orig_tree->copy();
-	    //	    orig_tree->node_map = *pruned_tree->prune(inds, true);
 	    orig_tree->node_map = pruned_tree->prune(inds, true);
 	    pruned_trees[sample] = pruned_tree;
 	  } else if (pruned_tree->recomb_node != NULL) {
 	    pruned_tree->apply_spr();
 	  }
-	  /*	  printf("SPR2: ");
-	  pruned_tree->print_newick(stdout); printf("\n");
-	  fflush(stdout);*/
-
-	  /*	  for (int f=0; f < orig_tree->nnodes; f++) {
-            printf("map[%i]=%i\n", f, orig_tree->node_map.nm[f]);
-          }
-	  fflush(stdout);*/

 	  //map recomb_node and coal_node onto pruned tree
 	  if (orig_tree->recomb_node == NULL) {
 	    pruned_tree->recomb_node = pruned_tree->coal_node = NULL;
 	  } else {
 	    int num=orig_tree->node_map.nm[orig_tree->recomb_node->name];
-	    //	    printf("num=%i\n", num);
 	    if (num == -1 || pruned_tree->nodes[num] == pruned_tree->root) {
 	      pruned_tree->recomb_node = pruned_tree->coal_node = NULL;
 	    } else {
@@ -424,7 +420,6 @@
  	      pruned_tree->recomb_node = pruned_tree->nodes[num];
 	      pruned_tree->recomb_time = orig_tree->recomb_time;
 	      num = orig_tree->node_map.nm[orig_tree->coal_node->name];
-	      //	      printf("num2=%i\n", num);
 	      if (num == -1) {
 		// coal node does not map; need to trace back until it does
 		Node *n = orig_tree->coal_node;
@@ -446,9 +441,6 @@
 	      }
 	    }
 	  }
-	  /*	  printf("update spr2 recomb_node=%i coal_node=%i\n",
-		 pruned_tree->recomb_node==NULL ? -1 : pruned_tree->recomb_node->name,
-		 pruned_tree->coal_node==NULL ? -1 : pruned_tree->coal_node->name);*/
 	  if (pruned_tree->recomb_node != NULL)
 	    assert(pruned_tree->coal_node != NULL);
 	}
@@ -457,15 +449,12 @@
       map<int,BedLine*>::iterator it3 = bedlineMap.find(sample);
       BedLine *currline;
       if (it3 == bedlineMap.end()) {
-	//	printf("new bedline map for sample %i (%s\t%i\t%i)\n", sample, chrom, start-offset, end-offset); fflush(stdout);
 	currline = new BedLine(chrom, start, end, sample, newick, orig_tree,
 			       pruned_tree);
 	bedlineMap[sample] = currline;
 	bedlineQueue.push(currline);
       } else {
 	currline = it3->second;
-	//	printf("found entry for sample %i\n", sample); fflush(stdout);
-	//	printf("entry has sample %i start=%i end=%i\n", currline->sample, currline->start-offset, currline->end-offset); fflush(stdout);
 	assert(strcmp(currline->chrom, chrom)==0);
 	assert(currline->end == start);
 	currline->end = end;
@@ -479,7 +468,6 @@
 	  pruned_tree->recomb_node != NULL) {
 	scoreBedLine(currline, statname);
 	bedlineMap.erase(sample);
-	//	  printf("replaced bedline map for sample %i (old=(%i,%i) new=(%i,%i)\n", sample, oldstart-offset, oldend-offset, currline->start-offset, currline->end-offset); fflush(stdout);
       }

       while (bedlineQueue.size() > 0) {
@@ -487,15 +475,12 @@
 	if (firstline->stats.size() == statname.size()) {
 	  processNextBedLine(firstline, &results, statname,
 			     region_chrom, region_start, region_end);
-	  //	  printf("processing sample %i\t(%s\t%i\t%i)\n", firstline->sample,
-	  //		 firstline->chrom, firstline->start-offset, firstline->end-offset);
 	  it3 = bedlineMap.find(firstline->sample);
 	  if (it3 != bedlineMap.end() && it3->second == firstline) {
 	    assert(0);
-	    //	    printf("erasing bedlineMap entry for sample %i (%i,%i)\n", firstline->sample, firstline->start-offset, firstline->end-offset);
 	    bedlineMap.erase(firstline->sample);
 	  }
-	  delete &*firstline;
+	  //	  delete &*firstline;
 	  bedlineQueue.pop();
 	} else break;
       }
@@ -508,13 +493,16 @@
       BedLine *firstline = bedlineQueue.front();
       processNextBedLine(firstline, &results, statname,
 			 region_chrom, region_start, region_end);
-      delete &*firstline;
+      //      delete &*firstline;
       bedlineQueue.pop();
     }

     if (summarize) {
         results.finish();
         checkResults(&results);
+    } else {
+      processNextBedLine(NULL, &results, statname, region_chrom,
+			 region_start, region_end);
     }

     it = orig_trees.begin();


- Works4: change character set

- Works4: change character set

svn path=/libwps/; revision=16

--- src/lib/WPS4.cpp
+++ src/lib/WPS4.cpp
@@ -19,6 +19,7 @@
  *
  */

+#include <iconv.h>
 #include <math.h>
 #include <stdlib.h>
 #include <string.h>
@@ -356,7 +357,14 @@
 		FOD fod = *(FODs_iter);
 //		WPD_DEBUG_MSG(("FOD  fcLim=%u (0x%04x), bfprop=%u, bfprop_abs=%u\n", fod.fcLim, fod.fcLim, fod.bfprop, fod.bfprop_abs));
 	}
-#endif
+#endif
+
+	iconv_t cd = iconv_open("UTF-8", "WINDOWS-1252");
+	if ((iconv_t)-1 == cd)
+	{
+		WPD_DEBUG_MSG(("Works: error: iconv_open() failed\n"));
+		throw GenericException();
+	}

 	uint32_t last_fcLim = 0x100;
 	for (FODs_iter = CHFODs.begin(); FODs_iter!= CHFODs.end(); FODs_iter++)
@@ -369,6 +377,11 @@
 		input->seek(last_fcLim, WPX_SEEK_SET);
 		for (uint32_t i = len; i>0; i--)
 		{
+			char *inchar;
+			char outbuf;
+			char *outchar;
+			size_t outbytesleft = 1;
+			size_t inbytesleft = 0;
 			uint8_t readVal = readU8(input);
 //			WPD_DEBUG_MSG(("Works: info: position %x = %c (0x%02x)\n", (input->tell())-1, readVal, readVal));
 			if (0x00 == readVal)
@@ -385,13 +398,21 @@
 					listener->insertEOL();
 					break;
 				default:
-					//fixme: convert Windows 1252 to UTF-8
-					listener->insertCharacter( (uint16_t)readVal );
+					inchar = (char *)&readVal;
+					outchar = &outbuf;
+					size_t rc = iconv(cd, &inchar, &inbytesleft, &outchar, &outbytesleft);
+					if ((size_t) -1 == rc || inbytesleft != 0)
+					{
+						WPD_DEBUG_MSG(("Works: error: iconv() failed\n"));
+						throw GenericException();
+					}
+					listener->insertCharacter( (uint16_t)outbuf );
 					break;
 			}
 		}
 		last_fcLim = (*FODs_iter).fcLim;
 	}
+	iconv_close(cd);

 }


[arith_uint256] Do not destroy *this content if passed-in operator may reference it

--- src/arith_uint256.cpp
+++ src/arith_uint256.cpp
@@ -69,16 +69,16 @@
 template <unsigned int BITS>
 base_uint<BITS>& base_uint<BITS>::operator*=(const base_uint& b)
 {
-    base_uint<BITS> a = *this;
-    *this = 0;
+    base_uint<BITS> a;
     for (int j = 0; j < WIDTH; j++) {
         uint64_t carry = 0;
         for (int i = 0; i + j < WIDTH; i++) {
-            uint64_t n = carry + pn[i + j] + (uint64_t)a.pn[j] * b.pn[i];
-            pn[i + j] = n & 0xffffffff;
+            uint64_t n = carry + a.pn[i + j] + (uint64_t)pn[j] * b.pn[i];
+            a.pn[i + j] = n & 0xffffffff;
             carry = n >> 32;
         }
     }
+    *this = a;
     return *this;
 }


sort karabiner_grabber_device_details.json

--- src/core/grabber/include/device_grabber.hpp
+++ src/core/grabber/include/device_grabber.hpp
@@ -719,7 +719,10 @@
       return;
     }

-    nlohmann::json json = nlohmann::json::array();
+    // ----------------------------------------
+    // Make devices json
+
+    std::vector<nlohmann::json> devices;
     for (const auto& pair : hids_) {
       nlohmann::json j;
       if (auto v = pair.second->find_vendor_id()) {
@@ -743,10 +746,54 @@
       if (auto v = pair.second->find_transport()) {
         j["transport"] = *v;
       }
-      json.push_back(j);
-    }
-
-    output << std::setw(4) << json << std::endl;
+      if (auto v = pair.second->find_registry_entry_id()) {
+        j["registry_entry_id"] = *v;
+      }
+      devices.push_back(j);
+    }
+
+    // ----------------------------------------
+    // Sort
+
+    auto make_sort_key = [](const nlohmann::json& j) {
+      std::stringstream ss;
+      {
+        auto it = j.find("product");
+        if (it != std::end(j)) {
+          ss << it->get<std::string>();
+        } else {
+          ss << " ";
+        }
+      }
+      {
+        auto it = j.find("manipulator");
+        if (it != std::end(j)) {
+          ss << it->get<std::string>();
+        } else {
+          ss << " ";
+        }
+      }
+      {
+        auto it = j.find("location_id");
+        if (it != std::end(j)) {
+          ss << it->get<int>();
+        } else {
+          ss << " ";
+        }
+      }
+      return ss.str();
+    };
+
+    std::sort(std::begin(devices),
+              std::end(devices),
+              [&](auto& a, auto& b) {
+                return make_sort_key(a) < make_sort_key(b);
+              });
+
+    // ----------------------------------------
+    // Output
+
+    output << std::setw(4) << nlohmann::json(devices) << std::endl;
   }

   void set_profile(const core_configuration::profile& profile) {


IVGCVSW-6801 Remove the call to sync after EnqueueWorkload if we didn't import

Signed-off-by: David Monahan <476043a87acf0a0db3269febcc27fec698dc718c@arm.com>
Change-Id: I0c79518fb0d849809d972241ce02653259d4f8c4

--- src/armnn/Runtime.cpp
+++ src/armnn/Runtime.cpp
@@ -631,15 +631,18 @@
     auto status = loadedNetwork->EnqueueWorkload(inputTensors, outputTensors,
                                                  preImportedInputIds, preImportedOutputIds);

+
+    // Check if we imported, if not there's no need to call the After EnqueueWorkload events
+    if (!preImportedInputIds.empty() || !preImportedOutputIds.empty())
+    {
+        // Call After EnqueueWorkload events
+        for (auto&& context : m_BackendContexts)
+        {
+            context.second->AfterEnqueueWorkload(networkId);
+        }
+    }
     ARMNN_LOG(info) << "Execution time: " << std::setprecision(2)
                     << std::fixed << armnn::GetTimeDuration(startTime).count() << " ms.";
-
-    // Call After EnqueueWorkload events
-    for (auto&& context : m_BackendContexts)
-    {
-        context.second->AfterEnqueueWorkload(networkId);
-    }
-
     return status;
 }


Slightly modified.

Slightly modified.

--- src/lib/h264.cpp
+++ src/lib/h264.cpp
@@ -85,7 +85,8 @@
 static int32_t se_golomb(dec_bits *stream)
 {
 	int32_t ue = ue_golomb(stream);
-	return (((ue & 1) ? ue : -ue) + 1) >> 1;
+	int32_t t = (ue + 1) >> 1;
+	return (ue & 1) ? t : -t;
 }

 static const int8_t me_golomb_lut[2][48] = {
@@ -107,14 +108,13 @@
 	}
 };

-static int32_t me_golomb(dec_bits *stream, int is_inter)
+static inline int32_t me_golomb(dec_bits *stream, const int8_t *me_lut)
 {
 	uint32_t ue = ue_golomb(stream);
-	assert((unsigned)is_inter <= 1);
-	return me_golomb_lut[is_inter][(ue < 48) ? ue : 0];
-}
-
-static int32_t te_golomb(dec_bits *stream, int range)
+	return me_lut[(ue < 48) ? ue : 0];
+}
+
+static inline int32_t te_golomb(dec_bits *stream, int range)
 {
 	return (range == 1) ? (get_onebit_inline(stream) ^ 1) : ue_golomb(stream);
 }
@@ -2179,13 +2179,13 @@

 struct cbp_intra_cavlc {
 	uint32_t operator()(h264d_mb_current *mb, dec_bits *st, int avail) {
-		return me_golomb(st, 0);
+		return me_golomb(st, me_golomb_lut[0]);
 	}
 };

 struct cbp_inter_cavlc {
 	uint32_t operator()(h264d_mb_current *mb, dec_bits *st, int avail) {
-		return me_golomb(st, 1);
+		return me_golomb(st, me_golomb_lut[1]);
 	}
 };


optimize stop message

optimize stop message

--- src/atframe/atapp.cpp
+++ src/atframe/atapp.cpp
@@ -386,7 +386,11 @@
     }

     LIBATAPP_MACRO_API int app::stop() {
-        WLOGINFO("============ receive stop signal and ready to stop all modules ============");
+        if (check_flag(flag_t::STOPING)) {
+            WLOGINFO("============= recall stop after some event action(s) finished =============");
+        } else {
+            WLOGINFO("============ receive stop signal and ready to stop all modules ============");
+        }
         // step 1. set stop flag.
         // bool is_stoping = set_flag(flag_t::STOPING, true);
         set_flag(flag_t::STOPING, true);


Update pi_deleglise_rivat2.cpp

Update pi_deleglise_rivat2.cpp

--- src/deleglise-rivat/pi_deleglise_rivat2.cpp
+++ src/deleglise-rivat/pi_deleglise_rivat2.cpp
@@ -85,8 +85,8 @@
   return S2_result;
 }

-/// Calculate the contribution of the trivial leaves, the clustered
-/// easy leaves and the sparse easy leaves.
+/// Calculate the contribution of the clustered easy
+/// leaves and the sparse easy leaves.
 ///
 int64_t S2_easy(int64_t x,
                 int64_t y,


Add implementation of CBF

Add implementation of CBF

--- src/lib/h265.cpp
+++ src/lib/h265.cpp
@@ -662,8 +662,12 @@
 	}
 }

-static inline uint32_t cbf_cbcr_flag(m2d_cabac_t& cabac, dec_bits& st, uint32_t depth) {
+static inline uint32_t cbf_chroma(m2d_cabac_t& cabac, dec_bits& st, uint32_t depth) {
 	return cabac_decode_decision_raw(&cabac, &st, reinterpret_cast<h265d_cabac_context_t*>(cabac.context)->cbf_chroma + depth);
+}
+
+static inline uint32_t cbf_luma(m2d_cabac_t& cabac, dec_bits& st, uint32_t depth) {
+	return cabac_decode_decision_raw(&cabac, &st, reinterpret_cast<h265d_cabac_context_t*>(cabac.context)->cbf_luma + (depth == 0));
 }

 static inline uint32_t intra_chroma_pred_dir(uint32_t chroma_pred_mode, uint32_t mode) {
@@ -721,26 +725,29 @@
 	} else {
 		split = true;
 	}
-	uint8_t cbf_cbcr;
+	uint8_t cbf = 0;
 	if (2 < size_log2) {
-		cbf_cbcr = 0;
 		for (int i = 0; i < 2; ++i) {
 			if (upper_cbf_cbcr & 1) {
-				cbf_cbcr = (cbf_cbcr << 1) | cbf_cbcr_flag(dst.cabac, st, depth);
+				cbf = (cbf << 1) | cbf_chroma(dst.cabac, st, depth);
 			}
 			upper_cbf_cbcr >>= 1;
 		}
-	} else {
-		cbf_cbcr = 0;
 	}
 	if (split) {
 		size_log2 -= 1;
 		depth += 1;
-		transform_tree(dst, st, size_log2, depth, cbf_cbcr);
-		transform_tree(dst, st, size_log2, depth, cbf_cbcr);
-		transform_tree(dst, st, size_log2, depth, cbf_cbcr);
-		transform_tree(dst, st, size_log2, depth, cbf_cbcr);
-	} else {
+		transform_tree(dst, st, size_log2, depth, cbf);
+		transform_tree(dst, st, size_log2, depth, cbf);
+		transform_tree(dst, st, size_log2, depth, cbf);
+		transform_tree(dst, st, size_log2, depth, cbf);
+	} else {
+		uint8_t cbf_y = 0;
+		if (depth || cbf) {
+			cbf = (cbf << 1) | cbf_luma(dst.cabac, st, depth);
+		}
+		if (cbf) {
+		}
 	}
 }


VFS-1142 Remove unused config.h import.

VFS-1142 Remove unused config.h import.

--- src/auth/grAdapter.cc
+++ src/auth/grAdapter.cc
@@ -9,7 +9,6 @@
 #include "auth/grAdapter.h"

 #include "auth/authException.h"
-#include "config.h"
 #include "context.h"
 #include "logging.h"


Have system_clock return 0, rather than crash, if no timer is set

Initialize the X.509 global state object lazily, on first access

Alter the order that global objects are deleted.

--- src/libstate.cpp
+++ src/libstate.cpp
@@ -129,7 +129,7 @@
 *************************************************/
 u64bit Library_State::system_clock() const
    {
-   return timer->clock();
+   return (timer) ? timer->clock() : 0;
    }

 /*************************************************
@@ -309,7 +309,7 @@
 X509_GlobalState& Library_State::x509_state() const
    {
    if(!x509_state_obj)
-      throw Invalid_State("Library_State::x509_state: No state set");
+      x509_state_obj = new X509_GlobalState();

    return (*x509_state_obj);
    }
@@ -334,7 +334,7 @@
    locks["engine"] = get_mutex();
    rng = 0;
    cached_default_allocator = 0;
-   x509_state_obj = new X509_GlobalState();
+   x509_state_obj = 0;

    set_default_policy();
    }
@@ -344,16 +344,17 @@
 *************************************************/
 Library_State::~Library_State()
    {
-   cached_default_allocator = 0;
-   delete rng;
    delete x509_state_obj;
-
+   delete transcoder;
    for(u32bit j = 0; j != entropy_sources.size(); ++j)
       delete entropy_sources[j];

+   delete rng;
+
    for(u32bit j = 0; j != engines.size(); ++j)
       delete engines[j];

+   cached_default_allocator = 0;
    for(std::map<std::string, Allocator*>::iterator j = alloc_factory.begin();
        j != alloc_factory.end(); ++j)
       {
@@ -361,7 +362,6 @@
       delete j->second;
       }

-   delete transcoder;
    delete mutex_factory;
    delete timer;


One task less.

One task less.

--- src/blackhole/log.cpp
+++ src/blackhole/log.cpp
@@ -1,6 +1,5 @@
 //!@todo: performance: Review string formatting. Use attached stream.
 //!@todo: api: Make elasticsearch frontend. Use swarm + asio and only index request with simple response checking.
-//!@todo: files_t: Make file naming by pattern.
 //!@todo: api: Ability to set global attribute mapper (?)
 //!@todo: api: Global thread-safe guarantee. Do not lock if underlying class is thread-safe itself.


Fix for bootstrapping under theta_hat.

Fix for bootstrapping under theta_hat.

Now pulling obj values from a guessed model under theta hat.

Former-commit-id: 60ee470b36967d82a6853bb858af1d1ce3134645

--- src/bootstrappers.cpp
+++ src/bootstrappers.cpp
@@ -4,6 +4,9 @@

 #include "gmwm_logic.h"
+
+#include "guess_values.h"
+

 // Include support functions
 #include "transform_data.h"
@@ -162,6 +165,8 @@
                                 unsigned int H){
   unsigned int nb_level = floor(log2(N));

+  unsigned int p = theta.n_elem;
+
   arma::mat theo(nb_level, H);

   arma::mat all_wv_empir(nb_level, H);
@@ -184,13 +189,21 @@

     // WV Empirical
     arma::vec wv_empir = wvar.col(0);
+
+    // Take the mean of the first difference
+    double expect_diff = mean_diff(x);
+
+    arma::vec theta_star = guess_initial(desc, objdesc, model_type, p, expect_diff, N, wv_empir, scales, 10000);

     // Obtain the GMWM estimator's estimates. (WV_EMPIR)
     arma::vec est = gmwm_engine(theta, desc, objdesc, model_type,
                                 wv_empir, omega, scales, false);

+    arma::vec est_starting = gmwm_engine(theta_star, desc, objdesc, model_type,
+                                         wv_empir, omega, scales, true);
+
     // Obtain the objective value function
-    obj_values(i) = getObjFun(est, desc, objdesc, model_type, omega, wv_empir, scales);
+    obj_values(i) = getObjFun(est_starting, desc, objdesc, model_type, omega, wv_empir, scales);

     // Decomposition of the WV.
     theo.col(i) = theoretical_wv(est, desc, objdesc, scales);
@@ -409,13 +422,23 @@
     arma::mat omega = arma::inv(fast_cov_cpp(wvar.col(2), wvar.col(1)));

     arma::vec wv_empir = wvar.col(0);
+
+    // Take the mean of the first difference
+    double expect_diff = mean_diff(x);
+
+    arma::vec theta_star = guess_initial(desc, objdesc, model_type, p, expect_diff, N, wv_empir, scales, 10000);
+

     // Obtain the GMWM estimator's estimates. (WV_EMPIR)
     arma::vec est = gmwm_engine(theta, desc, objdesc, model_type,
                                 wv_empir, omega, scales, false);

+
+    arma::vec est_starting = gmwm_engine(theta_star, desc, objdesc, model_type,
+                                         wv_empir, omega, scales, true);
+
     // Obtain the objective value function
-    obj_values(i) = getObjFun(est, desc, objdesc, model_type, omega, wv_empir, scales);
+    obj_values(i) = getObjFun(est_starting, desc, objdesc, model_type, omega, wv_empir, scales);

     // Decomposition of the WV.
     theo.col(i) = theoretical_wv(est, desc, objdesc, scales);
@@ -444,6 +467,6 @@

   // Obj Fun
   out(4) = obj_values; // Use N-1 and take by row
-
+
   return out;
 }


cleanup error syntax

cleanup error syntax

--- src/builtin_syntax.cc
+++ src/builtin_syntax.cc
@@ -17,22 +17,13 @@

 namespace {

-Lisp_ptr error_whole_function(const char* msg){
+Lisp_ptr whole_function_error(){
   ZsArgs wargs{1};
   auto sym = wargs[0].get<Cons*>()->car().get<Symbol*>();
-
   assert(sym);

-  throw make_zs_error("eval error: '%s' -- %s\n",
-                      sym->name().c_str(), msg);
-}
-
-Lisp_ptr whole_function_error(){
-  return error_whole_function("cannot be used as operator!!");
-}
-
-Lisp_ptr whole_function_unimplemented(){
-  return error_whole_function("under development...");
+  throw make_zs_error("eval error: '%s' -- cannot be used as operator!!\n",
+                      sym->name().c_str());
 }

 Lisp_ptr whole_function_pass_through(){


fixed arg passing

fixed arg passing

--- src/builtin_util.i.hh
+++ src/builtin_util.i.hh
@@ -9,6 +9,7 @@
 #include <vector>
 #include <array>
 #include <cstdio>
+#include <iterator>

 #include "util.hh"
 #include "lisp_ptr.hh"
@@ -57,15 +58,19 @@
   Lisp_ptr argc = st.back();
   st.pop_back();

-  for(int i = 0; i < argc.get<int>(); ++i){
-    v.push_back(st.back());
-    st.pop_back();
+  auto arg_start = st.end() - argc.get<int>();
+  auto arg_end = st.end();
+
+  for(auto i = arg_start; i != arg_end; ++i){
+    v.push_back(*i);
   }
+
+  st.erase(arg_start, arg_end);
 }

 template<typename StackT>
 int list_to_stack(const char* opname, Lisp_ptr l, StackT& st){
-  std::stack<Lisp_ptr, std::vector<Lisp_ptr>> tmp;
+  std::stack<Lisp_ptr> tmp;

   do_list(l,
           [&](Cons* c) -> bool {
@@ -103,9 +108,9 @@
   }

   for(int i = 0; i < size; ++i){
-    ret[i] = vm.stack.back();
-    vm.stack.pop_back();
+    ret[i] = vm.stack[vm.stack.size() - size + i];
   }
+  vm.stack.erase(vm.stack.end() - size, vm.stack.end());

   return ret;
 }


Speedup of Spatial BVH split code

Speedup of Spatial BVH split code

Avoid memmove() happening on every insert of duplicated node to the references
list. Temporary pre-allocated vector is used for new references which is then
being inserted into actual array in one go later.

Gives around 4x speedup building spatially split BVH for the grass field in the
cassette player shot from Gooseberry.

--- src/bvh/bvh_split.cpp
+++ src/bvh/bvh_split.cpp
@@ -191,11 +191,16 @@
 		}
 	}

-	/* duplicate or unsplit references intersecting both sides. */
+	/* Duplicate or unsplit references intersecting both sides.
+	 *
+	 * Duplication happens into a temporary pre-allocated vector in order to
+	 * reduce number of memmove() calls happening in vector.insert().
+	 */
+	vector<BVHReference> new_refs;
+	new_refs.reserve(right_start - left_end);
 	while(left_end < right_start) {
 		/* split reference. */
 		BVHReference lref, rref;
-
 		split_reference(builder, lref, rref, refs[left_end], this->dim, this->pos);

 		/* compute SAH for duplicate/unsplit candidates. */
@@ -234,11 +239,16 @@
 			left_bounds = ldb;
 			right_bounds = rdb;
 			refs[left_end++] = lref;
-			refs.insert(refs.begin() + right_end, rref);
+			new_refs.push_back(rref);
 			right_end++;
 		}
 	}
-
+	/* Insert duplicated references into actual array in one go. */
+	if(new_refs.size() != 0) {
+		refs.insert(refs.begin() + right_end - new_refs.size(),
+		            new_refs.begin(),
+		            new_refs.end());
+	}
 	left = BVHRange(left_bounds, left_start, left_end - left_start);
 	right = BVHRange(right_bounds, right_start, right_end - right_start);
 }


make textured tank be 50% trans if it has PZ and is active

git-svn-id: 67bf12f30ddf2081c31403e0b02b2123541f1680@5381 08b3d480-bf2c-0410-a26f-811ee3361c24

--- src/bzflag/Player.cxx
+++ src/bzflag/Player.cxx
@@ -245,7 +245,7 @@
   static const GLfloat	tankSpecular[3] = { 0.1f, 0.1f, 0.1f };
   static GLfloat	tankEmissive[3] = { 0.0f, 0.0f, 0.0f };
   static float		tankShininess = 20.0f;
-  static GLfloat	rabbitEmissive[3] = { 0.25f, 0.25f, 0.25f };
+  static GLfloat	rabbitEmissive[3] = { 0.0f, 0.0f, 0.0f };
   static float		rabbitShininess = 100.0f;

   GLfloat *emissive;
@@ -302,7 +302,7 @@
       color[2] = _color[2];
     }
   }
-  color[3] = 1.0f;
+  color[3] = (getFlag() == Flags::PhantomZone) && isFlagActive() ? 0.5f : 1.0f;
   tankNode->setColor(color);
   tankNode->setMaterial(OpenGLMaterial(tankSpecular, emissive, shininess));
   tankNode->setTexture(*tankTexture);


Fix crash when pre-translating big XLIFF documents

Massively-parallel local TM pre-translation could segfault, because
Poedit didn't respect pugixml's (limited) thread-safety guarantees.

--- src/catalog_xliff.cpp
+++ src/catalog_xliff.cpp
@@ -36,6 +36,7 @@
 #include <boost/algorithm/string.hpp>

 #include <memory>
+#include <mutex>
 #include <set>
 #include <sstream>

@@ -44,6 +45,11 @@

 namespace
 {
+
+// FIXME: This should be per-document mutex in XLIFFCatalog, but that is
+//        currently not accessible from XLIFFCatalogItem, hence a global.
+std::mutex gs_documentMutex;
+

 inline bool has_child_elements(xml_node node)
 {
@@ -511,6 +517,9 @@
     {
         wxASSERT( m_translations.size() == 1 ); // no plurals

+        // modifications in the pugixml tree can affect other nodes, we must lock the entire document
+        std::lock_guard<std::mutex> lock(gs_documentMutex);
+
         auto target = m_node.child("target");
         if (!target)
         {
@@ -672,6 +681,9 @@
     {
         wxASSERT( m_translations.size() == 1 ); // no plurals

+        // modifications in the pugixml tree can affect other nodes, we must lock the entire document
+        std::lock_guard<std::mutex> lock(gs_documentMutex);
+
         auto target = m_node.child("target");
         if (!target)
         {


XLIFF: use needs-l10n for fuzzy state

XLIFF: use needs-l10n for fuzzy state

Per spec (http://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html#state)
"needs-adaptation" was wrong, as it concerns only non-textual
information; needs-l10n (both textual and non-textual) is more
appropriate.

--- src/catalog_xliff.cpp
+++ src/catalog_xliff.cpp
@@ -545,7 +545,7 @@
         target.remove_attribute("state-qualifier");

         if (isTranslated)
-            attribute(target, "state") = isFuzzy ? "needs-adaptation" : "translated";
+            attribute(target, "state") = isFuzzy ? "needs-l10n" : "translated";
         else
             attribute(target, "state") = "needs-translation";
     }


Fixed crash because of an uninitialized input

git-svn-id: 0634bf30b6d7a21f2003d4a9f34c102a3ffa6fda@2738 34602234-ff1f-0410-a465-ea8f3b77ab7f

--- src/client/AuxLib.cpp
+++ src/client/AuxLib.cpp
@@ -439,7 +439,7 @@
 void ProcessScreenshots()
 {
 	// Check if user pressed screenshot key
-	if (cTakeScreenshot->isDownOnce())  {
+	if (cTakeScreenshot && cTakeScreenshot->isDownOnce())  {
 		screenshot_t scr;
 		scr.sData = "";
 		scr.sDir = "scrshots";


Another stule tweak

Another stule tweak

--- src/client_manager.cc
+++ src/client_manager.cc
@@ -152,10 +152,9 @@

 Client& ClientManager::get_client(StringView name)
 {
-    Client* client = get_client_ifp(name);
-    if (not client)
-        throw runtime_error("no client named: " + name);
-    return *client;
+    if (Client* client = get_client_ifp(name))
+        return *client;
+    throw runtime_error("no client named: " + name);
 }

 void ClientManager::redraw_clients() const


Fixed crash when the model does not contain any reactions.

--- copasi/elementaryFluxModes/CStepMatrix.cpp
+++ copasi/elementaryFluxModes/CStepMatrix.cpp
@@ -1,9 +1,9 @@
 // Begin CVS Header
 //   $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/elementaryFluxModes/CStepMatrix.cpp,v $
-//   $Revision: 1.6 $
+//   $Revision: 1.7 $
 //   $Name:  $
 //   $Author: shoops $
-//   $Date: 2009/09/24 18:13:13 $
+//   $Date: 2009/09/29 16:33:48 $
 // End CVS Header

 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
@@ -81,7 +81,14 @@
   // We need to add the information of the unconverted rows of nullspace matrix
   // to the columns

-  pValue = & nullspaceMatrix(mFirstUnconvertedRow, 0);
+  if (nullspaceMatrix.size() != 0)
+    {
+      pValue = & nullspaceMatrix(mFirstUnconvertedRow, 0);
+    }
+  else
+    {
+      pValue = NULL;
+    }

   for (i = mFirstUnconvertedRow; i < mRows; ++i)
     {


--- BaseType.cc
+++ BaseType.cc
@@ -10,6 +10,9 @@
 // jhrg 9/6/94

 // $Log: BaseType.cc,v $
+// Revision 1.27  1996/10/28 23:43:55  jimg
+// Added UInt32 to type names returned by type_name() member function.
+//
 // Revision 1.26  1996/06/04 21:33:09  jimg
 // Multiple connections are now possible. It is now possible to open several
 // URLs at the same time and read from them in a round-robin fashion. To do
@@ -272,6 +275,8 @@
 	return String("Byte");
       case dods_int32_c:
 	return String("Int32");
+      case dods_uint32_c:
+	return String("UInt32");
       case dods_float64_c:
 	return String("Float64");
       case dods_str_c: