我有下表存储有关图像的数据:
images
- id (int)
- sample_1_1 (int)
- sample_1_2 (int)
- sample_1_3 (int)
- sample_2_1 (int)
- sample_2_2 (int)
- sample_2_3 (int)
- ... # Up until sample_25_3
Run Code Online (Sandbox Code Playgroud)
任务是计算收集的数据之间的距离.目前,我正在使用75维(正确的,3*25 = 75)欧几里德距离计算编程为数据库中的存储过程:
CREATE DEFINER=`root`@`localhost`
FUNCTION `distanceBetween`(compareId INT, toId INT) RETURNS double
READS SQL DATA
DETERMINISTIC
BEGIN
DECLARE distance DOUBLE;
SELECT euclidDistance(
i1.sample_1_1, i1.sample_1_2, i1.sample_1_3,
i2.sample_1_1, i2.sample_1_2, i2.sample_1_3,
...
) INTO distance
FROM images i1, (SELECT * FROM images WHERE id = toId) i2
WHERE i1.id = compareId;
RETURN distance;
END …Run Code Online (Sandbox Code Playgroud) mysql database-design query-optimization database-optimization
我想BackgroundWorker在另一个完成后开始一个。我不确定如何为它编写代码,所以我真的没有什么可展示的。
我想把它写在RunWorkerCompleted.
我应该在哪里以及如何做到这一点?
基本上,我想使用同一个工人,但做其他事情。与第 1 步一样,它从文件中解析数据,在第 2 步中,在第 1 步完成后,它应该将解析后的数据从内存写入数据库。
我有下表
CREATE TABLE [dbo].[LogFiles_Warehouse](
[id] [int] IDENTITY(1,1) NOT NULL,
[timestamp] [datetime] NOT NULL,
[clientNr] [int] NOT NULL,
[server] [nvarchar](150) COLLATE Latin1_General_CI_AS NOT NULL,
[storeNr] [int] NOT NULL,
[account] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL,
[software] [nvarchar](300) COLLATE Latin1_General_CI_AS NOT NULL,
CONSTRAINT [PK_Astoria_LogFiles_Warehouse] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
Run Code Online (Sandbox Code Playgroud)
并希望避免在我的表中有重复的行.我想在整个表上创建一个UNIQUE索引,但是然后SQL Manager Studio告诉我这是不可能的,因为密钥太大了.
除了索引之外,还有另一种方法可以在所有列上强制执行唯一的行吗?
我有一个应用程序,允许使用抽象类,人们编写自己的实现.我从目录中将这些实现加载为.class-files.目前,我有这个解决方案:
File classDir = new File("/users/myproject/classes/");
URL[] url = { classDir.toURI().toURL() };
URLClassLoader urlLoader = new URLClassLoader(url);
String filename;
for (File file : classDir.listFiles()) {
filename = string.getFilenameWithoutExtension(file);
if (filename.equals(".") || filename.equals("..") || filename.startsWith("."))
continue;
AbstractClass instance = (AbstractClass)urlLoader
.loadClass("org.mypackage." + filename)
.getConstructor(ConfigUtil.class, DatabaseUtil.class, StringUtil.class)
.newInstance(config, database, string));
instance.doSomething();
}
Run Code Online (Sandbox Code Playgroud)
如您所见 - 我需要指定类所在的包,以便正确加载它们.省略了包裹,我得到了一个
java.lang.NoClassDefFoundError:
MyClass (wrong name: org/mypackage/MyClass)
Run Code Online (Sandbox Code Playgroud)
错误.
现在,从建筑POV来看,我认为设计其他人的类在加载时必须编译为MY包,这是非常糟糕的设计.
所以我问你:有没有办法从文件系统加载类而不必指定它们所在的包?
我想连接一个已经分配的变量并将其保存到一个新变量,如下所示:
{assign var=permCat value="de.admin"}
{assign var=objectName value="myClass"}
{assign var=objectNameUpper value=$objectName|ucfirst}
{assign var=editPerm value=$permCat|cat:"canEdit"|cat:$objectNameUpper}
Run Code Online (Sandbox Code Playgroud)
所以,结果$editPerm应该是:de.admin.canEditMyClass
我怎样才能做到这一点?目前,它会抛出一个错误:Cannot use string as array offset...
我有以下课程:
import java.awt.Color;
import java.util.Vector;
public class MyClass {
private ImageSignature imageSignature;
private class ImageSignature implements Serializable {
private static final long serialVersionUID = -6552319171850636836L;
private Vector<Color> colors = new Vector<Color>();
public void addColor(Color color) {
colors.add(color);
}
public Vector<Color> getColors() {
return colors;
}
}
// Will be called after imageSignature was set, obviously
public String getImageSignature() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(imageSignature);
oos.close();
return String(Base64Coder.encode(baos.toByteArray()));
}
}
Run Code Online (Sandbox Code Playgroud)
当我试着打电话时getImageSignature(),我得到了NotSerializableException- …
我得到了
malloc: *** error for object 0x1001012f8: incorrect checksum for freed object
- object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Run Code Online (Sandbox Code Playgroud)
以下函数中的错误:
char* substr(const char* source, const char* start, const char* end) {
char *path_start, *path_end, *path;
int path_len, needle_len = strlen(start);
path_start = strcasestr(source, start);
if (path_start != NULL) {
path_start += needle_len;
path_end = strcasestr(path_start, end);
path_len = path_end - path_start;
path = malloc(path_len + 1);
strncpy(path, path_start, path_len);
path[path_len] = …Run Code Online (Sandbox Code Playgroud) 我收到了错误
文件/DocomGUI;component/Resources/logo.jpg不是项目的一部分,或者其"Build Action"属性未设置为"Resource".
但该logo.jpg文件肯定是项目的一部分,Build Actions也设置为"Resource".

它驻留在/Resources/项目根目录中的文件夹中,并且也位于Resources.resx具有相同名称的文件中.

我尝试重建解决方案,清理它然后,错误弹出.还有什么可能出错,以至于无法找到该文件?
代码:
<Window x:Class="DocomGUI.AboutWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="AboutWindow" Height="180" Width="220" Background="LightGray" MinWidth="220" MinHeight="115" MaxWidth="220" MaxHeight="115">
<Grid>
<Label Margin="0,66,24,48">DocomGUI</Label>
<Label Height="30" Margin="12,0,12,12" Name="VersionLabel" VerticalAlignment="Bottom"></Label>
<Image Margin="12,12,12,0" Stretch="Fill" Height="48" VerticalAlignment="Top" Source="/DocomGUI;component/Resources/logo.jpg" />
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud) 使用以下jspx代码
<jsp:root jsfc="f:view" xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ice="http://www.icesoft.com/icefaces/components"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:fn="http://java.sun.com/jsp/jstl/functions">
<ui:composition template="WEB-INF/includes/template/main-template.jspx"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:ice="http://www.icesoft.com/icefaces/components"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:m="http://www.tag.com/jsf">
<!-- params for page titles-->
<ui:define name="content">
<ice:form id="iceForm" partialSubmit="true">
<ice:panelGroup styleClass="error">
<ice:messages id="error" />
</ice:panelGroup>
<ice:panelGroup styleClass="progress"
rendered="#{login.inProgress and exportselection.renderView}">
<ice:panelGroup style="margin-top: 3px">
<ice:outputProgress id="buildView" labelPosition="embed"
labelComplete="completed" indeterminate="false"
rendered="#{login.inProgress and exportselection.renderView}"
value="#{exportselection.progressStatus}" />
<ice:panelGroup styleClass="cellTopRight">
<ice:panelGrid columns="2" cellspacing="10">
<ice:commandButton value="#{msgs['xliff.button.cancel1']}"
id="resetbutton" action="export"
rendered="#{login.inProgress and exportselection.renderView}"
actionListener="#{exportselection.cancel}" />
<ice:commandButton value="#{msgs['xliff.button.next']}"
id="nextger1"
rendered="#{login.inProgress and exportselection.renderView}"
action="#{exportselection.forward}"
disabled="#{login.inProgress}"
actionListener="#{exportselection.showExportView}" />
</ice:panelGrid>
</ice:panelGroup>
</ice:panelGroup>
</ice:panelGroup>
<ice:panelGrid …Run Code Online (Sandbox Code Playgroud) 当我想使用XPath遍历我的XmlDocument时,我遇到了文档中有许多丑陋的命名空间的问题,所以我开始使用NamespaceManagerXPath.
XML看起来像这样
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<Worksheet ss:Name="KA0100401">
<Table>
<Row>
<Cell>Data</Cell>
</Row>
<!-- more rows... -->
</Table>
</Worksheet>
<Worksheet ss:Name="KA0100402">
<!-- .... --->
</Worksheet>
</Workbook>
Run Code Online (Sandbox Code Playgroud)
现在,从我在本文档中看到的"urn:schemas-microsoft-com:office:spreadsheet"是默认命名空间,因为它位于根元素上.
所以天真地,我配置了NamespaceManager这样的:
XmlDocument document = new XmlDocument();
document.Load(reader);
XmlNamespaceManager manager = new XmlNamespaceManager(document.NameTable);
manager.AddNamespace(String.Empty, "urn:schemas-microsoft-com:office:spreadsheet");
manager.AddNamespace("o", "urn:schemas-microsoft-com:office:office");
manager.AddNamespace("x", "urn:schemas-microsoft-com:office:excel");
manager.AddNamespace("ss", "urn:schemas-microsoft-com:office:spreadsheet");
manager.AddNamespace("html", "http://www.w3.org/TR/REC-html40");
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试访问节点时
foreach (XmlNode row in document.SelectNodes("/Workbook/Worksheet[1]/Table/Row", manager))
Run Code Online (Sandbox Code Playgroud)
我从来没有得到任何结果.我的印象是,通过使用空前缀设置第一个命名空间,在搜索该工作空间中的节点时,我不需要设置它.
但是,因为它是在规定AddNamespace的方法:
如果XPath表达式不包含前缀,则假定名称空间统一资源标识符(URI)是空名称空间.
这是为什么?而且,更重要的是:如何访问默认命名空间中的节点,如果不使用前缀将它们设置为空命名空间?
如果我在搜索节点时甚至无法访问它,那么在管理器上设置默认命名空间有什么用呢?