예제 #1
0
/*
 * Class:     org_voltdb_jni_ExecutionEngine
 * Method:    nativeUpdateHashinator
 * Signature: (JI)I
 */
SHAREDLIB_JNIEXPORT void JNICALL Java_org_voltdb_jni_ExecutionEngine_nativeUpdateHashinator(JNIEnv *env, jobject obj, jlong engine_ptr)
{
    VOLT_DEBUG("nativeUpdateHashinator in C++ called");
    VoltDBEngine *engine = castToEngine(engine_ptr);
    assert(engine);
    Topend *topend = static_cast<JNITopend*>(engine->getTopend())->updateJNIEnv(env);
    try {
        updateJNILogProxy(engine); //JNIEnv pointer can change between calls, must be updated
        NValueArray& params = engine->getParameterContainer();
        Pool *stringPool = engine->getStringPool();
        deserializeParameterSet(engine->getParameterBuffer(), engine->getParameterBufferCapacity(), params, engine->getStringPool());
        HashinatorType hashinatorType = static_cast<HashinatorType>(voltdb::ValuePeeker::peekAsInteger(params[0]));
        const char *configValue = static_cast<const char*>(voltdb::ValuePeeker::peekObjectValue(params[1]));
        engine->updateHashinator(hashinatorType, configValue);
        stringPool->purge();
    } catch (const FatalException &e) {
        topend->crashVoltDB(e);
    }
}
// Add missing descriptors which are not computed yet, but will be for the
// final release or during the 1.x cycle. However, the schema need to be
// complete before that, so just put default values for these.
// Also make sure that some descriptors that might have f****d up come out nice.
void PostProcess(Pool& pool, const Pool& options, const string& nspace) {
  if (options.value<Real>("rhythm.compute") != 0) {
    string rhythmspace = "rhythm.";
    if (!nspace.empty()) rhythmspace = nspace + ".rhythm.";
    const vector<string>& descNames = pool.descriptorNames();
    if (find(descNames.begin(), descNames.end(), rhythmspace + "bpm_confidence") == descNames.end())
      pool.set(rhythmspace + "bpm_confidence", 0.0);
    if (find(descNames.begin(), descNames.end(), rhythmspace + "perceptual_tempo") == descNames.end())
      pool.set(rhythmspace + "perceptual_tempo", "unknown");
    if (find(descNames.begin(), descNames.end(), rhythmspace + "beats_loudness") == descNames.end())
      pool.add(rhythmspace + "beats_loudness", Real(0.0));
    if (find(descNames.begin(), descNames.end(), rhythmspace + "beats_loudness_band_ratio") == descNames.end())
      pool.add(rhythmspace + "beats_loudness_band_Ratio", vector<Real>());
    //if (find(descNames.begin(), descNames.end(), rhythmspace + "rubato_start") == descNames.end())
    //  pool.set(rhythmspace + "rubato_start", vector<Real>(0));
    //if (find(descNames.begin(), descNames.end(), rhythmspace + "rubato_stop") == descNames.end())
    //  pool.set(rhythmspace + "rubato_stop", vector<Real>(0));
  }
}
void computeMidLevel(const string& audioFilename, Real startTime, Real endTime, Pool& pool, const Pool& options, const string& nspace) {

  /*************************************************************************
   *    3rd pass: HPCP & beats loudness (depend on some descriptors that   *
   *              have been computed during the 2nd pass)                  *
   *************************************************************************/
  Real replayGain = 0;
  Real analysisSampleRate = options.value<Real>("analysisSampleRate");

  const vector<string>& desc = pool.descriptorNames();
  if (find(desc.begin(), desc.end(), "replayGain") != desc.end()) {
    replayGain = pool.value<Real>("metadata.audio_properties.replay_gain");
  }
  string downmix = "mix";
  try {
    downmix = pool.value<string>("metadata.audio_properties.downmix");
  }
  catch (const EssentiaException&) {
    throw EssentiaException("StreamingExtractor::computeLowLevel, could not determine downmix type");
  }

  streaming::AlgorithmFactory& factory = streaming::AlgorithmFactory::instance();

  Algorithm* audio_3 = factory.create("EqloudLoader",
                                               "filename", audioFilename,
                                               "sampleRate", analysisSampleRate,
                                               "startTime", startTime,
                                               "endTime", endTime,
                                               "replayGain", replayGain,
                                               "downmix", downmix);


  SourceBase& audioSource_2 = audio_3->output("audio");

  // Compute Tonal descriptors (needed TuningFrequency before)
  TonalDescriptors(audioSource_2, pool, options, nspace);


  // Compute the loudness at the beats position (needed beats position)
  string rhythmspace = "rhythm.";
  if (!nspace.empty()) rhythmspace = nspace + ".rhythm.";
  vector<Real> ticks = pool.value<vector<Real> >(rhythmspace + "beats_position");

  Algorithm* beatsLoudness = factory.create("BeatsLoudness",
                                                     "sampleRate", analysisSampleRate,
                                                     "beats", ticks);

  connect(audioSource_2, beatsLoudness->input("signal"));
  connect(beatsLoudness->output("loudness"), pool, rhythmspace + "beats_loudness");
  connect(beatsLoudness->output("loudnessBandRatio"), pool, rhythmspace + "beats_loudness_band_ratio");

  cout << "Process step 3: Mid Level" << endl;
  Network network(audio_3);
  network.run();
}
예제 #4
0
void SVNAdmin::deltify(const char *path, Revision &revStart, Revision &revEnd)
{
  Pool requestPool;
  SVN_JNI_NULL_PTR_EX(path, "path", );
  path = svn_path_internal_style(path, requestPool.pool());
  svn_repos_t *repos;
  svn_fs_t *fs;
  svn_revnum_t start = SVN_INVALID_REVNUM, end = SVN_INVALID_REVNUM;
  svn_revnum_t youngest, revision;
  Pool revisionPool;

  SVN_JNI_ERR(svn_repos_open(&repos, path, requestPool.pool()), );
  fs = svn_repos_fs (repos);
  SVN_JNI_ERR(svn_fs_youngest_rev(&youngest, fs, requestPool.pool()), );

  if (revStart.revision()->kind == svn_opt_revision_number)
    /* ### We only handle revision numbers right now, not dates. */
    start = revStart.revision()->value.number;
  else if (revStart.revision()->kind == svn_opt_revision_head)
    start = youngest;
  else
    start = SVN_INVALID_REVNUM;

  if (revEnd.revision()->kind == svn_opt_revision_number)
    end = revEnd.revision()->value.number;
  else if (revEnd.revision()->kind == svn_opt_revision_head)
    end = youngest;
  else
    end = SVN_INVALID_REVNUM;

  /* Fill in implied revisions if necessary. */
  if (start == SVN_INVALID_REVNUM)
    start = youngest;
  if (end == SVN_INVALID_REVNUM)
    end = start;

  if (start > end)
    {
      SVN_JNI_ERR(svn_error_create
                  (SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
                   _("First revision cannot be higher than second")), );
    }
예제 #5
0
파일: path.cpp 프로젝트: Jopie64/GitSvn2
  void
  Path::init(const char * path)
  {
    Pool pool;

    m_pathIsUrl = false;

    if (path == 0)
      m_path = "";
    else
    {
      const char * int_path =
        svn_path_internal_style(path, pool.pool());

      m_path = int_path;

      if (svn::Url::isValid(int_path))
        m_pathIsUrl = true;
    }
  }
예제 #6
0
/*
 * Class:     org_voltdb_jni_ExecutionEngine
 * Method:    nativeHashinate
 * Signature: (JI)I
 */
SHAREDLIB_JNIEXPORT jint JNICALL Java_org_voltdb_jni_ExecutionEngine_nativeHashinate(JNIEnv *env, jobject obj, jlong engine_ptr, jint partitionCount)
{
    VOLT_DEBUG("nativeHashinate in C++ called");
    VoltDBEngine *engine = castToEngine(engine_ptr);
    assert(engine);
    try {
        updateJNILogProxy(engine); //JNIEnv pointer can change between calls, must be updated
        NValueArray& params = engine->getParameterContainer();
        Pool *stringPool = engine->getStringPool();
        deserializeParameterSet(engine->getParameterBuffer(), engine->getParameterBufferCapacity(), params, engine->getStringPool());
        int retval =
            voltdb::TheHashinator::hashinate(params[0], partitionCount);
        stringPool->purge();
        return retval;
    } catch (FatalException e) {
        std::cout << "HASHINATE ERROR: " << e.m_reason << std::endl;
        return org_voltdb_jni_ExecutionEngine_ERRORCODE_ERROR;
    }
    return org_voltdb_jni_ExecutionEngine_ERRORCODE_ERROR;
}
예제 #7
0
void idle(void) {
    thisTime = glutGet(GLUT_ELAPSED_TIME);
    if (thisTime - lastTime > 1000 / FPS) {
        // update the fountain and the pool
        fountain.update(TIME_DELTA, pool);
        pool.update(TIME_DELTA);

        //render the scene:
        display();
        lastTime = thisTime;
    }
}
예제 #8
0
OXT_FORCE_INLINE void
Group::onSessionInitiateFailure(Process *process, Session *session) {
	boost::container::vector<Callback> actions;

	TRACE_POINT();
	// Standard resource management boilerplate stuff...
	Pool *pool = getPool();
	boost::unique_lock<boost::mutex> lock(pool->syncher);
	assert(process->isAlive());
	assert(isAlive() || getLifeStatus() == SHUTTING_DOWN);

	UPDATE_TRACE_POINT();
	P_DEBUG("Could not initiate a session with process " <<
		process->inspect() << ", detaching from pool if possible");
	if (!pool->detachProcessUnlocked(process->shared_from_this(), actions)) {
		P_DEBUG("Process was already detached");
	}
	pool->fullVerifyInvariants();
	lock.unlock();
	runAllActions(actions);
}
예제 #9
0
void EntityManager::Dump()
{
	Logger::Info("============================");
	Logger::Info("EntityManager dump");
	Logger::Info("============================");
	Logger::Info("Pools:");
	Logger::Info("============================");
	
	Map<const char *, Pool *>::iterator poolIterator;
	for(poolIterator = pools.begin(); poolIterator != pools.end(); ++poolIterator)
	{
		const char * poolName = poolIterator->first;
		Pool * pool = poolIterator->second;
		Logger::Info("Pool \"%s\" of type %s", poolName, typeid(*pool).name());
		Logger::Info("----------------------------");
		
		while(pool)
		{
			int32 count = pool->GetCount();
			int32 maxCount = pool->GetMaxCount();
			Logger::Info("    subpool of family %lld (%d elements, %d maxCount, %d bytes)", pool->GetEntityFamily()->family.GetBit(), count, maxCount, maxCount*pool->typeSizeof);
			for(int32 i = 0; i < count; ++i)
			{
				pool->DumpElement(i);
			}

			pool = pool->GetNext();
			Logger::Info("    ----------------------------");
		}
	}
}
예제 #10
0
 void bytePoolFree( eBytePool bytePool, u8* data )
 {
     switch( bytePool )
     {
         case eBytePool0:
         {
             break;
         }
         case eBytePool32:
         {
             _bytePool32.Delete( ( Bx32* )data );
             break;
         }
         case eBytePool128:
         {
             _bytePool128.Delete( ( Bx128* )data );
             break;
         }
         case eBytePool512:
         {
             _bytePool512.Delete( ( Bx512* )data );
             break;
         }
         case eBytePool2048:
         {
             _bytePool2048.Delete( ( Bx2048* )data );
             break;
         }
         case eBytePool8192:
         {
             _bytePool8192.Delete( ( Bx8192* )data );
             break;
         }
         case eBytePool16384:
         {
             _bytePool16384.Delete( ( Bx16384* )data );
             break;
         }
         case eBytePool32768:
         {
             _bytePool32768.Delete( ( Bx32768* )data );
             break;
         }
         case eBytePool65534:
         {
             _bytePool65534.Delete( ( Bx65534* )data );
             break;
         }
     }
 }
// Add missing descriptors which are not computed yet, but will be for the
// final release or during the 1.x cycle. However, the schema need to be
// complete before that, so just put default values for these.
// Also make sure that some descriptors that might have f****d up come out nice.
void PostProcess(Pool& pool, const string& nspace) {
  string rhythmspace = "rhythm.";
  if (!nspace.empty()) rhythmspace = nspace + ".rhythm.";
  pool.set(rhythmspace + "bpm_confidence", 0.0);
  pool.set(rhythmspace + "perceptual_tempo", "unknown");

  try {
    pool.value<vector<Real> >(rhythmspace + "beats_loudness");
  }
  catch (EssentiaException&) {
    pool.set(rhythmspace + "beats_loudness", 0.0);
    pool.set(rhythmspace + "beats_loudness_bass", 0.0);
  }

  try {
    pool.value<vector<Real> >(rhythmspace + "rubato_start");
  }
  catch (EssentiaException&) {
    pool.set(rhythmspace + "rubato_start", vector<Real>(0));
  }

  try {
    pool.value<vector<Real> >(rhythmspace + "rubato_stop");
  }
  catch (EssentiaException&) {
    pool.set(rhythmspace + "rubato_stop", vector<Real>(0));
  }

  // PCA analysis of spectral contrast output:
  PCA(pool, nspace);
}
예제 #12
0
void SVNAdmin::create(const char *path, bool disableFsyncCommits,
                      bool keepLogs, const char *configPath,
                      const char *fstype)
{
  Pool requestPool;
  SVN_JNI_NULL_PTR_EX(path, "path", );
  path = svn_path_internal_style(path, requestPool.pool());
  if (configPath != NULL)
    configPath = svn_path_internal_style(configPath, requestPool.pool());
  svn_repos_t *repos;
  apr_hash_t *config;
  apr_hash_t *fs_config = apr_hash_make (requestPool.pool());;

  apr_hash_set (fs_config, SVN_FS_CONFIG_BDB_TXN_NOSYNC,
                APR_HASH_KEY_STRING,
                (disableFsyncCommits? "1" : "0"));

  apr_hash_set (fs_config, SVN_FS_CONFIG_BDB_LOG_AUTOREMOVE,
                APR_HASH_KEY_STRING,
                (keepLogs ? "0" : "1"));
  apr_hash_set (fs_config, SVN_FS_CONFIG_FS_TYPE,
                APR_HASH_KEY_STRING,
                fstype);

  SVN_JNI_ERR(svn_config_get_config(&config,
                                    configPath,
                                    requestPool.pool()),);
  SVN_JNI_ERR(svn_repos_create(&repos, path, NULL, NULL,
                               config, fs_config, requestPool.pool()), );
}
예제 #13
0
Pool * EntityManager::CreatePool(const char * dataName, int32 maxSize)
{
	Pool * pool = 0;

    Map<const char *, Pool *>::iterator poolsIt = poolAllocators.find(dataName);
    if (poolsIt != poolAllocators.end())
    {
        Pool * newPool = poolsIt->second->CreateCopy(maxSize);

        Pool * prevPool = 0;
        Map<const char *, Pool*>::iterator find = pools.find(dataName);
        if(pools.end() != find)
        {
            prevPool = find->second;
        }
        newPool->SetNext(prevPool);
        pools[dataName] = newPool;
		pool = newPool;
    }
	
	return pool;
}
예제 #14
0
bool StreamedTable::insertTuple(TableTuple &source)
{
    size_t mark = 0;
    if (m_wrapper) {
        mark = m_wrapper->appendTuple(m_executorContext->m_lastCommittedTxnId,
                                      m_executorContext->currentTxnId(),
                                      m_sequenceNo++,
                                      m_executorContext->currentTxnTimestamp(),
                                      source,
                                      TupleStreamWrapper::INSERT);
        m_tupleCount++;
        m_usedTupleCount++;

        UndoQuantum *uq = m_executorContext->getCurrentUndoQuantum();
        Pool *pool = uq->getDataPool();
        StreamedTableUndoAction *ua =
          new (pool->allocate(sizeof(StreamedTableUndoAction)))
          StreamedTableUndoAction(this, mark);
        uq->registerUndoAction(ua);
    }
    return true;
}
예제 #15
0
파일: pool.c 프로젝트: bhanug/mps
Res PoolFix(Pool pool, ScanState ss, Seg seg, Addr *refIO)
{
  AVERT_CRITICAL(Pool, pool);
  AVERT_CRITICAL(ScanState, ss);
  AVERT_CRITICAL(Seg, seg);
  AVER_CRITICAL(pool == SegPool(seg));
  AVER_CRITICAL(refIO != NULL);

  /* Should only be fixing references to white segments. */
  AVER_CRITICAL(TraceSetInter(SegWhite(seg), ss->traces) != TraceSetEMPTY);

  return pool->fix(pool, ss, seg, refIO);
}
void LevelAverage(Pool& pool, const string& nspace) {

  // namespace:
  string llspace = "lowlevel.";
  if (!nspace.empty()) llspace = nspace + ".lowlevel.";

  vector<Real> levelArray = pool.value<vector<Real> >(llspace + "loudness");
  pool.remove(llspace + "loudness");

  // Maximum dynamic
  Real EPSILON = 10e-5;
  Real maxValue = levelArray[argmax(levelArray)];
  if (maxValue <= EPSILON) {
    maxValue = EPSILON;
  }

  // Normalization to the maximum
  Real THRESHOLD = 0.0001; // this corresponds to -80dB
  for (uint i=0; i<levelArray.size(); i++) {
    levelArray[i] /= maxValue;
    if (levelArray[i] <= THRESHOLD) {
      levelArray[i] = THRESHOLD;
    }
  }

  // Average Level
  Real levelAverage = 10*log10(mean(levelArray));

  // Re-scaling and range-control
  // This yields in numbers between
  // 0 for signals with  large dynamic variace and thus low dynamic average
  // 1 for signal with little dynamic range and thus
  // a dynamic average close to the maximum
  Real x1 = -5.0;
  Real x2 = -2.0;
  Real levelAverageSqueezed = squeezeRange(levelAverage, x1, x2);
  pool.set(llspace + "average_loudness", levelAverageSqueezed);
}
예제 #17
0
TEST(move, DISABLED_there_should_be_only_one_owner)
{
    class Resource {
    public:
        Resource(std::string id)
            : id(std::move(id))
        {}

        std::string id;
    };

    class Pool {
    public:
        Pool()
            : resources{ {Resource{"one"}, Resource{"two"}} }
        {}
        size_t size() const {
            return resources.size();
        }
        
        Resource borrow() {
            return Resource{ "?" };
        }
        
        void return_(Resource) {}

        bool contains(const std::string &id) const
        {
            return std::any_of(begin(resources), end(resources),
                [&](const auto &resource) { return resource.id == id; });
        }
    private:
        std::vector<Resource> resources;
    };


    Pool pool;
    auto r1 = pool.borrow();
    EXPECT_EQ("one", r1.id);
    EXPECT_EQ(1u, pool.size());
    EXPECT_FALSE(pool.contains("one"));
    EXPECT_TRUE(pool.contains("two"));

    pool.return_(r1);
    EXPECT_EQ(2u, pool.size());
    EXPECT_TRUE(pool.contains("one")); 
    EXPECT_TRUE(pool.contains("two"));
}
예제 #18
0
double DecisionTree::infoGain(const CategoricalDescriptor& desc,const Pool& currPool,double first)
{
    double sum = 0;

    for(int i=0;i<desc.levelSize();i++)
    {
        std::vector<int> descIdxs = desc.idxs(i);
        std::vector<int> probPoolLev(currPool.levelSize());
        for(int j=0;j<currPool.levelSize();j++)
        {
            std::vector<int> respIdxs = currPool.idxs(j);
            std::vector<int> intersec;
            intersec.reserve(currPool.sampleSize());
            std::set_intersection(descIdxs.begin(),descIdxs.end(),respIdxs.begin(),
                                    respIdxs.end(),std::back_inserter(intersec));
            probPoolLev[j] = intersec.size();
        }
        double totPoolInLeaf = static_cast<double>(std::accumulate(probPoolLev.begin(),probPoolLev.end(),0));

        sum +=  (totPoolInLeaf/currPool.sampleSize())*entropy(probPoolLev,totPoolInLeaf);
    }
    return first-sum;
}
예제 #19
0
void setOptions(Pool& options, const std::string& filename) {
  setDefaultOptions(options);
  if (filename.empty()) return;
  Pool opts;
  standard::Algorithm * yaml = standard::AlgorithmFactory::create("YamlInput", "filename", filename);
  yaml->output("pool").set(opts);
  yaml->compute();
  delete yaml;
  options.merge(opts, "replace");
  //const vector<string>& descriptorNames = options.descriptorNames();
  //for (int i=0; i<(int)descriptorNames.size(); i++) {
  //  cout << descriptorNames[i] << endl;
  //}
}
    void testUserHome() {
      LogString actual(OptionConverter::substVars(
         LOG4CXX_STR("${user.home}"), nullProperties));
      Pool p;

      apr_uid_t userid;
      apr_gid_t groupid;
      apr_status_t stat = apr_uid_current(&userid, &groupid, p.getAPRPool());
      if (stat == APR_SUCCESS) {
         char* username = NULL;
         stat = apr_uid_name_get(&username, userid, p.getAPRPool());
         if (stat == APR_SUCCESS) {
            char* dirname = NULL;
            stat = apr_uid_homepath_get(&dirname, username, p.getAPRPool());
            if (stat == APR_SUCCESS) {
               LogString expected;
               Transcoder::decode(dirname, expected);
               LOGUNIT_ASSERT_EQUAL(expected, actual);
             }
          }
      }   

    }
void PCA(Pool& pool, const string& nspace) {

  // namespace:
  string llspace = "lowlevel.";
  if (!nspace.empty()) llspace = nspace + ".lowlevel.";

  vector<vector<Real> > sccoeffs = pool.value<vector<vector<Real> > >(llspace + "sccoeffs");
  vector<vector<Real> > scvalleys = pool.value<vector<vector<Real> > >(llspace + "scvalleys");

  Pool poolSc, poolTransformed;

  for (int iFrame = 0; iFrame < (int)sccoeffs.size(); iFrame++) {
    vector<Real> merged(2*sccoeffs[iFrame].size(), 0.0);
    for(int i=0, j=0; i<(int)sccoeffs[iFrame].size(); i++, j++) {
      merged[j++] = sccoeffs[iFrame][i];
      merged[j] = scvalleys[iFrame][i];
    }
    poolSc.add("contrast", merged);
  }

  standard::Algorithm* pca  = standard::AlgorithmFactory::create("PCA",
                                             "namespaceIn",  "contrast",
                                             "namespaceOut", "contrast");
  pca->input("poolIn").set(poolSc);
  pca->output("poolOut").set(poolTransformed);
  pca->compute();

  pool.set(llspace + "spectral_contrast.mean",
           meanFrames(poolTransformed.value<vector<vector<Real> > >("contrast")));
  pool.set(llspace + "spectral_contrast.var",
           varianceFrames(poolTransformed.value<vector<vector<Real> > >("contrast")));

  // remove original data from spectral contrast:
  pool.remove(llspace + "sccoeffs");
  pool.remove(llspace + "scvalleys");
  delete pca;
}
예제 #22
0
// Function runs at set interval, (a onFrame function, of sorts)
void onFrame(int value) {
	// emitter stuff
	static int count = 0;
	count++;
	if (count % EMIT_FRAME_DELAY == 0) {
		for (int i = 0; i < EMIT_AMOUNT; i++) {

			if (pool.count() >= MAX_PARTICLES)
				break;

			Particle* t = pool.new_object();

			init_random_triparticle(t);

		}
	}

	for (int i = 0; i < pool.count(); ++i) {
		Particle* t = pool.at(i);

		update_triparticle(t);

		if (t->lifetime < 0)
		{
			pool.mark_dead(i--);
			continue;
		}

		// Draw the triparticle to the buffer arrays
		drawInBuffer(t, i);
	}

	display();

	// Call this func again after delay
	glutTimerFunc(FRAME_MSEC, onFrame, 0);
}
예제 #23
0
void LocationInfo::write(ObjectOutputStream& os, Pool& p) const {
    if (lineNumber == -1 && fileName == NA && methodName == NA_METHOD) {
         os.writeNull(p);
    } else {
        unsigned char prolog[] = {
         0x72,
         0x00,
         0x21, 0x6F, 0x72, 0x67, 0x2E, 0x61, 0x70, 0x61, 0x63, 0x68, 0x65, 0x2E,
         0x6C, 0x6F, 0x67, 0x34, 0x6A, 0x2E, 0x73, 0x70, 0x69, 0x2E, 0x4C, 0x6F,
         0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x49, 0x6E, 0x66, 0x6F, 0xED, 0x99,
         0xBB, 0xE1, 0x4A, 0x91, 0xA5, 0x7C, 0x02,
         0x00,
         0x01, 0x4C,
         0x00,
         0x08, 0x66, 0x75, 0x6C, 0x6C, 0x49, 0x6E, 0x66, 0x6F, 0x74,
         0x00,
         0x12, 0x4C, 0x6A, 0x61, 0x76, 0x61, 0x2F, 0x6C, 0x61, 0x6E, 0x67, 0x2F,
         0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x3B, 0x78, 0x70
        };
      os.writeProlog("org.apache.log4j.spi.LocationInfo", 2, (char*) prolog, sizeof(prolog), p);
        char* line = p.itoa(lineNumber);
        //
        //   construct Java-like fullInfo (replace "::" with ".")
        //
        std::string fullInfo(methodName);
        size_t openParen = fullInfo.find('(');
        if (openParen != std::string::npos) {
            size_t space = fullInfo.find(' ');
            if (space != std::string::npos && space < openParen) {
                fullInfo.erase(0, space + 1);
            }
        }
        openParen = fullInfo.find('(');
        if (openParen != std::string::npos) {
            size_t classSep = fullInfo.rfind("::", openParen);
            if (classSep != std::string::npos) {
                fullInfo.replace(classSep, 2, ".");
            } else {
                fullInfo.insert(0, ".");
            }
        }
        fullInfo.append(1, '(');
        fullInfo.append(fileName);
        fullInfo.append(1, ':');
        fullInfo.append(line);
        fullInfo.append(1, ')');
        os.writeUTFString(fullInfo, p);
    }
}
예제 #24
0
파일: main.cpp 프로젝트: MyBoon/Object-Pool
int main()
{
	Pool p;
	p.configure<Human>(500);
	p.configure<Animal>(200);

	Human *h1 = p.get<Human>();
	if (h1)
	{
		std::cout << "life : " << h1->getLife() << std::endl;
		std::cout << p.size<Human>() << std::endl;
		p.release(h1);
		std::cout << p.size<Human>() << std::endl;
	}

	Animal *a1 = p.get<Animal>();
	if (a1)
	{
		std::cout << "life : " << a1->getLife() << std::endl;
		std::cout << p.size<Animal>() << std::endl;
		p.release(a1);
		std::cout << p.size<Animal>() << std::endl;
	}
}
예제 #25
0
/*
 * Class:     org_voltdb_jni_ExecutionEngine
 * Method:    nativeUpdateHashinator
 * Signature: (JI)I
 */
SHAREDLIB_JNIEXPORT void JNICALL Java_org_voltdb_jni_ExecutionEngine_nativeUpdateHashinator(JNIEnv *env, jobject obj, jlong engine_ptr, jint type, jlong configPtr, jint tokenCount)
{
    VOLT_DEBUG("nativeUpdateHashinator in C++ called");
    VoltDBEngine *engine = castToEngine(engine_ptr);
    assert(engine);
    Topend *topend = static_cast<JNITopend*>(engine->getTopend())->updateJNIEnv(env);
    try {
        HashinatorType hashinatorType = static_cast<HashinatorType>(type);
        //Fast path processing, just use the config given by pointer
        if (configPtr != 0) {
            engine->updateHashinator(hashinatorType, NULL, reinterpret_cast<int32_t*>(configPtr), static_cast<uint32_t>(tokenCount));
            return;
        }
        updateJNILogProxy(engine); //JNIEnv pointer can change between calls, must be updated
        NValueArray& params = engine->getParameterContainer();
        Pool *stringPool = engine->getStringPool();
        deserializeParameterSet(engine->getParameterBuffer(), engine->getParameterBufferCapacity(), params, engine->getStringPool());
        const char *configValue = static_cast<const char*>(voltdb::ValuePeeker::peekObjectValue(params[0]));
        engine->updateHashinator(hashinatorType, configValue, reinterpret_cast<int32_t*>(configPtr), static_cast<uint32_t>(tokenCount));
        stringPool->purge();
    } catch (const FatalException &e) {
        topend->crashVoltDB(e);
    }
}
예제 #26
0
// Tests that, when multiple threads ask for a child node of the same syntax
// node:
// - Only one thread inserts the realized child into the parent
// - Both threads get the exact same child (by identity)
TEST(ThreadSafeCachingTests, ReturnGetExpression) {
  auto ReturnKW = SyntaxFactory::makeReturnKeyword({}, Trivia::spaces(1));
  auto Minus = SyntaxFactory::makePrefixOperator("-", {}, {});
  auto One = SyntaxFactory::makeIntegerLiteral("1", {}, {});
  auto MinusOne = SyntaxFactory::makeIntegerLiteralExpr(Minus, One);

  Pool P;

  for (unsigned i = 0; i < 10000; ++i) {
    auto Return = SyntaxFactory::makeReturnStmt(ReturnKW, MinusOne, None);

    auto Future1 = P.run(getExpressionFrom, Return);
    auto Future2 = P.run(getExpressionFrom, Return);

    auto FirstDataPointer = Future1.get();
    auto SecondDataPointer = Future2.get();

    auto DataPointer = reinterpret_cast<uintptr_t>(
      Return.getExpression().getValue().getDataPointer());

    ASSERT_EQ(FirstDataPointer, SecondDataPointer);
    ASSERT_EQ(FirstDataPointer, DataPointer);
  }
}
예제 #27
0
 u8* bytePoolAlloc( eBytePool bytePool )
 {
     switch( bytePool )
     {
         case eBytePool0:
         {
             return Null;
         }
         case eBytePool32:
         {
             return ( u8* )_bytePool32.New();
         }
         case eBytePool128:
         {
             return ( u8* )_bytePool128.New();
         }
         case eBytePool512:
         {
             return ( u8* )_bytePool512.New();
         }
         case eBytePool2048:
         {
             return ( u8* )_bytePool2048.New();
         }
         case eBytePool8192:
         {
             return ( u8* )_bytePool8192.New();
         }
         case eBytePool16384:
         {
             return ( u8* )_bytePool16384.New();
         }
         case eBytePool32768:
         {
             return ( u8* )_bytePool32768.New();
         }
         case eBytePool65534:
         {
             return ( u8* )_bytePool65534.New();
         }
     }
 }
예제 #28
0
void computeSegments(const string& audioFilename, Real startTime, Real endTime, Pool& pool) {

  int lowlevelHopSize = 1024;
  int minimumSegmentsLength = 10;
  int size1 = 1000, inc1 = 300, size2 = 600, inc2 = 50, cpw = 5;

  // compute low level features to feed SBIc
  computeLowLevel(audioFilename, startTime, endTime, pool);

  vector<vector<Real> > features;
  try {
    features = pool.value<vector<vector<Real> > >("lowlevel.mfcc");
  }
  catch(const EssentiaException&) {
    cerr << "Error: could not find MFCC features in low level pool. Aborting..." << endl;
    exit(3);
  }

  TNT::Array2D<Real> featuresArray(features[0].size(), features.size());
  for (int frame = 0; frame < int(features.size()); ++frame) {
    for (int mfcc = 0; mfcc < int(features[0].size()); ++mfcc) {
      featuresArray[mfcc][frame] = features[frame][mfcc];
    }
  }
  // only BIC segmentation available
  standard::Algorithm* sbic = standard::AlgorithmFactory::create("SBic", "size1", size1, "inc1", inc1,
                                                                 "size2", size2, "inc2", inc2, "cpw", cpw,
                                                                 "minLength", minimumSegmentsLength);
  vector<Real> segments;
  sbic->input("features").set(featuresArray);
  sbic->output("segmentation").set(segments);
  sbic->compute();
  Real analysisSampleRate = 44100;
  try {
    analysisSampleRate = pool.value<Real>("metadata.audio_properties.analysis_sample_rate");
  }
  catch(const EssentiaException&) {
    throw EssentiaException("Warning: StreamingExtractor::computeSegments, could not find analysis sampling rate");
  }
  for (int i=0; i<int(segments.size()); ++i) {
    segments[i] *= Real(lowlevelHopSize)/analysisSampleRate;
    pool.add("segmentation.timestamps", segments[i]);
  }
}
예제 #29
0
TEST_F(PoolTest, OverflowTest) {
    Pool testPool;
    void* space;
    // Size the allocations to allow some chunk packing before overflowing several chunks.
    space = testPool.allocate(100000);
    EXPECT_NE(space, NULL);
    space = testPool.allocate(100000);
    EXPECT_NE(space, NULL);
    space = testPool.allocate(100000);
    EXPECT_NE(space, NULL);
    space = testPool.allocate(100000);
    EXPECT_NE(space, NULL);
    space = testPool.allocate(100000);
    EXPECT_NE(space, NULL);
    space = testPool.allocate(100000);
    EXPECT_NE(space, NULL);
}
예제 #30
0
파일: save.cpp 프로젝트: kekimmo/tuk
void load_actors (FILE* file, Pool& actors) {
  long int size = 0;

  int ret = fscanf(file, "Actors: %ld\n", &size);
  if (ret == EOF) {
    raisef("Failed to read actors: %s",
        ferror(file) ? strerror(errno) : "Premature EOF");
  }
  else if (ret == 0) {
    raise("Invalid actor header");
  }

  for (int i = 0; i < size; ++i) {
    int x, y;
    if (fscanf(file, "(%d, %d)\n", &x, &y) != 2) {
      raise("Invalid actor");
    }
    actors.push_back(new Actor(x, y));
  }
}