Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove getBinaryFileLevel from the public API #294

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Remove getBinaryFileLevel from the public API
Clean up some ResultSet code
  • Loading branch information
bmeike committed May 23, 2024
commit 85e71aa61ff70c187ea394a8f071a611fca4d47d
1 change: 0 additions & 1 deletion common/jni_android.ld
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ CBL {
Java_com_couchbase_lite_internal_core_impl_NativeC4Listener_shareDbCollections;
Java_com_couchbase_lite_internal_core_impl_NativeC4Listener_startHttp;
Java_com_couchbase_lite_internal_core_impl_NativeC4Listener_startTls;
Java_com_couchbase_lite_internal_core_impl_NativeC4Log_getBinaryFileLevel;
Java_com_couchbase_lite_internal_core_impl_NativeC4Log_log;
Java_com_couchbase_lite_internal_core_impl_NativeC4Log_setBinaryFileLevel;
Java_com_couchbase_lite_internal_core_impl_NativeC4Log_setCallbackLevel;
Expand Down
4 changes: 2 additions & 2 deletions common/main/java/com/couchbase/lite/AbstractQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public ResultSet execute() throws CouchbaseLiteException {
}
}

return new ResultSet(this, c4enum, new HashMap<>(colNames));
return new ResultSet(getDatabase(), c4enum, new HashMap<>(colNames));
}
catch (LiteCoreException e) {
throw CouchbaseLiteException.convertException(e);
Expand Down Expand Up @@ -338,7 +338,7 @@ private void onQueryChanged(
@NonNull ChangeListenerToken<QueryChange> token,
@Nullable C4QueryEnumerator results,
@Nullable LiteCoreException err) {
token.postChange(new QueryChange(this, new ResultSet(this, results, columnNames), err));
token.postChange(new QueryChange(this, new ResultSet(getDatabase(), results, columnNames), err));
}

@NonNull
Expand Down
28 changes: 11 additions & 17 deletions common/main/java/com/couchbase/lite/ResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ public class ResultSet implements Iterable<Result>, AutoCloseable {
@NonNull
private final Object lock = new Object();

@NonNull
private final AbstractQuery query;
@NonNull
private final Map<String, Integer> columnNames;
@NonNull
Expand All @@ -82,12 +80,11 @@ public class ResultSet implements Iterable<Result>, AutoCloseable {

// This object is the sole owner of the c4enum passed as the second argument.
ResultSet(
@NonNull AbstractQuery query,
@Nullable AbstractDatabase database,
@Nullable C4QueryEnumerator c4enum,
@NonNull Map<String, Integer> cols) {
this.query = Preconditions.assertNotNull(query, "query");
this.columnNames = Preconditions.assertNotNull(cols, "columns");
this.context = new ResultContext(query.getDatabase(), this);
this.context = new ResultContext(database, this);
this.c4enum = c4enum;
}

Expand Down Expand Up @@ -142,10 +139,6 @@ public List<Result> allResults() {
return results;
}

//---------------------------------------------
// Iterable implementation
//---------------------------------------------

/**
* Return Iterator of Results.
* <p>Caution: {@link ResultSet#next}, {@link ResultSet#allResults} and {@link ResultSet#iterator}
Expand All @@ -157,6 +150,10 @@ public List<Result> allResults() {
@Override
public Iterator<Result> iterator() { return allResults().iterator(); }

public boolean isClosed() {
synchronized (lock) { return c4enum == null; }
}

@Override
public void close() {
final C4QueryEnumerator qEnum;
Expand All @@ -172,6 +169,10 @@ public void close() {
synchronized (db.getDbLock()) { qEnum.close(); }
}

//---------------------------------------------
// Protected access
//---------------------------------------------

@Override
protected void finalize() throws Throwable {
try {
Expand All @@ -188,12 +189,9 @@ protected void finalize() throws Throwable {
}

//---------------------------------------------
// Package level access
// Package access
//---------------------------------------------

@NonNull
AbstractQuery getQuery() { return query; }

int getColumnCount() { return columnNames.size(); }

@NonNull
Expand All @@ -203,10 +201,6 @@ int getColumnIndex(@NonNull String name) {
final Integer idx = columnNames.get(name);
return (idx == null) ? -1 : idx;
}

boolean isClosed() {
synchronized (lock) { return c4enum == null; }
}
}