-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Hand wrapped KafkaTools, ParquetTools
- Loading branch information
1 parent
701e8e3
commit 003f272
Showing
21 changed files
with
1,414 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
pyintegration/deephaven2/_utils/start_jvm.py → pyintegration/deephaven2/_init/start_jvm.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# | ||
# Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending | ||
# | ||
""" This module provides Java compatibility support including convenience functions to create some widely used Java | ||
data structures from corresponding Python ones in order to be able to call Java methods. """ | ||
from typing import Any, Iterable, Dict, Set | ||
|
||
import jpy | ||
|
||
|
||
def is_java_type(obj: Any) -> bool: | ||
""" Returns True if the object is originated in Java. """ | ||
return isinstance(obj, jpy.JType) | ||
|
||
|
||
def j_array_list(values: Iterable = None) -> jpy.JType: | ||
""" Creates a Java ArrayList instance from an iterable. """ | ||
if values is None: | ||
return None | ||
r = jpy.get_type("java.util.ArrayList")(len(list(values))) | ||
for v in values: | ||
r.add(v) | ||
return r | ||
|
||
|
||
def j_hashmap(d: Dict = None) -> jpy.JType: | ||
""" Creates a Java HashMap from a dict. """ | ||
if d is None: | ||
return None | ||
|
||
r = jpy.get_type("java.util.HashMap")() | ||
for key, value in d.items(): | ||
if value is None: | ||
value = '' | ||
r.put(key, value) | ||
return r | ||
|
||
|
||
def j_hashset(s: Set = None) -> jpy.JType: | ||
""" Creates a Java HashSet from a set. """ | ||
if s is None: | ||
return None | ||
|
||
r = jpy.get_type("java.util.HashSet")() | ||
for v in s: | ||
r.add(v) | ||
return r | ||
|
||
|
||
def j_properties(d: Dict = None) -> jpy.JType: | ||
""" Creates a Java Properties from a dict. """ | ||
if d is None: | ||
return None | ||
r = jpy.get_type("java.util.Properties")() | ||
for key, value in d.items(): | ||
if value is None: | ||
value = '' | ||
r.setProperty(key, value) | ||
return r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# | ||
# Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending | ||
# | ||
""" This module defines an Abstract Class for Java object wrappers. | ||
The primary purpose of this ABC is to enable downstream code to retrieve the wrapped Java objects in a uniform way. | ||
""" | ||
from abc import ABC, abstractmethod | ||
|
||
import jpy | ||
|
||
|
||
class JObjectWrapper(ABC): | ||
@property | ||
@abstractmethod | ||
def j_object(self) -> jpy.JType: | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# | ||
# Copyright (c) 2016-2021 Deephaven Data Labs and Patent Pending | ||
# | ||
""" This module provides access to the Deephaven server configuration. """ | ||
import jpy | ||
|
||
from deephaven2 import DHError | ||
from deephaven2.time import TimeZone | ||
|
||
_JDHConfig = jpy.get_type("io.deephaven.configuration.Configuration") | ||
_JDateTimeZone = jpy.get_type("org.joda.time.DateTimeZone") | ||
|
||
|
||
def get_log_dir() -> str: | ||
""" Returns the server's log directory. """ | ||
try: | ||
return _JDHConfig.getInstance().getLogDir() | ||
except Exception as e: | ||
raise DHError(e, "failed to get the server's log directory.") from e | ||
|
||
|
||
def get_server_timezone() -> TimeZone: | ||
""" Returns the server's time zone. """ | ||
try: | ||
j_timezone = _JDateTimeZone.forTimeZone(_JDHConfig.getInstance().getServerTimezone()) | ||
for tz in TimeZone: | ||
if j_timezone == tz.value.getTimeZone(): | ||
return tz | ||
raise NotImplementedError("can't find the time zone in the TImeZone Enum.") | ||
except Exception as e: | ||
raise DHError(e, message=f"failed to find a recognized time zone") from e |
Oops, something went wrong.