Skip to content

Commit

Permalink
CASL-561 minor cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Amanowicz <[email protected]>
  • Loading branch information
Amaneusz committed Oct 18, 2024
1 parent 575e106 commit 0e50edd
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 33 deletions.
16 changes: 13 additions & 3 deletions here-naksha-lib-model/src/commonMain/kotlin/naksha/model/TagMap.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,22 @@
package naksha.model

import naksha.base.MapProxy
import naksha.model.objects.NakshaFeature
import kotlin.js.JsExport
import kotlin.js.JsName

// TODO: Document me!
// Improve me!

/**
* Map of tags persisted as (key, value) pairs where values are nullable.
* This class represents the persisted form of [TagList] / [Tag].
* It is stored as byte_array and can be accessed in PG via `naksha_tags` function.
*
* It is advised to only construct it in one of two ways:
* 1) Via [TagList]-based constructor
* 2) By deserializing byte array fetched from DB
*
* If for some reason, one would like to use it otherwise, it is advised to properly prepare tags upfront
* with use of [TagNormalizer] (that is used for example by [TagList])
*/
@JsExport
open class TagMap() : MapProxy<String, Any>(String::class, Any::class) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,10 @@ class WhereClauseBuilder(private val request: ReadFeatures) {
tagValue(tagQuery, PgType.STRING),
valuePlaceholder
)
where.append(stringEquals) // naksha_tags(tags, flags)::jsonb->>foo = $1
where.append(stringEquals)
}

is TagValueMatches -> {
/*
SELECT *
FROM read_by_tags_test
WHERE naksha_tags(tags, flags) @? '$.year ? (@ like_regex "^202\\d$")'
*/
// val regex = Regex.escape(tagQuery.regex)
val regex = tagQuery.regex
where.append("$tagsAsJsonb @?? '\$.${tagQuery.name} ? (@ like_regex \"${regex}\")'")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ class PsqlPlan(internal val query: PsqlQuery, conn: Connection) : PgPlan {
stmt.execute()
return PsqlCursor(stmt, false)
}
/**
* TODO: remove
*
* SELECT gzip(bytea_agg(tuple_number)) AS rs FROM (SELECT tuple_number FROM (
* (SELECT tuple_number, id FROM read_by_tags_test WHERE (naksha_tags(tags, flags)::jsonb->>foo = '''bar'''))
* ) ORDER BY id, tuple_number) LIMIT 1000000
*/

/**
* Adds the prepared statement with the given arguments into batch-execution queue. This requires a mutation query like UPDATE or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@

import static com.here.naksha.storage.http.RequestSender.KeyProperties;

import naksha.model.NakshaContext;
import com.here.naksha.lib.core.lambdas.Fe1;
import com.here.naksha.lib.core.models.naksha.Storage;
import naksha.model.IReadSession;
import naksha.model.IStorage;
import com.here.naksha.lib.core.util.json.JsonSerializable;
import com.here.naksha.storage.http.cache.RequestSenderCache;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import naksha.model.IReadSession;
import naksha.model.IStorage;
import naksha.model.NakshaContext;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Map;
import naksha.geo.XyzProperties;
import naksha.model.NakshaVersion;
import naksha.geo.XyzProperties;
import java.util.Map;
import org.jetbrains.annotations.ApiStatus.AvailableSince;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
import static com.here.naksha.storage.http.PrepareResult.prepareResult;
import static java.lang.String.format;

import naksha.model.NakshaContext;
import com.here.naksha.lib.core.models.XyzError;
import naksha.model.XyzFeature;
import naksha.model.XyzFeatureCollection;
import naksha.model.ErrorResult;
import naksha.model.POp;
import com.here.naksha.lib.core.models.storage.ReadFeaturesProxyWrapper;
import com.here.naksha.lib.core.models.storage.Result;
import java.net.HttpURLConnection;
Expand All @@ -32,11 +37,6 @@
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import naksha.model.ErrorResult;
import naksha.model.NakshaContext;
import naksha.model.POp;
import naksha.model.XyzFeature;
import naksha.model.XyzFeatureCollection;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
*/
package com.here.naksha.storage.http;

import naksha.model.NakshaContext;
import com.here.naksha.lib.core.models.XyzError;
import com.here.naksha.lib.core.models.storage.*;
import java.util.concurrent.TimeUnit;
import naksha.model.ErrorResult;
import naksha.model.IReadSession;
import naksha.model.NakshaContext;
import java.util.concurrent.TimeUnit;

import naksha.model.ReadRequest;
import naksha.model.ErrorResult;
import org.apache.commons.lang3.NotImplementedException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
import static com.here.naksha.lib.core.exceptions.UncheckedException.unchecked;
import static naksha.model.POpType.*;

import naksha.model.POp;
import naksha.model.POpType;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import naksha.model.POp;
import naksha.model.POpType;
import org.apache.commons.lang3.ArrayUtils;
import org.jetbrains.annotations.NotNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import com.here.naksha.lib.core.models.Typed;
import com.here.naksha.lib.core.models.XyzError;
import naksha.model.XyzFeature;
import com.here.naksha.lib.core.models.storage.*;
import com.here.naksha.lib.core.util.json.JsonSerializable;
import java.io.ByteArrayInputStream;
Expand All @@ -34,8 +35,8 @@
import java.util.List;
import java.util.function.Function;
import java.util.zip.GZIPInputStream;

import naksha.model.ErrorResult;
import naksha.model.XyzFeature;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down

0 comments on commit 0e50edd

Please sign in to comment.