Skip to content

Commit

Permalink
build: release version 2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisKujawa committed Mar 20, 2024
1 parent 3d42cc0 commit a289163
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 19 deletions.
4 changes: 2 additions & 2 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
<parent>
<groupId>io.zell</groupId>
<artifactId>zdb</artifactId>
<version>2.2.0-SNAPSHOT</version>
<version>2.2.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>backend</artifactId>
<version>2.2.0-SNAPSHOT</version>
<version>2.2.0</version>
<packaging>jar</packaging>
<name>ZDB Backend</name>

Expand Down
6 changes: 3 additions & 3 deletions cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
<parent>
<groupId>io.zell</groupId>
<artifactId>zdb</artifactId>
<version>2.2.0-SNAPSHOT</version>
<version>2.2.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>cli</artifactId>
<version>2.2.0-SNAPSHOT</version>
<version>2.2.0</version>
<name>ZDB CLI</name>
<packaging>jar</packaging>

Expand Down Expand Up @@ -59,7 +59,7 @@
<dependency>
<groupId>io.zell</groupId>
<artifactId>backend</artifactId>
<version>2.2.0-SNAPSHOT</version>
<version>2.2.0</version>
</dependency>


Expand Down
12 changes: 6 additions & 6 deletions cli/src/main/java/io/zell/zdb/state/KeyFormatters.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,18 @@
import io.camunda.zeebe.db.DbValue;
import io.camunda.zeebe.db.impl.*;
import io.camunda.zeebe.protocol.ZbColumnFamilies;
import org.agrona.concurrent.UnsafeBuffer;

import java.util.HexFormat;
import java.util.Map;
import org.agrona.concurrent.UnsafeBuffer;

public interface KeyFormatters {
KeyFormatter HEX_FORMATTER = new KeyFormatter.HexFormatter();
Map<ZbColumnFamilies, KeyFormatter> FORMATTERS = Map.of(
Map<ZbColumnFamilies, KeyFormatter> FORMATTERS =
Map.of(
ZbColumnFamilies.DEFAULT, KeyFormatter.DbValueFormatter.of("s"),
ZbColumnFamilies.KEY, KeyFormatter.DbValueFormatter.of("s"),
ZbColumnFamilies.BANNED_INSTANCE, KeyFormatter.DbValueFormatter.of("l"),
ZbColumnFamilies.MESSAGE_SUBSCRIPTION_BY_KEY, KeyFormatter.DbValueFormatter.of("ls")
);
ZbColumnFamilies.MESSAGE_SUBSCRIPTION_BY_KEY, KeyFormatter.DbValueFormatter.of("ls"));

KeyFormatter forColumnFamily(ZbColumnFamilies columnFamily);

Expand Down Expand Up @@ -106,7 +105,8 @@ public String formatKey(final byte[] key) {
final var buf = dbBytes.getDirectBuffer();
final var bytes = new byte[dbBytes.getLength()];
buf.getBytes(0, bytes);
formatted.append(HEX_FORMATTER.formatKey(bytes)); }
formatted.append(HEX_FORMATTER.formatKey(bytes));
}
default -> formatted.append(dbValue);
}
}
Expand Down
32 changes: 25 additions & 7 deletions cli/src/test/java/io/zell/zdb/KeyFormattersTest.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,38 @@
/*
* Copyright © 2021 Christopher Kujawa ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.zell.zdb;

import static org.assertj.core.api.Assertions.assertThat;

import io.camunda.zeebe.db.impl.*;
import io.camunda.zeebe.protocol.ZbColumnFamilies;
import io.zell.zdb.state.KeyFormatters;
import org.agrona.ExpandableArrayBuffer;
import org.agrona.collections.MutableInteger;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

final class KeyFormattersTest {
@Test
void shouldFallbackToHex() {
// given
final var key = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

// when -- using a column family that is not registered with a specific formatter
final var formatter = KeyFormatters.ofDefault().forColumnFamily(ZbColumnFamilies.MIGRATIONS_STATE);
final var formatter =
KeyFormatters.ofDefault().forColumnFamily(ZbColumnFamilies.MIGRATIONS_STATE);

// then
assertThat(formatter.formatKey(key)).isEqualTo("01 02 03 04 05 06 07 08 09 0a");
Expand Down Expand Up @@ -62,11 +78,14 @@ void shouldDecodeWithFormat() {
keyBuffer.getBytes(0, key, 0, key.length);

// when
final var fullFormatter = KeyFormatters.ofFormat("lisbB").forColumnFamily(ZbColumnFamilies.DEFAULT);
final var partialFormatter = KeyFormatters.ofFormat("lis").forColumnFamily(ZbColumnFamilies.DEFAULT);
final var fullFormatter =
KeyFormatters.ofFormat("lisbB").forColumnFamily(ZbColumnFamilies.DEFAULT);
final var partialFormatter =
KeyFormatters.ofFormat("lis").forColumnFamily(ZbColumnFamilies.DEFAULT);

// then
assertThat(fullFormatter.formatKey(key)).isEqualTo("5:987:hello:123:01 02 03 04 05 06 07 08 09 0a");
assertThat(fullFormatter.formatKey(key))
.isEqualTo("5:987:hello:123:01 02 03 04 05 06 07 08 09 0a");
assertThat(partialFormatter.formatKey(key)).isEqualTo("5:987:hello");
}

Expand All @@ -92,5 +111,4 @@ void shouldUseRegisteredFormatter() {
// then
assertThat(formatter.formatKey(key)).isEqualTo("hello");
}

}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.zell</groupId>
<artifactId>zdb</artifactId>
<version>2.2.0-SNAPSHOT</version>
<version>2.2.0</version>
<packaging>pom</packaging>
<name>ZDB</name>
<inceptionYear>2021</inceptionYear>
Expand Down

0 comments on commit a289163

Please sign in to comment.