我目前正在开发一个嵌入式项目(STM32F103RB,CooCox CoIDE v.1.7.6 with arm-none-eabi-gcc 4.8 2013q4),我试图了解当RAM满时如何malloc()表现C.
我的STM32有20kB = 0x5000Bytes的RAM,0x200用于堆栈.
#include <stdlib.h>
#include "stm32f10x.h"
struct list_el {
char weight[1024];
};
typedef struct list_el item;
int main(void)
{
item * curr;
// allocate until RAM is full
do {
curr = (item *)malloc(sizeof(item));
} while (curr != NULL);
// I know, free() is missing. Program is supposed to crash
return 0;
}
Run Code Online (Sandbox Code Playgroud)
一旦堆太小而无法分配,我希望malloc()能够返回NULL:
0x5000(RAM) - 0x83C(bss) - 0x200(堆栈)= 0x45C4(堆) …
我们正在研究一个复杂的统计项目Java.我们用R编程语言编写了原始代码.有没有办法将此代码转换为Java代码(转换器)或我们如何R在Java项目中使用?
我正在使用angular-ui typeahead.如何在焦点输入框时触发弹出项目,而不是在键入后触发弹出项目.
我想,从我运行Spark工作的地方,获得该工作的唯一ID.
通过Spark主节点网站,我可以看到该ID.它是这样的:
ID: app-20140429125304-0452
Run Code Online (Sandbox Code Playgroud)
在创建一份正在运行的工作时,有没有办法解决这个问题?也许通过SparkContext?
我花了很长时间来编写多个SQL查询,这些查询以前用于获取各种R脚本的数据.这就是它的工作原理
sqlContent = readSQLFile("file1.sql")
sqlContent = setSQLVariables(sqlContent, variables)
results = executeSQL(sqlContent)
Run Code Online (Sandbox Code Playgroud)
线索是,对于某些查询,需要先前查询的结果 - 为什么VIEW在数据库中创建s本身并不能解决这个问题.随着Spark 2.0我已经想出了一个办法,通过做到这一点
// create a dataframe using a jdbc connection to the database
val tableDf = spark.read.jdbc(...)
var tempTableName = "TEMP_TABLE" + java.util.UUID.randomUUID.toString.replace("-", "").toUpperCase
var sqlQuery = Source.fromURL(getClass.getResource("/sql/" + sqlFileName)).mkString
sqlQuery = setSQLVariables(sqlQuery, sqlVariables)
sqlQuery = sqlQuery.replace("OLD_TABLE_NAME",tempTableName)
tableDf.createOrReplaceTempView(tempTableName)
var data = spark.sql(sqlQuery)
Run Code Online (Sandbox Code Playgroud)
但这是我非常愚蠢的意见.此外,更复杂的查询,例如,当前无法使用子查询因子的查询不起作用.有没有像重新实现的SQL代码到一个更强大的方式Spark.SQL使用代码filter($""),.select($"")等等.
总体目标是获得多个org.apache.spark.sql.DataFrames,每个s代表一个以前的SQL查询(总是几个JOINs,WITHs等)的结果.所以n查询导致n DataFrame …
精简版:
有没有办法指导插入符号训练回归模型
长版:
我有一个数据帧
> feature1 <- c(1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0)
> feature2 <- c(1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1)
> feature3 <- c(0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0)
> TARGET <- factor(make.names(c(1,0,1,1,0,0,1,0,1,1,1,0,1,0,0,0,1,0,1,1)))
> df <- data.frame(feature1, feature2, feature3, TARGET)
Run Code Online (Sandbox Code Playgroud)
模型训练就像实施一样
> ctrl <- trainControl(
+ method="repeatedcv",
+ repeats = 2)
>
> tuneGrid <- expand.grid(k = c(2,5,7))
>
> tune <- train(
+ TARGET ~ .,
+ metric = '???',
+ maximize = TRUE,
+ data = df,
+ method = "knn",
+ trControl = ctrl,
+ preProcess = c("center","scale"), …Run Code Online (Sandbox Code Playgroud) Bokeh服务允许使用绘图和小部件编写快速Web应用程序.我如何在使用时调试python代码bokeh serve --show code.py?
我有一个具有以下文件结构的 monorepo 设置:
\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 functions\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 src\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 package.json\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 shared\n| \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 dist\n| \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 src\n| \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 package.json\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 frontend\n| \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 ...\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 firebase.json\nRun Code Online (Sandbox Code Playgroud)\n./shared持有在./backend和之间共享的 TypeScript 类./frontend。理想情况下,我想使用functions/package.json符号链接引用共享库,以避免每次更改共享代码(大部分功能都位于其中)后都必须重新安装。
但是,这不起作用(既不使用link:,也不使用绝对file:路径,也不使用相对file:路径)
// functions/package.json\n ...\n "dependencies": {\n "shared": "file:/home/boern/Desktop/wd/monorepo/shared"\n ...\n }\nRun Code Online (Sandbox Code Playgroud)\n导致错误firebase deploy --only functions( error Package "shared" refers to a non-existing file \'"home/boern/Desktop/wd/monorepo/shared"\')。库(尽管存在于 中./functions/node_modules/)未传输到服务器?
此外,"functions": {"ignore": …
好的,这是一个超级超级菜鸟问题,我几乎不好意思问...
我想在我的XAML文件中引用一个类.它是一个DataTemplateSelector,用于为DataGrid列选择正确的编辑模板.
无论如何,我已经将类编写到我的代码后面,将本地命名空间添加到XAML顶部的顶部,但是当我尝试从XAML引用该类时,它告诉我该类在本地命名空间中不存在.我必须遗漏一些非常简单但我无法理解的东西......
这是我的代码.
XAML:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tk="http://schemas.microsoft.com/wpf/2008/toolkit"
xmlns:local="clr-namespace:CustomFields"
xmlns:col="clr-namespace:System.Collections;assembly=mscorlib"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
x:Class="CustomFields.MainWindow"
x:Name="Window"
Title="Define Custom Fields"
Width="425" Height="400" MinWidth="425" MinHeight="400">
<Window.Resources>
<ResourceDictionary>
<local:RangeValuesEditTemplateSelector>
blah blah blah...
</local:RangeValuesEditTemplateSelector>
</ResourceDictionary>
</Window.Resources>
Run Code Online (Sandbox Code Playgroud)
C#:
namespace CustomFields
{
public partial class MainWindow : Window
{
public MainWindow()
{
this.InitializeComponent();
// Insert code required on object creation below this point.
}
}
public class RangeValuesEditTemplateSelector : DataTemplateSelector
{
public RangeValuesEditTemplateSelector(){
MessageBox.Show("hello");
}
}
}
Run Code Online (Sandbox Code Playgroud)
我有什么想法我做错了吗?我认为这应该很简单,如1-2-3 ......
谢谢!
有人设法在 Windows 上使用 Spark 的DataFrame编写文件(尤其是 CSV)吗?
由于自 2.0 版以来Sparks 编写 .CSV 的本机功能(和统一方法),许多关于 SO 的答案已经过时(例如这个)write()。此外,我下载并添加winutils.exe了此处建议的内容。
代码:
// reading works just fine
val df = spark.read
.option("header", true)
.option("inferSchema", true)
.csv("file:///C:/tmp/in.csv")
// writing fails, none of these work
df.write.csv("file:///C:/tmp/out.csv")
df.write.csv("C:/tmp/out.csv")
Run Code Online (Sandbox Code Playgroud)
错误:
Exception in thread "main" org.apache.spark.SparkException: Job aborted.
at org.apache.spark.sql.execution.datasources.InsertIntoHadoopFsRelationCommand$$anonfun$run$1.apply$mcV$sp(InsertIntoHadoopFsRelationCommand.scala:149)
at org.apache.spark.sql.execution.datasources.InsertIntoHadoopFsRelationCommand$$anonfun$run$1.apply(InsertIntoHadoopFsRelationCommand.scala:115)
at org.apache.spark.sql.execution.datasources.InsertIntoHadoopFsRelationCommand$$anonfun$run$1.apply(InsertIntoHadoopFsRelationCommand.scala:115)
at org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:57)
at org.apache.spark.sql.execution.datasources.InsertIntoHadoopFsRelationCommand.run(InsertIntoHadoopFsRelationCommand.scala:115)
at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult$lzycompute(commands.scala:60)
at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult(commands.scala:58)
at org.apache.spark.sql.execution.command.ExecutedCommandExec.doExecute(commands.scala:74)
at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$1.apply(SparkPlan.scala:115)
at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$1.apply(SparkPlan.scala:115)
at org.apache.spark.sql.execution.SparkPlan$$anonfun$executeQuery$1.apply(SparkPlan.scala:136) …Run Code Online (Sandbox Code Playgroud)