static int wt_snappy_decompress(WT_COMPRESSOR *compressor, WT_SESSION *session, uint8_t *src, size_t src_len, uint8_t *dst, size_t dst_len, size_t *result_lenp) { snappy_status snret; size_t snaplen; __UNUSED(compressor); /* retrieve the saved length */ snaplen = *(size_t *)src; if (snaplen + sizeof(size_t) > src_len) { wiredtiger_err_printf( session, "wt_snappy_decompress: stored size exceeds buffer size"); return (WT_ERROR); } /* dst_len is an input and an output arg. */ snret = snappy_uncompress( (char *)src + sizeof(size_t), snaplen, (char *)dst, &dst_len); if (snret == SNAPPY_OK) { *result_lenp = dst_len; return (0); } return (wt_snappy_error(session, "snappy_decompress", snret)); }
static int nop_decompress(WT_COMPRESSOR *compressor, WT_SESSION *session, uint8_t *src, size_t src_len, uint8_t *dst, size_t dst_len, size_t *result_lenp) { __UNUSED(compressor); __UNUSED(session); if (dst_len < src_len) return (ENOMEM); memcpy(dst, src, src_len); *result_lenp = src_len; return (0); }
static int wt_snappy_pre_size(WT_COMPRESSOR *compressor, WT_SESSION *session, uint8_t *src, size_t src_len, size_t *result_lenp) { __UNUSED(compressor); __UNUSED(session); __UNUSED(src); /* * Snappy requires the dest buffer be somewhat larger than the source. * Fortunately, this is fast to compute, and will give us a dest buffer * in wt_snappy_compress that we can compress to directly. We add space * in the dest buffer to store the accurate compressed size. */ *result_lenp = snappy_max_compressed_length(src_len) + sizeof(size_t); return (0); }
void specialInput(int k, int x, int y) { __UNUSED(x); __UNUSED(y); switch(k) { case GLUT_KEY_LEFT: xrot = (xrot + 5) % 360; break; case GLUT_KEY_RIGHT: xrot = (xrot - 5) % 360; break; case GLUT_KEY_UP: yrot = (yrot - 5); break; case GLUT_KEY_DOWN: yrot = (yrot + 5); break; default: break; } glutPostRedisplay(); }
/* Implementation of WT_COMPRESSOR for WT_CONNECTION::add_compressor. */ static int nop_compress(WT_COMPRESSOR *compressor, WT_SESSION *session, uint8_t *src, size_t src_len, uint8_t *dst, size_t dst_len, size_t *result_lenp, int *compression_failed) { __UNUSED(compressor); __UNUSED(session); *compression_failed = 0; if (dst_len < src_len) { *compression_failed = 1; return (0); } memcpy(dst, src, src_len); *result_lenp = src_len; return (0); }
int wiredtiger_extension_init( WT_SESSION *session, WT_EXTENSION_API *api, const char *config) { WT_CONNECTION *conn; __UNUSED(config); wt_api = api; conn = session->connection; return (conn->add_compressor( conn, "snappy_compress", &wt_snappy_compressor, NULL)); }
static int wt_snappy_compress(WT_COMPRESSOR *compressor, WT_SESSION *session, uint8_t *src, size_t src_len, uint8_t *dst, size_t dst_len, size_t *result_lenp, int *compression_failed) { snappy_status snret; size_t snaplen; char *snapbuf; __UNUSED(compressor); /* * dst_len was computed in wt_snappy_pre_size, so we know it's big * enough. Skip past the space we'll use to store the final count * of compressed bytes. */ snaplen = dst_len - sizeof(size_t); snapbuf = (char *)dst + sizeof(size_t); /* snaplen is an input and an output arg. */ snret = snappy_compress((char *)src, src_len, snapbuf, &snaplen); if (snret == SNAPPY_OK) { /* * On decompression, snappy requires the exact compressed byte * count (the current value of snaplen). WiredTiger does not * preserve that value, so save snaplen at the beginning of the * destination buffer. */ if (snaplen + sizeof(size_t) < src_len) { *(size_t *)dst = snaplen; *result_lenp = snaplen + sizeof(size_t); *compression_failed = 0; } else /* The compressor failed to produce a smaller result. */ *compression_failed = 1; return (0); } return (wt_snappy_error(session, "snappy_compress", snret)); }
void draw(float timeDelta) { __UNUSED(timeDelta); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(70.0f, width / (float)height, 0.01f, 10000.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); float dist = MAX(MAX(dimensions[1] - dimensions[0], dimensions[3] - dimensions[2]), dimensions[5] - dimensions[4]); glTranslatef(0, 0, zoom * dist/5.0f); gluLookAt((dimensions[0] + dimensions[1])/2.0f, (dimensions[2] + dimensions[3])/2.0f, dimensions[5] + 1.0f * dist, (dimensions[0] + dimensions[1])/2.0f, (dimensions[2] + dimensions[3])/2.0f, (dimensions[4] + dimensions[5])/2.0f, 0, 1, 0); if(lines) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); else glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); render(); glutSwapBuffers(); }
void keyboardInput(unsigned char key, int x, int y) { __UNUSED(x); __UNUSED(y); switch(key) { case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { int initEdges = mesh->numEdges; int initPolys = mesh->numFaces; int targetEdges = MAX(6, (1.0f - 0.1f * (int)(key - '0')) * mesh->numEdges); while(mesh->numEdges > targetEdges) { if(!reduce(mesh)) break; } printf("Mesh successfully reduced by %c0%%. From %d to %d edges, %d to %d polys.\n", key, initEdges, mesh->numEdges, initPolys, mesh->numFaces); break; } case '`': reduce(mesh); printf("Mesh successfully reduced by one vertex.\n"); break; case 'v': lines = 1 - lines; printf("Display mode changed. "); if(lines) printf("Drawing with GL_LINES.\n"); else printf("Drawing with GL_TRIANGLES.\n"); break; case 'p': printMesh(mesh, stdout); break; case 'q': exit(0); break; case 'r': reset(); printf("Mesh successfully reset.\n"); break; case 'm': changeCostFunc(mesh, melaxCost); printf("Cost function changed to Melax.\n"); break; case 's': changeCostFunc(mesh, simpleCost); printf("Cost function changed to Simple.\n"); break; case '+': zoom += 1; break; case '-': zoom -= 1; break; default: break; } glutPostRedisplay(); }
void ButtonWithName::leaveEvent(QEvent *event) { __UNUSED(event); m_isEnter = false; update(); }
void ButtonWithName::enterEvent(QEvent *event) { __UNUSED(event); m_isEnter = true; update(); }