简易数据库实现 UNIX环境高级编程(APUE)第二十章 A Database Library
将课程的源代码 使用C++写了一部分
LINUX WINDOW均可运行
#ifndef MYDB_H
#define MYDB_H #include <iostream>
#include <fstream>
#include <string> #define NHASH_DEF 137 /* default hash table size */
#define FREE_LINK NHASH_DEF
#define PTR_SZ 8
#define MAGIC_WORDS "MyDB_Start:\n"
#define SEPARATOE "#" class MyDB{
public:
MyDB(const char* pathName) : hashOffset(),
dataOffset(),writeDataLength(),idxOffset(),writeIdxLength()
{
DBidxName = pathName;
DBidxName += ".idx";
DBdataName = pathName;
DBdataName += ".dat";
}
void CloseDB(){
idxFile.close();
datFile.close();
}
~MyDB(){ CloseDB();} bool Init();
unsigned long HashFunc(const char *key);
bool WriteData(const char* data);
bool WriteIndex(const char* key);
size_t GetIndexOffsetBykey(const char* key);
long ReadPtr(std::fstream& fs, size_t offset);
bool Writeptr(std::fstream& fs, size_t offset, const std::string& writeString);
void TestFunc(const char* searchKey);
size_t SearchLinkForKey(size_t offset, const char* key);
std::string Query(const char* key);
private: bool DoWriteIndex(const char* key, const size_t nextOffset);
bool OpenFileOrExit(std::fstream& fs, const std::string& fileName);
size_t hashOffset;
size_t dataOffset;
size_t writeDataLength;
unsigned long idxOffset;
size_t writeIdxLength;
MyDB& operator=(const MyDB&);
MyDB(const MyDB&);
std::string DBidxName;
std::string DBdataName;
std::fstream idxFile;
std::fstream datFile;
}; #endif // MYDB_H
mydb.h
#include <string>
#include "mydb.h" void MyDB::TestFunc(const char* key)
{ } std::string MyDB::Query(const char* key)
{
size_t offset = GetIndexOffsetBykey(key);
if ( == offset)
return ""; size_t nextPtr = ReadPtr(idxFile, offset);
size_t indexLength = ReadPtr(idxFile, offset + PTR_SZ); char* indexstr = new char[indexLength + ];
idxFile.read(indexstr, indexLength);
indexstr[indexLength] = '\0';
std::string indexString(indexstr);
delete[] indexstr; std::string keyString = indexString.substr(, indexString.find_first_of(SEPARATOE)); return keyString;
} bool MyDB::OpenFileOrExit(std::fstream& fs, const std::string& fileName) {
fs.open(fileName, std::ios::in | std::ios::out | std::ios::binary);
if (!fs.is_open()) {
fs.open(fileName, std::ios::in | std::ios::out | std::ios::binary | std::ios::app);
fs.close();
fs.open(fileName, std::ios::in | std::ios::out | std::ios::binary);
if (!fs.is_open()) {
std::cerr << "open idxFile error.exit!" << std::endl;
exit(-);
}
}
return true;
} bool MyDB::Init() {
OpenFileOrExit(idxFile,DBidxName);
OpenFileOrExit(datFile, DBdataName); idxFile.seekg(, std::ios_base::end);
size_t len = idxFile.tellg();
hashOffset = ; if (len != )
return true; //进行初始化
idxFile.seekp(, std::ios::beg); std::string ptrstr(PTR_SZ, ' ');
ptrstr[PTR_SZ - ] = '';
//std::cout << ptrstr << std::endl;
for (int i = ; i < NHASH_DEF + ; i++)
idxFile << ptrstr;
idxFile << '\n';
idxFile.flush();
return true;
} unsigned long
MyDB::HashFunc(const char *key)
{
unsigned long hval = ;
char c;
int i; for (i = ; (c = *key++) != ; i++)
hval += c * i;
return(hval % NHASH_DEF);
} bool MyDB::Writeptr(std::fstream& fs,size_t offset,const std::string& writeString) {
fs.seekp(offset, std::ios::beg);
fs << writeString;
return true;
} long MyDB::ReadPtr(std::fstream& fs,size_t offset) {
long ret = ; char ptrstr[PTR_SZ + ];
fs.seekg(offset, std::ios::beg);
fs.read(ptrstr, PTR_SZ);
ptrstr[PTR_SZ] = '\0'; ret = atol(ptrstr);
return ret;
} size_t MyDB::SearchLinkForKey(size_t offset, const char* key)
{
size_t currentPtr = offset; do {
size_t nextPtr = ReadPtr(idxFile, currentPtr);
size_t indexLength = ReadPtr(idxFile, currentPtr + PTR_SZ); char* indexstr = new char[indexLength + ];
idxFile.read(indexstr, indexLength);
indexstr[indexLength] = '\0';
std::string indexString(indexstr);
delete[] indexstr; std::string keyString = indexString.substr(, indexString.find_first_of(SEPARATOE));
if (keyString == std::string(key))
break;
currentPtr = nextPtr;
} while ( != currentPtr); return currentPtr; } size_t MyDB::GetIndexOffsetBykey(const char* key) {
size_t indexOff = ;
unsigned long hashKeyValue = HashFunc(key); size_t linkOffset = hashKeyValue*PTR_SZ + hashOffset;
size_t idxOffset = ReadPtr(idxFile,linkOffset);
if ( == idxOffset)
return ;
//有链表 便历链表 查看是否已有关键字
size_t offset = SearchLinkForKey(idxOffset,key); return offset;
} bool MyDB::DoWriteIndex(const char* key,const size_t nextOffset) {
idxFile.seekp(, std::ios::end);
idxOffset = idxFile.tellp(); std::string s = std::to_string(nextOffset);
if (s.size() > PTR_SZ) {
return false;
} std::string writeString(PTR_SZ - s.size(), ' ');
writeString += s; char ptrstr[PTR_SZ + ];
sprintf(ptrstr, "%*d", PTR_SZ,); std::string idxString(writeString);
idxString += ptrstr;
idxString += key;
idxString += SEPARATOE;
idxString += std::to_string(dataOffset);
idxString += SEPARATOE;
idxString += std::to_string(writeDataLength);
idxString += "\n"; unsigned long size = idxString.size() - strlen(ptrstr) * ;
sprintf(ptrstr, "%*d", PTR_SZ, size);
idxString.replace(PTR_SZ, PTR_SZ, ptrstr);
//std::cout << idxString << std::endl;
idxFile << idxString;
//idxFile.flush(); return true;
} bool MyDB::WriteIndex(const char* key)
{
unsigned long hashKeyValue = HashFunc(key);
size_t linkOffset = hashKeyValue*PTR_SZ + hashOffset;
size_t idxInLinkHeadoffset = ReadPtr(idxFile, linkOffset); if ( == idxInLinkHeadoffset) {
DoWriteIndex(key, );
std::string s = std::to_string(idxOffset);
if (s.size() <= PTR_SZ) {
std::string writeString(PTR_SZ - s.size(), ' ');
writeString += s;
Writeptr(idxFile, linkOffset, writeString);
return true;
}
else {
return false;
}
}
else {
//在链表中寻找
size_t offset = GetIndexOffsetBykey(key);
if ( != offset) {
//寻找到则直接返回
return true;
}
DoWriteIndex(key, idxInLinkHeadoffset);
std::string s = std::to_string(idxOffset);
if (s.size() <= PTR_SZ) {
std::string writeString(PTR_SZ - s.size(), ' ');
writeString += s;
Writeptr(idxFile, linkOffset, writeString);
return true;
}
else {
return false;
} } return true;
} bool MyDB::WriteData(const char* data)
{
try {
writeDataLength = strlen(data);
datFile.seekp(, std::ios::end);
dataOffset = datFile.tellp();
datFile << data;
}
catch (std::exception& e) {
std::cerr << e.what() << std::endl;
exit();
} return true;
}
mydb.cpp
测试代码
// DB0_4.cpp : 定义控制台应用程序的入口点。
// #include "stdafx.h"
#include <assert.h>
#include "mydb.h" int main()
{
MyDB db("");
db.Init();
for (int i = ; i < ; ++i) {
std::string s = std::to_string(i);
std::string writeIdxString("indexWrite");
std::string writeDatString("dataWrite");
writeIdxString += s;
writeDatString += s;
db.WriteData(writeDatString.c_str());
db.WriteIndex(writeIdxString.c_str());
}
std::string queryKeyString1("indexWrite0");
std::string queryKeyString2("indexWrite1");
std::string queryKeyString3("indexWrite10");
std::string queryKeyString4("indexWrite100");
std::string queryKeyString5("indexWrite_");
std::string queryKeyString6("indexWritex");
std::string queryKeyString7("ShouldNotFind");
assert(db.Query(queryKeyString1.c_str()) == queryKeyString1);
assert(db.Query(queryKeyString2.c_str()) == queryKeyString2);
assert(db.Query(queryKeyString3.c_str()) == queryKeyString3);
assert(db.Query(queryKeyString4.c_str()) == queryKeyString4); assert(db.Query(queryKeyString5.c_str()) != queryKeyString5);
assert(db.Query(queryKeyString6.c_str()) != queryKeyString6);
assert(db.Query(queryKeyString7.c_str()) != queryKeyString7); std::cout << "fine" << std::endl;
return ;
}
main.cpp
代码运行后 文件效果
17indexWrite0##
18indexWrite1##
18indexWrite2##
18indexWrite3##
18indexWrite4##
18indexWrite5##
18indexWrite6##
18indexWrite7##
18indexWrite8##
18indexWrite9##
20indexWrite10##
20indexWrite11##
20indexWrite12##
20indexWrite13##
20indexWrite14##
20indexWrite15##
20indexWrite16##
20indexWrite17##
20indexWrite18##
20indexWrite19##
20indexWrite20##
20indexWrite21##
20indexWrite22##
20indexWrite23##
20indexWrite24##
20indexWrite25##
20indexWrite26##
20indexWrite27##
20indexWrite28##
20indexWrite29##
20indexWrite30##
20indexWrite31##
20indexWrite32##
20indexWrite33##
20indexWrite34##
20indexWrite35##
20indexWrite36##
20indexWrite37##
20indexWrite38##
20indexWrite39##
20indexWrite40##
20indexWrite41##
20indexWrite42##
20indexWrite43##
20indexWrite44##
20indexWrite45##
20indexWrite46##
20indexWrite47##
20indexWrite48##
20indexWrite49##
20indexWrite50##
20indexWrite51##
20indexWrite52##
20indexWrite53##
20indexWrite54##
20indexWrite55##
20indexWrite56##
20indexWrite57##
20indexWrite58##
20indexWrite59##
20indexWrite60##
20indexWrite61##
20indexWrite62##
20indexWrite63##
20indexWrite64##
20indexWrite65##
20indexWrite66##
20indexWrite67##
20indexWrite68##
20indexWrite69##
20indexWrite70##
20indexWrite71##
20indexWrite72##
20indexWrite73##
20indexWrite74##
20indexWrite75##
20indexWrite76##
20indexWrite77##
20indexWrite78##
20indexWrite79##
20indexWrite80##
20indexWrite81##
20indexWrite82##
20indexWrite83##
20indexWrite84##
20indexWrite85##
20indexWrite86##
20indexWrite87##
20indexWrite88##
20indexWrite89##
20indexWrite90##
20indexWrite91##
21indexWrite92##
21indexWrite93##
21indexWrite94##
21indexWrite95##
21indexWrite96##
21indexWrite97##
21indexWrite98##
21indexWrite99##
22indexWrite100##
22indexWrite101##
22indexWrite102##
22indexWrite103##
22indexWrite104##
22indexWrite105##
22indexWrite106##
22indexWrite107##
22indexWrite108##
22indexWrite109##
22indexWrite110##
22indexWrite111##
22indexWrite112##
22indexWrite113##
22indexWrite114##
22indexWrite115##
22indexWrite116##
22indexWrite117##
22indexWrite118##
22indexWrite119##
22indexWrite120##
22indexWrite121##
22indexWrite122##
22indexWrite123##
22indexWrite124##
22indexWrite125##
22indexWrite126##
22indexWrite127##
22indexWrite128##
22indexWrite129##
22indexWrite130##
22indexWrite131##
22indexWrite132##
22indexWrite133##
22indexWrite134##
22indexWrite135##
22indexWrite136##
22indexWrite137##
22indexWrite138##
22indexWrite139##
22indexWrite140##
22indexWrite141##
22indexWrite142##
22indexWrite143##
22indexWrite144##
22indexWrite145##
22indexWrite146##
22indexWrite147##
22indexWrite148##
22indexWrite149##
22indexWrite150##
22indexWrite151##
22indexWrite152##
22indexWrite153##
22indexWrite154##
22indexWrite155##
22indexWrite156##
22indexWrite157##
22indexWrite158##
22indexWrite159##
22indexWrite160##
22indexWrite161##
22indexWrite162##
22indexWrite163##
22indexWrite164##
22indexWrite165##
22indexWrite166##
22indexWrite167##
22indexWrite168##
22indexWrite169##
22indexWrite170##
22indexWrite171##
22indexWrite172##
22indexWrite173##
22indexWrite174##
22indexWrite175##
22indexWrite176##
22indexWrite177##
22indexWrite178##
22indexWrite179##
22indexWrite180##
22indexWrite181##
22indexWrite182##
22indexWrite183##
22indexWrite184##
22indexWrite185##
22indexWrite186##
22indexWrite187##
22indexWrite188##
22indexWrite189##
22indexWrite190##
22indexWrite191##
22indexWrite192##
22indexWrite193##
22indexWrite194##
22indexWrite195##
22indexWrite196##
22indexWrite197##
22indexWrite198##
22indexWrite199##
22indexWrite200##
22indexWrite201##
22indexWrite202##
22indexWrite203##
22indexWrite204##
22indexWrite205##
22indexWrite206##
22indexWrite207##
22indexWrite208##
22indexWrite209##
22indexWrite210##
22indexWrite211##
22indexWrite212##
22indexWrite213##
22indexWrite214##
22indexWrite215##
22indexWrite216##
22indexWrite217##
22indexWrite218##
22indexWrite219##
22indexWrite220##
22indexWrite221##
22indexWrite222##
22indexWrite223##
22indexWrite224##
22indexWrite225##
22indexWrite226##
22indexWrite227##
22indexWrite228##
22indexWrite229##
22indexWrite230##
22indexWrite231##
22indexWrite232##
22indexWrite233##
22indexWrite234##
22indexWrite235##
22indexWrite236##
22indexWrite237##
22indexWrite238##
22indexWrite239##
22indexWrite240##
22indexWrite241##
22indexWrite242##
22indexWrite243##
22indexWrite244##
22indexWrite245##
22indexWrite246##
22indexWrite247##
22indexWrite248##
22indexWrite249##
22indexWrite250##
22indexWrite251##
22indexWrite252##
22indexWrite253##
22indexWrite254##
22indexWrite255##
22indexWrite256##
22indexWrite257##
22indexWrite258##
22indexWrite259##
22indexWrite260##
22indexWrite261##
22indexWrite262##
22indexWrite263##
22indexWrite264##
22indexWrite265##
22indexWrite266##
22indexWrite267##
22indexWrite268##
22indexWrite269##
22indexWrite270##
22indexWrite271##
22indexWrite272##
22indexWrite273##
22indexWrite274##
22indexWrite275##
22indexWrite276##
22indexWrite277##
22indexWrite278##
22indexWrite279##
22indexWrite280##
22indexWrite281##
22indexWrite282##
22indexWrite283##
22indexWrite284##
22indexWrite285##
22indexWrite286##
22indexWrite287##
22indexWrite288##
22indexWrite289##
22indexWrite290##
22indexWrite291##
22indexWrite292##
22indexWrite293##
22indexWrite294##
22indexWrite295##
22indexWrite296##
22indexWrite297##
22indexWrite298##
22indexWrite299##
22indexWrite300##
22indexWrite301##
22indexWrite302##
22indexWrite303##
22indexWrite304##
22indexWrite305##
22indexWrite306##
22indexWrite307##
22indexWrite308##
22indexWrite309##
22indexWrite310##
22indexWrite311##
22indexWrite312##
22indexWrite313##
22indexWrite314##
22indexWrite315##
22indexWrite316##
22indexWrite317##
22indexWrite318##
22indexWrite319##
22indexWrite320##
22indexWrite321##
22indexWrite322##
22indexWrite323##
22indexWrite324##
22indexWrite325##
22indexWrite326##
22indexWrite327##
22indexWrite328##
22indexWrite329##
22indexWrite330##
22indexWrite331##
22indexWrite332##
22indexWrite333##
22indexWrite334##
22indexWrite335##
22indexWrite336##
22indexWrite337##
22indexWrite338##
22indexWrite339##
22indexWrite340##
22indexWrite341##
22indexWrite342##
22indexWrite343##
22indexWrite344##
22indexWrite345##
22indexWrite346##
22indexWrite347##
22indexWrite348##
22indexWrite349##
22indexWrite350##
22indexWrite351##
22indexWrite352##
22indexWrite353##
22indexWrite354##
22indexWrite355##
22indexWrite356##
22indexWrite357##
22indexWrite358##
22indexWrite359##
22indexWrite360##
22indexWrite361##
22indexWrite362##
22indexWrite363##
22indexWrite364##
22indexWrite365##
22indexWrite366##
22indexWrite367##
22indexWrite368##
22indexWrite369##
22indexWrite370##
22indexWrite371##
22indexWrite372##
22indexWrite373##
22indexWrite374##
22indexWrite375##
22indexWrite376##
22indexWrite377##
22indexWrite378##
22indexWrite379##
22indexWrite380##
22indexWrite381##
22indexWrite382##
22indexWrite383##
22indexWrite384##
22indexWrite385##
22indexWrite386##
22indexWrite387##
22indexWrite388##
22indexWrite389##
22indexWrite390##
22indexWrite391##
22indexWrite392##
22indexWrite393##
22indexWrite394##
22indexWrite395##
22indexWrite396##
22indexWrite397##
22indexWrite398##
22indexWrite399##
22indexWrite400##
22indexWrite401##
22indexWrite402##
22indexWrite403##
22indexWrite404##
22indexWrite405##
22indexWrite406##
22indexWrite407##
22indexWrite408##
22indexWrite409##
22indexWrite410##
22indexWrite411##
22indexWrite412##
22indexWrite413##
22indexWrite414##
22indexWrite415##
22indexWrite416##
22indexWrite417##
22indexWrite418##
22indexWrite419##
22indexWrite420##
22indexWrite421##
22indexWrite422##
22indexWrite423##
22indexWrite424##
22indexWrite425##
22indexWrite426##
22indexWrite427##
22indexWrite428##
22indexWrite429##
22indexWrite430##
22indexWrite431##
22indexWrite432##
22indexWrite433##
22indexWrite434##
22indexWrite435##
22indexWrite436##
22indexWrite437##
22indexWrite438##
22indexWrite439##
22indexWrite440##
22indexWrite441##
22indexWrite442##
22indexWrite443##
22indexWrite444##
22indexWrite445##
22indexWrite446##
22indexWrite447##
22indexWrite448##
22indexWrite449##
22indexWrite450##
22indexWrite451##
22indexWrite452##
22indexWrite453##
22indexWrite454##
22indexWrite455##
22indexWrite456##
22indexWrite457##
22indexWrite458##
22indexWrite459##
22indexWrite460##
22indexWrite461##
22indexWrite462##
22indexWrite463##
22indexWrite464##
22indexWrite465##
22indexWrite466##
22indexWrite467##
22indexWrite468##
22indexWrite469##
22indexWrite470##
22indexWrite471##
22indexWrite472##
22indexWrite473##
22indexWrite474##
22indexWrite475##
22indexWrite476##
22indexWrite477##
22indexWrite478##
22indexWrite479##
22indexWrite480##
22indexWrite481##
22indexWrite482##
22indexWrite483##
22indexWrite484##
22indexWrite485##
22indexWrite486##
22indexWrite487##
22indexWrite488##
22indexWrite489##
22indexWrite490##
22indexWrite491##
22indexWrite492##
22indexWrite493##
22indexWrite494##
22indexWrite495##
22indexWrite496##
22indexWrite497##
22indexWrite498##
22indexWrite499##
大体思路如下:
使用两个文件分开存储 key 和value
value存储在data文件中 中规中矩的存储 不多描述
key值存储在index文件中 使用素数(137)个桶来存储key值
0 0 0 0 0 0.........0 0 <-----137 个桶
当输入一个 kv 值时,比如输入 ''key" "value"
经过哈希运算 key的哈希值为2 则在第3个桶(计数规则从0开始,0,1,2)记录key写入index文件的偏移值
则index文件内容如下
0 0 1137 0 0 0.......0 0
0 8key#0#5
表示在第3个桶内有内容 由于仅有一个记录 所以INDEX的一开始为0 若有其他记录则记录桶内下个元素在文件里的偏移 后面的8 表示接下来的字节加'\n'共长8个字节
后面的内容则是key值与data在data文件里的起始位置和长度
简易数据库实现 UNIX环境高级编程(APUE)第二十章 A Database Library的更多相关文章
- (四) 一起学 Unix 环境高级编程(APUE) 之 系统数据文件和信息
. . . . . 目录 (一) 一起学 Unix 环境高级编程 (APUE) 之 标准IO (二) 一起学 Unix 环境高级编程 (APUE) 之 文件 IO (三) 一起学 Unix 环境高级编 ...
- (十三) [终篇] 一起学 Unix 环境高级编程 (APUE) 之 网络 IPC:套接字
. . . . . 目录 (一) 一起学 Unix 环境高级编程 (APUE) 之 标准IO (二) 一起学 Unix 环境高级编程 (APUE) 之 文件 IO (三) 一起学 Unix 环境高级编 ...
- (一) 一起学 Unix 环境高级编程 (APUE) 之 标准IO
. . . . . 目录 (一) 一起学 Unix 环境高级编程 (APUE) 之 标准IO (二) 一起学 Unix 环境高级编程 (APUE) 之 文件 IO (三) 一起学 Unix 环境高级编 ...
- (二) 一起学 Unix 环境高级编程 (APUE) 之 文件 IO
. . . . . 目录 (一) 一起学 Unix 环境高级编程 (APUE) 之 标准IO (二) 一起学 Unix 环境高级编程 (APUE) 之 文件 IO (三) 一起学 Unix 环境高级编 ...
- (三) 一起学 Unix 环境高级编程 (APUE) 之 文件和目录
. . . . . 目录 (一) 一起学 Unix 环境高级编程 (APUE) 之 标准IO (二) 一起学 Unix 环境高级编程 (APUE) 之 文件 IO (三) 一起学 Unix 环境高级编 ...
- (五) 一起学 Unix 环境高级编程 (APUE) 之 进程环境
. . . . . 目录 (一) 一起学 Unix 环境高级编程 (APUE) 之 标准IO (二) 一起学 Unix 环境高级编程 (APUE) 之 文件 IO (三) 一起学 Unix 环境高级编 ...
- (六) 一起学 Unix 环境高级编程 (APUE) 之 进程控制
. . . . . 目录 (一) 一起学 Unix 环境高级编程 (APUE) 之 标准IO (二) 一起学 Unix 环境高级编程 (APUE) 之 文件 IO (三) 一起学 Unix 环境高级编 ...
- (七) 一起学 Unix 环境高级编程(APUE) 之 进程关系 和 守护进程
. . . . . 目录 (一) 一起学 Unix 环境高级编程 (APUE) 之 标准IO (二) 一起学 Unix 环境高级编程 (APUE) 之 文件 IO (三) 一起学 Unix 环境高级编 ...
- (八) 一起学 Unix 环境高级编程 (APUE) 之 信号
. . . . . 目录 (一) 一起学 Unix 环境高级编程 (APUE) 之 标准IO (二) 一起学 Unix 环境高级编程 (APUE) 之 文件 IO (三) 一起学 Unix 环境高级编 ...
随机推荐
- 2017-2018-2 20165312 课下选做 MySort
2017-2018-2 20165312 课下选做 MySort 题目描述 模拟实现Linux下Sort -t : -k 2的功能,参考 Sort的实现. import java.util.*; pu ...
- 20165312 2017-2018-2《Java程序设计》第9周学习总结
20165312 2017-2018-2<Java程序设计>第9周学习总结 上周错题总结 1.进程的基本状态有:新建.运行.阻塞.死亡. A . true B . false 解析:A 这 ...
- 2017-2018-2 20165312 实验三《敏捷开发与XP实践》实验报告
2017-2018-2 20165312 实验三<敏捷开发与XP实践>实验报告 一.实验内容 1.XP基础 极限编程(Extreme Programming,XP)是一种全新而快捷的软件开 ...
- VS2015密匙--VS2015打开丢失msvcp140.dll--cannot find one or more components ,please reinstall the application
win7旗舰版 64位 + vs2015 专业版 1.安装VS2015过程中可能需要用到的VS2015专业版钥匙:(测试,可用) HMGNV-WCYXV-X7G9W-YCX63-B98R2 2.VS2 ...
- web监控,if 语句
对页面的测试 curl "] #if [`curl -I http://10.0.0.7 &>/dev/null|head -l|grep 200|wc -l` -eq 1] ...
- zookeeper 集群部署
参考: https://www.cnblogs.com/linuxprobe/p/5851699.html
- sqlserver float小数存数据库变成多位了 比如说12.23存进去变成 12.229999998 甚至更长
使用 numeric(12,2)的数据类型,或者decimal(12,2) 追问 不能随意修改表结构 有别人办法么 程序上控制的 追答 那你就不用管他了,所谓 浮点数,必然是这么存储的.
- IOS 发布 升级新版本
ERROR ITMS-90725: "SDK Version Issue. ERROR ITMS-90725: "SDK Version Issue. This app was b ...
- linux 杀死进程kill 等用法
kill -9 $(ps -ef | grep process_name | grep -v grep | awk '{print $2}') 稍微解释一下: awk '{print $2} ...
- input 选择框改变背景小技巧
最近在项目中遇到一个问题,想要改变input选择框的背景,然而,令我没有想到的是,竟然无法直接改变背景的颜色 通常情况下:我们都可以通过改变元素的 background-color 的值来改变元素的背 ...