小编Ale*_*lex的帖子

RavenDB跟踪更改绕过验证

我正在试图获得使用RavenDB的应用程序框架.我已经设置了一个业务逻辑服务,它与会话具有1对1的关系,并且有效地成为工作抽象的单元.

部分业务逻辑服务将包含所有验证.服务的方法可能是这样的

    public void StoreUser(User user)
    {
        //Some validation logic
        if(string.IsNullOrWhiteSpace(user.Name))
            throw new Exception("User name can not be empty");

        Session.Store(user);
    }
Run Code Online (Sandbox Code Playgroud)

问题在于,因为用户一旦被存储就会被跟踪,我可以绕过存储方法的任何验证但是存储正确的值然后稍后更改它

    public void TestUserStore()
    {
        var u1 = new User() {Name = "John"};
        var u2 = new User() { Name = "Amy" };

        Service.StoreUser(u1);
        u1.Name = null; //change is tracked and will persist on the next save changes
        Service.StoreUser(u2);
        Service.SaveChanges();

        //The following fails, as we have stored null as the name rather than "John" bypassing our validation
        Assert.IsTrue(Service.AdhocQuery<User>().Any(u => …
Run Code Online (Sandbox Code Playgroud)

ravendb

13
推荐指数
1
解决办法
442
查看次数

不同资源组中自定义主题的 Azure 事件网格订阅

我正在尝试订阅存在于不同资源组上的自定义事件网格主题。例如,如果我my-custom-topic在资源组中有一个自定义事件网格主题publisher-group。如何从资源组中创建对我的主题的事件网格订阅subscriber-group

仅当以下 ARM 模板my-custom-topic与我应用该模板位于同一资源组中时才有效

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "eventGridSubscriptionName": {
            "type": "String",
            "metadata": {
                "description": "The name of the Event Grid custom topic's subscription."
            }
        },
        "location": {
            "defaultValue": "[resourceGroup().location]",
            "type": "String",
            "metadata": {
                "description": "The location in which the Event Grid resources should be deployed."
            }
        }
    },
    "resources": [
        {
            "type": "Microsoft.EventGrid/topics/providers/eventSubscriptions",
            "apiVersion": "2018-01-01",
            "name": "[concat('my-custom-topic', '/Microsoft.EventGrid/', parameters('eventGridSubscriptionName'))]",
            "location": "[parameters('location')]",
            "properties": {
                "destination": {
                    "endpointType": "EventHub",
                    "properties": …
Run Code Online (Sandbox Code Playgroud)

azure-eventgrid

5
推荐指数
1
解决办法
1201
查看次数

为什么创建测试增量表很慢?

我试图通过创建具有已知值的微小输入增量表来为我们的 Spark 逻辑编写一些测试用例。但是我注意到创建单个项目增量表需要很长时间,每个表大约需要 6 秒。这很快就会增加,一些使用多个表的测试用例需要几分钟才能运行!

我承认 Spark 测试也会很慢,但类似的 Parquet 测试的创建速度约为 400 毫秒,这是可以忍受的

我在 Windows 上的这些测试中运行这些,这可能会导致我的问题,但其他格式似乎运行良好,并且速度要快几个数量级

我用来生成计时的测试用例是

  "delta" should "create in a reasonable time" in {

    val spark: SparkSession = SparkSession.builder
      .master("local[1]")
      .getOrCreate()

    import spark.implicits._

    // This takes ~15seconds but most of that can be attributed to spark warming up
    val preloadStart = System.currentTimeMillis()
    Seq(("test-1", "my-test"))
      .toDF("Id", "Source")
      .write
      .format("delta")
      .save(s"c:/tmp/test-${java.util.UUID.randomUUID()}")
    val preloadEnd = System.currentTimeMillis()
    println("Preload Elapsed time: " + (preloadEnd - preloadStart) + "ms")

    //actual test, why does this take …
Run Code Online (Sandbox Code Playgroud)

delta-lake

2
推荐指数
1
解决办法
2025
查看次数

标签 统计

azure-eventgrid ×1

delta-lake ×1

ravendb ×1