我有一个带有ImageViews的GridView.我每行有3个.我可以使用WRAP_CONTENT和scaleType = CENTER_CROP正确设置宽度,但我不知道如何将ImageView的大小设置为正方形.这是我到目前为止所做的,除了高度,它似乎没问题,那就是"静态":
imageView = new ImageView(context);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setLayoutParams(new GridView.LayoutParams(GridView.LayoutParams.WRAP_CONTENT, 300));
Run Code Online (Sandbox Code Playgroud)
我在适配器里面做的.
我有一个类似这样的数据框df.printSchema:
root
|-- ts: timestamp (nullable = true)
|-- geoip: struct (nullable = true)
| |-- city: string (nullable = true)
| |-- continent: string (nullable = true)
| |-- location: struct (nullable = true)
| | |-- lat: float (nullable = true)
| | |-- lon: float (nullable = true)
Run Code Online (Sandbox Code Playgroud)
我知道,例如用df = df.withColumn("error", lit(null).cast(StringType))我可以添加一个null名为场error型的String正下方root.如何在geoipStruct下或Struct 下添加相同的字段location?
我也试过df = df.withColumn("geoip.error", lit(null).cast(StringType))没有运气.
我正在尝试将示例脚本(在 中提供的脚本README.md)包含到 Visual Studio 2019 中的测试 C# 代码中。我使用的是 Python virtualenv。
关于我的环境的一些信息:
pythonnet-2.4.0-cp37-cp37m-win_amd64.whlPython 3.7.6 (tags/v3.7.6:43364a7ae0, Dec 19 2019, 00:42:30) [MSC v.1916 64 bit (AMD64)]Windows 10 64-bit首先,我创建了一个全新的virtualenv并安装了包,只要numpy.
mkvirtualenv pynet
workon pynet
pip3 install numpy
pip3 install pythonnet
Run Code Online (Sandbox Code Playgroud)
这是结果输出pythonnet:
Collecting pythonnet
Using cached pythonnet-2.4.0-cp37-cp37m-win_amd64.whl (70 kB)
Installing collected packages: pythonnet
Successfully installed pythonnet-2.4.0
Run Code Online (Sandbox Code Playgroud)
我创建了一个示例 Visual Studio 2019 项目。我做的第一件事是取消对勾的设置Properties -> Build -> Prefer 32-bit,然后我添加了引用Python.Runtime.dll,在我的情况下它在C:\Users\andrea\Envs\pynet\Lib\site-packages\Python.Runtime.dll. 然后我创建了以下示例脚本: …
我正在使用kinect,我需要保存RAW深度图像.这意味着我不应该通过转换为8位来保存它(这就是imwrite正在做的事情!)但是将其保存为16位,而没有任何位深度减少.我希望这个问题不会太微不足道,但我是OpenCV编程的新手.我尝试了以下,但它不起作用:
[...]
Mat imageDepth ( 480, 640, CV_16UC1 );
Mat imageRGB;
// Video stream settings
VideoCapture capture;
capture.open( CAP_OPENNI );
if ( !capture.isOpened() ) {
cerr << "Cannot get video stream!" << endl;
exit ( EXIT_WITH_ERROR );
}
if ( !capture.grab() ) {
cerr << "Cannot grab images!" << endl;
exit ( EXIT_WITH_ERROR );
}
// Getting frames
if ( capture.retrieve( imageDepth, CAP_OPENNI_DISPARITY_MAP ) ) {
imwrite( fileDepth, imageDepth );
}
if( capture.retrieve( imageRGB, CAP_OPENNI_BGR_IMAGE ) ) {
imwrite( fileRGB, …Run Code Online (Sandbox Code Playgroud) 我在这个函数中遇到错误,但我不知道为什么.你能帮助我吗?
错误发生在我调用的行中 executeQuery()
public static int numeroElementi(String table) throws SQLException {
// viene reistanziata perché questa è una funziona statica!
String DB_URL = "jdbc:mysql://localhost:3306/kmzero";
Connection connection = DriverManager.getConnection(DB_URL, "root", "root");
String query = "SELECT COUNT(*) AS count FROM ? ";
PreparedStatement pStatement = connection.prepareStatement(query);
pStatement.setString(1, table);
try {
ResultSet resultSet = pStatement.executeQuery();
try {
if (resultSet.next())
return resultSet.getInt("count");
else
return 0;
} finally {
resultSet.close();
}
} finally {
pStatement.close();
}
}
Run Code Online (Sandbox Code Playgroud) 我有时间Timestamp格式化,这是产品的到期时间,我必须检查此产品是否已过期.我能怎么做?
我试过这种方式,但实际上函数总是返回TRUE(我无法弄清楚为什么)
public boolean isAuctionExpired() {
// expiration_time is setted before, is the expiration date of a product!
Timestamp actualTimeStampDate = null;
try {
Date actual = new Date();
actualTimeStampDate = new Timestamp(actual.getTime());
} catch (Exception e) {
System.out.println("Exception :" + e);
}
boolean expired = (expiration_time.getTime() < actualTimeStampDate.getTime());
// Everything seems ok, except the boolean
System.out.println("product exp: "+expiration_time+", actual: "+actualTimeStampDate+" expired? "+expired);
return expired;
}
Run Code Online (Sandbox Code Playgroud)
我想我犯了一个愚蠢的错误,但我看不到它!
首先我们来搭建一个测试环境:
CREATE TABLE IF NOT EXISTS source_table (
`col1` TIMESTAMP,
`col2` STRING
);
CREATE TABLE IF NOT EXISTS dest_table (
`col1` TIMESTAMP,
`col2` STRING,
`col3` STRING
)
PARTITIONED BY (day STRING)
STORED AS AVRO;
INSERT INTO TABLE source_table VALUES ('2018-03-21 17:08:04.401', 'test1'), ('2018-03-22 12:02:04.222', 'test2'), ('2018-03-22 07:21:04.111', 'test3');
Run Code Online (Sandbox Code Playgroud)
如何在插入期间列出列名并动态放置分区值?以下命令不起作用:
INSERT INTO TABLE dest_table(col1, col2) PARTITION(day) SELECT col1, col2, date_format(col1, 'yyyy-MM-dd') FROM source_table;
Run Code Online (Sandbox Code Playgroud)
顺便说一句,如果没有列出命令dest_table内部的列INSERT INTO,只要有两个具有相同列号的表,一切都可以正常工作。如果 my 的dest_table字段多于 的字段怎么办source_table?
感谢你们对我的帮助。
聚苯乙烯
好的,如果我硬编码NULL这有效。我保留这个问题是因为可能有更好的方法来实现这一目标。 …