AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-9128863

Jelly's questions

Martin Hope
Jelly
Asked: 2025-03-09 19:02:52 +0800 CST

FTPConnectionClosedException:连接无提示关闭

  • 5

我正在尝试使用 Apache 客户端连接从 docker 映像部署的 FTP 服务器:

import org.apache.commons.net.ftp.FTPClient

import java.io.IOException

object FtpClient {

  def main(args: Array[String]): Unit = {

    val ftpClient = new FTPClient()

    try {
      ftpClient.connect("localhost", 21)
      val success = ftpClient.login("one", "1234")

      if (success) {
        println("Success connect")
      }

    } catch {
      case e: IOException => throw new RuntimeException(e)
    } finally {
      // 
    }

  }
}

FTP 服务器运行者:

docker run -d     -p 21:21     -p 21000-21010:21000-21010     -e USERS="one|1234"     -e ADDRESS=ftp.site.domain     delfer/alpine-ftp-server

我收到以下错误:

      Exception in thread "main" java.lang.RuntimeException: org.apache.commons.net.ftp.FTPConnectionClosedException: Connection closed without indication.
at ru.spb.client.FtpClient$.main(FtpClient.scala:23)
at ru.spb.client.FtpClient.main(FtpClient.scala)
     Caused by: org.apache.commons.net.ftp.FTPConnectionClosedException: Connection closed without indication.
at org.apache.commons.net.ftp.FTP.getReply(FTP.java:568)
at org.apache.commons.net.ftp.FTP.getReply(FTP.java:556)

编辑:

Docker 日志返回:

Changing password for one
New password: 
Bad password: too short
Retype password: 
adduser: /ftp/one: No such file or directory
passwd: password for one changed by root
seems like pidfd_open syscall does not work, falling back to 
polling
failed to watch for direct child exit (pidfd_open error): Operation not permitted

也许我错过了一些重要的连接设置?

docker
  • 1 个回答
  • 27 Views
Martin Hope
Jelly
Asked: 2024-11-11 01:51:33 +0800 CST

使用文件内容更新字符串值

  • 5

传入的 csv 文件具有以下模式:

 latitude;longtitude
 90.232;24.244

我需要通过使用新字段“json”更新传入模式来生成流文件。

预期输出模式为:

latitude;longtitude;json
90.232;24.244;"{\"type\":\"Point\",\"coordinates\":[90.232,24.244]}"

所以我需要提取纬度和经度值并将它们放入 json(表示为字符串值)。

为了这个目的我使用了带有属性的 UpdateRecord:

更新记录

/json 值为:

  {"type":"Point","coordinates":[${\latitude},${\longtitude}]}

我也尝试过:

 {"type":"Point","coordinates":[${latitude},${longtitude}]}

但输出是:

 latitude;longtitude;json
 90.232;24.244;"{\"type\":\"Point\",\"coordinates\":[,]}"

因此没有任何东西被放置在坐标“占位符”中。

有人能帮助我吗?

apache-nifi
  • 1 个回答
  • 26 Views
Martin Hope
Jelly
Asked: 2024-11-10 18:34:07 +0800 CST

Scipy:计算正交向量

  • 5

我正在尝试使用 Scipy 进行正交向量计算:

import numpy as np
from scipy import linalg

e1 = np.float16([-0.913,  -0.4072]).reshape(2,1)

e2 = linalg.orth(e1)

print(f'e_1 {e1} ,'
      f' ortogonal e2 is {e2}')

我预期的输出是:

   e2 is [[-0.4072] [0.913]]

我检查了一下:0.913 * -0.4072 + (-0.4072)*0.913 = 0

但收到:

   e2 is [[-0.913] [-0.4072 ]]

我做错什么了?

python
  • 1 个回答
  • 28 Views
Martin Hope
Jelly
Asked: 2024-11-09 17:58:22 +0800 CST

Python Scipy:接受 1 个位置参数,但给出了 2 个

  • 5

我正在尝试使用 Scipy lib 实现简单的优化:

   def f1(x):
          sum(x)

   initial_x_1 = np.ndarray([1])

   res = optimize.minimize(f1, initial_x_1, [], 'COBYLA')

但出现错误:

    fx = fun(np.copy(x), *args)
     ^^^^^^^^^^^^^^^^^^^^^^

    TypeError: f1() takes 1 positional argument but 2 were given
python
  • 1 个回答
  • 33 Views
Martin Hope
Jelly
Asked: 2024-09-28 00:39:50 +0800 CST

带有一个分隔符连字符的表达式的正则表达式

  • 7

