Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4 Log Server Suppose you are responsible for building a log server that will receive a large number of logs. Each log will have

4 Log Server Suppose you are responsible for building a log server that will receive a large number of logs. left ALL 1 2 17 The first line contains a single integer, m denoting the maximum number of logs getLogs ()

4 Log Server Suppose you are responsible for building a log server that will receive a large number of logs. Each log will have a log ID and timestamp. We want to keep track of these logs, but due to storage limitations, we can only return up to m logs from the last hour when requested. Problem Statement Complete the following functions record Log(logId, timestamp): Records a new log entry. o Each log is represented as an object with a logId and timestamp. The logId is an identifier for each log and the timestamp is an integer in seconds representing when the log was sent. o Logs may be received out of order o The log ID is not guaranteed to be unique - the same log ID can be used for different logs. getLogs (): Returns a comma separated string of the latest m logids from the last hour ascending by timestamp. In the event of a timestamp tie order from earliest received to latest. o Return a string of the form "logid1, logid2, logid3,logId4" where logid4 is the latest timestamp log and logid1 is the earliest timestamp log received < 1 hour before logid4's timestamp getLogCount (): Returns the total number of logs received < 1 hour from the most recently stored log timestamp. In the event more than m logs have been received still return the full count of logs Input Format left ALL 1 2 17 The first line contains a single integer, m denoting the maximum number of logs getLogs() should return. The second line contains a single integer, q denoting the number of queries. Each of the next q lines contains a query in one of the following formats: "RECORD logid timestamp" - This query represents a call to recordLog (logId, timestamp). "GET_LOGS" - This query represents a call to getLogs (). "COUNT" - This query represents a call to getLogCount(). Constraints: 1 m 1000 1 q 10^6 logId is an integer timestamp is an integer representing a timestamp in seconds Output Format: For each 'GET_LOGS' and 'COUNT' query, print the result of getLogs () or getLogCount() on a new line. For 'GET_LOGS' queries, print a comma-separated string of log IDs. For 'COUNT' queries, print an integer. Sample Case 0 Sample Input 100 Search Environment 1 4957234 6 8 9 10 11 12 13 14 15 16 429987222 2 2 2 2 2 17 18 19 20 21 23 25 27 28 #inclu #inclu #incl #incl #incl class priva in publi 333 Lo } VO } st } in } 29 //This Test Resul W

Step by Step Solution

There are 3 Steps involved in it

Step: 1

The images contain instructions for creating a log server system that handles a large number of logs with each log having a log ID and a timestamp The intent of this system is to track these logs and ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MIS Essentials

Authors: David M. Kroenke

4th edition

978-0133546590, 133546594, 978-0133807479

More Books

Students also viewed these Programming questions

Question

Is it eyewitness or hearsay evidence?

Answered: 1 week ago