Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
qb.set_cql_constraint(cql_query)
if index:
qb.set_index(index)
if auths:
qb.set_auth(auths)
if limit:
qb.set_limit(limit)
if type_names:
qb.set_type_names(type_names)
if which_fields:
qb.set_fields(which_fields)
return cls(qb.build())
class QueryBuilder(PyGwJavaWrapper):
"""
[INTERNAL]
Necessary for a query:
- Constraints (default: Everything)
- Index: either all or single (default: All)
- Authorizations: string array (default: empty string array)
- Limits (default: null)
- Fields: all fields or a subset (only 1 type-name if subset; default all)
- Type names: all or a subset (default: all)
"""
def __init__(self):
j_qbuilder = config.MODULE__core_store.QueryBuilder.newBuilder()
super().__init__(config.GATEWAY, j_qbuilder)
def set_type_names(self, type_names=None):
if type_names:
def __init__(self, type_, is_nilable, descriptor):
self.type_= type_
self.is_nilable = is_nilable
self.descriptor = descriptor
j_builder = config.MODULE__feature.AttributeTypeBuilder()
if not isinstance(type_, SimpleFeatureTypeAttribute.Type):
raise SimpleFeatureTypeAttribute.UnknownTypeError("Invalid argument to `type_`. Must be one of defined types in FeatureTypeAttribute.Type")
j_type_cls = config.reflection_util.classForName(type_.value)
j_builder.binding(j_type_cls)
j_builder.nillable(is_nilable)
j_attribute = j_builder.buildDescriptor(descriptor)
super().__init__(config.GATEWAY, j_attribute)
def __init__(self, gw_namespace=None, dir="rocksdb", compact_on_write=True, batch_write_size=1000):
"""
Create a RocksDB datastore.
Args:
gw_namespace (string) : namespace
dir (str) : directory of datastore
compact_on_write (bool)
batch_write_size (int)
"""
if gw_namespace:
j_rock_opts = config.MODULE__rocksdb_config.RocksDBOptions(gw_namespace)
else:
j_rock_opts = config.MODULE__rocksdb_config.RocksDBOptions()
if dir != "rocksdb":
j_rock_opts.setDirectory(dir)
if not compact_on_write:
j_rock_opts.setCompactOnWrite(compact_on_write)
if batch_write_size != 1000:
j_rock_opts.setBatchWriteSize(batch_write_size)
j_ds = config.MODULE__core_store.DataStoreFactory.createDataStore(j_rock_opts)
super().__init__(config.GATEWAY, j_ds)
def __init__(self, extended_id, type):
if type == "bbox":
builder = config.MODULE__geotime_query.VectorStatisticsQueryBuilder.newBuilder().factory().bbox()
elif type == "time_range":
builder = config.MODULE__geotime_query.VectorStatisticsQueryBuilder.newBuilder().factory().timeRange()
else:
raise AttributeError("Invalid query type")
builder.fieldName(extended_id)
java_ref = builder.build()
super().__init__(config.GATEWAY, java_ref)
def __init__(self, extended_id, type):
if type == "bbox":
builder = config.MODULE__geotime_query.VectorStatisticsQueryBuilder.newBuilder().factory().bbox()
elif type == "time_range":
builder = config.MODULE__geotime_query.VectorStatisticsQueryBuilder.newBuilder().factory().timeRange()
else:
raise AttributeError("Invalid query type")
builder.fieldName(extended_id)
java_ref = builder.build()
super().__init__(config.GATEWAY, java_ref)
def __init__(self, type_, is_nilable, descriptor):
self.type_= type_
self.is_nilable = is_nilable
self.descriptor = descriptor
j_builder = config.MODULE__feature.AttributeTypeBuilder()
if not isinstance(type_, SimpleFeatureTypeAttribute.Type):
raise SimpleFeatureTypeAttribute.UnknownTypeError("Invalid argument to `type_`. Must be one of defined types in FeatureTypeAttribute.Type")
j_type_cls = config.reflection_util.classForName(type_.value)
j_builder.binding(j_type_cls)
j_builder.nillable(is_nilable)
j_attribute = j_builder.buildDescriptor(descriptor)
super().__init__(config.GATEWAY, j_attribute)
def __init__(self):
j_vector_qbuilder = config.MODULE__geotime_query.VectorQueryBuilder.newBuilder()
PyGwJavaWrapper.__init__(self, config.GATEWAY, j_vector_qbuilder)
Args:
address (str) : address of Redis DB
gw_namespace (str) : gw namespace
compression (str) : compression type to use. Must be one of 'snappy', 'lz4', or 'none'.
"""
if compression not in RedisDs.__compression_opts:
raise RuntimeError("`compression` must be one of {}".format(RedisDs.__compression_opts))
if gw_namespace:
j_redis_opts = config.MODULE__redis_config.RedisOptions(gw_namespace)
else:
j_redis_opts = config.MODULE__redis_config.RedisOptions()
j_redis_opts.setAddress(address)
j_compression = RedisDs.__compression_to_j_enum[compression]()
j_redis_opts.setCompression(j_compression)
j_ds = config.MODULE__core_store.DataStoreFactory.createDataStore(j_redis_opts)
super().__init__(config.GATEWAY, j_ds)
def __init__(self, zookeeper="example", hbase_namespace=None):
"""
Create an HBase data store
zookeeperh (string): zoopkeeper for hbase
hbase_namespace (str): namespace of hbase
"""
if hbase_namespace:
j_hbase_opts = config.MODULE__hbase_config.HBaseOptions(hbase_namespace)
else:
j_hbase_opts = config.MODULE__hbase_config.HBaseOptions()
j_hbase_opts.setZookeeper(zookeeper)
j_ds = config.MODULE__core_store.DataStoreFactory.createDataStore(j_hbase_opts)
super().__init__(config.GATEWAY, j_ds)
def _set_geometry(self, attr, value):
# TODO Need to give better error.
assert isinstance(value, tuple)
for v in value:
assert (isinstance(v, int) or isinstance(v, float))
vals = [float(v) for v in value]
if len(vals) == 2:
j_coord = config.MODULE__jts_geom.Coordinate(vals[0], vals[1])
elif len(vals) == 3:
j_coord = config.MODULE__jts_geom.Coordinate(vals[0], vals[1], vals[2])
else:
raise Exception("Unsupported number of args to Coordinate")
j_geom = config.MODULE__geotime_util.GeometryUtils.GEOMETRY_FACTORY.createPoint(j_coord)
self._java_ref.set(attr.descriptor, j_geom)