Exemplo n.º 1
0
void ASCHandler::chunk_file(std::string path)
{
	int flag = get_cost_time();
	int fd = open(path.c_str(), O_RDONLY);
	unsigned char buf[8192];
	int count;
	Chunker chunker;

	while ((count = read (fd, buf, 8192))>0)
	{
		chunker.chunk_data (buf, count);
	}
	chunker.stop ();

	std::string pa = "/tmp/asc_handler_" + SysOperation::get_type(path);

	for (unsigned i=0; i<chunker.chunk_vector().size(); i++)
	{
		chunk *c = chunker.chunk_vector()[i];
		SegInfo seg(c->hash(),									//hash
					SysOperation::get_type(path),				//type
					c->pos(),									//pos
					c->count(),									//size
					path);										//path
		write_seg_into_file(seg, pa);
		type.insert(std::make_pair(seg.type, 0)).first->second ++;
	}
	close(fd);
	chunk_time += get_cost_time() - flag;
}
Exemplo n.º 2
0
Arquivo: write.C Projeto: fd0/lbfs
  void lbfs_condwrite (uint64 off, uint32 cnt,
                       ptr<aiobuf> buf, ssize_t sz, int err)
  {
    if (err) { 
      outstanding_writes--;
      warn << "lbfs_write: read failed: " << err << "\n";
      fail ();
      return;
    }
    
    if ((unsigned)sz != cnt) {
      warn << "lbfs_write: short read: got "
	   << sz << " wanted " << cnt << "\n";
    }

    if (callback) {
      outstanding_writes--;
      fail ();
      return;
    }

    chunker.chunk_data ((unsigned char*) buf->base (), off, (unsigned)sz);
    if (chunker.cur_pos () == size)
      chunker.stop ();
    const vec<chunk *>& cv = chunker.chunk_vector ();
    if (chunkv_sz < cv.size ()) {
      for (unsigned i=chunkv_sz; i < cv.size (); i++) {
        chunk *c = cv[i];
        uint64 off = c->location ().pos ();
        uint64 cnt = c->location ().count ();
        // warn << c->hashidx () << ": " << off << "+" << cnt << "\n";

	lbfs_condwrite3args arg;
        arg.commit_to = fh;
        arg.fd = tmpfd;
	arg.offset = off;
	arg.count = cnt;
	arg.hash = c->hash ();
        ref<ex_write3res> res = New refcounted <ex_write3res>;
        outstanding_writes++;
        srv->nfsc->call (lbfs_CONDWRITE, &arg, res,
	                 wrap (this, &write_obj::condwrite_reply,
			       off, cnt, res), auth);
        c->location ().set_fh (fh);
        server::fpdb.add_entry
	  (c->hashidx (), &(c->location ()), c->location ().size ());
      }
      chunkv_sz = cv.size ();
    }
    outstanding_writes--;
  }
Exemplo n.º 3
0
EnergyChunks get_energy_chunks(boost::filesystem::path filename) {
	MonoLoader loader;
	MonoLoader::Result audio = loader.compute(filename);
	
	BPMDetection bpm_detector;
	BPMDetection::Result bpm = bpm_detector.compute(audio.signal);
	
	Chunker chunker;
	Chunker::Result chunks = chunker.compute(audio.signal, bpm.ticks, 4);
	
	Energy energy_calculator;
	std::vector<Real> energies;
	
	auto i = 0;
	for(auto const& chunk : chunks.chunks) {
		auto energy_val = energy_calculator.compute(chunk);
		
		energies.push_back(energy_val.energy);
	}
	
	return EnergyChunks(chunks.chunks, energies);
}
SimFieldDictionary::Entry *SimFieldDictionary::addEntry( U32 bucket, StringTableEntry slotName, ConsoleBaseType* type, char* value )
{
   Entry* ret;
   if(smFreeList)
   {
      ret = smFreeList;
      smFreeList = ret->next;
   }
   else
      ret = fieldChunker.alloc();

   ret->next      = mHashTable[ bucket ];
   ret->slotName  = slotName;
   ret->type      = type;
   ret->value     = value;

   mHashTable[ bucket ] = ret;
   mNumFields ++;
   mVersion ++;

   return ret;
}