Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
75faec9
Fix numeric id queries using the new member query option.
xeus2001 Aug 25, 2026
10db243
Add some helper methods to convert AnyList into typed arrays.
xeus2001 Aug 27, 2026
92e9ce9
Add helper to try to proxy any type.
xeus2001 Aug 27, 2026
b52532a
Split featureNumber function for performance improvement at other pla…
xeus2001 Aug 27, 2026
accc50f
Fix that isInstance of members accept normal lists for TAG_MAP_FROM_A…
xeus2001 Aug 27, 2026
48e95f6
Add missing TAGLIST_CONTAINS, fix any type can be provided to detect …
xeus2001 Aug 27, 2026
20c82ad
Improve documentation of Tag queries, clarify that they operate on va…
xeus2001 Aug 27, 2026
730ad7a
Remove catching of exceptions, leaving this to the caller, needed for…
xeus2001 Aug 27, 2026
1ac0ea4
Fix convertValue to work with all values, rename childType to compone…
xeus2001 Aug 27, 2026
9d75b32
Log all errors with stack-trace for better debugging, the error respo…
xeus2001 Aug 27, 2026
a0e1a30
Use json_array_elements_text and add explicit cast, jsonb is slower h…
xeus2001 Aug 27, 2026
51e5bc9
Improve array handling, whenever possible use native array without co…
xeus2001 Aug 27, 2026
fa02d8f
Fix tag-map queries to use index and fix that queries on `id` work fo…
xeus2001 Aug 27, 2026
cb68c97
Add tests for tag-map.
xeus2001 Aug 28, 2026
08b5dc8
Add fixes for tag-map in PgRows.
xeus2001 Aug 28, 2026
57f0546
Improve documentation
xeus2001 Aug 31, 2026
2321a83
Move toArray helpers from AnyList into ListProxy so they are availabl…
xeus2001 Aug 31, 2026
1f5e1db
Rename dict to book, minor performance improvement to avoid data copy…
xeus2001 Aug 31, 2026
6d286e0
Improve static fromArray helper.
xeus2001 Aug 31, 2026
b61aa3d
Embed helpers only used by Tuple into Tuple to be improved further in…
xeus2001 Aug 31, 2026
df11395
Remove TAG_MAP_FROM_ARRAY
xeus2001 Aug 31, 2026
5ff1170
First part of replacing Int64 with Long
xeus2001 Aug 31, 2026
5baff82
Replace Int64 with Long
xeus2001 Aug 31, 2026
1085a0e
Improve PgRows to supports arrays and consistent resize, fix failing …
xeus2001 Aug 31, 2026
418f273
Fix that the name of an operation can be deducted from the instance t…
xeus2001 Aug 31, 2026
42d4d08
Fix brackets in query builder and where builder.
xeus2001 Aug 31, 2026
0bcf0f7
Fix activity log, do not mix old and new query style. Fix TagList tes…
xeus2001 Aug 31, 2026
615fb8f
Fix minor issue left from rebase and Int64 to Long switch.
xeus2001 Sep 1, 2026
09cfe1a
Added check that readFeatures.getFeatureIds() is empty
xeus2001 Sep 2, 2026
64d88d5
Fix addTag call in constructor to use skipNormalize.
xeus2001 Sep 3, 2026
423acf9
Modify coerceSpatial in Tuple to make the execution path clearer.
xeus2001 Sep 3, 2026
84ddbec
Fix that when an operation is a no-op, AND and OR to not linger.
xeus2001 Sep 3, 2026
ad03b52
Fix tests that faulty expect not normalized tag.
xeus2001 Sep 4, 2026
359be6f
Fix that only sourceID_ has special treatment.
xeus2001 Sep 4, 2026
f67ec7e
Fix bug in value iteration, added tests for sourceID_ and at tags.
xeus2001 Sep 4, 2026
c3f282e
Restore tests to original casing.
xeus2001 Sep 7, 2026
8c85ea3
Make tag normalization optional, defaulting to none, adding normalize…
xeus2001 Sep 7, 2026
8045988
Improve constructors of TagMap, update documentation.
xeus2001 Sep 7, 2026
9f6bace
Remove renamed skipNormalize parameter, is now normalize.
xeus2001 Sep 7, 2026
531171c
Improve normalizer, use last equals for split instead of first, added…
xeus2001 Sep 7, 2026
98663bf
Fix error message of joinTag, fix test to expect more error messages.
xeus2001 Sep 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import java.util.concurrent.atomic.AtomicBoolean;

