a*5
3 楼
应该是要实现一个简单的抽象语法树parser吧,parser本身可以用状态机来做
l*s
5 楼
首先,Table一定是一个List,那么需要示意地定义几个类或接口IObject1,
IObject2准备被from 选用。
选用一个Hashmap,mapping From的Table名字字符串和List的变量。
假设有
IList list = new List();
list.Add(...);...
map[table] = list;
从易到难,单表查询且没有Group By开始,写一个解析器存入三个字符组string[]
select,string[] from,KeyValuePair[] where
三个参数的函数
public IList> Retrieve(string[] select, string[] from,
KeyValuePair[] where){
...
//在.Net中Linq可以简化为
return map[from[0]].Select(select[0], select[1], ...).Where(where.Key =
where.Value);
}
然后加上多表Join,这里用DI Container好一些,因为表的数量不定,Group By比较麻
烦,相信面试时候这两样也就说说,代码是写不完的。
【在 b*********n 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: 比如说有下面的数据 和 sql query, 让输出结果
: String[][] data = {
: { "id", "gender", "age", "job" },
: { "1", "male", "10", "yes" },
: { "2", "female", "20", "no" },
: { "3", "male", "30", "yes" }, };
: String query = "select id, gender, age from table where gender = male";
IObject2准备被from 选用。
选用一个Hashmap,mapping From的Table名字字符串和List的变量。
假设有
IList
list.Add(...);...
map[table] = list;
从易到难,单表查询且没有Group By开始,写一个解析器存入三个字符组string[]
select,string[] from,KeyValuePair[] where
三个参数的函数
public IList
KeyValuePair[] where){
...
//在.Net中Linq可以简化为
return map[from[0]].Select(select[0], select[1], ...).Where(where.Key =
where.Value);
}
然后加上多表Join,这里用DI Container好一些,因为表的数量不定,Group By比较麻
烦,相信面试时候这两样也就说说,代码是写不完的。
【在 b*********n 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: 比如说有下面的数据 和 sql query, 让输出结果
: String[][] data = {
: { "id", "gender", "age", "job" },
: { "1", "male", "10", "yes" },
: { "2", "female", "20", "no" },
: { "3", "male", "30", "yes" }, };
: String query = "select id, gender, age from table where gender = male";
b*n
6 楼
需要写现场可以运行的代码
求思路
用什么数据结构
比如说有下面的数据 和 sql query, 让输出结果
String[][] data = {
{ "id", "gender", "age", "job" },
{ "1", "male", "10", "yes" },
{ "2", "female", "20", "no" },
{ "3", "male", "30", "yes" }, };
String query = "select id, gender, age from table where gender = male";
求思路
用什么数据结构
比如说有下面的数据 和 sql query, 让输出结果
String[][] data = {
{ "id", "gender", "age", "job" },
{ "1", "male", "10", "yes" },
{ "2", "female", "20", "no" },
{ "3", "male", "30", "yes" }, };
String query = "select id, gender, age from table where gender = male";
l*s
7 楼
具体一些,解析的结果是怎样要求的?
【在 b*********n 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: 需要写现场可以运行的代码
: 求思路
: 用什么数据结构
: 比如说有下面的数据 和 sql query, 让输出结果
: String[][] data = {
: { "id", "gender", "age", "job" },
: { "1", "male", "10", "yes" },
: { "2", "female", "20", "no" },
: { "3", "male", "30", "yes" }, };
: String query = "select id, gender, age from table where gender = male";
【在 b*********n 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: 需要写现场可以运行的代码
: 求思路
: 用什么数据结构
: 比如说有下面的数据 和 sql query, 让输出结果
: String[][] data = {
: { "id", "gender", "age", "job" },
: { "1", "male", "10", "yes" },
: { "2", "female", "20", "no" },
: { "3", "male", "30", "yes" }, };
: String query = "select id, gender, age from table where gender = male";
a*5
8 楼
应该是要实现一个简单的抽象语法树parser吧,parser本身可以用状态机来做
l*s
10 楼
首先,Table一定是一个List,那么需要示意地定义几个类或接口IObject1,
IObject2准备被from 选用。
选用一个Hashmap,mapping From的Table名字字符串和List的变量。
假设有
IList list = new List();
list.Add(...);...
map[table] = list;
从易到难,单表查询且没有Group By开始,写一个解析器存入三个字符组string[]
select,string[] from,KeyValuePair[] where
三个参数的函数
public IList> Retrieve(string[] select, string[] from,
KeyValuePair[] where){
...
//在.Net中Linq可以简化为
return map[from[0]].Select(select[0], select[1], ...).Where(where.Key =
where.Value);
}
然后加上多表Join,这里用DI Container好一些,因为表的数量不定,Group By比较麻
烦,相信面试时候这两样也就说说,代码是写不完的。
【在 b*********n 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: 比如说有下面的数据 和 sql query, 让输出结果
: String[][] data = {
: { "id", "gender", "age", "job" },
: { "1", "male", "10", "yes" },
: { "2", "female", "20", "no" },
: { "3", "male", "30", "yes" }, };
: String query = "select id, gender, age from table where gender = male";
IObject2准备被from 选用。
选用一个Hashmap,mapping From的Table名字字符串和List的变量。
假设有
IList
list.Add(...);...
map[table] = list;
从易到难,单表查询且没有Group By开始,写一个解析器存入三个字符组string[]
select,string[] from,KeyValuePair[] where
三个参数的函数
public IList
KeyValuePair[] where){
...
//在.Net中Linq可以简化为
return map[from[0]].Select(select[0], select[1], ...).Where(where.Key =
where.Value);
}
然后加上多表Join,这里用DI Container好一些,因为表的数量不定,Group By比较麻
烦,相信面试时候这两样也就说说,代码是写不完的。
【在 b*********n 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: 比如说有下面的数据 和 sql query, 让输出结果
: String[][] data = {
: { "id", "gender", "age", "job" },
: { "1", "male", "10", "yes" },
: { "2", "female", "20", "no" },
: { "3", "male", "30", "yes" }, };
: String query = "select id, gender, age from table where gender = male";
l*h
11 楼
这道题可不可以用直接用regex去match?
【在 b*********n 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: 需要写现场可以运行的代码
: 求思路
: 用什么数据结构
: 比如说有下面的数据 和 sql query, 让输出结果
: String[][] data = {
: { "id", "gender", "age", "job" },
: { "1", "male", "10", "yes" },
: { "2", "female", "20", "no" },
: { "3", "male", "30", "yes" }, };
: String query = "select id, gender, age from table where gender = male";
【在 b*********n 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: 需要写现场可以运行的代码
: 求思路
: 用什么数据结构
: 比如说有下面的数据 和 sql query, 让输出结果
: String[][] data = {
: { "id", "gender", "age", "job" },
: { "1", "male", "10", "yes" },
: { "2", "female", "20", "no" },
: { "3", "male", "30", "yes" }, };
: String query = "select id, gender, age from table where gender = male";
l*h
12 楼
如果只是最基本的Select from where,好像不难,比如
String query = "select id, gender, age from table where gender = male";
只要parse出来Target (id, gender, age) 和condition (gender='male').
就和Data的第一行比较,拿到index, 然后顺序scanData二维数组,
打印出结果。
【在 b*********n 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: 需要写现场可以运行的代码
: 求思路
: 用什么数据结构
: 比如说有下面的数据 和 sql query, 让输出结果
: String[][] data = {
: { "id", "gender", "age", "job" },
: { "1", "male", "10", "yes" },
: { "2", "female", "20", "no" },
: { "3", "male", "30", "yes" }, };
: String query = "select id, gender, age from table where gender = male";
String query = "select id, gender, age from table where gender = male";
只要parse出来Target (id, gender, age) 和condition (gender='male').
就和Data的第一行比较,拿到index, 然后顺序scanData二维数组,
打印出结果。
【在 b*********n 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: 需要写现场可以运行的代码
: 求思路
: 用什么数据结构
: 比如说有下面的数据 和 sql query, 让输出结果
: String[][] data = {
: { "id", "gender", "age", "job" },
: { "1", "male", "10", "yes" },
: { "2", "female", "20", "no" },
: { "3", "male", "30", "yes" }, };
: String query = "select id, gender, age from table where gender = male";
相关阅读
hackerrank 和 leetcode 比怎么样?说说吧 你刷题的真正原因 你不刷题的真正原因国庆时候故宫,黄山之类的门票是怎么在网上销售的?FDA ORISE Fellow vs. CRO PM有点失落果家的rsuS家过了, 没headcount求职贴为什么总是被删啊?AMP Job Description SW Engineer Leader一定要刷题吗?怎么刷?你们看看我这个回答有没有什么硬伤?某家,脸家,狗家总感觉祝你好运更像是咒人的话。为什么说投行的IT是笑话?是很简单么?少壮不刷题,老大徒伤悲二爷还在唔吧?为什么现在这么多人唾弃唔吧?H1B extension 要求补件以及时间问题 求指点 (转载)人类对第二语言的反应速度比第一语言反应速度 (转载)请问自动化测试有什么career path?发个面经吧[Data Scientist] (转载)Baidu USA还是Jump Trading?