我在编写搜索功能的速度方面遇到了麻烦.功能步骤如下所述:
功能目标是能够跟踪链接直接或具有多个分离度的表之间的链接.递归级别是固定的整数值.
我的问题是,每当我尝试在两个级别的搜索深度上运行此功能时(在此阶段不敢尝试更深),作业内存不足,或者我失去了耐心.我等了17分钟才把工作用完了一次.
每个表的平均列数为28,标准差为34.
下面的图表显示了可以在表之间建立的各种链接的示例:

这是我的代码:
private void FindLinkingTables(List<TableColumns> sourceList, TableSearchNode parentNode, string targetTable, int maxSearchDepth)
{
if (parentNode.Level < maxSearchDepth)
{
IEnumerable<string> tableColumns = sourceList.Where(x => x.Table.Equals(parentNode.Table)).Select(x => x.Column);
foreach (string sourceColumn in tableColumns)
{
string shortName = sourceColumn.Substring(1);
IEnumerable<TableSearchNode> tables = sourceList.Where(
x => x.Column.Substring(1).Equals(shortName) && !x.Table.Equals(parentNode.Table) && !parentNode.Ancenstory.Contains(x.Table)).Select(
x => new TableSearchNode { Table = x.Table, Column = x.Column, Level = parentNode.Level + 1 });
foreach (TableSearchNode table …Run Code Online (Sandbox Code Playgroud) 声明为动态的变量的默认值是private dynamic banana;什么?
default()在运行时确定类型时,我可以依赖该函数吗?
我需要找到默认值的原因是我声明了一个类的动态成员,我想将它设置一次(但不是readonly),然后多次使用它.
如何在不知道运行时类型可能的情况下检查动态变量是否已设置为默认值以外的任何值?
谷歌对此没有任何想法:S
提前致谢.
我正在尝试从中选择Dictionary<String, Double>一个Dictionary<String, String>。为此,我使用IEnumrable<>.Whereso子选择a Dictionary<String, String>(有效),然后将其强制转换为Dictionary<String, Double>(无效)。
我的代码:
//linesTable is an System.data.DataTable object
//...for loop code in here
DataRow row = linesTable.Rows[i]; //Where i is the loop index
Dictionary<String, String> valuesDictionary
= row.Table.Columns.Cast<DataColumn>().ToDictionary(
col => col.ColumnName,
col => row.Field<String>(col.ColumnName));
//ATTEMPT #1
/*Dictionary<String, Double> numericValues = valuesDictionary.Where(
subs =>
{
double doubleValue;
return double.TryParse(subs.Value, out doubleValue);
}).Cast<Dictionary<String, Double>>();*/
//ATTEMPT #2
Dictionary<String, Double> numericValues = valuesDictionary.Where(
subs => {
double doubleValue;
return double.TryParse(subs.Value, out …Run Code Online (Sandbox Code Playgroud) 出于某种原因,尽管配置了 FasterXML Jackson CSV 映射器来创建基于 POJO 的架构,但它坚持认为没有提供合适的配置。我收到以下异常:
com.fasterxml.jackson.databind.JsonMappingException: No value type configured for ObjectReader
com.fasterxml.jackson.databind.ObjectReader._findRootDeserializer(ObjectReader.java:1371)
com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:1265)
com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:897)
aol.model.core.services.admin.CSVParserService.parseCSVFileStreamAsClass(CSVParserService.java:42)
aol.rest.controller.AdminController.importCsvData(AdminController.java:30)
aol.rest.controller.AdminController$$FastClassBySpringCGLIB$$b9304c43.invoke(<generated>)
org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
...
Run Code Online (Sandbox Code Playgroud)
我的POJO很简单
@JsonPropertyOrder({"firstName", "lastName", "age"})
public class Person {
String firstName;
String lastName;
Integer age;
public Person() {} //no other use than to avoid no-suitable-construction found issue
//getters and setters omitted for brevity
}
Run Code Online (Sandbox Code Playgroud)
我的解析代码是
public MappingIterator<Person> parseCSVFileStreamAsClass(MultipartFile file) throws IOException {
StringBuilder lines = new StringBuilder();
String lineSeparator = System.getProperty("line.separator");
try(BufferedReader reader = new BufferedReader(new InputStreamReader(file.getInputStream()))) {
for …Run Code Online (Sandbox Code Playgroud)