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-22872363

Mark Avreliy's questions

Martin Hope
Mark Avreliy
Asked: 2025-04-08 17:20:40 +0800 CST

使用 Jolt 在斜线后拆分值并构建 JSON

  • 6

我有一个 JSON:

[
  {
    "datetime": "2025-04-07T18:03:50+03:00",
    "title": "Theme Drive",
    "content": {
      "adPlacement": {
        "id": 4289485,
        "name": "otclick_OLV_apart_jan_mar_In_stream",
        "banners": {
          "href": [
            "https://api.adriver.ru/banners/12037384",
            "https://api.adriver.ru/banners/12043208",
            "https://api.adriver.ru/banners/11887226",
            "https://api.adriver.ru/banners/12028437"
          ]
        }
      }
    }
  }
]

我想构建下面的 json:将数组中的元素分成具有属性的对象banner_id,然后将数字存储为值banners/

我期望这个输出:

[
  {
    "banner_id": 12037384
  },
  {
    "banner_id": 12043208
  },
  {
    "banner_id": 11887226
  },
  {
    "banner_id": 12028437
  }
]

我写:

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "content": {
          "adPlacement": {
            "banners": {
              "href": {
                "*": "[&]"
              }
            }
          }
        }
      }
    }
  }
]

我刚刚得到了一个数组(与预期不符),而且我在处理 Banner_id 时遇到了麻烦。对于拆分,我尝试了类似这样的方法:"banner_id": "=split('banners/', @(1,&))",但它抛出了错误。如何达到预期的输出?

更新

第二种情况,里面有一个对象href:

[
   {
      "datetime":"2025-04-07T18:03:50+03:00",
      "title":"Theme Drive",
      "content":{
         "adPlacement":{
            "id":4289485,
            "name":"otclick_OLV_apart_jan_mar_In_stream",
            "banners":{
               "href":"https://api.adriver.ru/banners/12037384"
            }
         }
      }
   }
]

预期的:

[
  {
    "banner_id": 12037384
  }
]

我的结果:

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "content": {
          "adPlacement": {
            "banners": {
              "href": {
                "*": {
                  "*banners/*": {
                    "$(0,2)": "[&2].banner_id"
                  }
                },
                "*banners/*": {
                  "$(0,2)": "[0].banner_id"
                }
              }
            }
          }
        }
      }
    }
  },
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "*": {
        "banner_id": "=toInteger"
      }
    }
  }
]
json
  • 3 个回答
  • 64 Views
Martin Hope
Mark Avreliy
Asked: 2024-12-10 17:29:14 +0800 CST

Jolt 解除数组嵌套

  • 6

源 JSON:

[
  {
    "dimensions": [
      {
        "id": "1546382552",
        "name": "BLOOM FACE MASK DAY SPA AM APOTHEKA"
      },
      {
        "id": "2024-12-01",
        "name": ""
      }
    ],
    "metrics": [
      364,
      20
    ]
  },
  {
    "dimensions": [
      {
        "id": "857640546",
        "name": "Vitamin A"
      },
      {
        "id": "2024-12-02",
        "name": ""
      }
    ],
    "metrics": [
      310,
      22
    ]
  }
]

来自维度数组:

  1. id从第一个对象开始应该写为字段sku,并name写为sku_name
  2. id来自第二个对象应该写为字段date“

来自指标数组:

  • 数组中第一个元素应写为session_view,第二个元素应写为session_view_search

我尝试过(但失败了):

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "dimensions": {
          "*": {
            "0": {
              "id": "[&2].sku",
              "name": "[&2].sku_name"
            },
            "1": {
              "id": "[&2].date"
            }
          }
        },
        "metrics": {
          "0": "session_view",
          "1": "session_view_search"
        }
      }
    }
  }
]

最后我期望:

[
  {
    "sku": 1546382552,
    "sku_name": "BLOOM FACE MASK DAY SPA AM APOTHEKA",
    "date": "2024-12-01",
    "session_view": 364,
    "session_view_search": 20
  },
  {
    "sku": 857640546,
    "sku_name": "Vitamin A",
    "date": "2024-12-02",
    "session_view": 310,
    "session_view_search": 22
  }
]
json
  • 1 个回答
  • 19 Views
Martin Hope
Mark Avreliy
Asked: 2024-10-03 17:58:01 +0800 CST

发现 org.hibernate.InstantiationException:无法实例化抽象类或接口,但在恢复所有更改后仍然发生

  • 6

我有一个抽象类:

