Ejemplo n.º 1
0
int fch_dump(cmph_t *mphf, FILE *fd)
{
	char *buf = NULL;
	cmph_uint32 buflen;
	fch_data_t *data = (fch_data_t *)mphf->data;
	__cmph_dump(mphf, fd);

	hash_state_dump(data->h1, &buf, &buflen);
	//DEBUGP("Dumping hash state with %u bytes to disk\n", buflen);
	fwrite(&buflen, sizeof(cmph_uint32), (size_t)1, fd);
	fwrite(buf, (size_t)buflen, (size_t)1, fd);
	free(buf);

	hash_state_dump(data->h2, &buf, &buflen);
	//DEBUGP("Dumping hash state with %u bytes to disk\n", buflen);
	fwrite(&buflen, sizeof(cmph_uint32), (size_t)1, fd);
	fwrite(buf, (size_t)buflen, (size_t)1, fd);
	free(buf);

	fwrite(&(data->m), sizeof(cmph_uint32), (size_t)1, fd);
	fwrite(&(data->c), sizeof(double), (size_t)1, fd);
	fwrite(&(data->b), sizeof(cmph_uint32), (size_t)1, fd);
	fwrite(&(data->p1), sizeof(double), (size_t)1, fd);
	fwrite(&(data->p2), sizeof(double), (size_t)1, fd);
	fwrite(data->g, sizeof(cmph_uint32)*(data->b), (size_t)1, fd);
	#ifdef DEBUG
	cmph_uint32 i;
	fprintf(stderr, "G: ");
	for (i = 0; i < data->b; ++i) fprintf(stderr, "%u ", data->g[i]);
	fprintf(stderr, "\n");
	#endif
	return 1;
}
Ejemplo n.º 2
0
int chd_ph_dump(cmph_t *mphf, FILE *fd)
{
	char *buf = NULL;
	cmph_uint32 buflen;
	register size_t nbytes;
	chd_ph_data_t *data = (chd_ph_data_t *)mphf->data;
	
	__cmph_dump(mphf, fd);

	hash_state_dump(data->hl, &buf, &buflen);
	DEBUGP("Dumping hash state with %u bytes to disk\n", buflen);
	nbytes = fwrite(&buflen, sizeof(cmph_uint32), (size_t)1, fd);
	nbytes = fwrite(buf, (size_t)buflen, (size_t)1, fd);
	free(buf);

	compressed_seq_dump(data->cs, &buf, &buflen);
	DEBUGP("Dumping compressed sequence structure with %u bytes to disk\n", buflen);
	nbytes = fwrite(&buflen, sizeof(cmph_uint32), (size_t)1, fd);
	nbytes = fwrite(buf, (size_t)buflen, (size_t)1, fd);
	free(buf);

	// dumping n and nbuckets
	nbytes = fwrite(&(data->n), sizeof(cmph_uint32), (size_t)1, fd);
	nbytes = fwrite(&(data->nbuckets), sizeof(cmph_uint32), (size_t)1, fd);
	if (nbytes == 0 && ferror(fd)) {
          fprintf(stderr, "ERROR: %s\n", strerror(errno));
          return 0;
        }
	return 1;
}
Ejemplo n.º 3
0
int chm_dump(cmph_t *mphf, FILE *fd)
{
    char *buf = NULL;
    cmph_uint32 buflen;
    cmph_uint32 two = 2; //number of hash functions
    chm_data_t *data = (chm_data_t *)mphf->data;
    register size_t nbytes;

    __cmph_dump(mphf, fd);

    nbytes = fwrite(&two, sizeof(cmph_uint32), (size_t)1, fd);
    hash_state_dump(data->hashes[0], &buf, &buflen);
    DEBUGP("Dumping hash state with %u bytes to disk\n", buflen);
    nbytes = fwrite(&buflen, sizeof(cmph_uint32), (size_t)1, fd);
    nbytes = fwrite(buf, (size_t)buflen, (size_t)1, fd);
    free(buf);

    hash_state_dump(data->hashes[1], &buf, &buflen);
    DEBUGP("Dumping hash state with %u bytes to disk\n", buflen);
    nbytes = fwrite(&buflen, sizeof(cmph_uint32), (size_t)1, fd);
    nbytes = fwrite(buf, (size_t)buflen, (size_t)1, fd);
    free(buf);

    nbytes = fwrite(&(data->n), sizeof(cmph_uint32), (size_t)1, fd);
    nbytes = fwrite(&(data->m), sizeof(cmph_uint32), (size_t)1, fd);

    nbytes = fwrite(data->g, sizeof(cmph_uint32)*data->n, (size_t)1, fd);
    /*	#ifdef DEBUG
    	fprintf(stderr, "G: ");
    	for (i = 0; i < data->n; ++i) fprintf(stderr, "%u ", data->g[i]);
    	fprintf(stderr, "\n");
    	#endif*/
    return 1;
}
Ejemplo n.º 4
0
int chd_dump(cmph_t *mphf, FILE *fd)
{
	register size_t nbytes;
	chd_data_t *data = (chd_data_t *)mphf->data;
	
	__cmph_dump(mphf, fd);
	// Dumping CHD_PH perfect hash function

	DEBUGP("Dumping CHD_PH perfect hash function with %u bytes to disk\n", data->packed_chd_phf_size);
	nbytes = fwrite(&data->packed_chd_phf_size, sizeof(cmph_uint32), (size_t)1, fd);
	nbytes = fwrite(data->packed_chd_phf, data->packed_chd_phf_size, (size_t)1, fd);

	DEBUGP("Dumping compressed rank structure with %u bytes to disk\n", buflen);
	nbytes = fwrite(&data->packed_cr_size, sizeof(cmph_uint32), (size_t)1, fd);
	nbytes = fwrite(data->packed_cr, data->packed_cr_size, (size_t)1, fd);
	
	return 1;
}
Ejemplo n.º 5
0
int bmz_dump(cmph_t *mphf, FILE *fd)
{
	char *buf = NULL;
	cmph_uint32 buflen;
	cmph_uint32 two = 2; //number of hash functions
	bmz_data_t *data = (bmz_data_t *)mphf->data;
	register size_t nbytes;
#ifdef DEBUG
	cmph_uint32 i;
#endif

	__cmph_dump(mphf, fd);

	nbytes = fwrite(&two, sizeof(cmph_uint32), (size_t)1, fd);

	hash_state_dump(data->hashes[0], &buf, &buflen);
	DEBUGP("Dumping hash state with %u bytes to disk\n", buflen);
	nbytes = fwrite(&buflen, sizeof(cmph_uint32), (size_t)1, fd);
	nbytes = fwrite(buf, (size_t)buflen, (size_t)1, fd);
	free(buf);

	hash_state_dump(data->hashes[1], &buf, &buflen);
	DEBUGP("Dumping hash state with %u bytes to disk\n", buflen);
	nbytes = fwrite(&buflen, sizeof(cmph_uint32), (size_t)1, fd);
	nbytes = fwrite(buf, (size_t)buflen, (size_t)1, fd);
	free(buf);

	nbytes = fwrite(&(data->n), sizeof(cmph_uint32), (size_t)1, fd);
	nbytes = fwrite(&(data->m), sizeof(cmph_uint32), (size_t)1, fd);
	
	nbytes = fwrite(data->g, sizeof(cmph_uint32)*(data->n), (size_t)1, fd);
	if (nbytes == 0 && ferror(fd)) {
          fprintf(stderr, "ERROR: %s\n", strerror(errno));
          return 0;
        }
	#ifdef DEBUG
	fprintf(stderr, "G: ");
	for (i = 0; i < data->n; ++i) fprintf(stderr, "%u ", data->g[i]);
	fprintf(stderr, "\n");
	#endif
	return 1;
}
Ejemplo n.º 6
0
int chd_dump(cmph_t *mphf, FILE *fd)
{
	register size_t nbytes;
	chd_data_t *data = (chd_data_t *)mphf->data;
	
	__cmph_dump(mphf, fd);
	// Dumping CHD_PH perfect hash function

	DEBUGP("Dumping CHD_PH perfect hash function with %u bytes to disk\n", data->packed_chd_phf_size);
	nbytes = fwrite(&data->packed_chd_phf_size, sizeof(cmph_uint32), (size_t)1, fd);
	nbytes = fwrite(data->packed_chd_phf, data->packed_chd_phf_size, (size_t)1, fd);

	DEBUGP("Dumping compressed rank structure with %u bytes to disk\n", data->packed_cr_size);
	nbytes = fwrite(&data->packed_cr_size, sizeof(cmph_uint32), (size_t)1, fd);
	nbytes = fwrite(data->packed_cr, data->packed_cr_size, (size_t)1, fd);
	if (nbytes == 0 && ferror(fd)) {
          fprintf(stderr, "ERROR: %s\n", strerror(errno));
          return 0;
        }

	return 1;
}