-
Notifications
You must be signed in to change notification settings - Fork 12
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
Feature/resolve from storage #3441
base: develop
Are you sure you want to change the base?
Conversation
Signed-off-by: Max Thonagel <[email protected]>
Signed-off-by: Max Thonagel <[email protected]>
Signed-off-by: Max Thonagel <[email protected]>
Signed-off-by: Max Thonagel <[email protected]>
Signed-off-by: Max Thonagel <[email protected]>
Signed-off-by: Max Thonagel <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hier habe ich den Deserializer angepasst, so dass nicht erst zum Zeitpunkt der Deserializierung der IdResolver aus den Injectables rausgesucht wird, sondern schon während der Instantiierung
Signed-off-by: Max Thonagel <[email protected]>
Signed-off-by: Max Thonagel <[email protected]>
Signed-off-by: Max Thonagel <[email protected]>
@@ -18,7 +18,7 @@ public class BinaryJacksonCoder implements CQCoder<NetworkMessage<?>> { | |||
private final ObjectWriter writer; | |||
private final ObjectReader reader; | |||
|
|||
public BinaryJacksonCoder(IdResolveContext datasets, Validator validator, ObjectMapper objectMapper) { | |||
public BinaryJacksonCoder(NsIdResolver datasets, Validator validator, ObjectMapper objectMapper) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IdResolveContext konnte MetaId und NamespacedIds resolven. MetaIds werden aber gar nicht gebraucht in der Kommunikation zwischen Manager und Shards, deshalb gibt es hier nur einen NsIdResolver
@@ -196,4 +197,24 @@ public void addFormConfig(FormConfig formConfig) { | |||
public MutableInjectableValues inject(MutableInjectableValues values) { | |||
return values.add(MetaStorage.class, this); | |||
} | |||
|
|||
public <ID extends Id<VALUE>, VALUE extends Identifiable<?>> VALUE get(ID id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Diese get Methoden in den Storages imitieren einfach das ehemalöige getOptional der CentralRegistry.
Signed-off-by: Max Thonagel <[email protected]>
Signed-off-by: Max Thonagel <[email protected]>
Signed-off-by: Max Thonagel <[email protected]>
Signed-off-by: Max Thonagel <[email protected]>
Signed-off-by: Max Thonagel <[email protected]>
Signed-off-by: Max Thonagel <[email protected]>
Signed-off-by: Max Thonagel <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sieht gut aus 😃
concepts.remove(id); | ||
} | ||
|
||
public Collection<Concept<?>> getAllConcepts() { | ||
return concepts.getAll(); | ||
} | ||
|
||
public <ID extends Id<VALUE> & NamespacedId, VALUE extends Identifiable<?>> VALUE get(ID id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public <ID extends Id<VALUE> & NamespacedId, VALUE extends Identifiable<?>> VALUE get(ID id) { | |
@SuppressWarnings("unchecked") | |
public <ID extends Id<VALUE> & NamespacedId, VALUE extends Identifiable<?>> VALUE get(ID id) { | |
super.clear(); | ||
centralRegistry.clear(); | ||
} | ||
|
||
private void decorateDatasetStore(SingletonStore<Dataset> store) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wofür gibt es private void decorateDatasetStore
, private void decorateSecondaryIdDescriptionStore
, private void decorateTableStore
und private void decorateImportStore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Die Methoden wurden für eine etwaige Initialisierung eines Objektes angelegt. Viele Objekte müssen aber nicht initialisiert werden und für andere habe ich denke ich eine bessere Lösung gefunden. Also die Funktionen können potentiell weg
@@ -114,19 +114,21 @@ public record InfoCardSelect(@NotNull String label, SelectId select, String desc | |||
/** | |||
* Defines a group of selects that will be evaluated per quarter and year in the requested period of the entity-preview. | |||
*/ | |||
public record TimeStratifiedSelects(@NotNull String label, String description, @NotEmpty List<InfoCardSelect> selects){ | |||
public record TimeStratifiedSelects(@NotNull String label, String description, @NotEmpty List<InfoCardSelect> selects) { | |||
} | |||
|
|||
@ValidationMethod(message = "Selects may be referenced only once.") | |||
@JsonIgnore | |||
public boolean isSelectsUnique() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intellij meldet das diese ValidationMethods nicht benutzt werden.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh das kann natürlich sein, mir wurde die Warnung nicht angezeigt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Du musst Intellij einstellen, dass es bei dieser Anno kein unused meldet. Die werden automatisch ausgeführt bei Validierung
backend/src/main/java/com/bakdata/conquery/models/datasets/PreviewConfig.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
@ValidationMethod(message = "Labels must be unique.") | ||
@JsonIgnore | ||
public boolean isLabelsUnique() { | ||
return timeStratifiedSelects.stream().map(TimeStratifiedSelects::selects).flatMap(Collection::stream).map(InfoCardSelect::label).distinct().count() == timeStratifiedSelects.stream().map(TimeStratifiedSelects::selects).flatMap(Collection::stream).count(); | ||
return timeStratifiedSelects.stream().map(TimeStratifiedSelects::selects).flatMap(Collection::stream).map(InfoCardSelect::label).distinct().count() | ||
== timeStratifiedSelects.stream().map(TimeStratifiedSelects::selects).flatMap(Collection::stream).count(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
== timeStratifiedSelects.stream().map(TimeStratifiedSelects::selects).flatMap(Collection::stream).count(); | |
== timeStratifiedSelects.stream().map(TimeStratifiedSelects::selects).mapToLong(Collection::size).sum(); |
…viewConfig.java Co-authored-by: SebChmie <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-300 Zeilen code und es ist jetzt direkter gekoppelt, nice!
@@ -197,13 +202,21 @@ public void resolve(QueryResolveContext context) { | |||
* <p> | |||
* The resolved filter instructs the frontend on how to render and serialize the filter value using the {@link Filter#createFrontendConfig(com.bakdata.conquery.models.config.ConqueryConfig)} method. The filter must implement {@link GroupFilter} and provide the type information of the value to correctly deserialize the received object. | |||
*/ | |||
public static class GroupFilterDeserializer extends StdDeserializer<GroupFilterValue> { | |||
private final NsIdReferenceDeserializer<FilterId, Filter<?>> nsIdDeserializer = new NsIdReferenceDeserializer<>(Filter.class, null, FilterId.class); | |||
public static class GroupFilterDeserializer extends StdDeserializer<GroupFilterValue> implements ContextualDeserializer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ich weiß, es ist bisschen dein Baby, aber kann das nicht auch ganz weg?
|
||
@Override | ||
public VALUE fromString(String value) { | ||
final ID id = idParser.parse(value); | ||
|
||
return registry.resolve(id); | ||
return storage.get(id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
@@ -1,77 +0,0 @@ | |||
package com.bakdata.conquery.io.storage; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gelöscth, weil du caching verschieben willst?
@@ -196,4 +191,24 @@ public void addFormConfig(FormConfig formConfig) { | |||
public MutableInjectableValues inject(MutableInjectableValues values) { | |||
return values.add(MetaStorage.class, this); | |||
} | |||
|
|||
public <ID extends Id<VALUE>, VALUE extends Identifiable<?>> VALUE get(ID id) { | |||
if (id instanceof ManagedExecutionId executionId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
können nicht die ids das getten machen?
|
||
@Override | ||
public <ID extends Id<VALUE> & NamespacedId, VALUE extends Identifiable<?>> VALUE get(ID id) { | ||
if (id instanceof InternToExternMapperId castId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
würde den access den ids überlassen
datasetStorage.close(); | ||
|
||
return createNamespace(datasetStorage, metaStorage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatierun stimmt hier nicht
return values.add(NsIdResolver.class, this) | ||
.add(this.getClass(), this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sind beide injections notwendig?
doAnswer(invocation -> { | ||
throw new UnsupportedOperationException("Not yet implemented"); | ||
}).when(namespacesMock).getOptional(any()); | ||
// TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noch offen?
final WorkerStorage workerStorage = getWorkerStorage(); | ||
|
||
CentralRegistry registry = getMetaStorage().getCentralRegistry(); | ||
|
||
registry.register(dataset); | ||
registry.register(startCol); | ||
registry.register(endCol); | ||
registry.register(compoundCol); | ||
registry.register(table); | ||
registry.register(imp); | ||
registry.register(bucket); | ||
workerStorage.updateDataset(dataset); | ||
workerStorage.addTable(table); | ||
workerStorage.addImport(imp); | ||
workerStorage.addBucket(bucket); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fett
@NotNull | ||
public static TreeConcept createConcept(CentralRegistry registry, Dataset dataset) { | ||
public static TreeConcept createConcept(Dataset dataset, NamespacedStorage ... storages) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wieso können das mehrere Storages sein?
This pr makes the CentralRegistry obsolete, by resolving ids directly from the storage.
Before, the CentralResgistry held all objects in Memory so no memory optimized caching is possible.
Removing the registry removes one central point were hard references to all objects where held.
The CentralRegistry was used by deserializers (MetaIdReferenceDeserializer, NsIdReferenceDeserializer) to resolve incomming Ids in JSONs to concrete objects.
The CentralRegistry was however not a singleton, as every Storage (MetaStorage, NamespaceStorage, WorkerStorage) had one.
It is replaced by the NsIdResolver interface, which is implemented by NamespaceStorage, WorkerStorage and DatasetRegistry.
The MetaIdReferenceDeserializer just uses the MetaStorage directly.