import naksha.base.Int64;
import naksha.model.Naksha;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down Expand Up @@ -54,7 +53,7 @@ public NakshaTestWebClient getNakshaClient() {
public static String databaseId;

/** The number of the storage. */
public static Int64 databaseNumber;
public static long databaseNumber;

/** The identifier of the data catalog. */
public static String catalogId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public static FeatureMetadata from(NakshaFeature feature) {
return new FeatureMetadata(
feature.getId(),
xyzNamespace.getUuid(),
xyzNamespace.getCreatedAt().toLong(),
xyzNamespace.getUpdatedAt().toLong()
xyzNamespace.getCreatedAt(),
xyzNamespace.getUpdatedAt()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void testPatchOneFeatureByIdWrongUuid() throws Exception {
tupleNumber.catalogNumber,
tupleNumber.collectionNumber,
tupleNumber.featureNumber,
tupleNumber.version.minus(4) //older, invalid version, to simulate wrong uuid
tupleNumber.version - 4L //older, invalid version, to simulate wrong uuid
)).toString();
// NOTE: if the wrong uuid is different in databaseNumber, or catalogNumber, or collectionNumber, the response will be 400 (mapped from NakshaError.ILLEGAL_ARGUMENT, thrown by storage) instead of 409.
// But this requires manual modification of the uuid in the input JSON, which is not an expected behavior from the client, so we don't handle that currently.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ static void setup() throws URISyntaxException, IOException, InterruptedException
nakshaClient.post("hub/spaces/" + SPACE_ID + "/features", initialFeaturesJson, UUID.randomUUID().toString());
}


@Test
void tc2000_testCreateFeaturesWithSourceIdInMeta() throws Exception {
// Given:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package com.here.naksha.app.service.util;

import com.here.naksha.app.common.ApiTest;
import naksha.base.Int64;
import naksha.base.Action;
import naksha.model.Naksha;
import naksha.base.TupleNumber;
import naksha.base.Version;
import org.jetbrains.annotations.NotNull;

import static naksha.base.Platform.longToInt64;

public final class TupleInfo {
/**
* Create a new collection test info from the given collection identifier, using {@link ApiTest} static values for database and catalog.
Expand Down Expand Up @@ -43,7 +40,7 @@ public TupleInfo(@NotNull String databaseId, @NotNull String catalogId, @NotNull
public final @NotNull String databaseId;
public final @NotNull String catalogId;
public final @NotNull String collectionId;
public final @NotNull Int64 databaseNumber;
public final long databaseNumber;
Comment thread
xeus2001 marked this conversation as resolved.
Resolved
public final int catalogNumber;
public final int collectionNumber;

Expand All @@ -56,8 +53,8 @@ public TupleInfo(@NotNull String databaseId, @NotNull String catalogId, @NotNull
* @return the new unique virtual tuple-number.
*/
public @NotNull TupleNumber newTupleNumber(@NotNull String featureId, @NotNull Action action) {
final Version version = Version.now(longToInt64(seq++), action);
final Int64 featureNumber = Naksha.featureNumber(featureId);
final Version version = Version.now(seq++, action);
final long featureNumber = Naksha.featureNumber(featureId);
return new TupleNumber(databaseNumber, catalogNumber, collectionNumber, featureNumber, version.number);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import com.here.naksha.lib.core.models.geojson.WebMercatorTile;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
import naksha.base.Int64;
import naksha.base.Platform;
import naksha.base.TupleNumber;
import naksha.base.Version;
import naksha.geo.LineStringCoord;
Expand All @@ -25,12 +23,12 @@ final class GeneratingStorageService {
private final AtomicInteger tileIndex = new AtomicInteger(0);

@NotNull
FeatureTupleList generateDummyFeatureTuples(Int64 storageNumber, int numOfTuplesToGenerate) {
FeatureTupleList generateDummyFeatureTuples(long storageNumber, int numOfTuplesToGenerate) {
FeatureTupleList dummyFeatureTuples = new FeatureTupleList();
dummyFeatureTuples.setCapacity(numOfTuplesToGenerate);
for (int i = 0; i < numOfTuplesToGenerate; ++i) {
TupleNumber dummyTupleNumber = new TupleNumber(
storageNumber, 0, 0, Platform.intToInt64(0), Version.HEAD.number
storageNumber, 0, 0, 0L, Version.HEAD.number
);
FeatureTuple dummyFeatureTuple = new FeatureTuple(dummyTupleNumber, null);
dummyFeatureTuples.add(dummyFeatureTuple);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.here.naksha.cli.copy.service;

import naksha.base.Platform;
import naksha.model.ISession;
import naksha.model.IStorage;
import naksha.model.IWriteSession;
Expand Down Expand Up @@ -44,7 +43,7 @@ public static FeatureTupleList nakshaFeatureListToFeatureTupleList(List<NakshaFe
FeatureTupleList featureTuples = new FeatureTupleList();
featureTuples.setCapacity(nakshaFeatures.size());
TupleNumber dummyTupleNumber = new TupleNumber(
Platform.intToInt64(0), 0, 0, Platform.intToInt64(0), Version.HEAD.number
0L, 0, 0, 0L, Version.HEAD.number
);
for (NakshaFeature feature : nakshaFeatures) {
FeatureTuple featureTuple = new FeatureTuple(dummyTupleNumber, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private static String uuid(NakshaFeature feature) {
}

private static long updatedAt(NakshaFeature feature) {
return xyzNamespace(feature).getUpdatedAt().toLong();
return xyzNamespace(feature).getUpdatedAt();
}

private static XyzNs xyzNamespace(NakshaFeature feature) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ private static Original original(@Nullable XyzNs xyzNamespace, @Nullable String
Original original = new Original();
if (xyzNamespace != null) {
// original.setPuuid(xyzNamespace.getPuuid()); // TODO: restore this when CASL-1094 is fixed
original.setUpdatedAt(xyzNamespace.getUpdatedAt().toLong());
original.setCreatedAt(xyzNamespace.getCreatedAt().toLong());
original.setUpdatedAt(xyzNamespace.getUpdatedAt());
original.setCreatedAt(xyzNamespace.getCreatedAt());
}
if (spaceId != null) {
original.setSpace(spaceId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ private void collectMissingPredecessors(CollectedFeatures collectedFeatures, Nak
}

private ReadFeatures missingPredecessorFeatures(List<TupleNumber> tupleNumbers) {
// next_version is a plain int8 column, so we pass an Int64[] of the version values.
// next_version is a plain int8 column, so we pass Long version values.
final Or or = new Or();
final OpList orClauses = or.getChildren();
for (TupleNumber tupleNumber : tupleNumbers) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@
import naksha.base.Guid;
import naksha.base.TupleNumber;
import naksha.model.objects.StandardMembers;
import naksha.model.objects.XyzMembers;
import naksha.model.request.ReadFeatures;
import naksha.model.request.ops.And;
import naksha.model.request.ops.Equals;
import naksha.model.request.ops.OpList;
import naksha.model.request.ops.Or;
import naksha.model.request.ops.*;
import naksha.model.request.query.PQuery;
import naksha.model.request.query.Property;
import naksha.model.request.query.StringOp;
Expand Down Expand Up @@ -92,18 +90,30 @@ static void transformOriginalRequest(ReadFeatures readFeatures, String spaceId)
}
readFeatures.setQueryMembers(or);
}
StringList finalFeatureIds = new StringList();

// extractFeatureIds from activityLogId - populate featureIds
Set<PQuery> disabledActivityLogPOps = disablePQueriesInRequest(
readFeatures.getQuery(),
ActivityLogRequestTranslationUtil::isSingleActivityLogIdEqualityQuery
);

final StringList featureIds = new StringList();
if (!disabledActivityLogPOps.isEmpty()) {
disabledActivityLogPOps.forEach(activityLogOp -> finalFeatureIds.add(String.valueOf(activityLogOp.getValue())));
disabledActivityLogPOps.forEach(activityLogOp -> featureIds.add(String.valueOf(activityLogOp.getValue())));
readFeatures.refreshPropertyFilter();
}
readFeatures.setFeatureIds(finalFeatureIds);
// Translated from old syntax into new members query, because we do not allow to mix old and new syntax!
// TODO: Why do we need this?
if (!featureIds.isEmpty()) {
final IsAnyOf searchFeaturesByIdOp = new IsAnyOf(XyzMembers.XyzId);
for (var id : featureIds) searchFeaturesByIdOp.getItems().add(id);

final Op existing = readFeatures.getQueryMembers();
if (existing == null)
readFeatures.setQueryMembers(searchFeaturesByIdOp);
else
readFeatures.setQueryMembers(new And(existing, searchFeaturesByIdOp));
}
readFeatures.setFeatureIds(new StringList());
}

private static boolean isSingleActivityLogIdEqualityQuery(PQuery pQuery) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
import java.util.Map;
import java.util.stream.Stream;
import naksha.base.AnyList;
import naksha.base.Int64;
import naksha.base.JvmInt64;
import naksha.base.Timestamp;
import naksha.base.Action;
import naksha.base.Guid;
Expand Down Expand Up @@ -69,8 +67,8 @@
class ActivityLogHandlerTest {

private static final String SPACE_ID = "test_activity_space";
private static final JvmInt64 T0 = new JvmInt64(1749477141945L);
private static final JvmInt64 T1 = new JvmInt64(1749477141955L);
private static final long T0 = 1749477141945L;
private static final long T1 = 1749477141955L;

@Mock
INaksha naksha;
Expand Down Expand Up @@ -160,8 +158,8 @@ void shouldImmediatelySucceedOnWriteCollection() {
void shouldComposeActivityFeatures() throws Exception {
// Given: features uuid
String featureId = "featureId";
Guid initialUuid = guid(featureId, Version.now(new JvmInt64(1),Action.CREATE));
Guid newUuid = guid(featureId, Version.now(new JvmInt64(2),Action.UPDATE));
Guid initialUuid = guid(featureId, Version.now(1L, Action.CREATE));
Guid newUuid = guid(featureId, Version.now(2L, Action.UPDATE));

// And: old version of feature
NakshaFeature oldFeature = nakshaFeature(featureId)
Expand Down Expand Up @@ -232,7 +230,7 @@ void shouldComposeActivityFeatures() throws Exception {
void shouldNotCalculateReversePatchAfterCreation() throws Exception {
// Given
String featureId = "featureId";
Guid createdGuid = guid(featureId, Version.now(new JvmInt64(0), Action.CREATE));
Guid createdGuid = guid(featureId, Version.now(0L, Action.CREATE));

// And: space storage that returns only some feature with 'CREATE' action
configureSpaceStorage(
Expand Down Expand Up @@ -265,8 +263,8 @@ void shouldNotCalculateDiffAfterDeletion() throws Exception {
String featureId = "featureId";
Timestamp ts0 = Timestamp.fromMillis(T0);
Timestamp ts1 = Timestamp.fromMillis(T1);
Version createdVersion = Version.auto(ts0.getYear(), ts0.getMonth(), ts0.getDay(), new JvmInt64(0), Action.CREATE);
Version deletedVersion = Version.auto(ts1.getYear(), ts1.getMonth(), ts1.getDay(), new JvmInt64(1), Action.DELETE);
Version createdVersion = Version.auto(ts0.getYear(), ts0.getMonth(), ts0.getDay(), 0L, Action.CREATE);
Version deletedVersion = Version.auto(ts1.getYear(), ts1.getMonth(), ts1.getDay(), 1L, Action.DELETE);
Guid createdGuid = guid(featureId, createdVersion);
Guid deletedGuid = guid(featureId, deletedVersion);

Expand Down Expand Up @@ -467,7 +465,7 @@ private boolean containsNextVersionMetaQuery(ReadFeatures readFeatures, TupleNum
Op metaQuery = readFeatures.getQueryMembers();
if (metaQuery instanceof Or or) {
OpList orChildren = or.getChildren();
List<Int64> versions = new java.util.ArrayList<>();
List<Long> versions = new java.util.ArrayList<>();
if (orChildren.getSize() == 0) return false;
for (int i = 0; i < orChildren.getSize(); i++) {
Object child = orChildren.get(i);
Expand All @@ -492,7 +490,7 @@ private boolean containsNextVersionMetaQuery(ReadFeatures readFeatures, TupleNum
}

Object val = nextEq.getValue();
if (!(val instanceof Int64 v)) return false;
if (!(val instanceof Long v)) return false;
versions.add(v);
}

Expand All @@ -504,13 +502,13 @@ private boolean containsNextVersionMetaQuery(ReadFeatures readFeatures, TupleNum
}
if (!(metaQuery instanceof IsAnyOf op)) return false;
if (!StandardMembers.NextVersion.getName().equals(op.getAt())) return false;
// next_version is an int8 column — the IsAnyOf items hold the Int64 version values.
// next_version is an int8 column, so the IsAnyOf items hold Long version values.
AnyList items = op.getItems();
if (expectedTns.length == 0) return items.getSize() > 0;
List<Int64> versions = new java.util.ArrayList<>();
List<Long> versions = new java.util.ArrayList<>();
for (int i = 0; i < items.getSize(); i++) {
Object item = items.get(i);
if (item instanceof Int64 v) versions.add(v);
if (item instanceof Long v) versions.add(v);
else return false;
}
if (versions.size() != expectedTns.length) return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static com.here.naksha.handler.activitylog.GuidUtil.guid;
import static com.here.naksha.handler.activitylog.GuidUtil.randomVersion;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -21,6 +22,7 @@
import naksha.model.request.query.StringOp;
import org.junit.jupiter.api.Test;

@SuppressWarnings("deprecation")
class ActivityLogRequestTranslationUtilTest {

private static final String TEST_SPACE_ID = "test_space_id";
Expand All @@ -47,6 +49,26 @@ void shouldTranslateSingleGuidPassedAsFeatureId() {
checkOpIsUuidRequest(op, List.of(guid.tupleNumber.version));
}

private void checkOpIsIdRequest(Op op, List<String> ids) {
final IsAnyOf featureIdsOp = assertInstanceOf(IsAnyOf.class, op);
assertNotNull(featureIdsOp);
var items = featureIdsOp.getItems();
assertEquals(ids.size(), items.size());
for (var id : ids) assertTrue(items.contains(id));
}

private void checkOpIsUuidAndIdRequest(final Op op, final List<Object> versions, final List<String> ids) {
// We assume that op is Or(versions, ids)
final And andOp = assertInstanceOf(And.class, op);
assertEquals(2, andOp.getChildren().size());

// First uuid's
checkOpIsUuidRequest(andOp.getChildren().getFirst(), versions);

// second ids
checkOpIsIdRequest(andOp.getChildren().get(1), ids);
}

private void checkOpIsUuidRequest(final Op op, final List<Object> versions) {
assertInstanceOf(Or.class, op);
OpList orChildren = ((Or) op).getChildren();
Expand Down Expand Up @@ -124,15 +146,11 @@ void shouldTranslateActivityLogIdToFeatureId() {
assertNull(readFeatures.getVersion());

// And: there is a single featureId withing the request
StringList featureIds = readFeatures.getFeatureIds();
assertEquals(1, featureIds.getSize());
assertEquals(featureId, featureIds.get(0));
checkOpIsIdRequest(readFeatures.getQueryMembers(), List.of(featureId));

// And:
assertNull(readFeatures.getQuery().getProperties());

// And: there are no guids (nothing was declared in original featureIds)
assertNull(readFeatures.getQueryMembers());
Comment thread
xeus2001 marked this conversation as resolved.
Resolved
assertTrue(readFeatures.getFeatureIds().isEmpty());
}

@Test
Expand All @@ -154,15 +172,11 @@ void shouldTranslateActivityLogIdsToFeatureIds() {
verifyAllHistoricalVersionsInCollection(readFeatures);

// And: all ids defined in AcitvityLogNs are now part of featureIds
StringList featureIds = readFeatures.getFeatureIds();
assertEquals(2, featureIds.getSize());
assertTrue(featureIds.containsAll(List.of(firstId, secondId)));
checkOpIsIdRequest(readFeatures.getQueryMembers(), List.of(firstId, secondId));

// And: the pQuery left is effectively dead
assertNull(readFeatures.getQuery().getProperties());

// And: there are no guids (nothing was declared in original featureIds)
assertNull(readFeatures.getQueryMembers());
Comment thread
xeus2001 marked this conversation as resolved.
Resolved
assertTrue(readFeatures.getFeatureIds().isEmpty());
}

@Test
Expand All @@ -185,14 +199,8 @@ void shouldApplyMixedTranslations() {
// Then: request will reach correct collection and history
verifyAllHistoricalVersionsInCollection(readFeatures);

// And: feature ids are populated from ActivityLogNs
StringList finalFeatureIds = readFeatures.getFeatureIds();
assertEquals(1, finalFeatureIds.getSize());
assertEquals(activityLogId, finalFeatureIds.get(0));

// And: guuids are populated from original feature ids
Op op = readFeatures.getQueryMembers();
checkOpIsUuidRequest(op, List.of(version));
// And: uuid's and ids are populated from original request
checkOpIsUuidAndIdRequest(readFeatures.getQueryMembers(), List.of(version), List.of(activityLogId));
}

private void verifyAllHistoricalVersionsInCollection(ReadFeatures readFeatures) {
Expand Down
Loading
Loading