Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace concrete tree set primitive with abstract sorted/navigable se…
…t primitives.
- Loading branch information
Showing
27 changed files
with
477 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
core/src/main/java/io/atomix/core/set/DistributedNavigableSetBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,31 @@ | |||
/* | |||
* Copyright 2015-present Open Networking Foundation | |||
* | |||
* 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.atomix.core.set; | |||
|
|||
import io.atomix.core.collection.DistributedCollectionBuilder; | |||
import io.atomix.primitive.PrimitiveManagementService; | |||
|
|||
/** | |||
* Builder for distributed navigable set. | |||
* | |||
* @param <E> type set elements. | |||
*/ | |||
public abstract class DistributedNavigableSetBuilder<E extends Comparable<E>> | |||
extends DistributedCollectionBuilder<DistributedNavigableSetBuilder<E>, DistributedNavigableSetConfig, DistributedNavigableSet<E>, E> { | |||
public DistributedNavigableSetBuilder(String name, DistributedNavigableSetConfig config, PrimitiveManagementService managementService) { | |||
super(DistributedNavigableSetType.instance(), name, config, managementService); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
core/src/main/java/io/atomix/core/set/DistributedNavigableSetType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,111 @@ | |||
/* | |||
* Copyright 2017-present Open Networking Foundation | |||
* | |||
* 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.atomix.core.set; | |||
|
|||
import io.atomix.core.collection.CollectionEvent; | |||
import io.atomix.core.collection.impl.CollectionUpdateResult; | |||
import io.atomix.core.iterator.impl.IteratorBatch; | |||
import io.atomix.core.set.impl.DefaultDistributedNavigableSetBuilder; | |||
import io.atomix.core.set.impl.DefaultDistributedNavigableSetService; | |||
import io.atomix.core.set.impl.DistributedSetResource; | |||
import io.atomix.core.set.impl.SetUpdate; | |||
import io.atomix.core.transaction.TransactionId; | |||
import io.atomix.core.transaction.TransactionLog; | |||
import io.atomix.core.transaction.impl.CommitResult; | |||
import io.atomix.core.transaction.impl.PrepareResult; | |||
import io.atomix.core.transaction.impl.RollbackResult; | |||
import io.atomix.primitive.PrimitiveManagementService; | |||
import io.atomix.primitive.PrimitiveType; | |||
import io.atomix.primitive.resource.PrimitiveResource; | |||
import io.atomix.primitive.service.PrimitiveService; | |||
import io.atomix.primitive.service.ServiceConfig; | |||
import io.atomix.utils.serializer.Namespace; | |||
import io.atomix.utils.serializer.Namespaces; | |||
|
|||
import static com.google.common.base.MoreObjects.toStringHelper; | |||
|
|||
/** | |||
* Distributed navigable set primitive type. | |||
*/ | |||
public class DistributedNavigableSetType<E extends Comparable<E>> implements PrimitiveType<DistributedNavigableSetBuilder<E>, DistributedNavigableSetConfig, DistributedNavigableSet<E>> { | |||
private static final String NAME = "navigable-set"; | |||
private static final DistributedNavigableSetType INSTANCE = new DistributedNavigableSetType(); | |||
|
|||
/** | |||
* Returns a new distributed set type. | |||
* | |||
* @param <E> the set element type | |||
* @return a new distributed set type | |||
*/ | |||
@SuppressWarnings("unchecked") | |||
public static <E extends Comparable<E>> DistributedNavigableSetType<E> instance() { | |||
return INSTANCE; | |||
} | |||
|
|||
@Override | |||
public String name() { | |||
return NAME; | |||
} | |||
|
|||
@Override | |||
public Namespace namespace() { | |||
return Namespace.builder() | |||
.register(PrimitiveType.super.namespace()) | |||
.register(Namespaces.BASIC) | |||
.nextId(Namespaces.BEGIN_USER_CUSTOM_ID) | |||
.register(CollectionUpdateResult.class) | |||
.register(CollectionUpdateResult.Status.class) | |||
.register(CollectionEvent.class) | |||
.register(CollectionEvent.Type.class) | |||
.register(IteratorBatch.class) | |||
.register(TransactionId.class) | |||
.register(TransactionLog.class) | |||
.register(SetUpdate.class) | |||
.register(SetUpdate.Type.class) | |||
.register(PrepareResult.class) | |||
.register(CommitResult.class) | |||
.register(RollbackResult.class) | |||
.build(); | |||
} | |||
|
|||
@Override | |||
public PrimitiveService newService(ServiceConfig config) { | |||
return new DefaultDistributedNavigableSetService<>(); | |||
} | |||
|
|||
@Override | |||
@SuppressWarnings("unchecked") | |||
public PrimitiveResource newResource(DistributedNavigableSet<E> primitive) { | |||
return new DistributedSetResource((AsyncDistributedSet<String>) primitive.async()); | |||
} | |||
|
|||
@Override | |||
public DistributedNavigableSetConfig newConfig() { | |||
return new DistributedNavigableSetConfig(); | |||
} | |||
|
|||
@Override | |||
public DistributedNavigableSetBuilder<E> newBuilder(String name, DistributedNavigableSetConfig config, PrimitiveManagementService managementService) { | |||
return new DefaultDistributedNavigableSetBuilder<>(name, config, managementService); | |||
} | |||
|
|||
@Override | |||
public String toString() { | |||
return toStringHelper(this) | |||
.add("name", name()) | |||
.toString(); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.