Skip to content

Commit

Permalink
Working through problems.
Browse files Browse the repository at this point in the history
  • Loading branch information
lbooker42 committed Sep 13, 2024
1 parent dd12240 commit 944dac6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ private void initializeAvailableLocations() {
if (isRefreshing()) {
final TableLocationSubscriptionBuffer locationBuffer =
new TableLocationSubscriptionBuffer(locationProvider);
manage(locationBuffer);
try (final TableLocationSubscriptionBuffer.LocationUpdate locationUpdate =
locationBuffer.processPending()) {
maybeRemoveLocations(locationUpdate.getPendingRemovedLocationKeys());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ public ImmutableTableLocationKey getKey() {
return locationKey;
}

@Override
public int hashCode() {
return locationKey.hashCode();
}

@Override
public boolean equals(Object obj) {
if (obj instanceof ImmutableTableLocationKey) {
return locationKey.equals(obj);
}
return (this == obj);
}

/**
* This {@link TrackedTableLocationKey} should manage the given {@link TableLocation} and store a reference to it.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package io.deephaven.engine.table.impl.locations.impl;

import io.deephaven.base.verify.Assert;
import io.deephaven.engine.liveness.LivenessScopeStack;
import io.deephaven.engine.liveness.ReferenceCountedLivenessNode;
import io.deephaven.engine.table.Table;
import io.deephaven.engine.table.impl.locations.*;
Expand Down Expand Up @@ -124,6 +125,7 @@ protected void destroy() {
AbstractTableLocationProvider.this.destroy();
}
};
LivenessScopeStack.peek().manage(livenessNode);
}

/**
Expand Down Expand Up @@ -431,15 +433,14 @@ public TableLocation getTableLocationIfPresent(@NotNull final TableLocationKey t
// The intent is to create a TableLocation exactly once to replace the TableLocationKey placeholder that was
// added in handleTableLocationKey.
if (!(current instanceof TableLocation)) {
final TableLocationKey immutableKey = (TableLocationKey) current;
final TrackedTableLocationKey trackedKey = (TrackedTableLocationKey) current;
// noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized (immutableKey) {
current = tableLocations.get(immutableKey);
if (immutableKey == current) {
synchronized (trackedKey) {
current = tableLocations.get(trackedKey);
if (trackedKey == current) {
// Make a new location, have the tracked key manage it, then replace the key with the
// new location in the map and return it. Note, this may contend for the lock on tableLocations
final TrackedTableLocationKey trackedKey = (TrackedTableLocationKey) current;
final TableLocation newLocation = makeTableLocation(immutableKey);
final TableLocation newLocation = makeTableLocation(trackedKey.getKey());
trackedKey.manageTableLocation(newLocation);
tableLocations.add(current = newLocation);
}
Expand Down Expand Up @@ -522,6 +523,9 @@ private static TableLocationKey toKey(@NotNull final Object keyOrLocation) {
if (keyOrLocation instanceof TableLocation) {
return ((TableLocation) keyOrLocation).getKey();
}
if (keyOrLocation instanceof TrackedTableLocationKey) {
return (((TrackedTableLocationKey) keyOrLocation).getKey());
}
if (keyOrLocation instanceof TableLocationKey) {
return ((TableLocationKey) keyOrLocation);
}
Expand Down

0 comments on commit 944dac6

Please sign in to comment.