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...
-
The Public Relations Society of America (PRSA) awards the best public relations campaigns with Silver Anvil Awards. Visit www.prsa.org/Awards/Search and review several case reports of previous...
-
Find the area of one side of a wall standing orthogonally on the curve y = x 2 , 0 < x < 2 , with its top on the surface f ( x , y ) = x + sqrt ( y )
-
\(\mathrm{NaCl}\) is crystallizing from an aqueous (water) liquid solution onto a crystal particle of pure \(\mathrm{NaCl}\) at \(18^{\circ} \mathrm{C}\). Assume particle growth is controlled by mass...
-
Suppose there are a fixed number of 1,000 identical firms in the perfectly competitive concrete pipe industry. Each firm produces the same fraction of total market output and each firm's production...
-
Problem 3: (%20) Consider the following rotational and translational mechanical system and the free body diagram of the bar. Assume that the spring is unstreched when is zero and is small. Let m =...
-
You have been employed as a consultant to Golf R Us, Inc. The company has been having problems with account receivables and they want to use various dunning methods to better their receivables. But...
-
(A) Suppose you can invest in NZD at 5.127%, or you can invest in CHF at 5.5%. You are a resident of New Zealand, and the current spot rate is 0.79005/20 NZD/CHF. Required: i. Identify the factors...
-
1. Explain Amazon Inc free cash flow history. 2. What is normalization adjustment ? 3. What are three examples of balance sheet normalization adjustments that might appear on Amazon's balance sheet...
-
Let's assume CANCO acquired a heavy-duty equipment in 2017 for $25,000 and in 2023 it sold for $11,400. What is gain or loss achieved from sale if the net book value (NBV) for the equipment is...
-
1. Why did Coca-Cola enter into a strategic alliance with Monster? Note: Theme Name, ex. The power brand, Product Market profit, etc. Theme Name. Provide a detailed discussion of the anticipated...
-
When is government censorship considered constitutional in the United States? What legal restraints can be used in the U.S. to silence political dissent? What forms of sedition have been historically...
-
1) Make a simple analysis of the relationship between banks and the economy in general. 2) Briefly describe the structure of the financial system. 3) Make a brief analysis of the banking structure in...
-
Moses and Co. Market Wholefoods is an Australian-based exclusive retailer of Tofutti Brands's dairy-free products. It operates at capacity and decides to apply ABC analysis to the three main Tofutti...
-
C- Consider the following scenario:- A supermarket needs to develop the following software to encourage regular customers. For this, the customer needs to supply his/her residence address, telephone...
-
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...
-
The Arcadia Company is uncertain whether it should utilize the first-in, first-out (FIFO) method, the last-in, first-out (LIFO) method, or the weighted-average method to account for its inventory....
-
The Rock Creek Company has an ending inventory valuation using FIFO of \($350,000\). Had the company used LIFO the inventory would have been valued at \($320,000\). The company has determined the...
-
Walgreens Boots Alliance, Inc. (Walgreens) is a global pharmacy, health and well-being company. It operates over 13,000 stores in 11 countries, generating net sales of \($103.4\) billion. The...
Study smarter with the SolutionInn App