use of com.tvd12.dahlia.core.entity.Index in project ezyfox-server by youngmonkeys.
the class EzyAccessAppControllerTest method newRequest.
protected EzySimpleAccessAppRequest newRequest(int index) {
EzyAbstractSession session = spy(EzyAbstractSession.class);
EzySimpleUser user = new EzySimpleUser();
user.setName("user" + index);
user.setZoneId(1);
EzyArray params = EzyEntityFactory.newArrayBuilder().append("test").build();
EzySimpleAccessAppRequest request = new EzySimpleAccessAppRequest();
request.setUser(user);
request.setSession(session);
request.deserializeParams(params);
return request;
}
use of com.tvd12.dahlia.core.entity.Index in project dahlia by youngmonkeys.
the class BTreeSequentialAccessTest method test.
@Test
public void test() {
BTree<Integer, Integer> tree = new BTree<>(4);
System.out.println("sequential access 1st:\n");
tree.walk(e -> {
System.out.print(e + " ");
});
tree.walkReverse(e -> {
System.out.print(e + " ");
});
for (int i = 1; i <= 100; ++i) tree.insert(i, i);
System.out.println("\nsequential access 2nd:\n");
tree.walk(e -> {
System.out.print(e + " ");
});
System.out.println("\nsequential access 3rd:\n");
for (int i = 1; i <= 100; ++i) {
final int index = i;
tree.walk(new TreeWalker<Integer, Integer>() {
AtomicInteger count = new AtomicInteger();
@Override
public void accept(Tree.Entry<Integer, Integer> e) {
System.out.print(e + " ");
count.incrementAndGet();
}
@Override
public boolean next() {
return count.get() < index;
}
});
System.out.println();
}
System.out.println("\n\n========================================\n\n");
for (int i = 1; i <= 100; ++i) {
final int index = i;
tree.walkReverse(new TreeWalker<Integer, Integer>() {
AtomicInteger count = new AtomicInteger();
@Override
public void accept(Tree.Entry<Integer, Integer> e) {
System.out.print(e + " ");
count.incrementAndGet();
}
@Override
public boolean next() {
return count.get() < index;
}
});
System.out.println();
}
System.out.println("\n\n========================================\n\n");
tree.walkReverse(new TreeWalker<Integer, Integer>() {
@Override
public void accept(Tree.Entry<Integer, Integer> e) {
System.out.print(e + " ");
}
@Override
public boolean next() {
return true;
}
});
tree.delete(20);
tree.delete(21);
tree.delete(22);
System.out.println("\n\n========================================\n\n");
tree.walkReverse(new TreeWalker<Integer, Integer>() {
@Override
public void accept(Tree.Entry<Integer, Integer> e) {
System.out.print(e + " ");
}
@Override
public boolean next() {
return true;
}
});
}
use of com.tvd12.dahlia.core.entity.Index in project dahlia by youngmonkeys.
the class BTreePrinter method visitNode.
private void visitNode(BTreeProxy.NodeProxy node, List<List<BTreeProxy.NodeProxy>> treeTiers, int index) {
List<NodeProxy> children = node.getChildren();
if (children.isEmpty())
return;
List<BTreeProxy.NodeProxy> current = null;
if (treeTiers.size() > index)
current = treeTiers.get(index);
else
treeTiers.add((current = new ArrayList<>()));
current.addAll(children);
for (BTreeProxy.NodeProxy child : children) visitNode(child, treeTiers, index + 1);
}
use of com.tvd12.dahlia.core.entity.Index in project dahlia by youngmonkeys.
the class CollectionFactory method createCollection.
public Collection createCollection(CollectionSetting setting) {
Collection collection = new Collection(setting);
Map<String, IndexSetting> indexes = setting.getIndexes();
for (String indexName : indexes.keySet()) {
IndexSetting indexSetting = indexes.get(indexName);
Index index = new Index(indexSetting);
collection.addIndex(index);
}
return collection;
}
use of com.tvd12.dahlia.core.entity.Index in project dahlia by youngmonkeys.
the class Indexes method addIndex.
public void addIndex(Index index) {
IndexSetting setting = index.getSetting();
String indexName = setting.getIndexName();
Map<String, Boolean> fields = setting.getFields();
this.indexesByName.put(indexName, index);
this.indexBySetting.put(setting, index);
for (String fieldName : fields.keySet()) {
this.indexesByFieldName.computeIfAbsent(fieldName, k -> new HashSet<>()).add(index);
}
}
Aggregations