BloomFilter* NewBloomFilter(const float false_positive_rate, const uint64_t num_expected_entries, const uint64_t memory_available) { pre(false_positive_rate < 1.0); static uint index = 1; // number of bits that I will require assuming an optimal k (which is 7 for // m, in most cases) uint64_t num_bits; // if the user specifies the amount of memory available for this bloom // filter, then I will respect that. If not then I will create a bloom // filter using the expected false-positive rate if (memory_available != 0) { // the memory is expected to be given in MB (megabytes) num_bits = MB_to_Bits * memory_available; } else { num_bits = (num_expected_entries * -1.0 * log(false_positive_rate)) / (log(2) * log(2)); } num_bits += 1; uint num_hash_functions = num_bits * log(2) / num_expected_entries; // the false-positive rate float fdr; if (memory_available != 0) { fdr = exp((-1.0 * num_bits * log(2) * log(2)) / num_expected_entries); } else { fdr = false_positive_rate; } // lets create the bloom filter srand((unsigned)time(NULL)); BloomFilter* bf = CkalloczOrDie(sizeof(BloomFilter)); bf->seed = rand(); bf->false_positive_rate = fdr; bf->num_hash_functions = num_hash_functions; bf->num_bits = num_bits; bf->bs = NewBitset(bf->num_bits); PrintDebugMessage("Bloom filter%u:", index); PrintDebugMessage("\tNumber of expected entries: %"PRIu64, num_expected_entries); PrintDebugMessage("\tFalse positive rate: %2.6f", fdr); PrintDebugMessage("\tNumber of bits used: %"PRIu64, num_bits); PrintDebugMessage("\tNumber of hash functions used: %d\n", num_hash_functions); return bf; }
void DrawGLScene() #endif { glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); ProcessInput(); //glBlendFunc(GL_ONE, GL_ZERO); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_TEXTURE_2D); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(fovY, (GLfloat)_width/(GLfloat)_height, zNear, 1000.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // frame update #ifndef APPLE QueryPerformanceCounter(&lastTick); #endif int3 tmpId; int3 tmpOffset; int tmpSide; s_World->UpdateWorld(); #ifndef APPLE QueryPerformanceCounter(&currTick); #endif s_Render->DiscardUnneededChunks(m_Player->eyepos, m_Player->dir, s_World); s_Render->LoadNeededChunks(m_Player->eyepos, m_Player->dir, s_World); glEnable(GL_LIGHTING); s_Render->DrawScene(m_Player->eyepos, m_Player->dir, 400, s_World, 1, 1); glDisable(GL_LIGHTING); PrintDebugMessage(); // Draw Red Dot glPointSize(3.0f); glColor3f(1, 0, 0); glBegin(GL_POINTS); glVertex3f(0, 0, 0); glEnd(); glColor3f(1, 1, 1); #ifdef APPLE glutSwapBuffers(); #else return TRUE; #endif }
static void AppTask(void *pvParameters) { (void)pvParameters; for(;;) { #if DEBUG_PRINT && PL_CONFIG_HAS_SHELL_QUEUE { const unsigned char *msg; msg = SQUEUE_ReceiveMessage(); if (msg!=NULL) { PrintDebugMessage(msg); } } #endif /* PL_CONFIG_HAS_SHELL_QUEUE */ vTaskDelay(pdMS_TO_TICKS(50)); } }