我将使用正则表达式来匹配表达式,其:

  1. 用一个(且只能一个)连字符分隔
  2. 两部分均不包含任何空格

因此,它匹配:

ss-ss
12-s2
11-11
%@2s-#1

并且不匹配:

s s-ss
ss-s s
s s-s s
1 s-1s
1s-1 s
1 s-1 s
ss-ss-ss
s1-s2-s3

有没有办法用正则表达式来创建?

我尝试了类似这样的方法:

^.[^ ]-[^ ]*

但它仅匹配带有任意数量连字符和任意空格的表达式,例如

 ss-ss-ss
 1 s-1 s
regex
  • 1 个回答
  • 47 Views
Martin Hope
Jelly
Asked: 2024-09-17 23:01:10 +0800 CST

向 Kafka 主题发送自定义消息

  • 5

任务是向 Kafka 主题发送具有具体价值的消息。

例如,我想以纯文本形式发送“someValue”。

为此我应该使用 PublishKafkaRecord_2_6 中的哪个 Kafka 属性?

例如,我将“FreeFormTextRecordSetWriter”视为一种服务,它将 RecordSet 的内容写入自由格式的文本。

但是在 PublishKafkaRecord_2_6 中我可以设置“someValue”以将其发布在目标主题中。

apache-kafka
  • 1 个回答
  • 16 Views
Martin Hope
Jelly
Asked: 2024-07-25 23:48:27 +0800 CST

Spark:转换为仅包含月份和年份的 DateType 值

  • 5

给定带有月份和年份的日期值:

03.2020

我尝试将其转换为 DateType,如下所示:

to_timestamp(col("Date"), "MM.yyyy").cast(DateType)

但这却带来了一些我没想到的事情:

 2017-03-01

返回值包含额外的“01”(日期值),并重新排序月份和年份。因此预期值为“03.2020”

根据这个建议,我还尝试了:

 date_format(col("Date"), "MM.yyyy")

但在这种情况下,该函数返回 null。

我究竟做错了什么 ?

apache-spark
  • 1 个回答
  • 13 Views
Martin Hope
Jelly
Asked: 2024-05-26 03:01:33 +0800 CST

Spark:未找到参数证据的隐式

  • 6

我在 Scala 上有以下 Spark 代码:

  def main(args: Array[String]): Unit = {
       val spark = SparkSession.builder.master("local").getOrCreate()
       import spark.implicits._

    val scheme = new StructType()
        .add(new StructField("state_id", IntegerType, true))
        .add(new StructField("state", StringType, true))
         .add(new StructField("recommendation", StringType, true))

  val statesDf: DataFrame = spark.read
        .format("jdbc")
        .schema(scheme)
        .option("driver", "org.postgresql.Driver")
        .option("url", "jdbc:postgresql://localhost:5432/postgres")
        .option("dbtable", "public.states")
        .option("user", "postgres")
        .option("password", "postgres")
        .load()

   statesDf.map(r => Row(r.getInt(0) * 2)).show()

  }

我在“地图”功能附近收到错误:

 No implicits found for parameter evidence$6: Encoder[Row]  

我期望“import Spark.implicits._”足以防止这个问题,但我错了

dataframe
  • 1 个回答
  • 13 Views
Martin Hope
Jelly
Asked: 2024-05-23 21:20:27 +0800 CST

OpenCV 图像中的目标检测任务

  • 5
