我有一个表示安全摄像机NVR元数据的数据库.recording
每1分钟的视频片段有一个26字节的行.(如果你很好奇,一个设计文档正在进行这里.)我的设计限制是8个摄像头,1年(约4万行,半一万元左右的相机).我已经伪造了一些数据来测试性能.此查询比我预期的要慢:
select
recording.start_time_90k,
recording.duration_90k,
recording.video_samples,
recording.sample_file_bytes,
recording.video_sample_entry_id
from
recording
where
camera_id = ?
order by
recording.start_time_90k;
Run Code Online (Sandbox Code Playgroud)
这只是扫描相机的所有数据,使用索引过滤掉其他相机和订购.索引看起来像这样:
create index recording_camera_start on recording (camera_id, start_time_90k);
Run Code Online (Sandbox Code Playgroud)
explain query plan
看起来像预期:
0|0|0|SEARCH TABLE recording USING INDEX recording_camera_start (camera_id=?)
Run Code Online (Sandbox Code Playgroud)
行很小.
$ sqlite3_analyzer duplicated.db
...
*** Table RECORDING w/o any indices *******************************************
Percentage of total database...................... 66.3%
Number of entries................................. 4225560
Bytes of storage consumed......................... 143418368
Bytes of payload.................................. 109333605 76.2%
B-tree depth...................................... 4
Average payload per entry......................... 25.87
Average unused …
Run Code Online (Sandbox Code Playgroud) Linux内核源码有很多这样的数组文字:
enum {
FOO,
BAR
};
static const char* const names[] = {
[FOO] = "foo", /* wtf is this? */
[BAR] = "bar",
};
Run Code Online (Sandbox Code Playgroud)
这里每一行显式指示所提供值的数组中的索引,而不是依赖于排序.
我不知道要搜索的短语 - 这叫什么?什么标准定义它?(或者它是GNU扩展吗?)我可以用C++或纯C做到这一点吗?试验gcc
,我发现上面的test.c
,
$ gcc --version
gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
Run Code Online (Sandbox Code Playgroud)
这些命令返回成功:
$ gcc -Wall -c test.c
$ gcc -Wall …
Run Code Online (Sandbox Code Playgroud) 我的应用程序需要material-ui日期和时间选择器才能在服务器指定的远程时区上运行。我希望日期选择器上的今天圆圈实际指示远程时区中的今天,并且我想将远程时区中的日期时间转换为自 以来的秒数1970-01-01T00:00:00Z
。
我正在使用material-ui v5 alphas。文档说您为时间库指定了一个@date-io
适配器。看起来有四个明显的选择:
@date-io/date-fns
(基于date-fns和date-fns-tz 的远程时区设计有问题。它使用 Javascript Dates 来表示远程时区的日期和时间,但如果本地时区有“春天向前”小时,有时候你无法代表问题。@date-io/dayjs
(基于dayjs)无法正确处理夏令时。问题@date-io/luxon
(基于luxon)看起来很有前途@date-io/moment
(基于时刻和时刻时区)看起来很有希望所以我想为 luxon 或 moment 指定一个适配器,以在特定区域中构造日期。
这两个库都支持设置全局默认时区(luxon、moment),但我更愿意在构建特定日期适配器时设置时区。根据服务器响应来搞乱全局状态是很恶心的。
我发现了一个date-io 问题,上面写着:
您可以将时刻时区直接传递给 ,
libInstance
在这种情况下,它将使用时刻实例或全局实例的时区集
这就是我想要的!但我对这个实例到底应该是什么感到困惑。我对 Javascript 还很陌生,这并没有帮助。
今天的构造函数@date-io/luxon
似乎不允许重写这样的实例。
试图让第一时刻开始工作:
$ mkdir tztest
$ cd tztest
$ npm init -y
$ npm install --save moment moment-timezone '@date-io/moment' …
Run Code Online (Sandbox Code Playgroud) 我正在尝试将一些C++代码移植到Rust.它由几种切片(字符串引用,延迟评估的字符串引用,物理文件的一部分)组成虚拟(.mp4)文件,并根据结果提供HTTP请求.(如果你很好奇,看看Mp4File更是把优势FileSlice
接口及其具体实现在http.h.)
这是问题:我想要尽可能少的堆分配.假设我有一些实现resource::Slice
,我希望能够自己解决这个问题.然后我想制作一个组成它们的那个:
pub trait Slice : Send + Sync {
/// Returns the length of the slice in bytes.
fn len(&self) -> u64;
/// Writes bytes indicated by `range` to `out.`
fn write_to(&self, range: &ByteRange,
out: &mut io::Write) -> io::Result<()>;
}
// (used below)
struct SliceInfo<'a> {
range: ByteRange,
slice: &'a Slice,
}
/// A `Slice` composed of other `Slice`s.
pub struct Slices<'a> {
len: u64,
slices: Vec<SliceInfo<'a>>,
}
impl<'a> Slices<'a> { …
Run Code Online (Sandbox Code Playgroud) 我的项目使用libavformat连接到rtsp://
URL.设置套接字超时并在出错时重新连接非常重要.不幸的是,stimeout
open的选项仅存在于ffmpeg(特别是其libavformat版本> = 55.1.100),而不是竞争项目libav(任何版本).我想支持的一些系统(例如Raspbian Jessie)仍然与libav捆绑在一起.
所以,我认为我最好的选择是使用cmake检测我是否有合适的版本,如果没有,请安装ffmpeg in-tree.我想我应该可以通过以下方式做到这一点:
pkg_check_modules(FFMPEG libavutil libavcodec libavformat)
if(not FFMPEG_FOUND or FFMPEG_VERSION VERSION_LESS 55.1.101)
ExternalProject_Add(
FfmpegProject
URL "http://ffmpeg.org/releases/ffmpeg-2.8.3.tar.xz"
URL_HASH "SHA1=a6f39efe1bea9a9b271c903d3c1dcb940a510c87"
INSTALL_COMMAND "")
...set up flags and such to use this in-tree version...
endif()
Run Code Online (Sandbox Code Playgroud)
除了我不知道如何检测libav vs ffmpeg.我没有在pkgconfig中看到任何东西或libavformat/version.h
区分它们.他们使用的版本号似乎重叠.对我来说,如何以编程方式区分差异并不是很明显,更不用说使用非奇怪的cmake规则.有任何想法吗?
c ×1
c++ ×1
cmake ×1
date-fns ×1
ffmpeg ×1
javascript ×1
lifetime ×1
material-ui ×1
momentjs ×1
performance ×1
rust ×1
sqlite ×1