@Entity
@Table(name = "cas_base_accounts", schema = "connectors_account_service")
@Inheritance(strategy = InheritanceType.JOINED)
@Data
@SuperBuilder
@NoArgsConstructor
public abstract class BaseAccount {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(unique = true)
    private Integer id;
//some fields here

还有两个子类:

@Entity
@Table(name = "cas_simple_auth_accounts", schema = "connectors_account_service")
@Inheritance(strategy = InheritanceType.JOINED)
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@SuperBuilder
public class SimpleAuthAccount extends BaseAccount {


    @Id
    @GeneratedValue
    private Integer id;

    @NotNull
    @JsonIgnore
    private String clientId;

    @NotNull
    @JsonIgnore
    private String clientSecret;
//some other fields

和:

@Entity
@Table(name = "cas_oauth_accounts", schema = "connectors_account_service")
@Inheritance(strategy = InheritanceType.JOINED)
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@SuperBuilder
public class OAuthAccount extends BaseAccount {

    @Id
    @GeneratedValue
    private Integer id;

    @JsonIgnore
    private String state;

    @JsonIgnore
    private LocalDateTime stateExpirationTime;

    @Transient
    private String tokenLink;
//some fields

当我运行简单的 GET 请求时http://localhost:8889/accountservice/accountIds?cabinetId=12收到错误:

threw exception [Request processing failed; nested exception is org.springframework.orm.jpa.JpaSystemException: Cannot instantiate abstract class or interface:  : 
test.connectorsaccountservice.accountservice.model.BaseAccount; nested exception is org.hibernate.InstantiationException: Cannot instantiate abstract class or interface:  : test.connectorsaccountservice.accountservice.model.BaseAccount] 

cabinetId = 12 的实体始终是 SimpleAuthAccount。例如,当我运行 cabinetId = 10 时,它返回正确的结果。在这种情况下,id != 12(和 21)的实体是 OauthAccount。

说明这个方法出错了:

    public Mono<List<Integer>> getAccountIds(Integer cabinetId) {
        return findServiceByCabinetId(cabinetId)
                .then(Mono.fromCallable(() -> baseAccountRepository.findByCabinetId(cabinetId)))
                .flatMapIterable(e -> e)
                .filter(oAuthAccount -> !oAuthAccount.getIsDeleted()
                        && UserStatus.ENABLED.equals(oAuthAccount.getUserStatus()))
                .map(BaseAccount::getId)
                .collectList();
    }

在这一行:

.then(Mono.fromCallable(() -> baseAccountRepository.findByCabinetId(cabinetId)))

存储库:

public interface BaseAccountRepository extends JpaRepository<BaseAccount, Integer> {

    Optional<BaseAccount> findByIdAndCabinetId(Integer accountId, Integer cabinetId);

    Optional<BaseAccount> findByCabinetIdAndAccountLogin(Integer cabinetId, String accountLogin);

    List<BaseAccount> findByCabinetId(Integer cabinetId);

简单身份验证帐户存储库:

@Repository
public interface SimpleAuthAccountRepository extends
        JpaRepository<SimpleAuthAccount, Integer>,
        CustomAccountRepository<SimpleAuthAccount, Integer> {

    @Query("SELECT a FROM SimpleAuthAccount a " +
           "JOIN BaseCabinet c ON a.cabinetId = c.id " +
           "WHERE " +
           "(:realmId IS NULL OR a.realmId = :realmId) AND " +
           "(:accountLogin IS NULL OR a.accountLogin = :accountLogin) AND " +
           "(:accountId IS NULL OR a.id = :accountId) AND " +
           "(:cabinetId IS NULL OR a.cabinetId = :cabinetId) AND " +
           "(:isDeleted IS NULL OR a.isDeleted = :isDeleted) AND " +
           "((:advertiserIds) IS NULL OR a.advertiserId IN (:advertiserIds)) " +
           "ORDER BY c.description, a.accountLogin")
    List<SimpleAuthAccount> findAccounts(
            @Param("realmId") Integer realmId,
            @Param("accountLogin") String accountLogin,
            @Param("accountId") Integer accountId,
            @Param("cabinetId") Integer cabinetId,
            @Param("isDeleted") Boolean isDeleted,
            @Param("advertiserIds") Set<Integer> advertiserIds
    );

}

顺便说一句,之前好像可以,但我做了一些更改。发生此错误后,我恢复了所有更改,但错误仍然发生。在这些更改中,我没有触及本文中的任何类,只触及了其他类。

如何修复它?为什么会发生这种情况,为什么在恢复更改后仍然会发生这种情况?我想添加@DiscriminatorColumn和@DiscriminatorValue会有所帮助?对我来说,现有的列cabinetId就很好了@DiscriminatorColumn,但如果我有一个 SimpleAuthAccount 的 id 数组和 OAuthAccount 的 id 数组,我该如何为其设置值?我真的不想在这个表中添加另一列。但当然,如果这里没有更多的解决方案,我可以添加像auth_type和设置SIMPLE_AUTH这些OAUTH类的列。

java
  • 1 个回答
  • 15 Views
Martin Hope
Mark Avreliy
Asked: 2024-09-04 17:33:44 +0800 CST

在 JOLT 中将数字键存储为具有新键名的值

