Skip to content

Add LocalBucketing with storeConfig function working - #18

Merged
emmawillis merged 2 commits into
java-local-bucketing-changesfrom
DVC-4203-add-wasm
Sep 7, 2022
Merged

Add LocalBucketing with storeConfig function working#18
emmawillis merged 2 commits into
java-local-bucketing-changesfrom
DVC-4203-add-wasm

Conversation

@emmawillis

Copy link
Copy Markdown
Contributor
  • Add LocalBucketing class with all functions working (except generateBucketedConfig has the wrong return type)
  • Add small test for LocalBucketing - we'll probably want to delete this when we finish the DVCLocalClient since tests for that will cover the bucketing class
  • Add a local client to the test app so we can demo it
  • Also renamed local/DVCClient to DVCLocalClient (do we want to do this??)

@emmawillis
emmawillis requested review from a team and JamieSinn September 2, 2022 17:56
@emmawillis
emmawillis requested a review from VicV September 2, 2022 17:58
Comment thread src/main/java/com/devcycle/sdk/server/local/LocalBucketing.java Outdated
Comment thread src/test/java/com/devcycle/sdk/server/local/LocalBucketingTest.java Outdated
@emmawillis
emmawillis force-pushed the DVC-4203-add-wasm branch 4 times, most recently from d101aab to dabe136 Compare September 7, 2022 03:30
@emmawillis
emmawillis requested a review from JamieSinn September 7, 2022 03:31
private final DVCApi api;
private final DVCOptions dvcOptions;

private static final LocalBucketing localBucketing = new LocalBucketing();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want this to be final; static alone is fine.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed!

public DVCClient(String serverKey, DVCOptions dvcOptions) {
public DVCLocalClient(String serverKey, DVCOptions dvcOptions) {
new EnvironmentConfigManager(serverKey, dvcOptions);
DEFAULT_SDK_VERSION = "1.1.0";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're declaring this as final, it can be set in the initialization.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed!

Comment thread src/main/java/com/devcycle/sdk/server/local/LocalBucketing.java Outdated
Comment thread src/main/java/com/devcycle/sdk/server/local/LocalBucketing.java Outdated
Comment thread src/main/java/com/devcycle/sdk/server/local/LocalBucketing.java Outdated
byte[] headerBytes = {buf.get(startAddress - 1), buf.get(startAddress - 2), buf.get(startAddress - 3), buf.get(startAddress - 4)};
long stringLength = getUnsignedInt(headerBytes);
String result = "";
for (int i = 0; i < stringLength; i += 2) { // +=2 because every 2nd byte is null

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically this comment is correct, but it's because the data is formatted as WTF-16 - not UTF-8. So technically the second byte is a valid data byte - but we're not using it, so we skip. Not that the byte is \0.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh that makes sense, i'll just put that it's formatted as WTF-16 instead of UTF-8, hopefully that will be more helpful

String bucketedConfigString = readWasmString(resultAddress);

Map<String, Object> mapping = new ObjectMapper().readValue(bucketedConfigString, HashMap.class);
// TODO parse json as BucketedUserConfig class and return that

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets make sure we finish this before merging.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's already finished in the next commit, i'm going to PR it right after this one. just trying to get this into the feature branch to unblock Kaushal

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just because of how WASM is painful - I'd do it in this one.

@emmawillis
emmawillis merged commit 018e326 into java-local-bucketing-changes Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants