コード例 #1
0
 def setUp(self) -> None:
     with ugp_exclusive_lock():
         self.test_table = time_table("00:00:00.001").update(
             ["X=i%11"]).sort("X").tail(16)
         source_table = time_table("00:00:00.001").update(
             ["TS=currentTime()"])
         self.test_table2 = time_window(source_table,
                                        ts_col="TS",
                                        window=10**7,
                                        bool_col="InWindow")
コード例 #2
0
    def test_time_window(self):
        with ugp_exclusive_lock():
            source_table = time_table("00:00:00.01").update(
                ["TS=currentTime()"])
            t = time_window(source_table,
                            ts_col="TS",
                            window=10**8,
                            bool_col="InWindow")

        self.assertEqual("InWindow", t.columns[-1].name)
        self.wait_ticking_table_update(t, row_count=20, timeout=60)
        self.assertIn("true", t.to_string(1000))
        self.assertIn("false", t.to_string(1000))
コード例 #3
0
ファイル: testbase.py プロジェクト: chipkent/deephaven-core
    def wait_ticking_table_update(self, table: Table, row_count: int,
                                  timeout: int):
        """Waits for a ticking table to grow to the specified size or times out.

        Args:
            table (Table): the ticking table
            row_count (int): the target row count of the table
            timeout (int): the number of seconds to wait
        """
        with ugp_exclusive_lock():
            timeout *= 10**9
            while table.size < row_count and timeout > 0:
                s_time = time.time_ns()
                table.j_table.awaitUpdate(timeout // 10**6)
                timeout -= time.time_ns() - s_time

            self.assertGreaterEqual(table.size, row_count)
コード例 #4
0
def _do_locked(f: Callable, lock_type="shared") -> None:
    """Executes a function while holding the UpdateGraphProcessor (UGP) lock.  Holding the UGP lock
    ensures that the contents of a table will not change during a computation, but holding
    the lock also prevents table updates from happening.  The lock should be held for as little
    time as possible.

    Args:
        f (Callable): callable to execute while holding the UGP lock, could be function or an object with an 'apply'
            attribute which is callable
        lock_type (str): UGP lock type, valid values are "exclusive" and "shared".  "exclusive" allows only a single
            reader or writer to hold the lock.  "shared" allows multiple readers or a single writer to hold the lock.
    Raises:
        ValueError
    """
    if lock_type == "exclusive":
        with ugp_exclusive_lock():
            f()
    elif lock_type == "shared":
        with ugp_shared_lock():
            f()
    else:
        raise ValueError(f"Unsupported lock type: lock_type={lock_type}")
コード例 #5
0
def create_table():
    with ugp_exclusive_lock():
        return time_table("00:00:00.001").update(["X=i%11"]).sort("X").tail(16)