[LeetCode] Design Log Storage System 设计日志存储系统

You are given several logs that each log contains a unique id and timestamp. Timestamp is a string that has the following format: Year:Month:Day:Hour:Minute:Second, for example, 2017:01:01:23:59:59. All domains are zero-padded decimal numbers.

Design a log storage system to implement the following functions:

void Put(int id, string timestamp): Given a log‘s unique id and timestamp, store the log in your storage system.

int[] Retrieve(String start, String end, String granularity): Return the id of logs whose timestamps are within the range from start to end. Start and end all have the same format as timestamp. However, granularity means the time level for consideration. For example, start = "2017:01:01:23:59:59", end = "2017:01:02:23:59:59", granularity = "Day", it means that we need to find the logs within the range from Jan. 1st 2017 to Jan. 2nd 2017.

Example 1:

put(1, "2017:01:01:23:59:59");
put(2, "2017:01:01:22:59:59");
put(3, "2016:01:01:00:00:00");
retrieve("2016:01:01:01:01:01","2017:01:01:23:00:00","Year"); // return [1,2,3], because you need to return all logs within 2016 and 2017.
retrieve("2016:01:01:01:01:01","2017:01:01:23:00:00","Hour"); // return [1,2], because you need to return all logs start from 2016:01:01:01 to 2017:01:01:23, where log 3 is left outside the range.

Note:

  1. There will be at most 300 operations of Put or Retrieve.
  2. Year ranges from [2000,2017]. Hour ranges from [00,23].
  3. Output for Retrieve has no order required.

s

时间: 2024-07-31 22:23:39

[LeetCode] Design Log Storage System 设计日志存储系统的相关文章

[LeetCode] Design Search Autocomplete System 设计搜索自动补全系统

Design a search autocomplete system for a search engine. Users may input a sentence (at least one word and end with a special character '#'). For each character they type except '#', you need to return the top 3historical hot sentences that have pref

[LeetCode] Design In-Memory File System 设计内存文件系统

Design an in-memory file system to simulate the following functions: ls: Given a path in string format. If it is a file path, return a list that only contains this file's name. If it is a directory path, return the list of file and directory names in

[leetcode-635-Design Log Storage System]

You are given several logs that each log contains a unique id and timestamp. Timestamp is a string that has the following format: Year:Month:Day:Hour:Minute:Second, for example, 2017:01:01:23:59:59. All domains are zero-padded decimal numbers. Design

[LeetCode] Design Compressed String Iterator 设计压缩字符串的迭代器

Design and implement a data structure for a compressed string iterator. It should support the following operations: next and hasNext. The given compressed string will be in the form of each letter followed by a positive integer representing the numbe

Note: Bigtable, A Distributed Storage System for Structured Data

Abstract Introduction::  Bigtable设计主旨:可扩地扩展到pByte级别和数千台机器的系统, 通用.可伸缩.高性能.高可用性.  不实现完整的关系数据模型,而是支持一个可以动态控制,允许用户自解释数据属性:  用户甚至可以指定数据(使用时)是存在内存中还是磁盘中:  支持row级别的事务处理:不支持跨行事务:: 2. Data model数据模型:三位数据模型: row.column.timestamp.row:即数据的key,是任意字符串(其实不一定要求是"字符&

基于key/value+Hadoop HDFS 设计的存储系统的shell命令接口

对于hadoop HDFS 中的所有命令进行解析(其中操作流程是自己的想法有不同意见欢迎大家指正) 接口名称 功能 操作流程 get 将文件复制到本地文件系统 .如果指定了多个源文件,本地目的端必须是一个目录. (1)按照上述机制,在Config server上的存储引擎中逐层读取K-V,直到获得文件名(或大文件元数据信息): (2)根据文件名(或大文件元数据信息)到相应的Data server中获取相应的文件(大文件需要拼接): (3)将获取的文件写入本地文件系统. put 从本地文件系统中复

Atitit.index manager api design 索引管理api设计

Atitit.index manager api design 索引管理api设计 1. kw1 1.1. 索引类型 unique,normal,fulltxt1 1.2. 聚集索引(clustered index,也称聚类索引1 1.3. 索引方式:btree,hashtable2 1.4. 索引使用所有的页面规模百分比2 2. Ui2 3. api2 3.1. createIndex(indexName,cols)2 3.2. Rebuild2 3.3. Del2 3.4. Up2 4. -

使用log miner 分析oracle日志

当我们不小心误操作致使数据库数据丢失.改变时, 需要对数据库对象做基于时间点的恢复,找到我们需要的数据,这个时间点不能认为精确确定,我们可以通过对oracle日志进行分析,而获得无操作的精确时间点. oracle db提供了一个分析日志包logmnr logminer 工具的使用     -------对redo log 进行挖掘,找出在某个时间点所作的DDL 或DML 操作(包括:时间点.datablock scn .sql语句) 实验测试 SQL> select name from v$ar

SDCC:可软件定义的存储三——just-in-time caching in an enterprise storage system

    note:本文要说的是一篇论文(Software defined just-in-time caching in an enterprise storage system)的思想. 框架 如下图所示,如果你懂SAN,DAS以及cache的机制,从这个框架就可以看出这个框架的思想(~~不解释啦) note:虽然SAN中的存储节点画出了storage node的tier结构,实际上这个论文完全不讲tier policy,只关心DAS的cache read... SDCC layer 协调fl