我正在尝试在图像中检测一个片段,这个片段在以下MATLAB示例中有所表示。 我使用的是OpenCV库。 ```python import cv2 import numpy as np from imutils.object_detection import non_max_suppression # 读取图像和模板 img = cv2.imread('SourceImage.png') temp = cv2.imread('TargetFragment.png') # 保存图像尺寸 W, H = temp.shape[:2] # 定义最小阈值 thresh = 0.4 # 转换为灰度图像 img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) temp_gray = cv2.cvtColor(temp, cv2.COLOR_BGR2GRAY) # 将图像传递给matchTemplate方法 match = cv2.matchTemplate( image=img_gray, templ=temp_gray, method=cv2.TM_CCOEFF_NORMED) # 选择置信度大于阈值的矩形 (y_points, x_points) = np.where(match >= thresh) # 初始化我们的矩形列表 boxes = list() # 再次遍历起始(x, y)坐标 for (x, y) in zip(x_points, y_points): # 更新我们的矩形列表 boxes.append((x, y, x + W, y + H)) # 对矩形应用非极大值抑制 # 这将创建一个单一的边界框 boxes = non_max_suppression(np.array(boxes)) # 遍历最终的边界框 for (x1, y1, x2, y2) in boxes: # 在图像上绘制边界框 cv2.rectangle(img, (x1, y1), (x2, y2), (255, 0, 0), 3) cv2.imwrite('result.png', img) ``` 大图像是: ![大图像](https://isstatic.askoverflow.dev/gwPwZxeI.png) 要检测的目标片段是: ![目标片段](https://isstatic.askoverflow.dev/0MIQWSCY.png) 但是检测到了两个区域,而不是一个。其中一个区域根本不包含目标片段: ![错误检测区域](https://isstatic.askoverflow.dev/JpOJ8FM2.png) 我漏了什么吗?
python
  • 1 个回答
  • 31 Views
Martin Hope
Jelly
Asked: 2024-05-05 00:53:00 +0800 CST

PostgreSQL 窗口函数计算每个区间的总和

  • 6

该表由以下脚本表示:

CREATE TABLE sales (
  id SERIAL PRIMARY KEY,
  product_id INTEGER,
  sales_date DATE,
  quantity INTEGER,
  price NUMERIC
);

INSERT INTO sales (product_id, sales_date, quantity, price) VALUES
   (1, '2023-01-01', 10, 10.00),
   (1, '2023-01-02', 12, 12.00),
   (1, '2023-01-03', 15, 15.00),
   (2, '2023-01-01', 8, 8.00),
   (2, '2023-01-02', 10, 10.00),
   (2, '2023-01-03', 12, 12.00);

任务是计算每个 Product_id 最近 3 天的销售数量。该期间必须从每个product_id 的最大(最后)日期开始向后计算。因此,对于 1 来说,最大值是 2023-01-03,对于 2 来说也是如此。但是对于 Product_id 2,最后一天可能与 1 不同 - 比如说 2023-01-05。

通过在子查询中使用窗口函数应用此查询:

select product_id, max(increasing_sum) as quantity_last_3_days
   from 
        (SELECT product_id,
         SUM(quantity) OVER (PARTITION BY product_id ORDER BY sales_date RANGE BETWEEN INTERVAL '2 days'
                PRECEDING AND CURRENT ROW) AS increasing_sum
         FROM sales) as s
   group by product_id;

我收到预期的输出:

  | product_id | quantity_last_3_days |
  |____________|______________________|            
  |_____1______|___________37_________|
  |_____2______|___________30_________|     
 

但这是最优解吗?有没有办法通过使用不带子查询的窗口函数来解决这个问题?

sql
  • 2 个回答
  • 50 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    重新格式化数字,在固定位置插入分隔符

    • 6 个回答
  • Marko Smith

    为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会?

    • 2 个回答
  • Marko Smith

    VScode 自动卸载扩展的问题(Material 主题)

    • 2 个回答
  • Marko Smith

    Vue 3:创建时出错“预期标识符但发现‘导入’”[重复]

    • 1 个回答
  • Marko Smith

    具有指定基础类型但没有枚举器的“枚举类”的用途是什么?

    • 1 个回答
  • Marko Smith

    如何修复未手动导入的模块的 MODULE_NOT_FOUND 错误?

    • 6 个回答
  • Marko Smith

    `(表达式,左值) = 右值` 在 C 或 C++ 中是有效的赋值吗?为什么有些编译器会接受/拒绝它?

    • 3 个回答
  • Marko Smith

    在 C++ 中,一个不执行任何操作的空程序需要 204KB 的堆,但在 C 中则不需要

    • 1 个回答
  • Marko Smith

    PowerBI 目前与 BigQuery 不兼容:Simba 驱动程序与 Windows 更新有关

    • 2 个回答
  • Marko Smith

    AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String”

    • 1 个回答
  • Martin Hope
    Fantastic Mr Fox msvc std::vector 实现中仅不接受可复制类型 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant 使用 chrono 查找下一个工作日 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor 构造函数的成员初始化程序可以包含另一个成员的初始化吗? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský 为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul C++20 是否进行了更改,允许从已知绑定数组“type(&)[N]”转换为未知绑定数组“type(&)[]”? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann 为什么 {2,3,10} 和 {x,3,10} (x=2) 的顺序不同? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller 在 5.2 版中,bash 条件语句中的 [[ .. ]] 中的分号现在是可选的吗? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench 为什么双破折号 (--) 会导致此 MariaDB 子句评估为 true? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng 为什么 `dict(id=1, **{'id': 2})` 有时会引发 `KeyError: 'id'` 而不是 TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String” 2024-03-20 03:12:31 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve