4 Log Server Suppose you are responsible for building a log server that will receive a...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Answer rating: 100% (QA)
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 ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Tacos R Us had two operating divisions, a frozen foods company and taco chef academy. Both divisions are considered separate components. Towards the end of this year, Tacos R Us adopted a formal plan...
-
The Crazy Eddie fraud may appear smaller and gentler than the massive billion-dollar frauds exposed in recent times, such as Bernie Madoffs Ponzi scheme, frauds in the subprime mortgage market, the...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
I really would like to know the steps idk how to start this buttrying to look for the gross pays has been frustrating, pleasehelp! Each of the following workers is piece-rate workers at Golden Boats...
-
Find the distance between the parallel planes + 2y + z = 9 and 6x - 4y - 2z = 19.
-
Circle Stores has net income of $41,000, a profit margin of 6.7 percent, and a return on assets of 9 percent. What is the capital intensity ratio?
-
237 Use divisibility rules to determine if each of the following is divisible by 5 .
-
Iguana, Inc., manufactures bamboo picture frames that sell for $25 each. Each frame requires 4linear feet of bamboo, which costs $2.00 per foot. Each frame takes approximately 30 minutes to build,...
-
-75 !! Carla Vista Company uses the weighted average cost formula in a perpetual inventory system. Fill in the missing amounts for items (a) through (k) in the following perpetual inventory record:...
-
One criticism of Hofstedes work is that the scores on each dimension reflect only an average tendency of a particular country and, therefore, inadequately reflect the wide range of responses given...
-
A model rocket has two parachutes, a main one, and a secondary one that should deploy only if the first fails to do so. Suppose the main shoot deploys with probability 0.87. (a) Assume due to a...
-
The following questions relate to circumstances resulting in departure from the auditor's standard report. Select the best response. a Which of the following will not result in modification of the...
-
Assume that a CPA is expressing an opinion on Azalea Company's financial statements for the year ended September 30, 19X3, that the CPA completed field work on October 21, 19X3, and that the CPA now...
-
At the end of 2004, PepsiCo had total assets of \(\$ 28\) billion and total liabilities of \(\$ 14\) billion. Included among the assets were property, plant, and equipment with a cost of \(\$ 16\)...
-
Your client is involved in litigation involving a claim for damages that would be material with respect to its financial position if the plaintiff prevails. In response to your client's request for a...
-
On January 1, 2008, you borrowed \(\$ 10,000\) on a five-year, \(8 \%\) note payable. At December 31, 2009, you should record a. Interest payable of \(\$ 800\) b. Nothing (The note is already on the...
-
Discount amortization On the first day of the fiscal year, a company issues a $6,100,000, 9%, 5-year bond that pays semiannual interest of $274,500 ($5,100,000 9% * %), receiving cash of $5,426,551....
-
From 1970 to 1990, Sri Lanka's population grew by approximately 2.2 million persons every five years. The population in 1970 was 12.2 million people.What is the best formula for P, Sri Lanka's...
-
Use your answers in question 2 to explain the following statement: The structure of an organizations information system (here a Web storefront) is determined by its competitive strategy. Write your...
-
Consider the two different bike rental companies in Figure 3-6. Think about the bikes that they rent. Clearly, the student bikes will be just about anything that can be ridden out of the shop. The...
-
1. Clearly, Dynamo, Bigtable, and Cassandra are critical technology to the companies that create them. Why did they allow their employees to publish academic papers about them? Why did they not keep...
-
Consider the following network (in technical terms, a directed graph or "digraph"). Each circle, here marked with one of the letters A to P, represents a node of the network. Some of these nodes...
-
Consider the game Chomp from Exercise 1.5 of size \(2 \times 4\), in a game sum with a Nim heap of size 4. What are the winning moves of the starting player I, if any? 00
-
Consider the following variant of Nim called Split-Nim, which is played with heaps of tokens as in Nim. Like in Nim, a player can remove some tokens from one of the heaps, or else split a heap into...
Study smarter with the SolutionInn App