  • 5

源 JSON:

{
  "data": {
    "campaign": {
      "104": {
        "day": {
          "2024-07-01": {
            "metrics": {
              "reach_impression": "6.0000000",
              "unique_impression": 6,
              "impression": 9
            }
          },
          "2024-07-03": {
            "metrics": {
              "reach_impression": "19.0000000",
              "unique_click": 1,
              "reach_click": "2.0000000"
            }
          }
        }
      },
      "106": {
        "day": {
          "2024-07-01": {
            "metrics": {
              "unique_click": 29,
              "reach_click": "29.0000000",
              "click": 35
            }
          }
        }
      },
      "124": {
        "day": {
          "2024-07-01": {
            "metrics": {
              "unique_impression": 472,
              "event": 1,
              "unique_click": 25,
              "click": 49,
              "progress_100": 1,
              "impression": 690
            }
          },
          "2024-07-03": {
            "metrics": {
              "unique_click": 14,
              "reach_click": "52.0000000",
              "click": 33,
              "unique_impression": 28,
              "impression": 32
            }
          }
        }
      }
    },
    "metrics": {
      "click_average": 22107.6666666667
    }
  },
  "metadata": {
    "campaign": {
      "104": {
        "channel_id": 1,
        "real_end_date": null,
        "channel_label": "Display",
        "real_start_date": "2024-01-11 21:32:25",
        "label": "5ka_Promo_veer_2024"
      },
      "124": {
        "channel_id": 1,
        "real_end_date": null,
        "channel_label": "Display",
        "real_start_date": "2024-06-04 21:34:23",
        "label": " X5Club_Evergreen_June24"
      }
    }
  }
}

下面data.campaign有一些数字,如 124、104、106。这些数字是活动的 ID。我需要将这些值存储在字段中id,然后我们有字段day,并且在这个字段中2024-07-01,我想将这些值存储为report_date字段。在这个级别下,我们有metrics对象。在这个对象中,我想获取所有键值对。

对我来说主要的问题是如何以正确的方式将数字存储为键。

预期 JSON:

[
  {
    "id": 124,
    "report_date": "2024-07-01",
    "unique_impression": 472,
    "event": 1,
    "unique_click": 25,
    "click": 49,
    "progress_100": 1,
    "impression": 690
  },
  {
    "id": 124,
    "report_date": "2024-07-03",
    "unique_click": 14,
    "reach_click": "52.0000000",
    "click": 33,
    "unique_impression": 28,
    "impression": 32
  },
  {
    "id": 104,
    "report_date": "2024-07-01",
    "reach_impression": "6.0000000",
    "unique_impression": 6,
    "impression": 9
  },
  {
    "id": 104,
    "report_date": "2024-07-03",
    "reach_impression": "19.0000000",
    "unique_click": 1,
    "reach_click": "2.0000000"
  },
  {
    "id": 106,
    "report_date": "2024-07-01",
    "unique_click": 29,
    "reach_click": "29.0000000",
    "click": 35
  }
]
json
  • 1 个回答
  • 18 Views
Martin Hope
Mark Avreliy
Asked: 2024-08-02 17:57:24 +0800 CST

从字符串列中过滤非日期模式值

  • 5

我有一张包含一些列的表。不幸的是,它不是以最佳方式设计的,写入此表的 REST API 也设计得不好,但我需要一些快速的解决方案。在列dimension_id(text数据类型)中,我有以下值:90% 的行包含date类似2024-01-01,但其他行包含类似9391或 的字符串78417。我现在不想删除这些行(大量数据,大项目,理解和重写需要很长时间,也许它是一个有效值但需要其他列),但我需要过滤它们,因为当您尝试转换和过滤此列时,在此表上创建的视图会下降。

所以我需要抓住所有dimension_id包含date模式的行。

我尝试过

select * from table
where TO_DATE(dimension_id, 'YYYY-MM-DD') IS NOT NULL

但这没用。该怎么办?

postgresql
  • 1 个回答
  • 19 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